Skip Headers
Oracle® Fusion Middleware CQL Language Reference for Oracle Complex Event Processing
11g Release 1 (11.1.1.6.3)

Part Number E12048-10
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
PDF · Mobi · ePub

16 Oracle Spatial

This chapter provides a reference and guide to using the Oracle Spatial cartridge, which extends Oracle Continuous Query Language (Oracle CQL) to provide advanced spatial features for location-enabled applications.

You can use Oracle Spatial types, methods, fields, and constructors in Oracle CQL queries and views as you would Oracle CQL native types when building Oracle CEP applications.

This chapter describes:

For more information, see:

16.1 Understanding Oracle Spatial

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).

Oracle Spatial 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 Oracle Spatial, 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 Oracle Spatial, 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

Oracle Spatial 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 method call with the Oracle Spatial application context.

For more information, see:

16.1.2 Scope

Oracle Spatial is based on the Oracle Spatial Java API. Oracle Spatial 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 Oracle Spatial.

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

Table 16-1 Oracle Spatial 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:

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.3, "Ordinates and Coordinate Systems and the SDO_SRID".

Geometric Index

  • R-Tree

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

Geometric Relation Operators

For more information, see Section 16.1.2.5, "Geometric Relation Operators".

Geometric Filter Operators

For more information, see Section 16.1.2.6, "Geometric Filter Operators".

Geometry API

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 Oracle Spatial, see Section 16.2, "Using Oracle Spatial".

16.1.2.1 Geometry Types

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

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

  • SDO_GTYPES: Oracle Spatial 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 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 ordsgenerator function.

    For more information, see Section 16.1.2.3, "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.

Oracle Spatial 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 Ordinates and Coordinate Systems and the SDO_SRID

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

Table 16-3 Oracle Spatial 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 Oracle Spatial.


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 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 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 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 Application Context".

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

For more information, see:

16.1.2.4 Geometric Index

Oracle Spatial 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.

Oracle Spatial 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.5 Geometric Relation Operators

Oracle Spatial supports the following Oracle Spatial geometric relation operators:

You can use any of these operators in either the Oracle CQL query projection clause or where clause.

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

Oracle Spatial supports only geometric relations between point and other geometry types.

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

16.1.2.6 Geometric Filter Operators

Oracle Spatial supports the following Oracle Spatial geometric filter operators:

These filter 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.7 Geometry API

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

Although Oracle Spatial 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 Oracle Spatial supports) is inaccessible from Oracle Spatial.

This section describes:

For more information, see:

Note:

To simplify Oracle Spatial type names, you can use aliases as Section 2.7.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

Minimum Bounding Rectangle (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 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 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 Application Context".

16.1.2.7.2 oracle.spatial.geometry.JGeometry Methods

The following JGeometry public methods are applicable to Oracle Spatial:

  • 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 Minimum Bounding Rectangle (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 Application Context

You can define an application context for an instance of Oracle Spatial 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 instance.

Before you can define an Oracle Spatial application context, edit your Oracle CEP application EPN assembly file to add the required namespace and schema location entries as Example 16-1 shows:

Example 16-1 EPN Assembly File: Oracle Spatial Namespace and Schema Location

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:osgi="http://www.springframework.org/schema/osgi"
       xmlns:wlevs="http://www.bea.com/ns/wlevs/spring"
       xmlns:spatial="http://www.oracle.com/ns/ocep/spatial"
       xsi:schemaLocation="
  http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans.xsd
  http://www.springframework.org/schema/osgi
  http://www.springframework.org/schema/osgi/spring-osgi.xsd
  http://www.bea.com/ns/wlevs/spring
  http://www.bea.com/ns/wlevs/spring/spring-wlevs-v11_1_1_6.xsd"
  http://www.oracle.com/ns/ocep/spatial
  http://www.oracle.com/ns/ocep/spatial/ocep-spatial.xsd">

Example 16-2 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-2 spatial:context Element in EPN Assembly File

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

Example 16-3 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-2) to propagate this application context to Oracle Spatial. The spatial:context attribute settings of SpatialGRS80 are applied to the createPoint method call.

Example 16-3 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 "How to Configure Oracle Spatial Application Context" in the Oracle Fusion Middleware Developer's Guide for Oracle Complex Event Processing 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 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 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 Oracle Spatial

This section describes common use-cases that highlight how you can use Oracle Spatial 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 Oracle Spatial in an Oracle CQL query.

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

  1. Import the package com.oracle.cep.cartridge.spatial into your Oracle CEP application's MANIFEST.MF file.

    For more information, see "How to Import a Package" in the Oracle Fusion Middleware Developer's Guide for Oracle Complex Event Processing for Eclipse.

  2. Define your Oracle CEP application event type using the appropriate Oracle Spatial data types.

    Example 16-4 shows how to define event type MySpatialEvent with two event properties x and y of type com.oracle.cep.cartridge.spatial.Geometry.

    Example 16-4 Oracle CEP Event Using Oracle Spatial Types

    <wlevs:event-type-repository>
        <wlevs:event-type type-name="MySpatialEvent">
            <wlevs:properties>
                <wlevs:property name="x" type="com.oracle.cep.cartridge.spatial.Geometry"/>
                <wlevs:property name="y" type="com.oracle.cep.cartridge.spatial.Geometry"/>
            </wlevs:properties>
        </wlevs:event-type>
    </wlevs:event-type-repository>
    

    You can use these event properties in an Oracle CQL query like this:

    CONTAIN@spatial(x, y, 20.0d)
    

    For more information, see "Overview of Oracle CEP Events" in the Oracle Fusion Middleware Developer's Guide for Oracle Complex Event Processing for Eclipse.

  3. Choose an SDO_GTYPE, for example, GTYPE_POLYGON.

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

  4. Choose the Element Info appropriate for your ordinates.

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

  5. Define your coordinate values.

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

  6. Create your Oracle CQL query as Example 16-5 shows.

    Example 16-5 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 Oracle Spatial 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 Oracle Spatial supports.

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

Using a Static Method in the Oracle Spatial Geometry Class

Example 16-6 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 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 Application Context").

Example 16-6 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 Oracle Spatial, 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 Oracle Spatial supports) is inaccessible from Oracle Spatial.

In Example 16-7, 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-7 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 Oracle Spatial, you can access the following Oracle Spatial geometry relation operators in either the WHERE or SELECT clause of an Oracle CQL query:

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

Example 16-8 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.5, "Geometric Relation Operators".

16.2.5 How to Use Geometry Filter Operators

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

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

Example 16-9 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.6, "Geometric Filter Operators".

16.2.6 How to Use the Default Geodetic Coordinates

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

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

Example 16-10 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 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-11 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-11 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-12 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-11) to propagate this application context to Oracle Spatial. The spatial:context attribute settings of SpatialGRS80 are applied to the createPoint method call.

    Example 16-12 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>
    

ANYINTERACT

Syntax

Surrounding text describes anyinteract.png.

Note:

This is an Oracle Spatial geometric relation operator and not a method of the com.oracle.cep.cartridge.spatial.Geometry class so you invoke this operator as Example 16-13 shows, without a package prefix:

ANYINTERACT@spatial

Purpose

This operator returns true if the GTYPE_POINT interacts with the geometry, and false otherwise.

This operator takes the following arguments:

For more information, see "SDO_ANYINTERACT" in the Oracle Spatial Developer's Guide.

Examples

Example 16-27 shows how to use the ANYINTERACT Oracle Spatial geometric relation operator in an Oracle CQL query.

Example 16-13 Oracle CQL Query Using Geometric Relation Operator ANYINTERACT

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

bufferPolygon

Syntax

Surrounding text describes bufferpolygon.png.

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 application context. Consequently, you must use the spatial link name to associate the method call with the Oracle Spatial application context:

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

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

Examples

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

Example 16-14 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>

CONTAIN

Syntax

Surrounding text describes contain.png.

Note:

This is an Oracle Spatial geometric relation operator and not a method of the com.oracle.cep.cartridge.spatial.Geometry class so you invoke this operator as Example 16-13 shows, without a package prefix:

CONTAIN@spatial

Purpose

This operator returns true if the GTYPE_POINT is contained by the geometry, and false otherwise.

This operator takes the following arguments:

For more information, see "SDO_CONTAINS" in the Oracle Spatial Developer's Guide.

Examples

Example 16-27 shows how to use the CONTAIN Oracle Spatial geometric relation operator in an Oracle CQL query.

Example 16-15 Oracle CQL Query Using Geometric Relation Operator CONTAIN

<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>

createElemInfo

Syntax

Surrounding text describes createeleminfo.png.

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-16 shows how to use the createElemInfo method.

Example 16-16 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.png.

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-17 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 application context.

Example 16-17 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.png.

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-18 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 application context.

Example 16-18 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.png.

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-19 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-19 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.png.

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-20 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 application context.

Example 16-20 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.png.

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 application context. Consequently, you must use the spatial link name to associate the method call with the Oracle Spatial 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 Application Context".

Examples

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

Example 16-21 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.png.

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-22 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-22 shows how to use the oeinfogenerator function to create the element information for a geometry.

Example 16-22 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>

FILTER

Syntax

Surrounding text describes filter.png.

Note:

This is an Oracle Spatial geometric filter operator and not a method of the com.oracle.cep.cartridge.spatial.Geometry class so you invoke this operator as Example 16-13 shows, without a package prefix:

FILTER@spatial

Purpose

This operator returns true for object pairs that are non-disjoint, and false otherwise.

This operator takes the following arguments:

For more information, see "SDO_FILTER" in the Oracle Spatial Developer's Guide.

Examples

Example 16-27 shows how to use the FILTER Oracle Spatial geometric filter operator in an Oracle CQL query.

Example 16-23 Oracle CQL Query Using Geometric Relation Operator FILTER

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

get2dMbr

Syntax

Surrounding text describes get2dmbr.png.

Purpose

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

This method takes the following arguments:

Examples

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

Example 16-24 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>

INSIDE

Syntax

Surrounding text describes inside.png.

Note:

This is an Oracle Spatial geometric relation operator and not a method of the com.oracle.cep.cartridge.spatial.Geometry class so you invoke this operator as Example 16-13 shows, without a package prefix:

INSIDE@spatial

Purpose

This operator returns true if the GTYPE_POINT is inside the geometry, and false otherwise.

This operator takes the following arguments:

For more information, see "SDO_INSIDE" in the Oracle Spatial Developer's Guide.

Examples

Example 16-27 shows how to use the INSIDE Oracle Spatial geometric relation operator in an Oracle CQL query.

Example 16-25 Oracle CQL Query Using Geometric Relation Operator INSIDE

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

NN

Syntax

Surrounding text describes nn.png.

Note:

This is an Oracle Spatial geometric filter operator and not a method of the com.oracle.cep.cartridge.spatial.Geometry class so you invoke this operator as Example 16-13 shows, without a package prefix:

NN@spatial

Purpose

This operator returns the objects (nearest neighbors) from geom that are nearest to key. In determining how near two geometry objects are, the shortest possible distance between any two points on the surface of each object is used.

This function takes the following arguments:

For more information, see "SDO_NN" in the Oracle Spatial Developer's Guide.

Examples

Example 16-27 shows how to use the NN Oracle Spatial geometric filter operator in an Oracle CQL query.

Example 16-26 Oracle CQL Query Using Geometric Relation Operator NN

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

ordsgenerator

Syntax

Surrounding text describes ordsgenerator.png.

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-27 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-27 shows how to use the ordsgenerator function to create an Oracle Spatial double array out of six double coordinate values.

Example 16-27 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.png.

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-28 shows how to use the to_Geometry method.

Example 16-28 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.png.

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-29 shows how to use the to_JGeometry method.

Example 16-29 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>

WITHINDISTANCE

Syntax

Surrounding text describes withindistance.png.

Note:

This is an Oracle Spatial geometric relation operator and not a method of the com.oracle.cep.cartridge.spatial.Geometry class so you invoke this operator as Example 16-13 shows, without a package prefix:

WITHINDISTANCE@spatial

Purpose

This operator returns true if the GTYPE_POINT is within the given distance of the geometry, and false otherwise.

This operator takes the following arguments:

For more information, see "SDO_WITHIN_DISTANCE" in the Oracle Spatial Developer's Guide.

Examples

Example 16-27 shows how to use the WITHINDISTANCE Oracle Spatial geometric relation operator in an Oracle CQL query.

Example 16-30 Oracle CQL Query Using Geometric Relation Operator WITHINDISTANCE

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