Skip Headers
Oracle® Complex Event Processing CQL Language Reference
11g Release 1 (11.1.1)

Part Number E12048-03
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
View PDF

16 Oracle Spatial Data Cartridge

This chapter describes the types, methods, fields, and constructors that the Oracle Spatial data cartridge exposes. You can use these types, methods, fields, and constructors in Oracle CQL queries and views as you would Oracle CQL native types.

This chapter describes:

For more information, see:

16.1 Understanding the Oracle Spatial Data Cartridge

Oracle Spatial is an option for Oracle Database that provides advanced spatial features to support high-end geographic information systems (GIS) and location-enabled business intelligence solutions (LBS).

The Oracle Spatial data cartridge is an optional data cartridge which allows you to write Oracle CQL queries and views that seamlessly interact with Oracle Spatial classes in your Oracle CEP application.

Using the Oracle Spatial data cartridge, you can configure Oracle CQL queries that perform the most important geographic domain operations such as storing spatial data, performing proximity and overlap comparisons on spatial data, and integrating spatial data with the Oracle CEP server by providing the ability to index on spatial data.

To use the Oracle Spatial data cartridge, you require a working knowledge of the Oracle Spatial API. For more information about Oracle Spatial, see:

This section describes:

16.1.1 Data Cartridge Name

The Oracle Spatial data cartridge uses the cartridge ID com.oracle.cep.cartrdiges.spatial and registers the server-scoped reserved link name spatial.

Use the spatial link name to associate an Oracle Spatial data cartridge method call with the Oracle Spatial data cartridge application context.

For more information, see:

16.1.2 Scope

The Oracle Spatial data cartridge is based on the Oracle Spatial Java API. The Oracle Spatial data cartridge exposes Oracle Spatial functionality in the com.oracle.cep.cartridge.spatial.Geometry class. Oracle Spatial functionality that is not in the Oracle Spatial Java API is not accessible from the Oracle Spatial data cartridge.

Using the Oracle Spatial data cartridge, your Oracle CQL queries may access the Oracle Spatial functionality that Table 16-1 describes.

Table 16-1 Oracle Spatial Data Cartridge Scope

Oracle Spatial Feature Scope

Geometry Types

The following geometry types from the Oracle Spatial Java API:

  • 2D points

  • 2D simple polygons

  • 2D rectangles

The following geometry operations:

  • Creating geometry types

  • Accessing geometry type public member functions and public fields

For more information, see:

Geometric Relation Operators

  • ANYINTERACT

  • CONTAIN

  • INSIDE

  • WITHINDISTANCE

For more information, see Section 16.1.2.3, "Geometry Relation Operators".

Geometric Filter Operators

  • FILTER

  • NN

For more information, see Section 16.1.2.4, "Geometry Filter Operators".

Geometric Index

  • R-Tree

For more information, see Section 16.1.2.5, "Geometric Index".

Coordinate Systems

  • Cartesian and WGS84 geodetic coordinates (default)

  • Specifying the default coordinate system through SRID

  • Using other geodetic coordinates

For more information, see Section 16.1.2.6, "Ordinates and Coordinate Systems and the SDO_SRID".


For a complete list of the methods that com.oracle.cep.cartridge.spatial.Geometry provides, see Section 16.1.2.7, "Geometry API".

For more information on how to access these Oracle Spatial features using the Oracle Spatial data cartridge, see Section 16.2, "Using the Oracle Spatial Data Cartridge".

16.1.2.1 Geometry Types

The Oracle Spatial data cartridge data model consists of geometries. A geometry is an ordered sequence of vertices. The semantics of the geometry are determined by its type.

The Oracle Spatial data cartridge allows you to access the following Oracle Spatial types directly in Oracle CQL queries and views:

  • SDO_GTYPES: The Oracle Spatial data cartridge supports the following geometry types:

    • 2D points

    • 2D simple polygons

    • 2D rectangles

    Table 16-2 describes the geometry types from the com.oracle.cep.cartridge.spatial.Geometry class that you can use.

    Table 16-2 Oracle Spatial Data Cartridge Geometry Types

    Geometry Type Description

    GTYPE_POINT

    Point geometry type that contains one point.

    GTYPE_POLYGON

    Polygon geometry type that contains one polygon.


  • SDO_ELEMENT_INFO: You can create the Element Info array using:

    • com.oracle.cep.cartridge.spatial.Geometry.createElemInfo static method

    • einfogenerator function

    For more information, see Section 16.1.2.2, "Element Info Array".

  • ORDINATES: You can create the ordinates using the Oracle Spatial data cartridge ordsgenerator function.

    For more information, see Section 16.1.2.6, "Ordinates and Coordinate Systems and the SDO_SRID".

For more information, see:

16.1.2.2 Element Info Array

The Element Info attribute is defined using a varying length array of numbers. This attribute specifies how to interpret the ordinates stored in the Ordinates attribute.

The Oracle Spatial data cartridge provides the following helper function for generating Element Info attribute values:

com.oracle.cep.cartridge.spatial.Geometry.createElemInfo(int SDO_STARTING_OFFSET, int SDO_ETYPE , int SDO_INTERPRETATION)

You can also use the einfogenerator function.

For more information, see:

16.1.2.3 Geometry Relation Operators

The Oracle Spatial data cartridge supports all Oracle Spatial geometry relation operators in either the Oracle CQL query projection clause or where clause.

When you use a geometry relation operator in the where clause of an Oracle CQL query, the Oracle Spatial data cartridge enables Rtree indexing on the relation specified in the where clause.

The Oracle Spatial data cartridge supports only geometric relations between point and other geometry types. The geometry type of the geometry must be GTYPE_POINT or a RUNTIME_EXCEPTION will be thrown.

For more information, see Section 16.2.4, "How to Use Geometry Relation Operators".

16.1.2.4 Geometry Filter Operators

The FILTER and NN operators perform primary filtering and so they may only appear in an Oracle CQL query where clause.These filter operators use the spatial index to identify the set of spatial objects that are likely to interact spatially with the given object.

For more information, see:

16.1.2.5 Geometric Index

The Oracle Spatial data cartridge uses a spatial index to implement the primary filter. The purpose of the spatial index is to quickly create a subset of the data and reduce the processing burden on the secondary filter.

A spatial index, like any other index, provides a mechanism to limit searches, but in this case the mechanism is based on spatial criteria such as intersection and containment.

The Oracle Spatial data cartridge uses R-Tree indexing for the default indexing mechanism. A spatial R-tree index can index spatial data of up to four dimensions. An R-tree index approximates each geometry by a single rectangle that minimally encloses the geometry (called the minimum bounding rectangle, or MBR)

For more information, see:

16.1.2.6 Ordinates and Coordinate Systems and the SDO_SRID

Table 16-3 lists the coordinate systems that the Oracle Spatial data cartridge supports by default and the SDO_SRID value that identifies each coordinate system.

Table 16-3 Oracle Spatial Data Cartridge Coordinate Systems

Coordinate System SDO_SRID Description

Cartesian

0

Cartesian coordinates are coordinates that measure the position of a point from a defined origin along axes that are perpendicular in the represented space.

Geodetic (WGS84)

8307

Geodetic coordinates (sometimes called geographic coordinates) are angular coordinates (longitude and latitude), closely related to spherical polar coordinates, and are defined relative to a particular Earth geodetic datum.

This is the default coordinate system in the Oracle Spatial data cartridge.


You can specify the SDO_SRID value as an argument to each Oracle Spatial method and constructor you call or you can configure the SDO_SRID in the Oracle Spatial data cartridge application context once and use com.oracle.cep.cartridge.spatial.Geometry methods without having to set the SDO_SRID as an argument each time. Using the application context, you can also specify any coordinate system that Oracle Spatial supports.

Note:

If you use a com.oracle.cep.cartridge.spatial.Geometry method that does not take an SDO_SRID value, then you must use the Oracle Spatial data cartridge application context. For example, the following method call will cause a runtime exception:
com.oracle.cep.cartridge.spatial.Geometry.createPoint(lng, lat)

Instead, you must use the spatial link name to associate the method call with the Oracle Spatial data cartridge application context:

com.oracle.cep.cartridge.spatial.Geometry.createPoint@spatial(lng, lat)

If you use a Geometry method that takes an SDO_SRID value, then the use of the spatial link name is optional. For example, both the following method calls are valid:

com.oracle.cep.cartridge.spatial.Geometry.createPoint(8307, lng, lat)
com.oracle.cep.cartridge.spatial.Geometry.createPoint@spatial(lng, lat)

For more information, see Section 16.1.4, "Oracle Spatial Data Cartridge Application Context".

Ordinates define the array of coordinates for a geometry using a double array. The Oracle Spatial data cartridge provides the ordsgenerator helper function for generating the array of coordinates. For syntax, see "ordsgenerator".

For more information, see:

16.1.2.7 Geometry API

The Oracle Spatial data cartridge is based on the Oracle Spatial Java API. The Oracle Spatial data cartridge exposes Oracle Spatial functionality in the com.oracle.cep.cartridge.spatial.Geometry class. This Geometry class also extends oracle.spatial.geometry.J3D_Geometry.

Although the Oracle Spatial data cartridge supports only 2D geometries, for efficiency, the Geometry class uses some J3D_Geometry methods. The Geometry class automatically zero-pads the Z coordinates for J3D_Geometry methods.

Oracle Spatial functionality inaccessible from the Geometry class (or not conforming to the scope and geometry types that the Oracle Spatial data cartridge supports) is inaccessible from the Oracle Spatial data cartridge.

This section describes:

For more information, see:

Note:

To simplify Oracle Spatial data cartridge type names, you can use aliases as Section 2.8.2, "Defining Aliases Using the Aliases Element" describes.
16.1.2.7.1 com.oracle.cep.cartridge.spatial.Geometry Methods

Table 16-4 lists the public methods that the Geometry class provides.

Table 16-4 Oracle Spatial Geometry Methods

Type Method

Buffers

Distance

Element information

Geometries

Linear polygons

MBR

Points

Rectangles

Type and type conversion


Note:

Geometry class methods are case sensitive and you must use them in the case shown.

Note:

If you use a com.oracle.cep.cartridge.spatial.Geometry method that does not take an SDO_SRID value, then you must use the Oracle Spatial data cartridge application context. For example, the following method call will cause a runtime exception:
com.oracle.cep.cartridge.spatial.Geometry.createPoint(lng, lat)

Instead, you must use the spatial link name to associate the method call with the Oracle Spatial data cartridge application context:

com.oracle.cep.cartridge.spatial.Geometry.createPoint@spatial(lng, lat)

If you use a Geometry method that takes an SDO_SRID value, then the use of the spatial link name is optional. For example, both the following method calls are valid:

com.oracle.cep.cartridge.spatial.Geometry.createPoint(8307, lng, lat)
com.oracle.cep.cartridge.spatial.Geometry.createPoint@spatial(lng, lat)

For more information, see Section 16.1.4, "Oracle Spatial Data Cartridge Application Context".

16.1.2.7.2 oracle.spatial.geometry.JGeometry Methods

The following JGeometry public methods are applicable to the Oracle Spatial data cartridge:

  • double area(double tolerance): returns the total planar surface area of a 2D geometry.

  • double length(double tolerance): returns the perimeter of a 2D geometry. All edge lengths are added.

  • double[] getMBR(): returns the MBR of this geometry. It returns a double array containing the minX,minY, maxX, and maxY value of the MBR for 2D.

For more information, see:

16.1.3 Datatype Mapping

The Oracle Spatial cartridge supports one data type: com.oracle.cep.cartridge.spatial.Geometry.

For a complete list of the methods that com.oracle.cep.cartridge.spatial.Geometry provides, see Section 16.1.2.7, "Geometry API".

16.1.4 Oracle Spatial Data Cartridge Application Context

You can define an application context for an instance of an Oracle Spatial data cartridge and propagate this application context at runtime. This allows you to associate specific Oracle Spatial application defaults (such as an SDO_SRID) with a particular Oracle Spatial data cartridge instance.

Example 16-1 shows how to create a spatial context named SpatialGRS80 in an EPN assembly file using the Geodetic Reference System 1980 (GRS80) coordinate system.

Example 16-1 spatial:context Element in EPN Assembly File

<spatial:context id="SpatialGRS80" srid="4269" sma="6378137" rof="298.25722101" />

Example 16-2 shows how to reference a spatial:context in an Oracle CQL query. In this case, the query uses link name SpatialGRS80 (defined in Example 16-1) to propagate this application context to the Oracle Spatial data cartridge. The spatial:context attribute settings of SpatialGRS80 are applied to the createPoint method call.

Example 16-2 Referencing spatial:context in an Oracle CQL Query

<view  id="createPoint">
    select com.oracle.cep.cartridge.spatial.Geometry.createPoint@SpatialGRS80(
        lng, lat)
    from CustomerPos[NOW]
</view>

For more information (including a complete list of all spatial:context attributes), see "Configuring Oracle Spatial Data Cartridge Application Context" in the Oracle CEP Developer's Guide for Eclipse.

Note:

If you use a com.oracle.cep.cartridge.spatial.Geometry method that does not take an SDO_SRID value, then you must use the Oracle Spatial data cartridge application context. For example, the following method call will cause a runtime exception:
com.oracle.cep.cartridge.spatial.Geometry.createPoint(lng, lat)

Instead, you must use the spatial link name to associate the method call with the Oracle Spatial data cartridge application context:

com.oracle.cep.cartridge.spatial.Geometry.createPoint@spatial(lng, lat)

If you use a Geometry method that takes an SDO_SRID value, then the use of the spatial link name is optional. For example, both the following method calls are valid:

com.oracle.cep.cartridge.spatial.Geometry.createPoint(8307, lng, lat)
com.oracle.cep.cartridge.spatial.Geometry.createPoint@spatial(lng, lat)

For more information, see Section 16.1.2.7, "Geometry API".

16.2 Using the Oracle Spatial Data Cartridge

This section describes common use-cases that highlight how you can use the Oracle Spatial data cartridge in your Oracle CEP applications, including:

For more information, see Section 16.1.2.7, "Geometry API".

16.2.1 How to Access the Geometry Types That the Oracle Spatial Java API Supports

This procedure describes how to access Oracle Spatial geometry types SDO_GTYPE, SDO_ELEMENT_INFO, and ORDINATES using the Oracle Spatial data cartridge in an Oracle CQL query.

To access the geometry types that the Oracle Spatial Java API supports:

  1. Choose an SDO_GTYPE, for example, GTYPE_POLYGON.

    For more information, see Section 16.1.2.1, "Geometry Types".

  2. Choose the Element Info appropriate for your ordinates.

    For more information, see Section 16.1.2.2, "Element Info Array"

  3. Define your coordinate values.

    For more information, see Section 16.1.2.6, "Ordinates and Coordinate Systems and the SDO_SRID".

  4. Create your Oracle CQL query as Example 16-3 shows.

    Example 16-3 Oracle CQL Query Using Oracle Spatial Geometry Types

    view id="ShopGeom">
        select  com.oracle.cep.cartridge.spatial.Geometry.createGeometry@spatial(
            com.oracle.cep.cartridge.spatial.Geometry.GTYPE_POLYGON,
            com.oracle.cep.cartridge.spatial.Geometry.createElemInfo(1, 1003, 1),
            ordsgenerator@spatial(
                lng1, lat1, lng2, lat2, lng3, lat3,
                lng4, lat4, lng5, lat5, lng6, lat6
            ) 
        ) as geom
        from ShopDesc
    </view>
    

16.2.2 How to Create a Geometry

You can use the Oracle Spatial data cartridge to create a geometry in an Oracle CQL query by invoking:

  • static methods in com.oracle.cartridge.spatial.Geometry

  • methods in oracle.spatial.geometry.JGeometry that conform to the scope and geometry types that the Oracle Spatial data cartridge supports.

For more information, see Section 16.1.2.7, "Geometry API".

Using a Static Method in the Oracle Spatial Data Cartridge Geometry Class

Example 16-4 shows how to create a point geometry using a static method in com.oracle.cartridge.spatial.Geometry. In this case, you must use a link (@spatial) to identify the data cartridge that provides this class. The advantage of using this approach is that the Oracle Spatial data cartridge application context is applied to set the SRID and other Oracle Spatial options, either by default or based on an application context you configure (see Section 16.1.4, "Oracle Spatial Data Cartridge Application Context").

Example 16-4 Creating a Point Geometry Using a Geometry Static Method

<view  id="CustomerPosGeom">
    select com.oracle.cep.cartridge.spatial.Geometry.createPoint@spatial(
        lng, lat) as geom
    from CustomerPos[NOW]
</view>

For more information, see Section 16.1.2.1, "Geometry Types".

16.2.3 How to Access Geometry Type Public Methods and Fields

Using the Oracle Spatial data cartridge, you can access the public member functions and public member fields of Oracle Spatial classes directly in Oracle CQL.

Oracle Spatial functionality inaccessible from the Geometry class (or not conforming to the scope and geometry types that the Oracle Spatial data cartridge supports) is inaccessible from the Oracle Spatial data cartridge.

In Example 16-5, the view ShopGeom creates an Oracle Spatial geometry called geom. The view shopMBR calls JGeometry static method getMBR which returns a double[] as stream element mbr. The query qshopMBR accesses this double[] using regular Java API.

Example 16-5 Accessing Geometry Type Public Methods and Fields

<view id="ShopGeom">
    select  com.oracle.cep.cartridge.spatial.Geometry.createGeometry@spatial(
        com.oracle.cep.cartridge.spatial.Geometry.GTYPE_POLYGON,
        com.oracle.cep.cartridge.spatial.Geometry.createElemInfo(1, 1003, 1),
        ordsgenerator@spatial(
            lng1, lat1, lng2, lat2, lng3, lat3,
            lng4, lat4, lng5, lat5, lng6, lat6
        ) 
    ) as geom
    from ShopDesc
</view>
<view  id=”shopMBR”>
    select geom.getMBR() as mbr
    from ShopGeom
</view>
<query  id=”qshopMBR”>
    select mbr[0], mbr[1], mbr[2], mbr[3]
    from shopMBR
</query>

For more information, see:

16.2.4 How to Use Geometry Relation Operators

Using the Oracle Spatial data cartridge, you can access the following Oracle Spatial geometry relation operators in either the WHERE or SELECT clause of an Oracle CQL query:

  • ANYINTERACT

  • CONTAIN

  • INSIDE

  • WITHINDISTANCE

In Example 16-6, the view op_in_where uses the CONTAIN geometry relation operator in the WHERE clause: in this case, the Oracle Spatial data cartridge uses R-Tree indexing. The view op_in_proj uses CONTAIN in the SELECT clause.

Example 16-6 Using Geometry Relation Operators

<view id="op_in_where">
    RStream(
        select 
            loc.customerId, 
            shop.shopId
        from 
            LocGeomStream[NOW] as loc, 
            ShopGeomRelation as shop
        where 
            CONTAIN@spatial(shop.geom, loc.curLoc, 5.0d) = true
    )
</view>
<view id="op_in_proj">
    RStream(
        select 
            loc.customerId, 
            shop.shopId, 
            CONTAIN@spatial(shop.geom, loc.curLoc, 5.0d)
        from 
            LocGeomStream[NOW] as loc, 
            ShopGeomRelation as shop
    )
</view>

For more information, see Section 16.1.2.3, "Geometry Relation Operators".

16.2.5 How to Use Geometry Filter Operators

Using the Oracle Spatial data cartridge, you can access the following Oracle Spatial geometry filter operators in the WHERE clause of an Oracle CQL query:

  • FILTER

  • NN

In Example 16-7, the view filter uses the FILTER geometry filter operator in the WHERE clause.

Example 16-7 Using Geometry Filter Operators

<view id="filter">
    RStream(
        select loc.customerId, shop.shopId
        from LocGeomStream[NOW] as loc, ShopGeomRelation as shop
        where FILTER@spatial(shop.geom, loc.curLoc, 5.0d) = true
    )
</view>

For more information, see Section 16.1.2.4, "Geometry Filter Operators".

16.2.6 How to Use the Default Geodetic Coordinates

When you create an Oracle CQL query using the default Oracle Spatial data cartridge application context, the default SRID will be set to CARTESIAN.

As Example 16-8 shows, the createPoint method call uses the default link (@spatial). This guarantees that the default Oracle Spatial data cartridge application context is applied.

Example 16-8 Using the Default Geodetic Coordinates in an Oracle CQL Query

<view  id="createPoint">
    select com.oracle.cep.cartridge.spatial.Geometry.createPoint@spatial(
        lng, lat)
    from CustomerPos[NOW]
</view>

For more information, see:

16.2.7 How to Use Other Geodetic Coordinates

This procedure describes how to use the Oracle Spatial data cartridge application context to specify a geodetic coordinate system other than the default Cartesian geodetic coordinate system in an Oracle CQL query:

For more information, see:

To use other geodetic coordinates:

  1. Create an Oracle Spatial application context and define the srid attribute for the geodetic coordinate system you want to use.

    Example 16-9 shows how to create a spatial context named SpatialGRS80 in an EPN assembly file using the Geodetic Reference System 1980 (GRS80) coordinate system.

    Example 16-9 spatial:context Element in EPN Assembly File

    <spatial:context id="SpatialGRS80" srid="4269" sma="6378137" rof="298.25722101" />
    
  2. In your Oracle CQL query, use the id of this spatial:context in your links.

    Example 16-10 shows how to reference a spatial:context in an Oracle CQL query. In this case, the query uses link name SpatialGRS80 (defined in Example 16-9) to propagate this application context to the Oracle Spatial data cartridge. The spatial:context attribute settings of SpatialGRS80 are applied to the createPoint method call.

    Example 16-10 Referencing spatial:context in an Oracle CQL Query

    <view  id=”createPoint”>
        select com.oracle.cep.cartridge.spatial.Geometry.createPoint@SpatialGRS80(
            lng, lat)
        from CustomerPos[NOW]
    </view>
    

bufferPolygon

Syntax

Surrounding text describes bufferpolygon.gif.

Purpose

This com.oracle.cep.cartridge.spatial.Geometry method returns a new com.oracle.cep.cartridge.spatial.Geometry object which is the buffered version of the input oracle.spatial.geometry.JGeometry polygon.

This method takes the following arguments:

This method obtains parameters from the Oracle Spatial data cartridge application context. Consequently, you must use the spatial link name to associate the method call with the Oracle Spatial data cartridge application context:

com.oracle.cep.cartridge.spatial.Geometry.bufferPolygon@spatial(geom, 1300)

For more information, see Section 16.1.4, "Oracle Spatial Data Cartridge Application Context".

Examples

Example 16-11 shows how to use the bufferPolygon method. Because this bufferPolygon call depends on the Oracle Spatial data cartridge application context, it uses the spatial link name.

Example 16-11 Oracle CQL Query Using Geometry.bufferPolygon

<view id="LocGeomStream" schema="customerId curLoc">
    select 
        customerId, 
        com.oracle.cep.cartridge.spatial.Geometry.bufferPolygon@spatial(geom, 13) 
    from 
        CustomerLocStream
</view>

createElemInfo

Syntax

Surrounding text describes createeleminfo.gif.

Note:

Alternatively, you can use the function einfogenerator. For more information, see "einfogenerator".

Purpose

This com.oracle.cep.cartridge.spatial.Geometry method returns a single element info value as an int[] from the given arguments.

This method takes the following arguments:

Examples

Example 16-12 shows how to use the createElemInfo method.

Example 16-12 Oracle CQL Query Using Geometry.createElemInfo

<view id="ShopGeom">
    select  com.oracle.cep.cartridge.spatial.Geometry.createGeometry@spatial(
        com.oracle.cep.cartridge.spatial.Geometry.GTYPE_POLYGON,
        com.oracle.cep.cartridge.spatial.Geometry.createElemInfo(1, 1003, 1),
        ordsgenerator@spatial(
            lng1, lat1, lng2, lat2, lng3, lat3,
            lng4, lat4, lng5, lat5, lng6, lat6
        ) 
    ) as geom
    from ShopDesc
</view>

createGeometry

Syntax

Surrounding text describes creategeometry.gif.

Purpose

This com.oracle.cep.cartridge.spatial.Geometry method returns a new 2D oracle.cep.cartridge.spatial.Geometry object.

This method takes the following arguments:

Examples

Example 16-13 shows how to use the createGeometry method. Because this createGeometry call does not include the srid argument, it uses the spatial link name to associate the method call with the Oracle Spatial data cartridge application context.

Example 16-13 Oracle CQL Query Using Geometry.createGeometry

<view id="ShopGeom">
    select  com.oracle.cep.cartridge.spatial.Geometry.createGeometry@spatial(
        com.oracle.cep.cartridge.spatial.Geometry.GTYPE_POLYGON,
        com.oracle.cep.cartridge.spatial.Geometry.createElemInfo(1, 1003, 1),
        ordsgenerator@spatial(
            lng1, lat1, lng2, lat2, lng3, lat3,
            lng4, lat4, lng5, lat5, lng6, lat6
        ) 
    ) as geom
    from ShopDesc
</view>

createLinearPolygon

Syntax

Surrounding text describes createlinearpolygon.gif.

Purpose

This com.oracle.cep.cartridge.spatial.Geometry method returns a new com.oracle.cep.cartridge.spatial.Geometry object which is a 2D simple linear polygon without holes. If the coordinate array does not close itself (the last coordinate is not the same as the first) then this method copies the first coordinate and appends this coordinate value to the end of the input coordinates array.

To create a simple linear polygon without holes, use the following arguments:

Examples

Example 16-14 shows how to use the createLinearPolygon method. Because this createLinearPolygon method call does not include the srid argument, it must use the spatial link name to associate the method call with the Oracle Spatial data cartridge application context.

Example 16-14 Oracle CQL Query Using Geometry.createLinearPolygon

<view id="LocGeomStream" schema="customerId curLoc">
    select 
        customerId, 
        com.oracle.cep.cartridge.spatial.Geometry.createLinearPolygon@spatial(coords) 
    from 
        CustomerLocStream
</view>

createPoint

Syntax

Surrounding text describes createpoint.gif.

Purpose

This com.oracle.cep.cartridge.spatial.Geometry method returns a new com.oracle.cep.cartridge.spatial.Geometry object which is a 3D point.

This method takes the following arguments:

Examples

Example 16-15 shows how to use the createPoint method. Because this createPoint call includes the srid argument, it does not need to use the spatial link name.

Example 16-15 Oracle CQL Query Using Geometry.createPoint

<view id="LocGeomStream" schema="customerId curLoc">
    select 
        customerId, 
        com.oracle.cep.cartridge.spatial.Geometry.createPoint@spatial(lng, lat) 
    from 
        CustomerLocStream
</view>

createRectangle

Syntax

Surrounding text describes createrectangle.gif.

Purpose

This com.oracle.cep.cartridge.spatial.Geometry method returns a new com.oracle.cep.cartridge.spatial.Geometry object which is a 2D rectangle.

This method takes the following arguments:

Examples

Example 16-16 shows how to use the createRectangle method. Because this createRectangle method call does not include the srid argument, it must use the spatial link name to associate the method call with the Oracle Spatial data cartridge application context.

Example 16-16 Oracle CQL Query Using Geometry.createRectangle

<view id="LocGeomStream" schema="customerId curLoc">
    select 
        customerId, 
        com.oracle.cep.cartridge.spatial.Geometry.createRectangle@spatial(x1, y1, x2, y2) 
    from 
        CustomerLocStream
</view>

distance

Syntax

Surrounding text describes distance.gif.

Purpose

This com.oracle.cep.cartridge.spatial.Geometry method calculates the distance between two geometries as a double.

To calculate the distance between a given com.oracle.cep.cartridge.spatial.Geometry object and another, use the non-static distance method of the current Geometry object with the following arguments:

To calculate the distance between two com.oracle.cep.cartridge.spatial.Geometry objects, use the static distance method with the following arguments:

In both cases, this method obtains parameters from the Oracle Spatial data cartridge application context. Consequently, you must use the spatial link name to associate the method call with the Oracle Spatial data cartridge application context:

com.oracle.cep.cartridge.spatial.Geometry.distance@spatial(geom)
com.oracle.cep.cartridge.spatial.Geometry.distance@spatial(geom1, geom2)

For more information, see Section 16.1.4, "Oracle Spatial Data Cartridge Application Context".

Examples

Example 16-17 shows how to use the distance method. Because the distance method depends on the Oracle Spatial data cartridge application context, it must use the spatial link name.

Example 16-17 Oracle CQL Query Using Geometry.distance

<view id="LocGeomStream" schema="customerId curLoc">
    select 
        customerId, 
        com.oracle.cep.cartridge.spatial.Geometry.createRectangle(x1, y1, x2, y2, 8307) 
    from 
        CustomerLocStream
    where
        com.oracle.cep.cartridge.spatial.Geometry.distance@spatial(geom1, geom2) < 5
</view>

einfogenerator

Syntax

Surrounding text describes einfogenerator.gif.

Note:

This is an Oracle CQL function and not a method of the com.oracle.cep.cartridge.spatial.Geometry class so you invoke this function as Example 16-18 shows, without a package prefix:
einfogenerator@spatial

Alternatively, you can use the Geometry method createElemInfo. For more information, see "createElemInfo".

Purpose

This function returns a single element info value as an int[] from the given arguments.

This function takes the following arguments:

Examples

Example 16-18 shows how to use the oeinfogenerator function to create the element information for a geometry.

Example 16-18 Oracle CQL Query Using Oracle Spatial Geometry Types

view id="ShopGeom">
    select  com.oracle.cep.cartridge.spatial.Geometry.createGeometry@spatial(
        com.oracle.cep.cartridge.spatial.Geometry.GTYPE_POLYGON,
        einfogenerator@spatial(1, 1003, 1),
        ordsgenerator@spatial(
            lng1, lat1, lng2, lat2, lng3, lat3,
            lng4, lat4, lng5, lat5, lng6, lat6
        ) 
    ) as geom
    from ShopDesc
</view>

get2dMbr

Syntax

Surrounding text describes get2dmbr.gif.

Purpose

This com.oracle.cep.cartridge.spatial.Geometry method returns the MBR of a given Geometry as a double[][] that contains the following values:

This method takes the following arguments:

Examples

Example 16-19 shows how to use the get2dMbr method.

Example 16-19 Oracle CQL Query Using Geometry.get2dMbr

<view id="LocGeomStream" schema="customerId mbr">
    select 
        customerId, 
        com.oracle.cep.cartridge.spatial.Geometry.get2dMbr(geom)
    from 
        CustomerLocStream
    where
        com.oracle.cep.cartridge.spatial.Geometry.distance@spatial(geom1, geom2) < 5
</view>

ordsgenerator

Syntax

Surrounding text describes ordsgenerator.gif.

Note:

This is an Oracle CQL function and not a method of the com.oracle.cep.cartridge.spatial.Geometry class so you invoke this function as Example 16-20 shows, without a package prefix:
ordsgenerator@spatial

Purpose

This function returns the double array of 2D coordinates that Oracle Spatial requires.

This function takes the following arguments:

Examples

Example 16-20 shows how to use the ordsgenerator function to create an Oracle Spatial double array out of six double coordinate values.

Example 16-20 Oracle CQL Query Using Oracle Spatial Geometry Types

view id="ShopGeom">
    select  com.oracle.cep.cartridge.spatial.Geometry.createGeometry@spatial(
        com.oracle.cep.cartridge.spatial.Geometry.GTYPE_POLYGON,
        com.oracle.cep.cartridge.spatial.Geometry.createElemInfo(1, 1003, 1),
        ordsgenerator@spatial(
            lng1, lat1, lng2, lat2, lng3, lat3,
            lng4, lat4, lng5, lat5, lng6, lat6
        ) 
    ) as geom
    from ShopDesc
</view>

to_Geometry

Syntax

Surrounding text describes to_geometry.gif.

Purpose

This com.oracle.cep.cartridge.spatial.Geometry method converts an oracle.spatial.geometry.JGeometry type to a 3D com.oracle.cep.cartridge.spatial.Geometry type. If the given geometry is already a Geometry type and a 3D geometry, then no conversion is done. If the given geometry is a 2D geometry, then the given geometry is converted to 3D by padding z coordinates.

This method takes the following arguments:

Examples

Example 16-21 shows how to use the to_Geometry method.

Example 16-21 Oracle CQL Query Using Geometry.to_Geometry

<view id="LocStream" schema="customerId loc">
    select 
        customerId, 
        com.oracle.cep.cartridge.spatial.Geometry.to_Geometry(geom) 
    from 
        CustomerLocStream
</view>

to_JGeometry

Syntax

Surrounding text describes to_jgeometry.gif.

Purpose

This com.oracle.cep.cartridge.spatial.Geometry method converts a com.oracle.cep.cartridge.spatial.Geometry object to an oracle.spatial.geometry.JGeometry 2D type.

This method takes the following arguments:

Examples

Example 16-22 shows how to use the to_JGeometry method.

Example 16-22 Oracle CQL Query Using Geometry.to_JGeometry

<view id="LocStream" schema="customerId loc">
    select 
        customerId, 
        com.oracle.cep.cartridge.spatial.Geometry.to_JGeometry(geom) 
    from 
        CustomerLocStream
</view>