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:
Oracle Spatial is an option for Oracle Database that provides advanced spatial features to support highend geographic information systems (GIS) and locationenabled 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:
Product overview: http://www.oracle.com/technology/products/spatial/index.html
Oracle Spatial documentation: http://www.oracle.com/pls/db112/portal.portal_db?selected=7&frame=#oracle_spatial_and_location_information
Oracle Spatial Java API reference: http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11829/toc.htm
This section describes:
The Oracle Spatial data cartridge uses the cartridge ID com.oracle.cep.cartrdiges.spatial
and registers the serverscoped 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:
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 161 describes.
Table 161 Oracle Spatial Data Cartridge Scope
Oracle Spatial Feature  Scope 

Geometry Types 
The following geometry types from the Oracle Spatial Java API:
The following geometry operations:
For more information, see: 
Geometric Relation Operators 
For more information, see Section 16.1.2.3, "Geometry Relation Operators". 
Geometric Filter Operators 
For more information, see Section 16.1.2.4, "Geometry Filter Operators". 
Geometric Index 
For more information, see Section 16.1.2.5, "Geometric Index". 
Coordinate Systems 
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".
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 162 describes the geometry types from the com.oracle.cep.cartridge.spatial.Geometry
class that you can use.
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:
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:
"SDO_ELEM_INFO" in the Oracle Spatial Developer's Guide.
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".
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:
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 RTree indexing for the default indexing mechanism. A spatial Rtree index can index spatial data of up to four dimensions. An Rtree index approximates each geometry by a single rectangle that minimally encloses the geometry (called the minimum bounding rectangle, or MBR)
For more information, see:
"Indexing of Spatial Data" in the Oracle Spatial Developer's Guide
Table 163 lists the coordinate systems that the Oracle Spatial data cartridge supports by default and the SDO_SRID
value that identifies each coordinate system.
Table 163 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 acom.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:
"SDO_SRID" in the Oracle Spatial Developer's Guide
"Coordinate Systems (Spatial Reference Systems)" in the Oracle Spatial Developer's Guide
Section 16.2.6, "How to Use the Default Geodetic Coordinates"
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 zeropads 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:
Section 16.1.2.7.1, "com.oracle.cep.cartridge.spatial.Geometry Methods"
Section 16.1.2.7.2, "oracle.spatial.geometry.JGeometry Methods"
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.Table 164 lists the public methods that the Geometry
class provides.
Table 164 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 acom.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".
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:
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".
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 161 shows how to create a spatial context named SpatialGRS80
in an EPN assembly file using the Geodetic Reference System 1980 (GRS80) coordinate system.
Example 161 spatial:context Element in EPN Assembly File
<spatial:context id="SpatialGRS80" srid="4269" sma="6378137" rof="298.25722101" />
Example 162 shows how to reference a spatial:context
in an Oracle CQL query. In this case, the query uses link name SpatialGRS80
(defined in Example 161) 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 162 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 acom.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".
This section describes common usecases that highlight how you can use the Oracle Spatial data cartridge in your Oracle CEP applications, including:
Section 16.2.1, "How to Access the Geometry Types That the Oracle Spatial Java API Supports"
Section 16.2.3, "How to Access Geometry Type Public Methods and Fields"
Section 16.2.6, "How to Use the Default Geodetic Coordinates"
For more information, see Section 16.1.2.7, "Geometry API".
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:
Choose an SDO_GTYPE
, for example, GTYPE_POLYGON
.
For more information, see Section 16.1.2.1, "Geometry Types".
Choose the Element Info appropriate for your ordinates.
For more information, see Section 16.1.2.2, "Element Info Array"
Define your coordinate values.
For more information, see Section 16.1.2.6, "Ordinates and Coordinate Systems and the SDO_SRID".
Create your Oracle CQL query as Example 163 shows.
Example 163 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>
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 164 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 164 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".
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 165, 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 165 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:
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 166, the view op_in_where
uses the CONTAIN
geometry relation operator in the WHERE
clause: in this case, the Oracle Spatial data cartridge uses RTree indexing. The view op_in_proj
uses CONTAIN
in the SELECT
clause.
Example 166 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".
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 167, the view filter
uses the FILTER
geometry filter operator in the WHERE
clause.
Example 167 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".
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 168 shows, the createPoint
method call uses the default link (@spatial
). This guarantees that the default Oracle Spatial data cartridge application context is applied.
Example 168 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:
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:
Section 16.1.4, "Oracle Spatial Data Cartridge Application Context"
Section 16.1.2.6, "Ordinates and Coordinate Systems and the SDO_SRID"
To use other geodetic coordinates:
Create an Oracle Spatial application context and define the srid
attribute for the geodetic coordinate system you want to use.
Example 169 shows how to create a spatial context named SpatialGRS80
in an EPN assembly file using the Geodetic Reference System 1980 (GRS80) coordinate system.
In your Oracle CQL query, use the id of this spatial:context in your links.
Example 1610 shows how to reference a spatial:context
in an Oracle CQL query. In this case, the query uses link name SpatialGRS80
(defined in Example 169) 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.
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:
polygon
: an oracle.spatial.geometry.JGeometry
polygon.
distance
: the distance value used for this buffer as a double
.
This value is assumed to be in the same unit as the Unit of Projection for projected geometry. If the geometry is geodetic, this buffer width should be in meters.
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".
Example 1611 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.
Note:
Alternatively, you can use the functioneinfogenerator
. For more information, see "einfogenerator".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:
soffset
: the offset, as an int
, within the ordinates array where the first ordinate for this element is stored.
SDO_STARTING_OFFSET
values start at 1 and not at 0. Thus, the first ordinate for the first element will be at SDO_GEOMETRY.Ordinates(1)
. If there is a second element, its first ordinate will be at SDO_GEOMETRY.Ordinates(
n
* 3 + 2)
, where n
reflects the position within the SDO_ORDINATE_ARRAY
definition.
etype
: the type of the element as an int
.
The Oracle Spatial data cartridge supports SDO_ETYPE
values 1, 1003, and 2003 are considered simple elements (not compound types). They are defined by a single triplet entry in the element info array. These types are:
1: point.
1003: exterior polygon ring (must be specified in counterclockwise order).
2003: interior polygon ring (must be specified in clockwise order).
These types are further qualified by the SDO_INTERPRETATION
.
Note:
You cannot mix 1digit and 4digitSDO_ETYPE
values in a single geometry.interp
: the interpretation as an int
.
For an SDO_ETYPE that is a simple element (1, 1003, or 2003) the SDO_INTERPRETATION
attribute determines how the sequence of ordinates for this element is interpreted. For example, a polygon boundary may be made up of a sequence of connected straight line segments.
If a geometry consists of more than one element, then the last ordinate for an element is always one less than the starting offset for the next element. The last element in the geometry is described by the ordinates from its starting offset to the end of the ordinates varying length array.
Table 165 describes the relationship between SDO_ETYPE
and SDO_INTERPREATION
.
Table 165 SDO_ETYPE and SDO_INTERPRETATION
SDO_ETYPE  SDO_INTERPRETATION  Description 

0 
Any numeric value 
Used to model geometry types not supported by Oracle Spatial. 
1 
1 
Point type. 
1 
0 
Orientation for an oriented point. 
1003 or 2003 
1 
Simple polygon whose vertices are connected by straight line segments. You must specify a point for each vertex; and the last point specified must be exactly the same point as the first (within the tolerance value), to close the polygon. For example, for a 4sided polygon, specify 5 points, with point 5 the same as point 1. 
Example 1612 shows how to use the createElemInfo
method.
Example 1612 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>
This com.oracle.cep.cartridge.spatial.Geometry
method returns a new 2D oracle.cep.cartridge.spatial.Geometry
object.
This method takes the following arguments:
gtype
: the geometry type as an int
.
For more information, see Table 162.
eleminfo
: the geometry element info as an int[]
.
For more information, see "createElemInfo".
ordinates
: the geometry ordinates as a double[]
.
srid
: the optional SDO_SRID
of the geometry as an int
.
If you omit the srid
parameter, then 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.createGeometry@spatial(gtype, eleminfo, ordinates)
For more information, see Section 16.1.4, "Oracle Spatial Data Cartridge Application Context".
Example 1613 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 1613 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>
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:
coords
: the coordinates of the linear polygon as a double[]
.
srid
: the optional SRID
of the geometry as an int
.
If you omit the srid
parameter, then 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.createLinearPolygon@spatial(coords)
For more information, see Section 16.1.4, "Oracle Spatial Data Cartridge Application Context".
Example 1614 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.
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:
x
: the x coordinate of the lower left as a double
.
y
: the y coordinate of the lower left as a double
.
srid
: the optional SRID
of the geometry as an int
.
If you omit the srid
parameter, then 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.createPoint@spatial(x, y)
For more information, see Section 16.1.4, "Oracle Spatial Data Cartridge Application Context".
Example 1615 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.
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:
x1
: the x coordinate of the lower left as a double
.
y1
: the y coordinate of the lower left as a double
.
x2
: the x coordinate of the upper right as a double
.
y2
: the y coordinate of the upper right as a double
.
srid
: the optional SRID
of the geometry as an int
.
If you omit the srid
parameter, then 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.createRectangle@spatial(x1, y1, x2, y2)
For more information, see Section 16.1.4, "Oracle Spatial Data Cartridge Application Context".
Example 1616 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.
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 nonstatic distance
method of the current Geometry
object with the following arguments:
g
: the other com.oracle.cep.cartridge.spatial.Geometry
object.
To calculate the distance between two com.oracle.cep.cartridge.spatial.Geometry
objects, use the static distance
method with the following arguments:
g1
: the first com.oracle.cep.cartridge.spatial.Geometry
object.
g2
: the second com.oracle.cep.cartridge.spatial.Geometry
object.
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".
Example 1617 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 1617 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>
Note:
This is an Oracle CQL function and not a method of thecom.oracle.cep.cartridge.spatial.Geometry
class so you invoke this function as Example 1618 shows, without a package prefix:
einfogenerator@spatial
Alternatively, you can use the Geometry
method createElemInfo
. For more information, see "createElemInfo".
This function returns a single element info value as an int[]
from the given arguments.
This function takes the following arguments:
offset
: the offset, as an int
, within the ordinates array where the first ordinate for this element is stored.
SDO_STARTING_OFFSET
values start at 1 and not at 0. Thus, the first ordinate for the first element will be at SDO_GEOMETRY.Ordinates(1)
. If there is a second element, its first ordinate will be at SDO_GEOMETRY.Ordinates(
n
* 3 + 2)
, where n
reflects the position within the SDO_ORDINATE_ARRAY
definition.
etype
: the type of the element as an int
.
The Oracle Spatial data cartridge supports SDO_ETYPE
values 1, 1003, and 2003 are considered simple elements (not compound types). They are defined by a single triplet entry in the element info array. These types are:
1: point.
1003: exterior polygon ring (must be specified in counterclockwise order).
2003: interior polygon ring (must be specified in clockwise order).
These types are further qualified by the SDO_INTERPRETATION
.
Note:
You cannot mix 1digit and 4digitSDO_ETYPE
values in a single geometry.interp
: the interpretation as an int
.
For an SDO_ETYPE that is a simple element (1, 1003, or 2003) the SDO_INTERPRETATION
attribute determines how the sequence of ordinates for this element is interpreted. For example, a polygon boundary may be made up of a sequence of connected straight line segments.
If a geometry consists of more than one element, then the last ordinate for an element is always one less than the starting offset for the next element. The last element in the geometry is described by the ordinates from its starting offset to the end of the ordinates varying length array.
Table 166 describes the relationship between SDO_ETYPE
and SDO_INTERPREATION
.
Table 166 SDO_ETYPE and SDO_INTERPRETATION
SDO_ETYPE  SDO_INTERPRETATION  Description 

0 
Any numeric value 
Used to model geometry types not supported by Oracle Spatial. 
1 
1 
Point type. 
1 
0 
Orientation for an oriented point. 
1003 or 2003 
1 
Simple polygon whose vertices are connected by straight line segments. You must specify a point for each vertex; and the last point specified must be exactly the same point as the first (within the tolerance value), to close the polygon. For example, for a 4sided polygon, specify 5 points, with point 5 the same as point 1. 
Example 1618 shows how to use the oeinfogenerator
function to create the element information for a geometry.
Example 1618 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>
This com.oracle.cep.cartridge.spatial.Geometry
method returns the MBR
of a given Geometry
as a double[][]
that contains the following values:
[0][0]
: minX
[0][1]
: maxX
[1][0]
: minY
[1][1]
: maxY
This method takes the following arguments:
geom
: the com.oracle.cep.cartridge.spatial.Geometry
object.
Example 1619 shows how to use the get2dMbr
method.
Note:
This is an Oracle CQL function and not a method of thecom.oracle.cep.cartridge.spatial.Geometry
class so you invoke this function as Example 1620 shows, without a package prefix:
ordsgenerator@spatial
This function returns the double
array of 2D coordinates that Oracle Spatial requires.
This function takes the following arguments:
x1, y1, ... xN, yN
: a commaseparated list of double
coordinate values.
Example 1620 shows how to use the ordsgenerator
function to create an Oracle Spatial double array out of six double
coordinate values.
Example 1620 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>
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:
geom
: the oracle.spatial.geometry.JGeometry
object to convert.
Example 1621 shows how to use the to_Geometry
method.
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:
g
: the com.oracle.cep.cartridge.spatial.Geometry
object to convert.
Example 1622 shows how to use the to_JGeometry
method.