This chapter contains descriptions of the tuning subprograms shown in Table 191.
Table 191 Tuning Subprograms
Subprogram  Description 


Calculates the average minimum bounding rectangle for geometries in a layer. 
SDO_TUNE.ESTIMATE_RTREE_INDEX_SIZE 
Estimates the maximum number of megabytes needed for an Rtree spatial index table. 

Returns the minimum bounding rectangle of the data in a layer. 

Calculates geometry type information for a spatial layer, such as the percentage of each geometry type. 

Returns the quality degradation for an index or the average quality degradation for all index tables for an index, or returns the quality degradation for a specified index table. 
Format
SDO_TUNE.AVERAGE_MBR(
table_name IN VARCHAR2,
column_name IN VARCHAR2,
width OUT NUMBER,
height OUT NUMBER);
Description
Calculates the average minimum bounding rectangle (MBR) for geometries in a layer.
Parameters
Spatial geometry table.
Geometry column for which the average minimum bounding rectangle is to be computed.
Width of the average minimum bounding rectangle.
Height of the average minimum bounding rectangle.
Usage Notes
This procedure computes and stores the width and height of the average minimum bounding rectangle for all geometries in a spatial geometry table. It calculates the average MBR by keeping track of the maximum and minimum X and Y values for all geometries in a spatial geometry table.
Examples
The following example calculates the minimum bounding rectangle for the SHAPE column of the COLA_MARKETS table.
DECLARE table_name VARCHAR2(32) := 'COLA_MARKETS'; column_name VARCHAR2(32) := 'SHAPE'; width NUMBER; height NUMBER; BEGIN SDO_TUNE.AVERAGE_MBR( table_name, column_name, width, height); DBMS_OUTPUT.PUT_LINE('Width = '  width); DBMS_OUTPUT.PUT_LINE('Height = '  height); END; / Width = 3.5 Height = 4.5
Related Topics
SDO_AGGR_MBR spatial aggregate function (in Chapter 12)
Format
SDO_TUNE.ESTIMATE_RTREE_INDEX_SIZE(
schemaname IN VARCHAR2,
tabname IN VARCHAR2,
colname IN VARCHAR2,
partname IN VARCHAR2 DEFAULT NULL
) RETURN NUMBER;
or
SDO_TUNE.ESTIMATE_RTREE_INDEX_SIZE(
number_of_geoms IN INTEGER,
db_block_size IN INTEGER,
sdo_rtr_pctfree IN INTEGER DEFAULT 10,
num_dimensions IN INTEGER DEFAULT 2,
is_geodetic IN INTEGER DEFAULT 0
) RETURN NUMBER;
Description
Estimates the maximum number of megabytes needed for an Rtree spatial index table.
Parameters
Schema that owns the spatial geometry table.
Spatial geometry table name.
Geometry column name.
Name of a partition containing geometries from colname
. If you specify this parameter, the value returned by the function is the estimated size for an Rtree index table on geometries in that partition. If you do not specify this parameter, the value is the estimated size for an Rtree index table on all geometries in colname
.
Approximate number of geometries in the spatial geometry table.
Database block size (in bytes).
Minimum percentage of slots in each index tree node to be left empty when the index is created. Slots that are left empty can be filled later when new data is inserted into the table. The value can range from 0 to 50. The default value (10) is best for most applications; however, a value of 0 is recommended if no updates will be performed to the geometry column.
Number of dimensions to be indexed. The default value is 2. If you plan to specify the sdo_indx_dims
parameter in the CREATE INDEX statement, the num_dimensions
value should match the sdo_indx_dims
value.
A value indicating whether or not the spatial index will be a geodetic index: 1 for a geodetic index, or 0 (the default) for a nongeodetic index. (Section 4.1.1 explains geodetic indexes.)
Usage Notes
The function returns the estimated maximum number of megabytes needed for the spatial index table (described in Section 2.7.2) for an Rtree spatial index to be created. The value returned is the maximum number of megabytes needed after index creation. During index creation, approximately three times this value of megabytes will be needed in the tablespace, to ensure that there is enough space for temporary tables while the index is being created.
This function has two formats:
Use the format with character string parameters (schemaname
, tabname
, colname
, and optionally partname
) in most cases when the spatial geometry table already exists, you do not plan to add substantially more geometries to it before creating the index, and you plan to use the default Rtree indexing parameters.
Use the format with integer parameters (number_of_geoms
, db_block_size
, sdo_rtr_pctfree
, num_dimensions
, is_geodetic
) in any of the following cases: the spatial geometry table does not exist; the spatial geometry table exists but you plan to add substantially more geometries to it before creating the index; the num_dimensions
value is not 2 for nongeodetic data or 3 for geodetic data, and a nondefault value will be specified using the sdo_indx_dims
parameter in the CREATE INDEX statement; or the data is geodetic but you plan to specify 'geodetic=false'
in the CREATE INDEX statement (see Section 4.1.1).
Examples
The following example estimates the maximum number of megabytes needed for a spatial index table for an index given the following information: number_of_geoms
= 1000000
(one million), db_block_size
= 2048
, sdo_rtr_pctfree
= 10
, num_dimensions
= 2
, is_geodetic = 0
.
SELECT SDO_TUNE.ESTIMATE_RTREE_INDEX_SIZE(1000000, 2048, 10, 2, 0) FROM DUAL; SDO_TUNE.ESTIMATE_RTREE_INDEX_SIZE(1000000,2048,10,2,0)  82
The following example estimates the maximum number of megabytes needed for a spatial index table for an index on the SHAPE column in the COLA_MARKETS table in the SCOTT schema. The estimate is based on the geometries that are currently in the table.
SELECT SDO_TUNE.ESTIMATE_RTREE_INDEX_SIZE('SCOTT', 'COLA_MARKETS', 'SHAPE') FROM DUAL; SDO_TUNE.ESTIMATE_RTREE_INDEX_SIZE('SCOTT','COLA_MARKETS','SHAPE')  1
Format
SDO_TUNE.EXTENT_OF(
table_name IN VARCHAR2,
column_name IN VARCHAR2
) RETURN SDO_GEOMETRY;
Description
Returns the minimum bounding rectangle (MBR) of all geometries in a layer.
Parameters
Spatial geometry table.
Geometry column for which the minimum bounding rectangle is to be returned.
Usage Notes
The SDO_AGGR_MBR function, documented in Chapter 12, also returns the MBR of geometries. The SDO_TUNE.EXTENT_OF function has better performance than the SDO_AGGR_MBR function if the data is nongeodetic and if a spatial index is defined on the geometry column; however, the SDO_TUNE.EXTENT_OF function is limited to twodimensional geometries, whereas the SDO_AGGR_MBR function is not. In addition, the SDO_TUNE.EXTENT_OF function computes the extent for all geometries in a table; by contrast, the SDO_AGGR_MBR function can operate on subsets of rows.
The SDO_TUNE.EXTENT_OF function returns NULL if the data is inconsistent.
If a nongeodetic spatial index is used, this function may return an approximate MBR that encloses the largest extent of data stored in the index, even if data was subsequently deleted. This can occur because the function extracts MBR information from a nongeodetic spatial index, if one exists.
Examples
The following example calculates the minimum bounding rectangle for the objects in the SHAPE column of the COLA_MARKETS table.
SELECT SDO_TUNE.EXTENT_OF('COLA_MARKETS', 'SHAPE') FROM DUAL; SDO_TUNE.EXTENT_OF('COLA_MARKETS','SHAPE')(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y,  SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 3), SDO_ORDINATE_ARRAY(1, 1, 10, 11))
Related Topics
SDO_AGGR_MBR aggregate function (in Chapter 12)
SDO_TUNE.AVERAGE_MBR procedure
Format
SDO_TUNE.MIX_INFO(
table_name IN VARCHAR2,
column_name IN VARCHAR2
[, total_geom OUT INTEGER,
point_geom OUT INTEGER,
curve_geom OUT INTEGER,
poly_geom OUT INTEGER,
complex_geom OUT INTEGER] );
Description
Calculates geometry type information for a spatial layer, such as the percentage of each geometry type.
Parameters
Spatial geometry table.
Geometry object column for which the geometry type information is to be calculated.
Total number of geometry objects.
Number of point geometry objects.
Number of curve string geometry objects.
Number of polygon geometry objects.
Number of complex geometry objects.
Usage Notes
This procedure calculates geometry type information for the table. It calculates the total number of geometries, as well as the number of point, curve string, polygon, and complex geometries.
Examples
The following example displays information about the mix of geometry objects in the SHAPE column of the COLA_MARKETS table.
CALL SDO_TUNE.MIX_INFO('COLA_MARKETS', 'SHAPE'); Total number of geometries: 4 Point geometries: 0 (0%) Curvestring geometries: 0 (0%) Polygon geometries: 4 (100%) Complex geometries: 0 (0%)
Format
SDO_TUNE.QUALITY_DEGRADATION(
schemaname IN VARCHAR2,
indexname IN VARCHAR2
) RETURN NUMBER;
or
SDO_TUNE.QUALITY_DEGRADATION(
schemaname IN VARCHAR2,
indexname IN VARCHAR2,
indextable IN VARCHAR2
) RETURN NUMBER;
Description
Returns the quality degradation for an index or the average quality degradation for all index tables for an index, or returns the quality degradation for a specified index table.
Parameters
Name of the schema that contains the index specified in indexname
.
Name of the spatial Rtree index.
Name of an index table associated with the spatial Rtree index specified in indexname
.
Usage Notes
The quality degradation is a number indicating approximately how much longer it will take to execute the I/O operations of the index portion of any given query with the current index, compared to executing the I/O operations of the index portion of the same query when the index was created or most recently rebuilt. For example, if the I/O operations of the index portion of a typical query will probably take twice as much time as when the index was created or rebuilt, the quality degradation is 2. The exact degradation in overall query time is impossible to predict; however, a substantial quality degradation (2 or 3 or higher) can affect query performance significantly for large databases, such as those with millions of rows.
For local partitioned indexes, you must use the format that includes the indextable
parameter. That is, you must compute the quality degradation for each partition in which you are interested.
Index names are available through the xxx_SDO_INDEX_INFO and xxx_SDO_INDEX_METADATA views, which are described in Section 2.7.1.
For more information and guidelines relating to Rtree quality and its possible effect on query performance, see Section 1.7.2.
Examples
The following example returns the quality degradation for the COLA_SPATIAL_IDX index. In this example, the quality has not degraded at all, and therefore the degradation is 1; that is, the I/O operations of the index portion of queries will typically take the same time using the current index as using the original or previous index.
SELECT SDO_TUNE.QUALITY_DEGRADATION('SCOTT', 'COLA_SPATIAL_IDX') FROM DUAL; SDO_TUNE.QUALITY_DEGRADATION('SCOTT','COLA_SPATIAL_IDX')  1
This document has three parts:
Part I provides conceptual and usage information about Oracle Spatial.
Part II provides reference information about Oracle Spatial operators, functions, and procedures.
Part III provides supplementary information (appendixes and a glossary).
Part II contains the following chapters with reference information:
To understand the examples in the reference chapters, you must understand the conceptual and data type information in Chapter 2, "Spatial Data Types and Metadata", especially Section 2.2, "SDO_GEOMETRY Object Type".
Oracle Spatial is an integrated set of functions and procedures that enables spatial data to be stored, accessed, and analyzed quickly and efficiently in an Oracle database.
Spatial data represents the essential location characteristics of real or conceptual objects as those objects relate to the real or conceptual space in which they exist.
This chapter contains the following major sections:
Section 1.12, "Spatial Java Application Programming Interface"
Section 1.15, "Open Geospatial Consortium (OGC) Conformance"
Section 1.17, "Spatial Application Hardware Requirement Considerations"
Section 1.20, "README File for Spatial and Related Features"
Oracle Spatial, often referred to as Spatial, provides a SQL schema and functions that facilitate the storage, retrieval, update, and query of collections of spatial features in an Oracle database. Spatial consists of the following:
A schema (MDSYS) that prescribes the storage, syntax, and semantics of supported geometric data types
A spatial indexing mechanism
Operators, functions, and procedures for performing areaofinterest queries, spatial join queries, and other spatial analysis operations
Functions and procedures for utility and tuning operations
Topology data model for working with data about nodes, edges, and faces in a topology (described in Oracle Spatial Topology and Network Data Models).
Network data model for representing capabilities or objects that are modeled as nodes and links in a network (described in Oracle Spatial Topology and Network Data Models).
GeoRaster, a feature that lets you store, index, query, analyze, and deliver GeoRaster data, that is, raster image and gridded data and its associated metadata (described in Oracle Spatial GeoRaster).
The spatial component of a spatial feature is the geometric representation of its shape in some coordinate space. This is referred to as its geometry.
Caution: Do not modify any packages, tables, or other objects under the MDSYS schema. (The only exception is if you need to create a userdefined coordinate reference system, as explained in Section 6.8.) 
Spatial supports the objectrelational model for representing geometries. This model stores an entire geometry in the Oracle native spatial data type for vector data, SDO_GEOMETRY. An Oracle table can contain one or more SDO_GEOMETRY columns. The objectrelational model corresponds to a "SQL with Geometry Types" implementation of spatial feature tables in the Open GIS ODBC/SQL specification for geospatial features.
Note: The relational geometry model of Oracle Spatial is no longer supported, effective with Oracle release 9.2. Only the objectrelational model is supported. 
The benefits provided by the objectrelational model include:
Support for many geometry types, including arcs, circles, compound polygons, compound line strings, and optimized rectangles
Ease of use in creating and maintaining indexes and in performing spatial queries
Index maintenance by the Oracle database
Geometries modeled in a single column
Optimal performance
Oracle Spatial is designed to make spatial data management easier and more natural to users of locationenabled applications and geographic information system (GIS) applications. Once spatial data is stored in an Oracle database, it can be easily manipulated, retrieved, and related to all other data stored in the database.
A common example of spatial data can be seen in a road map. A road map is a twodimensional object that contains points, lines, and polygons that can represent cities, roads, and political boundaries such as states or provinces. A road map is a visualization of geographic information. The location of cities, roads, and political boundaries that exist on the surface of the Earth are projected onto a twodimensional display or piece of paper, preserving the relative positions and relative distances of the rendered objects.
The data that indicates the Earth location (such as longitude and latitude) of these rendered objects is the spatial data. When the map is rendered, this spatial data is used to project the locations of the objects on a twodimensional piece of paper. A GIS is often used to store, retrieve, and render this Earthrelative spatial data.
Types of spatial data (other than GIS data) that can be stored using Spatial include data from computeraided design (CAD) and computeraided manufacturing (CAM) systems. Instead of operating on objects on a geographic scale, CAD/CAM systems work on a smaller scale, such as for an automobile engine or printed circuit boards.
The differences among these systems are in the size and precision of the data, not the data's complexity. The systems might all involve the same number of data points. On a geographic scale, the location of a bridge can vary by a few tenths of an inch without causing any noticeable problems to the road builders, whereas if the diameter of an engine's pistons is off by a few tenths of an inch, the engine will not run.
In addition, the complexity of data is independent of the absolute scale of the area being represented. For example, a printed circuit board is likely to have many thousands of objects etched on its surface, containing in its small area information that may be more complex than the details shown on a road builder's blueprints.
These applications all store, retrieve, update, or query some collection of features that have both nonspatial and spatial attributes. Examples of nonspatial attributes are name, soil_type, landuse_classification, and part_number. The spatial attribute is a coordinate geometry, or vectorbased representation of the shape of the feature.
A geometry is an ordered sequence of vertices that are connected by straight line segments or circular arcs. The semantics of the geometry are determined by its type. Spatial supports several primitive types, and geometries composed of collections of these types, including twodimensional:
Points and point clusters
Line strings
npoint polygons
Arc line strings (All arcs are generated as circular arcs.)
Arc polygons
Compound polygons
Compound line strings
Circles
Optimized rectangles
Twodimensional points are elements composed of two ordinates, X and Y, often corresponding to longitude and latitude. Line strings are composed of one or more pairs of points that define line segments. Polygons are composed of connected line strings that form a closed ring, and the area of the polygon is implied. For example, a point might represent a building location, a line string might represent a road or flight path, and a polygon might represent a state, city, zoning district, or city block.
Selfcrossing polygons are not supported, although selfcrossing line strings are supported. If a line string crosses itself, it does not become a polygon. A selfcrossing line string does not have any implied area.
Figure 11 illustrates the geometric types.
Spatial also supports the storage and indexing of threedimensional and fourdimensional geometric types, where three or four coordinates are used to define each vertex of the object being defined. However, spatial functions (except for LRS functions and MBRrelated functions) can work with only the first two dimensions, and all spatial operators except SDO_FILTER are disabled if the spatial index has been created on more than two dimensions.
The Spatial data model is a hierarchical structure consisting of elements, geometries, and layers. Layers are composed of geometries, which in turn are made up of elements.
An element is the basic building block of a geometry. The supported spatial element types are points, line strings, and polygons. For example, elements might model star constellations (point clusters), roads (line strings), and county boundaries (polygons). Each coordinate in an element is stored as an X,Y pair. The exterior ring and zero or more interior rings (holes) of a complex polygon are considered a single element.
Point data consists of one coordinate. Line data consists of two coordinates representing a line segment of the element. Polygon data consists of coordinate pair values, one vertex pair for each line segment of the polygon. Coordinates are defined in order around the polygon (counterclockwise for an exterior polygon ring, clockwise for an interior polygon ring).
A geometry (or geometry object) is the representation of a spatial feature, modeled as an ordered set of primitive elements. A geometry can consist of a single element, which is an instance of one of the supported primitive types, or a homogeneous or heterogeneous collection of elements. A multipolygon, such as one used to represent a set of islands, is a homogeneous collection. A heterogeneous collection is one in which the elements are of different types, for example, a point and a polygon.
An example of a geometry might describe the buildable land in a town. This could be represented as a polygon with holes where water or zoning prevents construction.
A layer is a collection of geometries having the same attribute set. For example, one layer in a GIS might include topographical features, while another describes population density, and a third describes the network of roads and bridges in the area (lines and points). The geometries and associated spatial index for each layer are stored in the database in standard tables.
A coordinate system (also called a spatial reference system) is a means of assigning coordinates to a location and establishing relationships between sets of such coordinates. It enables the interpretation of a set of coordinates as a representation of a position in a real world space.
Any spatial data has a coordinate system associated with it. The coordinate system can be georeferenced (related to a specific representation of the Earth) or not georeferenced (that is, Cartesian, and not related to a specific representation of the Earth). If the coordinate system is georeferenced, it has a default unit of measurement (such as meters) associated with it, but you can have Spatial automatically return results in another specified unit (such as miles). (For more information about unit of measurement support, see Section 2.8.)
Before Oracle Spatial release 8.1.6, geometries (objects of type SDO_GEOMETRY) were stored as strings of coordinates without reference to any specific coordinate system. Spatial functions and operators always assumed a coordinate system that had the properties of an orthogonal Cartesian system, and sometimes did not provide correct results if Earthbased geometries were stored in longitude and latitude coordinates. With release 8.1.6, Spatial provided support for many different coordinate systems, and for converting data freely between different coordinate systems.
Spatial data can be associated with a Cartesian, geodetic (geographical), projected, or local coordinate system:
Cartesian coordinates are coordinates that measure the position of a point from a defined origin along axes that are perpendicular in the represented twodimensional or threedimensional space.
If a coordinate system is not explicitly associated with a geometry, a Cartesian coordinate system is assumed.
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. (A geodetic datum is a means of representing the figure of the Earth and is the reference for the system of geodetic coordinates.)
Projected coordinates are planar Cartesian coordinates that result from performing a mathematical mapping from a point on the Earth's surface to a plane. There are many such mathematical mappings, each used for a particular purpose.
Local coordinates are Cartesian coordinates in a nonEarth (nongeoreferenced) coordinate system. Local coordinate systems are often used for CAD applications and local surveys.
When performing operations on geometries, Spatial uses either a Cartesian or curvilinear computational model, as appropriate for the coordinate system associated with the spatial data.
For more information about coordinate system support in Spatial, including geodetic, projected, and local coordinates and coordinate system transformation, see Chapter 6.
Tolerance is used to associate a level of precision with spatial data. Tolerance reflects the distance that two points can be apart and still be considered the same (for example, to accommodate rounding errors). The tolerance value must be a positive number greater than zero. The significance of the value depends on whether or not the spatial data is associated with a geodetic coordinate system. (Geodetic and other types of coordinate systems are described in Section 1.5.4.)
For geodetic data (such as data identified by longitude and latitude coordinates), the tolerance value is a number of meters. For example, a tolerance value of 100 indicates a tolerance of 100 meters. The tolerance value for geodetic data should not be smaller than 0.05 (5 centimeters), and in most cases it should be larger. Spatial uses 0.05 as the tolerance value for geodetic data if you specify a smaller value.
For nongeodetic data, the tolerance value is a number of the units that are associated with the coordinate system associated with the data. For example, if the unit of measurement is miles, a tolerance value of 0.005 indicates a tolerance of 0.005 (that is, 1/200) mile (approximately 26 feet), and a tolerance value of 2 indicates a tolerance of 2 miles.
In both cases, the smaller the tolerance value, the more precision is to be associated with the data.
A tolerance value is specified in two cases:
In the geometry metadata definition for a layer (see Section 1.5.5.1)
As an input parameter to certain functions (see Section 1.5.5.2)
For additional information about tolerance with linear referencing system (LRS) data, see Section 7.6.
The dimensional information for a layer includes a tolerance value. Specifically, the DIMINFO column (described in Section 2.6.3) of the xxx_SDO_GEOM_METADATA views includes an SDO_TOLERANCE value for each dimension, and the value should be the same for each dimension.
If a function accepts an optional tolerance
parameter and this parameter is null or not specified, the SDO_TOLERANCE value of the layer is used. Using the nongeodetic data from the example in Section 2.1, the actual distance between geometries cola_b
and cola_d
is 0.846049894. If a query uses the SDO_GEOM.SDO_DISTANCE function to return the distance between cola_b
and cola_d
and does not specify a tolerance
parameter value, the result depends on the SDO_TOLERANCE value of the layer. For example:
If the SDO_TOLERANCE value of the layer is 0.005, this query returns .846049894.
If the SDO_TOLERANCE value of the layer is 0.5, this query returns 0.
The zero result occurs because Spatial first constructs an imaginary buffer of the tolerance value (0.5) around each geometry to be considered, and the buffers around cola_b
and cola_d
overlap in this case.
You can therefore take either of two approaches in selecting an SDO_TOLERANCE value for a layer:
The value can reflect the desired level of precision in queries for distances between objects. For example, if two nongeodetic geometries 0.8 units apart should be considered as separated, specify a small SDO_TOLERANCE value such as 0.05 or smaller.
The value can reflect the precision of the values associated with geometries in the layer. For example, if all geometries in a nongeodetic layer are defined using integers and if two objects 0.8 units apart should not be considered as separated, an SDO_TOLERANCE value of 0.5 is appropriate. To have greater precision in any query, you must override the default by specifying the tolerance
parameter.
With nongeodetic data, the guideline to follow for most instances of the second case (precision of the values of the geometries in the layer) is: take the highest level of precision in the geometry definitions, and use .5 at the next level as the SDO_TOLERANCE value. For example, if geometries are defined using integers (as in the simplified example in Section 2.1), the appropriate value is 0.5; however, if geometries are defined using numbers up to four decimal positions (for example, 31.2587), the appropriate value is 0.00005.
Note: This guideline should not be used if the geometries include any polygons that are so narrow at any point that the distance between facing sides is less than the proposed tolerance value. Be sure that the tolerance value is less than the shortest distance between any two sides in any polygon.Moreover, if you encounter "invalid geometry" errors with inserted or updated geometries, and if the geometries are in fact valid, consider increasing the precision of the tolerance value (for example, changing 0.00005 to 0.000005). 
Many Spatial functions accept a tolerance
parameter, which (if specified) overrides the default tolerance value for the layer (explained in Section 1.5.5.1). If the distance between two points is less than or equal to the tolerance value, Spatial considers the two points to be a single point. Thus, tolerance is usually a reflection of how accurate or precise users perceive their spatial data to be.
For example, assume that you want to know which restaurants are within 5 kilometers of your house. Assume also that Maria's Pizzeria is 5.1 kilometers from your house. If the spatial data has a geodetic coordinate system and if you ask, Find all restaurants within 5 kilometers and use a tolerance of 100 (or greater, such as 500), Maria's Pizzeria will be included, because 5.1 kilometers (5100 meters) is within 100 meters of 5 kilometers (5000 meters). However, if you specify a tolerance less than 100 (such as 50), Maria's Pizzeria will not be included.
Tolerance values for Spatial functions are typically very small, although the best value in each case depends on the kinds of applications that use or will use the data.
Spatial uses a twotier query model to resolve spatial queries and spatial joins. The term is used to indicate that two distinct operations are performed to resolve queries. The output of the two combined operations yields the exact result set.
The two operations are referred to as primary and secondary filter operations.
The primary filter permits fast selection of candidate records to pass along to the secondary filter. The primary filter compares geometry approximations to reduce computation complexity and is considered a lowercost filter. Because the primary filter compares geometric approximations, it returns a superset of the exact result set.
The secondary filter applies exact computations to geometries that result from the primary filter. The secondary filter yields an accurate answer to a spatial query. The secondary filter operation is computationally expensive, but it is only applied to the primary filter results, not the entire data set.
Figure 12 illustrates the relationship between the primary and secondary filters.
As shown in Figure 12, the primary filter operation on a large input data set produces a smaller candidate set, which contains at least the exact result set and may contain more records. The secondary filter operation on the smaller candidate set produces the exact result set.
Spatial uses a spatial index to implement the primary filter. Spatial does not require the use of both the primary and secondary filters. In some cases, just using the primary filter is sufficient. For example, a zoom feature in a mapping application queries for data that has any interaction with a rectangle representing visible boundaries. The primary filter very quickly returns a superset of the query. The mapping application can then apply clipping routines to display the target area.
The purpose of the primary filter is to quickly create a subset of the data and reduce the processing burden on the secondary filter. The primary filter, therefore, should be as efficient (that is, selective yet fast) as possible. This is determined by the characteristics of the spatial index on the data.
For more information about querying spatial data, see Section 4.2.
The introduction of spatial indexing capabilities into the Oracle database engine is a key feature of the Spatial product. 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. A spatial index is needed to:
Find objects within an indexed data space that interact with a given point or area of interest (window query)
Find pairs of objects from within two indexed data spaces that interact spatially with each other (spatial join)
A spatial index is considered a logical index. The entries in the spatial index are dependent on the location of the geometries in a coordinate space, but the index values are in a different domain. Index entries may be ordered using a linearly ordered domain, and the coordinates for a geometry may be pairs of integer, floatingpoint, or doubleprecision numbers.
Oracle Spatial lets you use Rtree indexing (the default) or quadtree indexing, or both. However, the use of quadtree indexes is discouraged, and you are strongly encouraged to use Rtree indexing. Significant performance improvements have been made to spatial Rtree indexing for this release. Quadtree indexing is a deprecated feature of Spatial. Almost all information about quadtree indexing has been removed from this guide and placed in a separate guide, Oracle Spatial Quadtree Indexing, which is available only through the Oracle Technology Network.
Testing of spatial indexes with many workloads and operators is ongoing, and results and recommendations will be documented as they become available.
The following sections explain the concepts anyZd options associated with Rtree indexing.
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), as shown in Figure 13.
For a layer of geometries, an Rtree index consists of a hierarchical index on the MBRs of the geometries in the layer, as shown in Figure 14.
In Figure 14:
1 through 9 are geometries in a layer.
a, b, c, and d are the leaf nodes of the Rtree index, and contain minimum bounding rectangles of geometries, along with pointers to the geometries. For example, a contains the MBR of geometries 1 and 2, b contains the MBR of geometries 3 and 4, and so on.
A contains the MBR of a and b, and B contains the MBR of c and d.
The root contains the MBR of A and B (that is, the entire area shown).
An Rtree index is stored in the spatial index table (SDO_INDEX_TABLE in the USER_SDO_INDEX_METADATA view, described in Section 2.7). The Rtree index also maintains a sequence object (SDO_RTREE_SEQ_NAME in the USER_SDO_INDEX_METADATA view) to ensure that simultaneous updates by concurrent users can be made to the index.
A substantial number of insert and delete operations affecting an Rtree index may degrade the quality of the Rtree structure, which may adversely affect query performance.
The Rtree is a hierarchical tree structure with nodes at different heights of the tree. The performance of an Rtree index structure for queries is roughly proportional to the area and perimeter of the index nodes of the Rtree. The area covered at level 0 represents the area occupied by the minimum bounding rectangles of the data geometries, the area at level 1 indicates the area covered by leaflevel Rtree nodes, and so on. The original ratio of the area at the root (topmost level) to the area at level 0 can change over time based on updates to the table; and if there is a degradation in that ratio (that is, if it increases significantly), rebuilding the index may help the performance of queries.
If the performance of SDO_FILTER operations has degraded, and if there have been a large number of insert, update, or delete operations affecting geometries, the performance degradation may be due to a degradation in the quality of the associated Rtree index. You can check for degradation of index quality by using the SDO_TUNE.QUALITY_DEGRADATION function (described in Chapter 19): if the function returns a number greater than 2, consider rebuilding the index. Note, however, that the Rtree index quality degradation number may not be significant in terms of overall query performance due to Oracle caching strategies and other significant Oracle capabilities, such as table pinning, which can essentially remove I/O overhead from Rtree index queries.
To rebuild an Rtree index, use the ALTER INDEX REBUILD statement, which is described in Chapter 10.
Spatial uses secondary filters to determine the spatial relationship between entities in the database. The spatial relationship is based on geometry locations. The most common spatial relationships are based on topology and distance. For example, the boundary of an area consists of a set of curves that separates the area from the rest of the coordinate space. The interior of an area consists of all points in the area that are not on its boundary. Given this, two areas are said to be adjacent if they share part of a boundary but do not share any points in their interior.
The distance between two spatial objects is the minimum distance between any points in them. Two objects are said to be within a given distance of one another if their distance is less than the given distance.
To determine spatial relationships, Spatial has several secondary filter methods:
The SDO_RELATE operator evaluates topological criteria.
The SDO_WITHIN_DISTANCE operator determines if two spatial objects are within a specified distance of each other.
The SDO_NN operator identifies the nearest neighbors for a spatial object.
The syntax of these operators is given in Chapter 11.
The SDO_RELATE operator implements a nineintersection model for categorizing binary topological relationships between points, lines, and polygons. Each spatial object has an interior, a boundary, and an exterior. The boundary consists of points or lines that separate the interior from the exterior. The boundary of a line string consists of its end points; however, if the end points overlap (that is, if they are the same point), the line string has no boundary. The boundaries of a multiline string are the end points of each of the component line strings; however, if the end points overlap, only the end points that overlap an odd number of times are boundaries. The boundary of a polygon is the line that describes its perimeter. The interior consists of points that are in the object but not on its boundary, and the exterior consists of those points that are not in the object.
Given that an object A has three components (a boundary Ab, an interior Ai, and an exterior Ae), any pair of objects has nine possible interactions between their components. Pairs of components have an empty (0) or not empty (1) set intersection. The set of interactions between two geometries is represented by a nineintersection matrix that specifies which pairs of components intersect and which do not. Figure 15 shows the nineintersection matrix for two polygons that are adjacent to one another. This matrix yields the following bit mask, generated in rowmajor form: "101001111".
Some of the topological relationships identified in the seminal work by Professor Max Egenhofer (University of Maine, Orono) and colleagues have names associated with them. Spatial uses the following names:
TOUCH  The boundaries intersect but the interiors do not intersect.
OVERLAPBDYDISJOINT  The interior of one object intersects the boundary and interior of the other object, but the two boundaries do not intersect. This relationship occurs, for example, when a line originates outside a polygon and ends inside that polygon.
OVERLAPBDYINTERSECT  The boundaries and interiors of the two objects intersect.
EQUAL  The two objects have the same boundary and interior.
CONTAINS  The interior and boundary of one object is completely contained in the interior of the other object.
COVERS  The interior of one object is completely contained in the interior or the boundary of the other object and their boundaries intersect.
INSIDE  The opposite of CONTAINS. A INSIDE B implies B CONTAINS A.
COVEREDBY  The opposite of COVERS. A COVEREDBY B implies B COVERS A.
ON  The interior and boundary of one object is on the boundary of the other object (and the second object covers the first object). This relationship occurs, for example, when a line is on the boundary of a polygon.
Figure 16 illustrates these topological relationships.
The SDO_WITHIN_DISTANCE operator determines if two spatial objects, A and B, are within a specified distance of one another. This operator first constructs a distance buffer, D_{b}, around the reference object B. It then checks that A and D_{b} are nondisjoint. The distance buffer of an object consists of all points within the given distance from that object. Figure 17 shows the distance buffers for a point, a line, and a polygon.
In the point, line, and polygon geometries shown in Figure 17:
The dashed lines represent distance buffers. Notice how the buffer is rounded near the corners of the objects.
The geometry on the right is a polygon with a hole: the large rectangle is the exterior polygon ring and the small rectangle is the interior polygon ring (the hole). The dashed line outside the large rectangle is the buffer for the exterior ring, and the dashed line inside the small rectangle is the buffer for the interior ring.
The SDO_NN operator returns a specified number of objects from a geometry column that are closest to a specified geometry (for example, the five closest restaurants to a city park). In determining how close two geometry objects are, the shortest possible distance between any two points on the surface of each object is used.
The Spatial PL/SQL application programming interface (API) includes several operators and many procedures and functions.
Spatial operators, such as SDO_FILTER and SDO_RELATE, provide optimum performance because they use the spatial index. (Spatial operators require that the geometry column in the first parameter have a spatial index defined on it.) Spatial operators must be used in the WHERE clause of a query. The first parameter of any operator specifies the geometry column to be searched, and the second parameter specifies a query window. If the query window does not have the same coordinate system as the geometry column, Spatial performs an implicit coordinate system transformation. For detailed information about the spatial operators, see Chapter 11.
Spatial procedures and functions are provided as subprograms in PL/SQL packages, such as SDO_GEOM, SDO_CS, and SDO_LRS. These subprograms do not require that a spatial index be defined, and they do not use a spatial index if it is defined. These subprograms can be used in the WHERE clause or in a subquery. If two geometries are input parameters to a Spatial procedure or function, both must have the same coordinate system.
The following performancerelated guidelines apply to the use of spatial operators, procedures, and functions:
If an operator and a procedure or function perform comparable operations, and if the operator satisfies your requirements, use the operator. For example, unless you need to do otherwise, use SDO_RELATE instead of SDO_GEOM.RELATE, and use SDO_WITHIN_DISTANCE instead of SDO_GEOM.WITHIN_DISTANCE.
With operators, always specify TRUE
in uppercase. That is, specify = 'TRUE'
, and do not specify <> 'FALSE'
or = 'true'
.
With operators, use the /*+ ORDERED */
optimizer hint if the query window comes from a table. (You must use this hint if multiple windows come from a table.) See the Usage Notes and Examples for specific operators for more information.
For information about using operators with topologies, see Oracle Spatial Topology and Network Data Models.
SQL has long had aggregate functions, which are used to aggregate the results of a SQL query. The following example uses the SUM aggregate function to aggregate employee salaries by department:
SELECT SUM(salary), dept FROM employees GROUP BY dept;
Oracle Spatial aggregate functions aggregate the results of SQL queries involving geometry objects. Spatial aggregate functions return a geometry object of type SDO_GEOMETRY. For example, the following statement returns the minimum bounding rectangle of all geometries in a table (using the definitions and data from Section 2.1):
SELECT SDO_AGGR_MBR(shape) FROM cola_markets;
The following example returns the union of all geometries except cola_d
:
SELECT SDO_AGGR_UNION(SDOAGGRTYPE(c.shape, 0.005)) FROM cola_markets c WHERE c.name < 'cola_d';
All geometries used with spatial aggregate functions must be defined using 4digit SDO_GTYPE values (that is, must be in the format used by Oracle Spatial release 8.1.6 or later). For information about SDO_GTYPE values, see Section 2.2.1.
For reference information about the spatial aggregate functions and examples of their use, see Chapter 12.
Many spatial aggregate functions accept an input parameter of type SDOAGGRTYPE. Oracle Spatial defines the object type SDOAGGRTYPE as:
CREATE TYPE sdoaggrtype AS OBJECT ( geometry SDO_GEOMETRY, tolerance NUMBER);
Note: Do not use SDOAGGRTYPE as the data type for a column in a table. Use this type only in calls to spatial aggregate functions. 
The tolerance
value in the SDOAGGRTYPE definition should be the same as the SDO_TOLERANCE value specified in the DIMINFO column in the xxx_SDO_GEOM_METADATA views for the geometries, unless you have a specific reason for wanting a different value. For more information about tolerance, see Section 1.5.5; for information about the xxx_SDO_GEOM_METADATA views, see Section 2.6.
The tolerance
value in the SDOAGGRTYPE definition can affect the result of a spatial aggregate function. Figure 18 shows a spatial aggregate union (SDO_AGGR_UNION) operation of two geometries using two different tolerance values: one smaller and one larger than the distance between the geometries.
In the first aggregate union operation in Figure 18, where the tolerance is less than the distance between the rectangles, the result is a compound geometry consisting of two rectangles. In the second aggregate union operation, where the tolerance is greater than the distance between the rectangles, the result is a single geometry.
Geocoding is the process of converting tables of address data into standardized address, location, and possibly other data. The result of a geocoding operation includes the pair of longitude and latitude coordinates that correspond with the input address or location. For example, if the input address is 22 Monument Square, Concord, MA 01742, the longitude and latitude coordinates in the result of the geocoding operation may be (depending on the geocoding data provider) 71.34937 and 42.46101, respectively.
Given a geocoded address, you can perform proximity or location queries using a spatial engine, such as Oracle Spatial, or demographic analysis using tools and data from Oracle's business partners. In addition, you can use geocoded data with other spatial data such as block group, postal code, and county code for association with demographic information. Results of analyses or queries can be presented as maps, in addition to tabular formats, using thirdparty software integrated with Oracle Spatial.
For conceptual and usage information about the geocoding capabilities of Oracle Spatial, see Chapter 5. For reference information about the MDSYS.SDO_GCDR PL/SQL package, see Chapter 14.
Oracle Spatial provides a Java application programming interface (API) that includes the following packages:
oracle.spatial.geometry
provides support for the Spatial SQL SDO_GEOMETRY data type, which is documented in this guide.
oracle.spatial.network
provides support for the Oracle Spatial network data model, which is documented in Oracle Spatial Topology and Network Data Models.
oracle.spatial.topo
provides support for the Oracle Spatial topology data model, which is documented in Oracle Spatial Topology and Network Data Models.
oracle.spatial.util
provides classes that perform miscellaneous operations.
For detailed reference information about the classes and interfaces in these packages, see Oracle Spatial Java API Reference (Javadoc).
Effective with Oracle Database 10g, Spatial creates a user and schema named MDDATA, using the following internal SQL statements:
CREATE USER mddata IDENTIFIED BY mddata; GRANT connect, resource TO mddata; ALTER USER mddata ACCOUNT LOCK;
You should use the MDDATA schema for storing data used by geocoding and routing applications. This is the default schema for Oracle software that accesses geocoding and routing data.
Many factors can affect the performance of Oracle Spatial applications, such as the use of optimizer hints to influence the plan for query execution. This guide contains some information about performance and tuning where it is relevant to a particular topic. For example, Section 1.7.2 discusses Rtree quality and its possible effect on query performance, and Section 1.9 explains why spatial operators provide better performance than procedures and functions.
In addition, more Spatial performance and tuning information is available in one or more white papers through the Oracle Technology Network (OTN). That information is often more detailed than what is in this guide, and it is periodically updated as a result of internal testing and consultations with Spatial users. To find that information on the OTN, go to
http://www.oracle.com/technology/products/spatial/
Look for material relevant to Spatial performance and tuning.
Oracle Spatial is conformant with Open Geospatial Consortium (OGC) Simple Features Specification 1.1.1 (Document 99049), starting with Oracle Database release 10g (version 10.1.0.4). Conformance with the SQL92 with Geometry Types Implementation means that Oracle Spatial supports all the types, functions, and language constructs detailed in Section 3.2 of the specification.
To check which release of Spatial you are running, use the SDO_VERSION function. For example:
SELECT SDO_VERSION FROM DUAL; SDO_VERSION  10.2.0.0.0
This section discusses some general guidelines that affect the amount of disk storage space and CPU power needed for applications that use Oracle Spatial. These guidelines are intended to supplement, not replace, any other guidelines you use for general application sizing.
The following characteristics of spatial applications can affect the need for storage space and CPU power:
Data volumes: The amount of storage space needed for spatial objects depends on their complexity (precision of representation and number of points for each object). For example, storing one million point objects takes less space than storing one million road segments or land parcels. Complex natural features such as coastlines, seismic fault lines, rivers, and land types can require significant storage space if they are stored at a high precision.
Query complexity: The CPU requirements for simple mapping queries, such as Select all features in this rectangle, are lower than for more complex queries, such as Find all seismic fault lines that cross this coastline.
Spatial error message numbers are in the range of 13000 to 13499. The messages are documented in Oracle Database Error Messages.
Oracle error message documentation is only available in HTML. If you only have access to the Oracle Documentation CD, you can browse the error messages by range. Once you find the specific range, use your browser's "find in page" feature to locate the specific message. When connected to the Internet, you can search for a specific error message using the error message search feature of the Oracle online documentation.
Oracle Spatial provides examples that you can use to reinforce your learning and to create models for coding certain operations. If you installed the demo files from the Companion CD, several examples are provided in the following directory:
$ORACLE_HOME/md/demos/examples
The following files in that directory are helpful for applications that use the Oracle Call Interface (OCI):
readgeom.c
and readgeom.h
writegeom.c
and writegeom.h
This guide also includes many examples in SQL and PL/SQL. One or more examples are usually provided with the reference information for each function or procedure, and several simplified examples are provided that illustrate table and index creation, combinations of functions and procedures, and advanced features:
Inserting, indexing, and querying spatial data (Section 2.1)
Coordinate systems (spatial reference systems) (Section 6.11)
Linear referencing system (LRS) (Section 7.7)
SDO_GEOMETRY objects in functionbased indexes (Section 9.2)
Complex queries (Appendix D)
A README.txt
file supplements the information in the following manuals: Oracle Spatial User's Guide and Reference (this manual), Oracle Spatial GeoRaster, and Oracle Spatial Topology and Network Data Models. This file is located at:
$ORACLE_HOME/md/doc/README.txt
After you have loaded spatial data (discussed in Chapter 3), you should create a spatial index on it to enable efficient query performance using the data. This chapter describes how to:
Create a spatial index (see Section 4.1)
Query spatial data efficiently, based on an understanding of the Oracle Spatial query model and primary and secondary filtering (see Section 4.2)
Once data has been loaded into the spatial tables through either bulk or transactional loading, a spatial index (that is, a spatial Rtree index) must be created on the tables for efficient access to the data. For example, the following statement creates a spatial index named territory_idx
using default values for all parameters:
CREATE INDEX territory_idx ON territories (territory_geom) INDEXTYPE IS MDSYS.SPATIAL_INDEX;
For detailed information about options for creating a spatial index, see the documentation for the CREATE INDEX statement in Chapter 10.
If the index creation does not complete for any reason, the index is invalid and must be deleted with the DROP INDEX <index_name> [FORCE] statement.
Spatial indexes can be built on two, three, or four dimensions of data. The default number of dimensions is two, but if the data has more than two dimensions, you can use the sdo_indx_dims
parameter keyword to specify the number of dimensions on which to build the index. However, if a spatial index has been built on more than two dimensions of a layer, the only spatial operator that can be used against that layer is SDO_FILTER (the primary filter or indexonly query), which considers all dimensions. The SDO_RELATE, SDO_NN, and SDO_WITHIN_DISTANCE operators are disabled if the index has been built on more than two dimensions.
If the rollback segment is not large enough, an attempt to create a spatial index will fail. The rollback segment should be 100*n bytes, where n is the number of rows of data to be indexed. For example, if the table contains 1 million (1,000,000) rows, the rollback segment size should be 100,000,000 (100 million) bytes.
To ensure an adequate rollback segment, or if you have tried to create a spatial index and received an error that a rollback segment cannot be extended, review (or have a DBA review) the size and structure of the rollback segments. Create a public rollback segment of the appropriate size, and place that rollback segment online. In addition, ensure that any small inappropriate rollback segments are placed offline during large spatial index operations. For information about performing these operations on a rollback segment, see Oracle Database Administrator's Guide.
The system parameter SORT_AREA_SIZE affects the amount of time required to create the index. The SORT_AREA_SIZE value is the maximum amount, in bytes, of memory to use for a sort operation. The optimal value depends on the database size, but a good guideline is to make it at least 1 million bytes when you create a spatial index. To change the SORT_AREA_SIZE value, use the ALTER SESSION statement. For example, to change the value to 20 million bytes:
ALTER SESSION SET SORT_AREA_SIZE = 20000000;
The tablespace specified with the tablespace
keyword in the CREATE INDEX statement (or the default tablespace if the tablespace
keyword is not specified) is used to hold both the index data table and some transient tables that are created for internal computations. If you specify WORK_TABLESPACE as the tablespace, the transient tables are stored in the work tablespace.
For large tables (over 1 million rows), a temporary tablespace may be needed to perform internal sorting operations. The recommended size for this temporary tablespace is 100*n bytes, where n is the number of rows in the table, up to a maximum requirement of 1 gigabyte of temporary tablespace.
To estimate the space that will be needed to create a spatial index, use the SDO_TUNE.ESTIMATE_RTREE_INDEX_SIZE function, described in Chapter 19.
To take full advantage of Spatial features, you must index geodetic data using a geodetic Rtree index. Geodetic data consists of geometries that have geodetic SDO_SRID values, reflecting the fact that they are based on a geodetic coordinate system (such as using longitude and latitude) as opposed to a flat or projected plane coordinate system. (Chapter 6 explains coordinate systems and related concepts.) A geodetic index is one that provides the full range of Spatial features with geodetic data. Thus, it is highly recommended that you use a geodetic index with geodetic data.
Only Rtree indexes can be geodetic indexes. Quadtree indexes cannot be geodetic indexes. If you create an Rtree or quadtree index and specify 'geodetic=false'
in the CREATE INDEX statement, the index is nongeodetic. The following notes and restrictions apply to nongeodetic indexes:
If you create a nongeodetic index on geodetic data, you cannot use the unit
parameter with the SDO_WITHIN_DISTANCE operator or the SDO_NN_DISTANCE ancillary operator with the SDO_NN operator.
If you create a nongeodetic index on projected data that has a projected SDO_SRID value, you can use the full range of Spatial features.
If you create a nongeodetic index on projected data that has a null SDO_SRID value, you cannot use the unit
parameter with the SDO_WITHIN_DISTANCE operator or the SDO_NN_DISTANCE ancillary operator with the SDO_NN operator.
For additional information, see the Usage Notes about the geodetic
parameter for the CREATE INDEX statement in Chapter 10.
When you create or rebuild a spatial index, you can ensure that all geometries that are in the table or that are inserted later are of a specified geometry type. To constrain the data to a geometry type in this way, use the layer_gtype
keyword in the PARAMETERS clause of the CREATE INDEX or ALTER INDEX REBUILD statement, and specify a value from the Geometry Type column of Table 21 in Section 2.2.1. For example, to constrain spatial data in a layer to polygons:
CREATE INDEX cola_spatial_idx ON cola_markets(shape) INDEXTYPE IS MDSYS.SPATIAL_INDEX PARAMETERS ('layer_gtype=POLYGON');
The geometry types in Table 21 are considered as a hierarchy when data is checked:
The MULTI forms include the regular form also. For example, specifying 'layer_gtype=
MULTIPOINT'
allows the layer to include both POINT and MULTIPOINT geometries.
COLLECTION allows the layer to include all types of geometries.
You can create a spatial index on a table that is not in your schema. Assume that user B wants to create a spatial index on column GEOMETRY in table T1 under user A's schema. Follow these steps:
Connect to the database as a privileged user (for example, as SYSTEM), and execute the following statement:
GRANT create table, create sequence to B;
Connect as a privileged user or as user A (or have user A connect), and execute the following statement:
GRANT select, index on A.T1 to B;
Connect as user B and execute a statement such as the following:
CREATE INDEX t1_spatial_idx on A.T1(geometry) INDEXTYPE IS mdsys.spatial_index;
You can create a partitioned spatial index on a partitioned table. This section describes usage considerations specific to Oracle Spatial. For a detailed explanation of partitioned tables and partitioned indexes, see Oracle Database Administrator's Guide.
A partitioned spatial index can provide the following benefits:
Reduced response times for longrunning queries, because partitioning reduces disk I/O operations
Reduced response times for concurrent queries, because I/O operations run concurrently on each partition
Easier index maintenance, because of partitionlevel create and rebuild operations
Indexes on partitions can be rebuilt without affecting the queries on other partitions, and storage parameters for each local index can be changed independent of other partitions.
Parallel query on multiple partition searching
The degree of parallelism is the value from the DEGREE column in the row for the index in the USER_INDEXES view (that is, the value specified or defaulted for the PARALLEL keyword with the CREATE INDEX, ALTER INDEX, or ALTER INDEX REBUILD statement).
Improved query processing in multiprocessor system environments
In a multiprocessor system environment, if a spatial operator is invoked on a table with partitioned spatial index and if multiple partitions are involved in the query, multiple processors can be used to evaluate the query. The number of processors used is determined by the degree of parallelism and the number of partitions used in evaluating the query.
The following restrictions apply to spatial index partitioning:
The partition key for spatial tables must be a scalar value, and must not be a spatial column.
Only range partitioning is supported on the underlying table. Hash and composite partitioning are not currently supported for partitioned spatial indexes.
To create a partitioned spatial index, you must specify the LOCAL keyword. For example:
CREATE INDEX counties_idx ON counties(geometry) INDEXTYPE IS MDSYS.SPATIAL_INDEX LOCAL;
In this example, the default values are used for the number and placement of index partitions, namely:
Index partitioning is based on the underlying table partitioning. For each table partition, a corresponding index partition is created.
Each index partition is placed in the default tablespace.
If you do specify parameters for individual partitions, the following considerations apply:
The storage characteristics for each partition can be the same or different for each partition. If they are different, it may enable parallel I/O (if the tablespaces are on different disks) and may improve performance.
The sdo_indx_dims
value must be the same for all partitions.
The layer_gtype
parameter value (see Section 4.1.2) used for each partition may be different.
To override the default partitioning values, use a CREATE INDEX statement with the following general format:
CREATE INDEX <indexname> ON <table>(<column>) INDEXTYPE IS MDSYS.SPATIAL_INDEX [PARAMETERS ('<spatialparams>, <storageparams>')] LOCAL [( PARTITION <index_partition> PARAMETERS ('<spatialparams>, <storageparams>') [, PARTITION <index_partition> PARAMETERS ('<spatialparams>, <storageparams>')] )]
Queries can operate on partitioned tables to perform the query on only one partition. For example:
SELECT * FROM counties PARTITION(p1) WHERE ...<somespatialpredicate>;
Querying on a selected partition may speed up the query and also improve overall throughput when multiple queries operate on different partitions concurrently.
When queries use a partitioned spatial index, the semantics (meaning or behavior) of spatial operators and functions is the same with partitioned and nonpartitioned indexes, except in the case of SDO_NN (nearest neighbor). With SDO_NN, the requested number of geometries is returned for each partition that is affected by the query. For example, if you request the 5 closest restaurants to a point and the spatial index has 4 partitions, SDO_NN returns up to 20 (5*4) geometries. In this case, you must use the ROWNUM pseudocolumn (here, WHERE ROWNUM <=5
) to return the 5 closest restaurants. See the description of the SDO_NN operator in Chapter 11 for more information.
You can use the ALTER TABLE statement with the EXCHANGE PARTITION ... INCLUDING INDEXES clause to exchange a spatial table partition and its index partition with a corresponding table and its index. For information about exchanging partitions, see the description of the ALTER TABLE statement in Oracle Database SQL Reference.
This feature can help you to operate more efficiently in a number of situations, such as:
Bringing data into a partitioned table and avoiding the cost of index recreation.
Managing and creating partitioned indexes. For example, the data could be divided into multiple tables. The index for each table could be built one after the other to minimize the memory and tablespace resources needed during index creation. Alternately, the indexes could be created in parallel in multiple sessions. The tables (along with the indexes) could then be exchanged with the partitions of the original data table.
Managing offline insert operations. New data can be stored in a temporary table and periodically exchanged with a new partition (for example, in a database with historical data).
To exchange partitions including indexes with spatial data and indexes, the two spatial indexes (one on the partition, the other on the table) must be of compatible types. Specifically:
Both indexes must have the same dimensionality (sdo_indx_dims
value).
Both indexes must be either geodetic or nongeodetic. (Geodetic and nongeodetic indexes are explained in Section 4.1.1.)
If the indexes are not compatible, an error is raised. The table data is exchanged, but the indexes are not exchanged and the indexes are marked as failed. To use the indexes, you must rebuild them.
If you use the Export utility to export tables with spatial data, the behavior of the operation depends on whether or not the spatial data has been spatially indexed:
If the spatial data has not been spatially indexed, the table data is exported. However, you must update the USER_SDO_GEOM_METADATA view with the appropriate information on the target system.
If the spatial data has been spatially indexed, the table data is exported, the appropriate information is inserted into the USER_SDO_GEOM_METADATA view on the target system, and the spatial index is built on the target system. However, if the insertion into the USER_SDO_GEOM_METADATA view fails (for example, if there is already a USER_SDO_GEOM_METADATA entry for the spatial layer), the spatial index is not built.
If you use the Import utility to import data that has been spatially indexed, the following considerations apply:
If the index on the exported data was created with a TABLESPACE
clause and if the specified tablespace does not exist in the database at import time, the index is not built. (This is different from the behavior with other Oracle indexes, where the index is created in the user's default tablespace if the tablespace specified for the original index does not exist at import time.)
If the import operation must be done by a privileged database user, and if the FROMUSER
and TOUSER
format is used, the TOUSER
user must be granted the CREATE TABLE and CREATE SEQUENCE privileges before the import operation, as shown in the following example:
sqlplus system/<password> SQL> grant CREATE TABLE, CREATE SEQUENCE to CHRIS; SQL> exit; imp system/<password> file=spatl_data.dmp fromuser=SCOTT touser=CHRIS
For information about using the Export and Import utilities, see Oracle Database Utilities.
In a distributed transaction, different branches of the transaction can execute in different sessions. The branches can detach from their current session and migrate to another within the transaction scope. To maintain the consistency of Spatial indexes in distributed transactions, you must follow the usage guidelines in this section.
When the first insert, update, or delete operation on a spatial table (one with a spatial index) is performed in a distributed transaction, all subsequent insert, update, or delete operations on the table, as well as any prepare to commit operation (the first branch to prepare a commit), in the transaction should happen in the same session as the first operation. The branches performing these subsequent operations will first have to connect to the session in which the first operation was performed.
For more information about distributed transactions, see Oracle Database Administrator's Guide.
This section describes how the structures of a Spatial layer are used to resolve spatial queries and spatial joins.
Spatial uses a twotier query model with primary and secondary filter operations to resolve spatial queries and spatial joins, as explained in Section 1.6. The term twotier indicates that two distinct operations are performed to resolve queries. If both operations are performed, the exact result set is returned.
You cannot append a database link (dblink) name to the name of a spatial table in a query if a spatial index is defined on that table.
If a spatial index is created in a database that was created using the UTF8 character set, spatial queries that use the spatial index will fail if the system parameter NLS_LENGTH_SEMANTICS
is set to CHAR
. For spatial queries to succeed in this case, the NLS_LENGTH_SEMANTICS
parameter must be set to BYTE
(its default value).
In a spatial Rtree index, each geometry is represented by its minimum bounding rectangle (MBR), as explained in Section 1.7.1. Consider the following layer containing several objects in Figure 41. Each object is labeled with its geometry name (geom_1 for the line string, geom_2 for the foursided polygon, geom_3 for the triangular polygon, and geom_4 for the ellipse), and the MBR around each object is represented by a dashed line.
A typical spatial query is to request all objects that lie within a query window, that is, a defined fence or window. A dynamic query window refers to a rectangular area that is not defined in the database, but that must be defined before it is used. Figure 42 shows the same geometries as in Figure 41, but adds a query window represented by the heavy dottedline box.
In Figure 42, the query window covers parts of geometries geom_1 and geom_2, as well as part of the MBR for geom_3 but none of the actual geom_3 geometry. The query window does not cover any part of the geom_4 geometry or its MBR.
The SDO_FILTER operator, described in Chapter 11, implements the primary filter portion of the twostep process involved in the Oracle Spatial query processing model. The primary filter uses the index data to determine only if a set of candidate object pairs may interact. Specifically, the primary filter checks to see if the MBRs of the candidate objects interact, not whether the objects themselves interact. The SDO_FILTER operator syntax is as follows:
SDO_FILTER(geometry1 SDO_GEOMETRY, geometry2 SDO_GEOMETRY, param VARCHAR2)
In the preceding syntax:
geometry1
is a column of type SDO_GEOMETRY in a table. This column must be spatially indexed.
geometry2
is an object of type SDO_GEOMETRY. This object may or may not come from a table. If it comes from a table, it may or may not be spatially indexed.
param
is an optional string of type VARCHAR2. It can specify either or both of the min_resolution
and max_resolution
keywords.
The following examples perform a primary filter operation only (with no secondary filter operation). They will return all the geometries shown in Figure 42 that have an MBR that interacts with the query window. The result of the following examples are geometries geom_1, geom_2, and geom_3.
Example 41 performs a primary filter operation without inserting the query window into a table. The window will be indexed in memory and performance will be very good.
Example 41 Primary Filter with a Temporary Query Window
SELECT A.Feature_ID FROM TARGET A WHERE sdo_filter(A.shape, SDO_geometry(2003,NULL,NULL, SDO_elem_info_array(1,1003,3), SDO_ordinate_array(x1,y1, x2,y2)) ) = 'TRUE';
In Example 41, (x1,y1)
and (x2,y2)
are the lowerleft and upperright corners of the query window.
In Example 42, a transient instance of type SDO_GEOMETRY was constructed for the query window instead of specifying the window parameters in the query itself.
Example 42 Primary Filter with a Transient Instance of the Query Window
SELECT A.Feature_ID FROM TARGET A WHERE sdo_filter(A.shape, :theWindow) = 'TRUE';
Example 43 assumes the query window was inserted into a table called WINDOWS, with an ID of WINS_1.
Example 43 Primary Filter with a Stored Query Window
SELECT A.Feature_ID FROM TARGET A, WINDOWS B WHERE B.ID = 'WINS_1' AND sdo_filter(A.shape, B.shape) = 'TRUE';
If the B.SHAPE column is not spatially indexed, the SDO_FILTER operator indexes the query window in memory and performance is very good.
The SDO_RELATE operator, described in Chapter 11, performs both the primary and secondary filter stages when processing a query. The secondary filter ensures that only candidate objects that actually interact are selected. This operator can be used only if a spatial index has been created on two dimensions of data. The syntax of the SDO_RELATE operator is as follows:
SDO_RELATE(geometry1 SDO_GEOMETRY, geometry2 SDO_GEOMETRY, param VARCHAR2)
In the preceding syntax:
geometry1
is a column of type SDO_GEOMETRY in a table. This column must be spatially indexed.
geometry2
is an object of type SDO_GEOMETRY. This object may or may not come from a table. If it comes from a table, it may or may not be spatially indexed.
param
is a quoted string with the mask
keyword and a valid mask value, and optionally either or both of the min_resolution
and max_resolution
keywords, as explained in the documentation for the SDO_RELATE operator in Chapter 11.
The following examples perform both primary and secondary filter operations. They return all the geometries in Figure 42 that lie within or overlap the query window. The result of these examples is objects geom_1 and geom_2.
Example 44 performs both primary and secondary filter operations without inserting the query window into a table. The window will be indexed in memory and performance will be very good.
Example 44 Secondary Filter Using a Temporary Query Window
SELECT A.Feature_ID FROM TARGET A WHERE sdo_relate(A.shape, SDO_geometry(2003,NULL,NULL, SDO_elem_info_array(1,1003,3), SDO_ordinate_array(x1,y1, x2,y2)), 'mask=anyinteract') = 'TRUE';
In Example 44, (x1,y1)
and (x2,y2)
are the lowerleft and upperright corners of the query window.
Example 45 assumes the query window was inserted into a table called WINDOWS, with an ID value of WINS_1.
Example 45 Secondary Filter Using a Stored Query Window
SELECT A.Feature_ID FROM TARGET A, WINDOWS B WHERE B.ID = 'WINS_1' AND sdo_relate(A.shape, B.shape, 'mask=anyinteract') = 'TRUE';
If the (B.SHAPE column is not spatially indexed, the SDO_RELATE operator indexes the query window in memory and performance is very good.
The SDO_WITHIN_DISTANCE operator, described in Chapter 11, is used to determine the set of objects in a table that are within n distance units from a reference object. This operator can be used only if a spatial index has been created on two dimensions of data. The reference object may be a transient or persistent instance of SDO_GEOMETRY (such as a temporary query window or a permanent geometry stored in the database). The syntax of the operator is as follows:
SDO_WITHIN_DISTANCE(geometry1 SDO_GEOMETRY, aGeom SDO_GEOMETRY, params VARCHAR2);
In the preceding syntax:
geometry1
is a column of type SDO_GEOMETRY in a table. This column must be spatially indexed.
aGeom
is an instance of type SDO_GEOMETRY.
params
is a quoted string of keyword value pairs that determines the behavior of the operator. See the SDO_WITHIN_DISTANCE operator in Chapter 11 for a list of parameters.
The following example selects any objects within 1.35 distance units from the query window:
SELECT A.Feature_ID FROM TARGET A WHERE SDO_WITHIN_DISTANCE( A.shape, :theWindow, 'distance=1.35') = 'TRUE';
The distance units are based on the geometry coordinate system in use. If you are using a geodetic coordinate system, the units are meters. If no coordinate system is used, the units are the same as for the stored data.
The SDO_WITHIN_DISTANCE operator is not suitable for performing spatial joins. That is, a query such as Find all parks that are within 10 distance units from coastlines will not be processed as an indexbased spatial join of the COASTLINES and PARKS tables. Instead, it will be processed as a nested loop query in which each COASTLINES instance is in turn a reference object that is buffered, indexed, and evaluated against the PARKS table. Thus, the SDO_WITHIN_DISTANCE operation is performed n times if there are n rows in the COASTLINES table.
For nongeodetic data, there is an efficient way to accomplish a spatial join that involves buffering all geometries of a layer. This method does not use the SDO_WITHIN_DISTANCE operator. First, create a new table COSINE_BUFS as follows:
CREATE TABLE cosine_bufs UNRECOVERABLE AS SELECT SDO_BUFFER (A.SHAPE, B.DIMINFO, 1.35) FROM COSINE A, USER_SDO_GEOM_METADATA B WHERE TABLE_NAME='COSINES' AND COLUMN_NAME='SHAPE';
Next, create a spatial index on the SHAPE column of COSINE_BUFS. Then you can perform the following query:
SELECT /*+ ordered */ a.gid, b.gid FROM TABLE(SDO_JOIN('PARKS', 'SHAPE', 'COSINE_BUFS', 'SHAPE', 'mask=ANYINTERACT')) c, parks a, cosine_bufs b WHERE c.rowid1 = a.rowid AND c.rowid2 = b.rowid;
The SDO_NN operator, described in Chapter 11, is used to identify the nearest neighbors for a geometry. This operator can be used only if a spatial index has been created on two dimensions of data. The syntax of the operator is as follows:
SDO_NN(geometry1 SDO_GEOMETRY, geometry2 SDO_GEOMETRY, param VARCHAR2 [, number NUMBER]);
In the preceding syntax:
geometry1
is a column of type SDO_GEOMETRY in a table. This column must be spatially indexed.
geometry2
is an instance of type SDO_GEOMETRY.
param
is a quoted string of keywordvalue pairs that can determine the behavior of the operator, such as how many nearest neighbor geometries are returned. See the SDO_NN operator in Chapter 11 for information about this parameter.
number
is the same number used in the call to SDO_NN_DISTANCE. Use this only if the SDO_NN_DISTANCE ancillary operator is included in the call to SDO_NN. See the SDO_NN operator in Chapter 11 for information about this parameter.
The following example finds the two objects from the SHAPE column in the COLA_MARKETS table that are closest to a specified point (10,7). (Note the use of the optimizer hint in the SELECT statement, as explained in the Usage Notes for the SDO_NN operator in Chapter 11.)
SELECT /*+ INDEX(cola_markets cola_spatial_idx) */ c.mkt_id, c.name FROM cola_markets c WHERE SDO_NN(c.shape, SDO_geometry(2001, NULL, SDO_point_type(10,7,NULL), NULL, NULL), 'sdo_num_res=2') = 'TRUE';
Spatial also supplies functions for determining relationships between geometries, finding information about single geometries, changing geometries, and combining geometries. These functions all take into account two dimensions of source data. If the output value of these functions is a geometry, the resulting geometry will have the same dimensionality as the input geometry, but only the first two dimensions will accurately reflect the result of the operation.
A spatial join is the same as a regular join except that the predicate involves a spatial operator. In Spatial, a spatial join takes place when you compare all geometries of one layer to all geometries of another layer. This is unlike a query window, which compares a single geometry to all geometries of a layer.
Spatial joins can be used to answer questions such as Which highways cross national parks?
The following table structures illustrate how the join would be accomplished for this example:
PARKS( GID VARCHAR2(32), SHAPE SDO_GEOMETRY) HIGHWAYS( GID VARCHAR2(32), SHAPE SDO_GEOMETRY)
To perform a spatial join, use the SDO_JOIN operator, which is described in Chapter 11. The following spatial join query, to list the GID column values of highways and parks where a highway interacts with a park, performs a primary filter operation only ('mask=FILTER'
), and thus it returns only approximate results:
SELECT /*+ ordered */ a.gid, b.gid FROM TABLE(SDO_JOIN('PARKS', 'SHAPE', 'HIGHWAYS', 'SHAPE', 'mask=FILTER')) c, parks a, highways b WHERE c.rowid1 = a.rowid AND c.rowid2 = b.rowid;
The following spatial join query requests the same information as in the preceding example, but it performs both primary and secondary filter operations ('mask=ANYINTERACT'
), and thus it returns exact results:
SELECT /*+ ordered */ a.gid, b.gid FROM TABLE(SDO_JOIN('PARKS', 'SHAPE', 'HIGHWAYS', 'SHAPE', 'mask=ANYINTERACT')) c, parks a, highways b WHERE c.rowid1 = a.rowid AND c.rowid2 = b.rowid;
You can invoke spatial operators on an indexed table that is not in your schema. Assume that user A has a spatial table T1 (with index table IDX_TAB1) with a spatial index defined, that user B has a spatial table T2 (with index table IDX_TAB2) with a spatial index defined, and that user C wants to invoke operators on tables in one or both of the other schemas.
If user C wants to invoke an operator only on T1, user C must perform the following steps:
Connect as user A and execute the following statements:
GRANT select on T1 to C; GRANT select on idx_tab1 to C;
Connect as user C and execute a statement such as the following:
SELECT a.gid FROM T1 a WHERE sdo_filter(a.geometry, :theGeometry) = 'TRUE';
If user C wants to invoke an operator on both T1 and T2, user C must perform the following steps:
Connect as user A and execute the following statements:
GRANT select on T1 to C; GRANT select on idx_tab1 to C;
Connect as user B and execute the following statements:
GRANT select on T2 to C; GRANT select on idx_tab2 to C;
Connect as user C and execute a statement such as the following:
SELECT a.gid FROM T1 a, T2 b WHERE b.gid = 5 AND sdo_filter(a.geometry, b.geometry) = 'TRUE';
Oracle Locator (also referred to as Locator) is a feature of Oracle Database 10g Standard Edition. Locator provides core features and services available in Oracle Spatial. It provides significant capabilities typically required to support Internet and wireless servicebased applications and partnerbased GIS solutions. Locator is not designed to be a solution for geographic information system (GIS) applications requiring complex spatial data management. If you need capabilities such as linear referencing, spatial functions, or coordinate system transformations, use Oracle Spatial instead of Locator.
Like Spatial, Locator is not designed to be an enduser application, but is a set of spatial capabilities for application developers.
Locator is available with both the Standard and Enterprise Editions of Oracle Database 10g. Spatial is a priced option available only with Oracle Database 10g Enterprise Edition. Spatial includes all Locator features as well as other features that are not available with Locator.
The installation of Locator depends on the successful and proper installation of Oracle interMedia. interMedia is installed and configured with Oracle Database 10g, although you can install interMedia manually if necessary, as documented in Oracle interMedia User's Guide. During the installation of interMedia, Locator is installed.
In general, Locator includes the data types, operators, and indexing capabilities of Oracle Spatial, along with a limited set of the functions and procedures of Spatial. The Locator features include the following:
An object type (SDO_GEOMETRY) that describes and supports any type of geometry
A spatial indexing capability that lets you create spatial indexes on geometry data
Spatial operators (described in Chapter 11) that use the spatial index for performing spatial queries
Some geometry functions and the SDO_AGGR_MBR spatial aggregate function
Coordinate system support for explicit geometry and layer transformations (SDO_CS.TRANSFORM function and SDO_CS.TRANSFORM_LAYER procedure, described in Chapter 13)
Tuning functions and procedures (SDO_TUNE package, described in Chapter 19)
Spatial utility functions (SDO_UTIL package, described in Chapter 20)
Integration with Oracle Application Server 10g
For information about spatial concepts, the SDO_GEOMETRY object type, and indexing and loading spatial data, see Chapters 1 through 4 in this guide. For reference and usage information about features supported by Locator, see the chapter or section listed in Table B1.
Table B1 Spatial Features Supported for Locator
Spatial Feature  Described in 

Functionbased spatial indexing 

Table partitioning support for spatial indexes (including splitting, merging, and exchanging partitions and their indexes)  
Geodetic data support  
SQL statements for creating, altering, and deleting indexes 

Parallel spatial index builds (PARALLEL keyword with ALTER INDEX REBUILD and CREATE INDEX statements) (new with release 9.2) 

SDO_GEOMETRY object type methods 

Spatial operators (including SDO_JOIN, which is technically a table function but is documented with the operators) 

Implicit coordinate system transformations for operator calls where a window needs to be converted to the coordinate system of the queried layer. 

SDO_AGGR_MBR spatial aggregate function 

Coordinate system support for explicit geometry and layer transformations (SDO_CS.TRANSFORM function and SDO_CS.TRANSFORM_LAYER procedure) 

The following SDO_GEOM package functions and procedures: SDO_GEOM.SDO_DISTANCE , SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT, SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT 

Package (SDO_MIGRATE) to upgrade data from previous Spatial releases to the current release 

Tuning functions and procedures (SDO_TUNE package) 

Spatial utility functions (SDO_UTIL package) 

Oracle Database Advanced Replication  
Graphical tool for tuning spatial quadtree indexes (Spatial Index Advisor integrated application in Oracle Enterprise Manager) 
Online help for Oracle Enterprise Manager 
Table B2 lists Spatial features that are not supported for Locator, with the chapter in this guide or the separate manual that describes the feature.
Table B2 Spatial Features Not Supported for Locator
Spatial Feature  Described in 

SDO_GEOM package functions and procedures, except for those listed in Table B1 

Spatial aggregate functions, except for any listed in Table B1 

Linear referencing system (LRS) support 
Chapter 7 (concepts and usage) and Chapter 16 (reference) 
Spatial analysis and mining functions and procedures (SDO_SAM package) 

Geocoding support (SDO_GCDR package) 
Chapter 5 (concepts and usage) and Chapter 14 (reference) 
GeoRaster support 

Topology data model 
Oracle Spatial Topology and Network Data Models 
Network data model 
Oracle Spatial Topology and Network Data Models 
Although Locator is available on both the Standard and Enterprise Editions of Oracle Database 10g, some Locator features requires database features that are not available or are limited on the Standard Edition. Some of those Locator features and their availability are listed in Table B3.
Table B3 Feature Availability with Standard and Enterprise Editions
Feature  Standard/Enterprise Edition Availability 

Parallel spatial index builds 
Supported with Enterprise Edition only. 
Supported with Enterprise Edition only. (Single master/materialized view replication for SDO_GEOMETRY objects is supported with both Standard Edition and Enterprise Edition. See Oracle Database Advanced Replication for more information.)  
Partitioned spatial indexes 
Requires the Partitioning Option with Enterprise Edition. Not supported with Standard Edition. 
Oracle Spatial consists of a set of object data types, type methods, and operators, functions, and procedures that use these types. A geometry is stored as an object, in a single row, in a column of type SDO_GEOMETRY. Spatial index creation and maintenance is done using basic DDL (CREATE, ALTER, DROP) and DML (INSERT, UPDATE, DELETE) statements.
This chapter starts with a simple example that inserts, indexes, and queries spatial data. You may find it helpful to read this example quickly before you examine the detailed data type and metadata information later in the chapter.
This chapter contains the following major sections:
This section presents a simple example of creating a spatial table, inserting data, creating the spatial index, and performing spatial queries. It refers to concepts that were explained in Chapter 1 and that will be explained in other sections of this chapter.
The scenario is a soft drink manufacturer that has identified geographical areas of marketing interest for several products (colas). The colas could be those produced by the company or by its competitors, or some combination. Each area of interest could represent any userdefined criterion: for example, an area where that cola has the majority market share, or where the cola is under competitive pressure, or where the cola is believed to have significant growth potential. Each area could be a neighborhood in a city, or a part of a state, province, or country.
Figure 21 shows the areas of interest for four colas.
Example 21 performs the following operations:
Creates a table (COLA_MARKETS) to hold the spatial data
Inserts rows for four areas of interest (cola_a
, cola_b
, cola_c
, cola_d
)
Updates the USER_SDO_GEOM_METADATA view to reflect the dimensional information for the areas
Creates a spatial index (COLA_SPATIAL_IDX)
Performs some spatial queries
Many concepts and techniques in Example 21 are explained in detail in other sections of this chapter.
Example 21 Simple Example: Inserting, Indexing, and Querying Spatial Data
 Create a table for cola (soft drink) markets in a  given geography (such as city or state).  Each row will be an area of interest for a specific  cola (for example, where the cola is most preferred  by residents, where the manufacturer believes the  cola has growth potential, and so on).  (For restrictions on spatial table and column names, see  Section 2.6.1 and Section 2.6.2.) CREATE TABLE cola_markets ( mkt_id NUMBER PRIMARY KEY, name VARCHAR2(32), shape SDO_GEOMETRY);  The next INSERT statement creates an area of interest for  Cola A. This area happens to be a rectangle.  The area could represent any userdefined criterion: for  example, where Cola A is the preferred drink, where  Cola A is under competitive pressure, where Cola A  has strong growth potential, and so on. INSERT INTO cola_markets VALUES( 1, 'cola_a', SDO_GEOMETRY( 2003,  twodimensional polygon NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,3),  one rectangle (1003 = exterior) SDO_ORDINATE_ARRAY(1,1, 5,7)  only 2 points needed to  define rectangle (lower left and upper right) with  Cartesiancoordinate data ) );  The next two INSERT statements create areas of interest for  Cola B and Cola C. These areas are simple polygons (but not  rectangles). INSERT INTO cola_markets VALUES( 2, 'cola_b', SDO_GEOMETRY( 2003,  twodimensional polygon NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,1),  one polygon (exterior polygon ring) SDO_ORDINATE_ARRAY(5,1, 8,1, 8,6, 5,7, 5,1) ) ); INSERT INTO cola_markets VALUES( 3, 'cola_c', SDO_GEOMETRY( 2003,  twodimensional polygon NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,1),  one polygon (exterior polygon ring) SDO_ORDINATE_ARRAY(3,3, 6,3, 6,5, 4,5, 3,3) ) );  Now insert an area of interest for Cola D. This is a  circle with a radius of 2. It is completely outside the  first three areas of interest. INSERT INTO cola_markets VALUES( 4, 'cola_d', SDO_GEOMETRY( 2003,  twodimensional polygon NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,4),  one circle SDO_ORDINATE_ARRAY(8,7, 10,9, 8,11) ) );   UPDATE METADATA VIEW    Update the USER_SDO_GEOM_METADATA view. This is required  before the Spatial index can be created. Do this only once for each  layer (that is, tablecolumn combination; here: COLA_MARKETS and SHAPE). INSERT INTO user_sdo_geom_metadata (TABLE_NAME, COLUMN_NAME, DIMINFO, SRID) VALUES ( 'cola_markets', 'shape', SDO_DIM_ARRAY(  20X20 grid SDO_DIM_ELEMENT('X', 0, 20, 0.005), SDO_DIM_ELEMENT('Y', 0, 20, 0.005) ), NULL  SRID );   CREATE THE SPATIAL INDEX   CREATE INDEX cola_spatial_idx ON cola_markets(shape) INDEXTYPE IS MDSYS.SPATIAL_INDEX;  Preceding statement created an Rtree index.   PERFORM SOME SPATIAL QUERIES    Return the topological intersection of two geometries. SELECT SDO_GEOM.SDO_INTERSECTION(c_a.shape, c_c.shape, 0.005) FROM cola_markets c_a, cola_markets c_c WHERE c_a.name = 'cola_a' AND c_c.name = 'cola_c';  Do two geometries have any spatial relationship? SELECT SDO_GEOM.RELATE(c_b.shape, 'anyinteract', c_d.shape, 0.005) FROM cola_markets c_b, cola_markets c_d WHERE c_b.name = 'cola_b' AND c_d.name = 'cola_d';  Return the areas of all cola markets. SELECT name, SDO_GEOM.SDO_AREA(shape, 0.005) FROM cola_markets;  Return the area of just cola_a. SELECT c.name, SDO_GEOM.SDO_AREA(c.shape, 0.005) FROM cola_markets c WHERE c.name = 'cola_a';  Return the distance between two geometries. SELECT SDO_GEOM.SDO_DISTANCE(c_b.shape, c_d.shape, 0.005) FROM cola_markets c_b, cola_markets c_d WHERE c_b.name = 'cola_b' AND c_d.name = 'cola_d';  Is a geometry valid? SELECT c.name, SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT(c.shape, 0.005) FROM cola_markets c WHERE c.name = 'cola_c';  Is a layer valid? (First, create the results table.) CREATE TABLE val_results (sdo_rowid ROWID, result VARCHAR2(2000)); CALL SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT('COLA_MARKETS', 'SHAPE', 'VAL_RESULTS', 2); SELECT * from val_results;
With Spatial, the geometric description of a spatial object is stored in a single row, in a single column of object type SDO_GEOMETRY in a userdefined table. Any table that has a column of type SDO_GEOMETRY must have another column, or set of columns, that defines a unique primary key for that table. Tables of this sort are sometimes referred to as spatial tables or spatial geometry tables.
Oracle Spatial defines the object type SDO_GEOMETRY as:
CREATE TYPE sdo_geometry AS OBJECT ( SDO_GTYPE NUMBER, SDO_SRID NUMBER, SDO_POINT SDO_POINT_TYPE, SDO_ELEM_INFO SDO_ELEM_INFO_ARRAY, SDO_ORDINATES SDO_ORDINATE_ARRAY);
Oracle Spatial also defines the SDO_POINT_TYPE, SDO_ELEM_INFO_ARRAY, and SDO_ORDINATE_ARRAY types, which are used in the SDO_GEOMETRY type definition, as follows:
CREATE TYPE sdo_point_type AS OBJECT ( X NUMBER, Y NUMBER, Z NUMBER); CREATE TYPE sdo_elem_info_array AS VARRAY (1048576) of NUMBER; CREATE TYPE sdo_ordinate_array AS VARRAY (1048576) of NUMBER;
Because the maximum SDO_ORDINATE_ARRAY size is 1,048,576 numbers, the maximum number of vertices in an SDO_GEOMETRY object depends on the number of dimensions per vertex: 524,288 for two dimensions, 349,525 for three dimensions, and 262,144 for four dimensions.
The sections that follow describe the semantics of each SDO_GEOMETRY attribute, and then describe some usage considerations (Section 2.2.6).
The SDO_GEOMETRY object type has methods that provide convenient access to some of the attributes. These methods are described in Section 2.3.
Some Spatial data types are described in locations other than this section:
Section 5.2 describes data types for geocoding.
Oracle Spatial GeoRaster describes data types for Oracle Spatial GeoRaster.
Oracle Spatial Topology and Network Data Models describes data types for the Oracle Spatial topology data model.
The SDO_GTYPE attribute indicates the type of the geometry. Valid geometry types correspond to those specified in the Geometry Object Model for the OGIS Simple Features for SQL specification (with the exception of Surfaces). The numeric values differ from those given in the OGIS specification, but there is a direct correspondence between the names and semantics where applicable.
The SDO_GTYPE value is 4 digits in the format dltt, where:
d identifies the number of dimensions (2, 3, or 4)
l identifies the linear referencing measure dimension for a threedimensional linear referencing system (LRS) geometry, that is, which dimension (3 or 4) contains the measure value. For a nonLRS geometry, or to accept the Spatial default of the last dimension as the measure for an LRS geometry, specify 0. For information about the linear referencing system (LRS), see Chapter 7.
tt identifies the geometry type (00 through 07, with 08 through 99 reserved for future use).
Table 21 shows the valid SDO_GTYPE values. The Geometry Type and Description values reflect the OGIS specification.
Table 21 Valid SDO_GTYPE Values
Value  Geometry Type  Description 

dl00 
UNKNOWN_GEOMETRY 
Spatial ignores this geometry. 
dl01 
POINT 
Geometry contains one point. 
dl02 
LINE or CURVE 
Geometry contains one line string that can contain straight or circular arc segments, or both. (LINE and CURVE are synonymous in this context.) 
dl03 
POLYGON 
Geometry contains one polygon with or without holes.^{Foot 1 } 
dl04 
COLLECTION 
Geometry is a heterogeneous collection of elements. COLLECTION is a superset that includes all other types. 
dl05 
MULTIPOINT 
Geometry has one or more points. (MULTIPOINT is a superset of POINT.) 
dl06 
MULTILINE or MULTICURVE 
Geometry has one or more line strings. (MULTILINE and MULTICURVE are synonymous in this context, and each is a superset of both LINE and CURVE.) 
dl07 
MULTIPOLYGON 
Geometry can have multiple, disjoint polygons (more than one exterior boundary). (MULTIPOLYGON is a superset of POLYGON.) 
^{Footnote 1 }For a polygon with holes, enter the exterior boundary first, followed by any interior boundaries.
The d in the Value column of Table 21 is the number of dimensions: 2, 3, or 4. For example, an SDO_GTYPE value of 2003 indicates a twodimensional polygon.
Note: The 1digit SDO_GTYPE values from before release 8.1.6 value are still supported. If a 1digit value is used, however, Oracle Spatial determines the number of dimensions from the DIMINFO column of the metadata views, described in Section 2.6.3.Also, if 1digit SDO_GTYPE values are converted to 4digit values, any SDO_ETYPE values that end in 3 or 5 in the SDO_ELEM_INFO array (described in Section 2.2.4) must also be converted. 
The number of dimensions reflects the number of ordinates used to represent each vertex (for example, X,Y for twodimensional objects). Points and lines are considered twodimensional objects. (However, see Section 7.2 for dimension information about LRS points.)
In any given layer (column), all geometries must have the same number of dimensions. For example, you cannot mix twodimensional and threedimensional data in the same layer.
The following methods are available for returning the individual dltt components of the SDO_GTYPE for a geometry object: Get_Dims, Get_LRS_Dim, and Get_Gtype. These methods are described in Section 2.3.
The SDO_SRID attribute can be used to identify a coordinate system (spatial reference system) to be associated with the geometry. If SDO_SRID is null, no coordinate system is associated with the geometry. If SDO_SRID is not null, it must contain a value from the SRID column of the SDO_COORD_REF_SYS table (described in Section 6.6.9), and this value must be inserted into the SRID column of the USER_SDO_GEOM_METADATA view (described in Section 2.6).
All geometries in a geometry column must have the same SDO_SRID value.
For information about coordinate systems, see Chapter 6.
The SDO_POINT attribute is defined using the SDO_POINT_TYPE object type, which has the attributes X, Y, and Z, all of type NUMBER. (The SDO_POINT_TYPE definition is shown in Section 2.2.) If the SDO_ELEM_INFO and SDO_ORDINATES arrays are both null, and the SDO_POINT attribute is nonnull, then the X and Y values are considered to be the coordinates for a point geometry. Otherwise, the SDO_POINT attribute is ignored by Spatial. You should store point geometries in the SDO_POINT attribute for optimal storage; and if you have only point geometries in a layer, it is strongly recommended that you store the point geometries in the SDO_POINT attribute.
Section 2.5.5 illustrates a point geometry and provides examples of inserting and querying point geometries.
Note: Do not use the SDO_POINT attribute in defining a linear referencing system (LRS) point or an oriented point. For information about LRS, see Chapter 7. For information about oriented points, see Section 2.5.6. 
The SDO_ELEM_INFO attribute is defined using a varying length array of numbers. This attribute lets you know how to interpret the ordinates stored in the SDO_ORDINATES attribute (described in Section 2.2.5).
Each triplet set of numbers is interpreted as follows:
SDO_STARTING_OFFSET  Indicates the offset within the SDO_ORDINATES array where the first ordinate for this element is stored. Offset values start at 1 and not at 0. Thus, the first ordinate for the first element will be at SDO_GEOMETRY.SDO_ORDINATES(1). If there is a second element, its first ordinate will be at SDO_GEOMETRY.SDO_ORDINATES(n), where n reflects the position within the SDO_ORDINATE_ARRAY definition (for example, 19 for the 19th number, as in Figure 23 in Section 2.5.2).
SDO_ETYPE  Indicates the type of the element. Valid values are shown in Table 22.
SDO_ETYPE values 1, 2, 1003, and 2003 are considered simple elements. They are defined by a single triplet entry in the SDO_ELEM_INFO array. For SDO_ETYPE values 1003 and 2003, the first digit indicates exterior (1) or interior (2):
1003: exterior polygon ring (must be specified in counterclockwise order)
2003: interior polygon ring (must be specified in clockwise order)
Note: The use of 3 as an SDO_ETYPE value for polygon ring elements in a single geometry is discouraged. You should specify 3 only if you do not know if the simple polygon is exterior or interior, and you should then upgrade the table or layer to the current format using the SDO_MIGRATE.TO_CURRENT procedure, described in Chapter 17.You cannot mix 1digit and 4digit SDO_ETYPE values in a single geometry. If you use 4digit SDO_ETYPE values, you must use 4digit SDO_GTYPE values. 
SDO_ETYPE values 4, 1005, and 2005 are considered compound elements. They contain at least one header triplet with a series of triplet values that belong to the compound element. For SDO_ETYPE values 1005 and 2005, the first digit indicates exterior (1) or interior (2):
1005: exterior polygon ring (must be specified in counterclockwise order)
2005: interior polygon ring (must be specified in clockwise order)
Note: The use of 5 as an SDO_ETYPE value for polygon ring elements in a single geometry is discouraged. You should specify 5 only if you do not know if the compound polygon is exterior or interior, and you should then upgrade the table or layer to the current format using the SDO_MIGRATE.TO_CURRENT procedure, described in Chapter 17.You cannot mix 1digit and 4digit SDO_ETYPE values in a single geometry. If you use 4digit SDO_ETYPE values, you must use 4digit SDO_GTYPE values. 
The elements of a compound element are contiguous. The last point of a subelement in a compound element is the first point of the next subelement. The point is not repeated.
SDO_INTERPRETATION  Means one of two things, depending on whether or not SDO_ETYPE is a compound element.
If SDO_ETYPE is a compound element (4, 1005, or 2005), this field specifies how many subsequent triplet values are part of the element.
If the SDO_ETYPE is not a compound element (1, 2, 1003, or 2003), the interpretation attribute determines how the sequence of ordinates for this element is interpreted. For example, a line string or polygon boundary may be made up of a sequence of connected straight line segments or circular arcs.
Descriptions of valid SDO_ETYPE and SDO_INTERPRETATION value pairs are given in Table 22.
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 SDO_ORDINATES varying length array.
For compound elements (SDO_ETYPE values 4, 1005, or 2005), a set of n triplets (one for each subelement) is used to describe the element. It is important to remember that subelements of a compound element are contiguous. The last point of a subelement is the first point of the next subelement. For subelements 1 through n1, the end point of one subelement is the same as the starting point of the next subelement. The starting point for subelements 2...n2 is the same as the end point of subelement 1...n1. The last ordinate of subelement n is either the starting offset minus 1 of the next element in the geometry, or the last ordinate in the SDO_ORDINATES varying length array.
The current size of a varying length array can be determined by using the function varray_variable.Count in PL/SQL or OCICollSize in the Oracle Call Interface (OCI).
The semantics of each SDO_ETYPE element and the relationship between the SDO_ELEM_INFO and SDO_ORDINATES varying length arrays for each of these SDO_ETYPE elements are given in Table 22.
Table 22 Values and Semantics in SDO_ELEM_INFO
SDO_ETYPE  SDO_INTERPRETATION  Meaning 

0 
(any numeric value) 
Type 0 (zero) element. Used to model geometry types not supported by Oracle Spatial. For more information, see Section 2.5.7. 
1 
1 
Point type. 
1 
0 
Orientation for an oriented point. For more information, see Section 2.5.6. 
1 
n > 1 
Point cluster with n points. 
2 
1 
Line string whose vertices are connected by straight line segments. 
2 
2 
Line string made up of a connected sequence of circular arcs. Each circular arc is described using three coordinates: the start point of the arc, any point on the arc, and the end point of the arc. The coordinates for a point designating the end of one arc and the start of the next arc are not repeated. For example, five coordinates are used to describe a line string made up of two connected circular arcs. Points 1, 2, and 3 define the first arc, and points 3, 4, and 5 define the second arc, where point 3 is only stored once. 
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 (to close the polygon), regardless of the tolerance value. For example, for a 4sided polygon, specify 5 points, with point 5 the same as point 1. 
1003 or 2003 
2 
Polygon made up of a connected sequence of circular arcs that closes on itself. The end point of the last arc is the same as the start point of the first arc. Each circular arc is described using three coordinates: the start point of the arc, any point on the arc, and the end point of the arc. The coordinates for a point designating the end of one arc and the start of the next arc are not repeated. For example, five coordinates are used to describe a polygon made up of two connected circular arcs. Points 1, 2, and 3 define the first arc, and points 3, 4, and 5 define the second arc. The coordinates for points 1 and 5 must be the same (tolerance is not considered), and point 3 is not repeated. 
1003 or 2003 
3 
Rectangle type (sometimes called optimized rectangle). A bounding rectangle such that only two points, the lowerleft and the upperright, are required to describe it. The rectangle type can be used with geodetic or nongeodetic data. However, with geodetic data, use this type only to create a query window (not for storing objects in the database). For detailed information about using this type with geodetic data, including examples, see Section 6.2.3. 
1003 or 2003 
4 
Circle type. Described by three distinct noncolinear points, all on the circumference of the circle. 
4 
n > 1 
Compound line string with some vertices connected by straight line segments and some by circular arcs. The value n in the Interpretation column specifies the number of contiguous subelements that make up the line string. The next n triplets in the SDO_ELEM_INFO array describe each of these subelements. The subelements can only be of SDO_ETYPE 2. The last point of a subelement is the first point of the next subelement, and must not be repeated. See Section 2.5.3 and Figure 24 for an example of a compound line string geometry. 
1005 or 2005 
n > 1 
Compound polygon with some vertices connected by straight line segments and some by circular arcs. The value n in the Interpretation column specifies the number of contiguous subelements that make up the polygon. The next n triplets in the SDO_ELEM_INFO array describe each of these subelements. The subelements can only be of SDO_ETYPE 2. The end point of a subelement is the start point of the next subelement, and it must not be repeated. The start and end points of the polygon must be exactly the same point (tolerance is ignored). See Section 2.5.4 and Figure 25 for an example of a compound polygon geometry. 
The SDO_ORDINATES attribute is defined using a varying length array (1048576) of NUMBER type that stores the coordinate values that make up the boundary of a spatial object. This array must always be used in conjunction with the SDO_ELEM_INFO varying length array. The values in the array are ordered by dimension. For example, a polygon whose boundary has four twodimensional points is stored as {X1, Y1, X2, Y2, X3, Y3, X4, Y4, X1, Y1}. If the points are threedimensional, then they are stored as {X1, Y1, Z1, X2, Y2, Z2, X3, Y3, Z3, X4, Y4, Z4, X1, Y1, Z1}. Spatial index creation, operators, and functions ignore the Z values because this release of the product supports only twodimensional spatial objects. The number of dimensions associated with each point is stored as metadata in the xxx_SDO_GEOM_METADATA views, described in Section 2.6.
The values in the SDO_ORDINATES array must all be valid and nonnull. There are no special values used to delimit elements in a multielement geometry. The start and end points for the sequence describing a specific element are determined by the STARTING_OFFSET values for that element and the next element in the SDO_ELEM_INFO array, as explained in Section 2.2.4. The offset values start at 1. SDO_ORDINATES(1) is the first ordinate of the first point of the first element.
You should use the SDO_GTYPE values as shown in Table 21; however, Spatial does not check or enforce all geometry consistency constraints. Spatial does check the following:
For SDO_GTYPE values d001 and d005, any subelement not of SDO_ETYPE 1 is ignored.
For SDO_GTYPE values d002 and d006, any subelement not of SDO_ETYPE 2 or 4 is ignored.
For SDO_GTYPE values d003 and d007, any subelement not of SDO_ETYPE 3 or 5 is ignored. (This includes SDO_ETYPE variants 1003, 2003, 1005, and 2005, which are explained in Section 2.2.4).
The SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT function can be used to evaluate the consistency of a single geometry object or of all geometry objects in a specified feature table.
The SDO_GEOMETRY object type (described in Section 2.2) has methods (member functions) that retrieve information about a geometry object. Table 23 lists these methods.
Table 23 SDO_GEOMETRY Methods
Name  Returns  Description 

NUMBER 
Returns the number of dimensions of a geometry object, as specified in its SDO_GTYPE value. In Oracle Spatial, the Get_Dims and ST_CoordDim methods return the same result.  
NUMBER 
Returns the geometry type of a geometry object, as specified in its SDO_GTYPE value.  
NUMBER 
Returns the measure dimension of an LRS geometry object, as specified in its SDO_GTYPE value. A return value of 0 indicates that the geometry is a standard (nonLRS) geometry, or is an LRS geometry in the format before release 9.0.1 and with measure as the default (last) dimension; 3 indicates that the third dimension contains the measure information; 4 indicates that the fourth dimension contains the measure information.  
BLOB 
Returns the wellknown binary (WKB) format of a geometry object. (The returned object does not include any SRID information.)  
CLOB 
Returns the wellknown text (WKT) format (explained in Section 6.7.1.1) of a geometry object. (The returned object does not include any SRID information.)  
NUMBER 
Returns the coordinate dimension (as defined by the ISO/IEC SQL Multimedia standard) of a geometry object. In Oracle Spatial, the Get_Dims and ST_CoordDim methods return the same result.  
NUMBER 
Returns 0 if a geometry object is invalid or 1 if it is valid. (The ISO/IEC SQL Multimedia standard uses the term well formed for valid in this context.) This method uses 0.001 as the tolerance value. (Tolerance is explained in Section 1.5.5.) To specify a different tolerance value or to learn more about why a geometry is invalid, use the SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT function, which is documented in Chapter 15. 
The geometry must have a 4digit SDO_GTYPE value in the format dltt, as described in Section 2.2.1.
Example 22 shows most of the SDO_GEOMETRY methods. (The Get_WKB method is not included because its output cannot be displayed by SQL*Plus.)
Example 22 SDO_GEOMETRY Methods
SELECT c.shape.Get_Dims() FROM cola_markets c WHERE c.name = 'cola_b'; C.SHAPE.GET_DIMS()  2 SELECT c.shape.Get_GType() FROM cola_markets c WHERE c.name = 'cola_b'; C.SHAPE.GET_GTYPE()  3 SELECT a.route_geometry.Get_LRS_Dim() FROM lrs_routes a WHERE a.route_id = 1; A.ROUTE_GEOMETRY.GET_LRS_DIM()  3 SELECT c.shape.Get_WKT() FROM cola_markets c WHERE c.name = 'cola_b'; C.SHAPE.GET_WKT()  POLYGON ((5.0 1.0, 8.0 1.0, 8.0 6.0, 5.0 7.0, 5.0 1.0)) SELECT c.shape.ST_CoordDim() FROM cola_markets c WHERE c.name = 'cola_b'; C.SHAPE.ST_COORDDIM()  2 SELECT c.shape.ST_IsValid() FROM cola_markets c WHERE c.name = 'cola_b'; C.SHAPE.ST_ISVALID()  1
The SDO_GEOMETRY object type (described in Section 2.2) has constructors that create a geometry object from a wellknown text (WKT) string in CLOB or VARCHAR2 format, or from a wellknown binary (WKB) object in BLOB format. The following constructor formats are available:
SDO_GEOMETRY(wkt CLOB, srid NUMBER DEFAULT NULL); SDO_GEOMETRY(wkt VARCHAR2, srid NUMBER DEFAULT NULL); SDO_GEOMETRY(wkb BLOB, srid NUMBER DEFAULT NULL);
If the created geometry is inserted into a table, the SRID value used with the constructor must match the SDO_SRID value of the geometries in the table.
The following simple example constructs a point geometry using a wellknown text string. (In a WKT, spaces separate ordinates of a vertex, and commas separate vertices.)
SELECT SDO_GEOMETRY('POINT(79 37)') FROM DUAL; SDO_GEOMETRY('POINT(7937)')(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_I  SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(79, 37, NULL), NULL, NULL)
Example 23 shows SDO_GEOMETRY constructors that create geometry objects, insert the objects into a table, and display the objects that were added to the table.
Example 23 SDO_GEOMETRY Constructors to Create Geometries
DECLARE cola_b_wkb BLOB; cola_b_wkt_clob CLOB; cola_b_wkt_varchar VARCHAR2(255); cola_b_geom SDO_GEOMETRY; BEGIN  Get cola_b geometry into CLOB, VARCHAR2, and BLOB objects,  for use by the constructor. SELECT c.shape.Get_WKT() INTO cola_b_wkt_clob FROM cola_markets c WHERE c.name = 'cola_b'; cola_b_wkt_varchar := cola_b_wkt_clob; SELECT c.shape.Get_WKB() INTO cola_b_wkb FROM cola_markets c WHERE c.name = 'cola_b';  Use some SDO_GEOMETRY constructors;  insert 3 geometries into the table; display the geometries later. cola_b_geom := SDO_GEOMETRY(cola_b_wkt_clob); INSERT INTO cola_markets VALUES (101, 'cola_b_from_clob', cola_b_geom); cola_b_geom := SDO_GEOMETRY(cola_b_wkt_varchar); INSERT INTO cola_markets VALUES (102, 'cola_b_from_varchar', cola_b_geom); cola_b_geom := SDO_GEOMETRY(cola_b_wkb); INSERT INTO cola_markets VALUES (103, 'cola_b_from_wkb', cola_b_geom); END; / PL/SQL procedure successfully completed.  Display the geometries created using SDO_GEOMETRY constructors.  All three geometries are identical. SELECT name, shape FROM cola_markets WHERE mkt_id > 100; NAME  SHAPE(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)  cola_b_from_clob SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR AY(5, 1, 8, 1, 8, 6, 5, 7, 5, 1)) cola_b_from_varchar SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR AY(5, 1, 8, 1, 8, 6, 5, 7, 5, 1)) cola_b_from_wkb SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR AY(5, 1, 8, 1, 8, 6, 5, 7, 5, 1))
This section contains examples of many geometry types:
Figure 22 illustrates the rectangle that represents cola_a
in the example in Section 2.1.
In the SDO_GEOMETRY definition of the geometry illustrated in Figure 22:
SDO_GTYPE = 2003. The 2 indicates twodimensional, and the 3 indicates a polygon.
SDO_SRID = NULL.
SDO_POINT = NULL.
SDO_ELEM_INFO = (1, 1003, 3). The final 3 in 1,1003,3 indicates that this is a rectangle. Because it is a rectangle, only two ordinates are specified in SDO_ORDINATES (lowerleft and upperright).
SDO_ORDINATES = (1,1, 5,7). These identify the lowerleft and upperright ordinates of the rectangle.
Example 24 shows a SQL statement that inserts the geometry illustrated in Figure 22 into the database.
Example 24 SQL Statement to Insert a Rectangle
INSERT INTO cola_markets VALUES( 1, 'cola_a', SDO_GEOMETRY( 2003,  twodimensional polygon NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,3),  one rectangle (1003 = exterior) SDO_ORDINATE_ARRAY(1,1, 5,7)  only 2 points needed to  define rectangle (lower left and upper right) with  Cartesiancoordinate data ) );
Figure 23 illustrates a polygon consisting of two elements: an exterior polygon ring and an interior polygon ring. The inner element in this example is treated as a void (a hole).
In the SDO_GEOMETRY definition of the geometry illustrated in Figure 23:
SDO_GTYPE = 2003. The 2 indicates twodimensional, and the 3 indicates a polygon.
SDO_SRID = NULL.
SDO_POINT = NULL.
SDO_ELEM_INFO = (1,1003,1, 19,2003,1). There are two triplet elements: 1,1003,1 and 19,2003,1.
1003 indicates that the element is an exterior polygon ring; 2003 indicates that the element is an interior polygon ring.
19 indicates that the second element (the interior polygon ring) ordinate specification starts at the 19th number in the SDO_ORDINATES array (that is, 7, meaning that the first point is 7,5).
SDO_ORDINATES = (2,4, 4,3, 10,3, 13,5, 13,9, 11,13, 5,13, 2,11, 2,4, 7,5, 7,10, 10,10, 10,5, 7,5).
The area (SDO_GEOM.SDO_AREA function) of the polygon is the area of the exterior polygon minus the area of the interior polygon. In this example, the area is 84 (99  15).
The perimeter (SDO_GEOM.SDO_LENGTH function) of the polygon is the perimeter of the exterior polygon plus the perimeter of the interior polygon. In this example, the perimeter is 52.9193065 (36.9193065 + 16).
Example 25 shows a SQL statement that inserts the geometry illustrated in Figure 23 into the database.
Example 25 SQL Statement to Insert a Polygon with a Hole
INSERT INTO cola_markets VALUES( 10, 'polygon_with_hole', SDO_GEOMETRY( 2003,  twodimensional polygon NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1003,1, 19,2003,1),  polygon with hole SDO_ORDINATE_ARRAY(2,4, 4,3, 10,3, 13,5, 13,9, 11,13, 5,13, 2,11, 2,4, 7,5, 7,10, 10,10, 10,5, 7,5) ) );
An example of such a "polygon with a hole" might be a land mass (such as a country or an island) with a lake inside it. Of course, an actual land mass might have many such interior polygons: each one would require a triplet element in SDO_ELEM_INFO, plus the necessary ordinate specification.
Exterior and interior rings cannot be nested. For example, if a country has a lake and there is an island in the lake (and perhaps a lake on the island), a separate polygon must be defined for the island; the island cannot be defined as an interior polygon ring within the interior polygon ring of the lake.
In a multipolygon (polygon collection), rings must be grouped by polygon, and the first ring of each polygon must be the exterior ring. For example, consider a polygon collection that contains two polygons (A and B):
Polygon A (one interior "hole"): exterior ring A0, interior ring A1
Polygon B (two interior "holes"): exterior ring B0, interior ring B1, interior ring B2
The elements in SDO_ELEM_INFO and SDO_ORDINATES must be in one of the following orders (depending on whether you specify Polygon A or Polygon B first):
A0, A1; B0, B1, B2
B0, B1, B2; A0, A1
Figure 24 illustrates a crescentshaped object represented as a compound line string made up of one straight line segment and one circular arc. Four points are required to represent this shape: points (10,10) and (10,14) describe the straight line segment, and points (10,14), (6,10), and (14,10) describe the circular arc.
In the SDO_GEOMETRY definition of the geometry illustrated in Figure 24:
SDO_GTYPE = 2002. The first 2 indicates twodimensional, and the second 2 indicates one or more line segments.
SDO_SRID = NULL.
SDO_POINT = NULL.
SDO_ELEM_INFO = (1,4,2, 1,2,1, 3,2,2). There are three triplet elements: 1,4,2, 1,2,1, and 3,2,2.
The first triplet indicates that this element is a compound line string made up of two subelement line strings, which are described with the next two triplets.
The second triplet indicates that the line string is made up of straight line segments and that the ordinates for this line string start at offset 1. The end point of this line string is determined by the starting offset of the second line string, 3 in this instance.
The third triplet indicates that the second line string is made up of circular arcs with ordinates starting at offset 3. The end point of this line string is determined by the starting offset of the next element or the current length of the SDO_ORDINATES array, if this is the last element.
SDO_ORDINATES = (10,10, 10,14, 6,10, 14,10).
Example 26 shows a SQL statement that inserts the geometry illustrated in Figure 24 into the database.
Figure 25 illustrates an ice cream coneshaped object represented as a compound polygon made up of one straight line segment and one circular arc. Five points are required to represent this shape: points (6,10), (10,1), and (14,10) describe one acute angleshaped line string, and points (14,10), (10,14), and (6,10) describe the circular arc. The starting point of the line string and the ending point of the circular arc are the same point (6,10). The SDO_ELEM_INFO array contains three triplets for this compound line string. These triplets are {(1,1005,2), (1,2,1), (5,2,2)}.
In the SDO_GEOMETRY definition of the geometry illustrated in Figure 25:
SDO_GTYPE = 2003. The 2 indicates twodimensional, and the 3 indicates a polygon.
SDO_SRID = NULL.
SDO_POINT = NULL.
SDO_ELEM_INFO = (1,1005,2, 1,2,1, 5,2,2). There are three triplet elements: 1,1005,2, 1,2,1, and 5,2,2.
The first triplet indicates that this element is a compound polygon made up of two subelement line strings, which are described using the next two triplets.
The second triplet indicates that the first subelement line string is made up of straight line segments and that the ordinates for this line string start at offset 1. The end point of this line string is determined by the starting offset of the second line string, 5 in this instance. Because the vertices are twodimensional, the coordinates for the end point of the first line string are at ordinates 5 and 6.
The third triplet indicates that the second subelement line string is made up of a circular arc with ordinates starting at offset 5. The end point of this line string is determined by the starting offset of the next element or the current length of the SDO_ORDINATES array, if this is the last element.
SDO_ORDINATES = (6,10, 10,1, 14,10, 10,14, 6,10).
Example 27 shows a SQL statement that inserts the geometry illustrated in Figure 25 into the database.
Figure 26 illustrates a pointonly geometry at coordinates (12,14).
In the SDO_GEOMETRY definition of the geometry illustrated in Figure 26:
SDO_GTYPE = 2001. The 2 indicates twodimensional, and the 1 indicates a single point.
SDO_SRID = NULL.
SDO_POINT = SDO_POINT_TYPE(12, 14, NULL). The SDO_POINT attribute is defined using the SDO_POINT_TYPE object type, because this is a pointonly geometry.
For more information about the SDO_POINT attribute, see Section 2.2.3.
SDO_ELEM_INFO and SDO_ORDINATES are both NULL, as required if the SDO_POINT attribute is specified.
Example 28 shows a SQL statement that inserts the geometry illustrated in Figure 26 into the database.
Example 28 SQL Statement to Insert a PointOnly Geometry
INSERT INTO cola_markets VALUES( 90, 'point_only', SDO_GEOMETRY( 2001, NULL, SDO_POINT_TYPE(12, 14, NULL), NULL, NULL));
You can search for pointonly geometries based on the X, Y, and Z values in the SDO_POINT_TYPE specification. Example 29 is a query that asks for all points whose first coordinate (the X value) is 12, and it finds the point that was inserted in Example 28.
Example 29 Query for PointOnly Geometry Based on a Coordinate Value
SELECT * from cola_markets c WHERE c.shape.SDO_POINT.X = 12; MKT_ID NAME   SHAPE(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)  90 point_only SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(12, 14, NULL), NULL, NULL)
An oriented point is a special type of point geometry that includes coordinates representing the locations of the point and a virtual end point, to indicate an orientation vector that can be used for rotating a symbol at the point or extending a label from the point. The main use for an oriented point is in map visualization and display applications that include symbols, such as a shield symbol to indicate a highway.
To specify an oriented point:
Use an SDO_GTYPE value (explained in Section 2.2.1) for a point or multipoint geometry.
Specify a null value for the SDO_POINT attribute.
In the SDO_ELEM_INFO array (explained in Section 2.2.4), specify an additional triplet, with the second and third values (SDO_ETYPE and SDO_INTERPRETATION) as 1 and 0. For example, a triplet of 3,1,0 indicates that the point is an oriented point, with the third number in the SDO_ORDINATES array being the first coordinate, or xaxis value, of the end point reflecting the orientation vector for any symbol or label.
In the SDO_ORDINATES array (explained in Section 2.2.5), specify the coordinates of the end point for the orientation vector from the point, with values between 1 and 1. The orientation start point is assumed to be (0,0), and it is translated to the location of the physical point to which it corresponds.
Figure 27 illustrates an oriented point geometry at coordinates (12,14), with an orientation vector of approximately 34 degrees (counterclockwise from the xaxis), reflecting the orientation coordinates 0.3,0.2. (To have an orientation that more precisely matches a specific angle, refer to the cotangent or tangent values in the tables in a trigonometry textbook.) The orientation vector in this example goes from (0,0) to (0.3,0.2) and extends onward. Assuming i=0.3 and j=0.2, the angle in radians can be calculated as follows: angle in radians = arctan (j/i). The angle is then applied to the physical point associated with the orientation vector.
In the SDO_GEOMETRY definition of the geometry illustrated in Figure 27:
SDO_GTYPE = 2001. The 2 indicates twodimensional, and the 1 indicates a single point.
SDO_SRID = NULL.
SDO_POINT = NULL.
SDO_ELEM_INFO = (1,1,1, 3,1,0). The final 1,0 in 3,1,0 indicates that this is an oriented point.
SDO_ORDINATES = (12,14, 0.3,0.2). The 12,14 identifies the physical coordinates of the point; and the 0.3,0.2 identifies the x and y coordinates (assuming 12,14 as the origin) of the end point of the orientation vector. The resulting orientation vector slopes upward at about a 34degree angle.
Example 210 shows a SQL statement that inserts the geometry illustrated in Figure 27 into the database.
Example 210 SQL Statement to Insert an Oriented Point Geometry
INSERT INTO cola_markets VALUES( 91, 'oriented_point', SDO_GEOMETRY( 2001, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1,1, 3,1,0), SDO_ORDINATE_ARRAY(12,14, 0.3,0.2)));
The following guidelines apply to the definition of an oriented point:
The numbers defining the orientation vector must be between 1 and 1. (In Example 210, these numbers are 0.3 and 0.2.)
Multipoint oriented points are allowed (see Example 211), but the orientation information must follow the point being oriented.
The following considerations apply to the dimensionality of the orientation vector for an oriented point:
A twodimensional point has a twodimensional orientation vector.
A twodimensional point with an LRS measure (SDO_GTYPE=3301) has a twodimensional orientation vector.
A threedimensional point (SDO_GTYPE=3001) has a threedimensional orientation vector.
A threedimensional point with an LRS measure (SDO_GTYPE=4401) has a threedimensional orientation vector.
A fourdimensional point (SDO_GTYPE=4001) has a threedimensional orientation vector.
Example 211 shows a SQL statement that inserts an oriented multipoint geometry into the database. The multipoint geometry contains two points, at coordinates (12,14) and (12, 10), with the two points having different orientation vectors. The statement is similar to the one in Example 210, but in Example 211 the second point has an orientation vector pointing down and to the left at 45 degrees (or, 135 degrees clockwise from the xaxis), reflecting the orientation coordinates 1,1.
Example 211 SQL Statement to Insert an Oriented Multipoint Geometry
 Oriented multipoint: 2 points, different orientations INSERT INTO cola_markets VALUES( 92, 'oriented_multipoint', SDO_GEOMETRY( 2005,  Multipoint NULL, NULL, SDO_ELEM_INFO_ARRAY(1,1,1, 3,1,0, 5,1,1, 7,1,0), SDO_ORDINATE_ARRAY(12,14, 0.3,0.2, 12,10, 1,1)));
Type 0 (zero) elements are used to model geometry types that are not supported by Oracle Spatial, such as curves and splines. A type 0 element has an SDO_ETYPE value of 0. (See Section 2.2.4 for information about the SDO_ETYPE.) Type 0 elements are not indexed by Oracle Spatial, and they are ignored by Spatial functions and procedures.
Geometries with type 0 elements must contain at least one nonzero element, that is, an element with an SDO_ETYPE value that is not 0. The nonzero element should be an approximation of the unsupported geometry, and therefore it must have both:
An SDO_ETYPE value associated with a geometry type supported by Spatial
An SDO_INTERPRETATION value that is valid for the SDO_ETYPE value (see Table 22)
(The SDO_INTERPRETATION value for the type 0 element can be any numeric value, and applications are responsible for determining the validity and significance of the value.)
The nonzero element is indexed by Spatial, and it will be returned by the spatial index.
The SDO_GTYPE value for a geometry containing a type 0 element must be set to the value for the geometry type of the nonzero element.
Figure 28 shows a geometry with two elements: a curve (unsupported geometry) and a rectangle (the nonzero element) that approximates the curve. The curve looks like the letter S, and the rectangle is represented by the dashed line.
In the example shown in Figure 28:
The SDO_GTYPE value for the geometry is 2003 (for a twodimensional polygon).
The SDO_ELEM_INFO array contains two triplets for this compound line string. For example, the triplets might be {(1,0,57), (11,1003,3)}. That is:
Ordinate Starting Offset (SDO_STARTING_OFFSET)  Element Type (SDO_ETYPE)  Interpretation (SDO_INTERPRETATION) 

1  0  57 
11  1003  3 
In this example:
The type 0 element has an SDO_ETYPE value of 0.
The nonzero element (rectangle) has an SDO_ETYPE value of 1003, indicating an exterior polygon ring.
The nonzero element has an SDO_STARTING_OFFSET value of 11 because ordinate x6 is the eleventh ordinate in the geometry.
The type 0 element has an SDO_INTERPRETATION value whose significance is applicationspecific. In this example, the SDO_INTERPRETATION value is 57.
The nonzero element has an SDO_INTERPRETATION value that is valid for the SDO_ETYPE of 1003. In this example, the SDO_INTERPRETATION value is 3, indicating a rectangle defined by two points (lowerleft and upperright).
Example 212 shows a SQL statement that inserts the geometry with a type 0 element (similar to the geometry illustrated in Figure 28) into the database. In the SDO_ORDINATE_ARRAY structure, the curve is defined by points (6,6), (12,6), (9,8), (6,10), and (12,10), and the rectangle is defined by points (6,4) and (12,12).
Example 212 SQL Statement to Insert a Geometry with a Type 0 Element
INSERT INTO cola_markets VALUES( 13, 'type_zero_element_geom', SDO_GEOMETRY( 2003,  twodimensional polygon NULL, NULL, SDO_ELEM_INFO_ARRAY(1,0,57, 11,1003,3),  1st is type 0 element SDO_ORDINATE_ARRAY(6,6, 12,6, 9,8, 6,10, 12,10, 6,4, 12,12) ) );
Example 213 creates a table and inserts various geometries, including multipoints (point clusters), multipolygons, and collections. At the end, it calls the SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT function to validate the inserted geometries. Note that some geometries are deliberately invalid, and their descriptions include the string INVALID
.
Example 213 SQL Statements to Insert Various Geometries
CREATE TABLE t1 ( i NUMBER, d VARCHAR2(50), g SDO_GEOMETRY ); INSERT INTO t1 (i, d, g) VALUES ( 1, 'Point', sdo_geometry (2001, null, null, sdo_elem_info_array (1,1,1), sdo_ordinate_array (10,5)) ); INSERT INTO t1 (i, d, g) VALUES ( 2, 'Line segment', sdo_geometry (2002, null, null, sdo_elem_info_array (1,2,1), sdo_ordinate_array (10,10, 20,10)) ); INSERT INTO t1 (i, d, g) VALUES ( 3, 'Arc segment', sdo_geometry (2002, null, null, sdo_elem_info_array (1,2,2), sdo_ordinate_array (10,15, 15,20, 20,15)) ); INSERT INTO t1 (i, d, g) VALUES ( 4, 'Line string', sdo_geometry (2002, null, null, sdo_elem_info_array (1,2,1), sdo_ordinate_array (10,25, 20,30, 25,25, 30,30)) ); INSERT INTO t1 (i, d, g) VALUES ( 5, 'Arc string', sdo_geometry (2002, null, null, sdo_elem_info_array (1,2,2), sdo_ordinate_array (10,35, 15,40, 20,35, 25,30, 30,35)) ); INSERT INTO t1 (i, d, g) VALUES ( 6, 'Compound line string', sdo_geometry (2002, null, null, sdo_elem_info_array (1,4,3, 1,2,1, 3,2,2, 7,2,1), sdo_ordinate_array (10,45, 20,45, 23,48, 20,51, 10,51)) ); INSERT INTO t1 (i, d, g) VALUES ( 7, 'Closed line string', sdo_geometry (2002, null, null, sdo_elem_info_array (1,2,1), sdo_ordinate_array (10,55, 15,55, 20,60, 10,60, 10,55)) ); INSERT INTO t1 (i, d, g) VALUES ( 8, 'Closed arc string', sdo_geometry (2002, null, null, sdo_elem_info_array (1,2,2), sdo_ordinate_array (15,65, 10,68, 15,70, 20,68, 15,65)) ); INSERT INTO t1 (i, d, g) VALUES ( 9, 'Closed mixed line', sdo_geometry (2002, null, null, sdo_elem_info_array (1,4,2, 1,2,1, 7,2,2), sdo_ordinate_array (10,78, 10,75, 20,75, 20,78, 15,80, 10,78)) ); INSERT INTO t1 (i, d, g) VALUES ( 10, 'Selfcrossing line', sdo_geometry (2002, null, null, sdo_elem_info_array (1,2,1), sdo_ordinate_array (10,85, 20,90, 20,85, 10,90, 10,85)) ); INSERT INTO t1 (i, d, g) VALUES ( 11, 'Polygon', sdo_geometry (2003, null, null, sdo_elem_info_array (1,1003,1), sdo_ordinate_array (10,105, 15,105, 20,110, 10,110, 10,105)) ); INSERT INTO t1 (i, d, g) VALUES ( 12, 'Arc polygon', sdo_geometry (2003, null, null, sdo_elem_info_array (1,1003,2), sdo_ordinate_array (15,115, 20,118, 15,120, 10,118, 15,115)) ); INSERT INTO t1 (i, d, g) VALUES ( 13, 'Compound polygon', sdo_geometry (2003, null, null, sdo_elem_info_array (1,1005,2, 1,2,1, 7,2,2), sdo_ordinate_array (10,128, 10,125, 20,125, 20,128, 15,130, 10,128)) ); INSERT INTO t1 (i, d, g) VALUES ( 14, 'Rectangle', sdo_geometry (2003, null, null, sdo_elem_info_array (1,1003,3), sdo_ordinate_array (10,135, 20,140)) ); INSERT INTO t1 (i, d, g) VALUES ( 15, 'Circle', sdo_geometry (2003, null, null, sdo_elem_info_array (1,1003,4), sdo_ordinate_array (15,145, 10,150, 20,150)) ); INSERT INTO t1 (i, d, g) VALUES ( 16, 'Point cluster', sdo_geometry (2005, null, null, sdo_elem_info_array (1,1,3), sdo_ordinate_array (50,5, 55,7, 60,5)) ); INSERT INTO t1 (i, d, g) VALUES ( 17, 'Multipoint', sdo_geometry (2005, null, null, sdo_elem_info_array (1,1,1, 3,1,1, 5,1,1), sdo_ordinate_array (65,5, 70,7, 75,5)) ); INSERT INTO t1 (i, d, g) VALUES ( 18, 'Multiline', sdo_geometry (2006, null, null, sdo_elem_info_array (1,2,1, 5,2,1), sdo_ordinate_array (50,15, 55,15, 60,15, 65,15)) ); INSERT INTO t1 (i, d, g) VALUES ( 19, 'Multiline  crossing', sdo_geometry (2006, null, null, sdo_elem_info_array (1,2,1, 5,2,1), sdo_ordinate_array (50,22, 60,22, 55,20, 55,25)) ); INSERT INTO t1 (i, d, g) VALUES ( 20, 'Multiarc', sdo_geometry (2006, null, null, sdo_elem_info_array (1,2,2, 7,2,2), sdo_ordinate_array (50,35, 55,40, 60,35, 65,35, 70,30, 75,35)) ); INSERT INTO t1 (i, d, g) VALUES ( 21, 'Multiline  closed', sdo_geometry (2006, null, null, sdo_elem_info_array (1,2,1, 9,2,1), sdo_ordinate_array (50,55, 50,60, 55,58, 50,55, 56,58, 60,55, 60,60, 56,58)) ); INSERT INTO t1 (i, d, g) VALUES ( 22, 'Multiarc  touching', sdo_geometry (2006, null, null, sdo_elem_info_array (1,2,2, 7,2,2), sdo_ordinate_array (50,65, 50,70, 55,68, 55,68, 60,65, 60,70)) ); INSERT INTO t1 (i, d, g) VALUES ( 23, 'Multipolygon  disjoint', sdo_geometry (2007, null, null, sdo_elem_info_array (1,1003,1, 11,1003,3), sdo_ordinate_array (50,105, 55,105, 60,110, 50,110, 50,105, 62,108, 65,112)) ); INSERT INTO t1 (i, d, g) VALUES ( 24, 'Multipolygon  touching', sdo_geometry (2007, null, null, sdo_elem_info_array (1,1003,3, 5,1003,3), sdo_ordinate_array (50,115, 55,120, 55,120, 58,122)) ); INSERT INTO t1 (i, d, g) VALUES ( 25, 'Multipolygon  tangent * INVALID 13351', sdo_geometry (2007, null, null, sdo_elem_info_array (1,1003,3, 5,1003,3), sdo_ordinate_array (50,125, 55,130, 55,128, 60,132)) ); INSERT INTO t1 (i, d, g) VALUES ( 26, 'Multipolygon  multitouch', sdo_geometry (2007, null, null, sdo_elem_info_array (1,1003,1, 17,1003,1), sdo_ordinate_array (50,95, 55,95, 53,96, 55,97, 53,98, 55,99, 50,99, 50,95, 55,100, 55,95, 60,95, 60,100, 55,100)) ); INSERT INTO t1 (i, d, g) VALUES ( 27, 'Polygon with void', sdo_geometry (2003, null, null, sdo_elem_info_array (1,1003,3, 5,2003,3), sdo_ordinate_array (50,135, 60,140, 51,136, 59,139)) ); INSERT INTO t1 (i, d, g) VALUES ( 28, 'Polygon with void  reverse', sdo_geometry (2003, null, null, sdo_elem_info_array (1,2003,3, 5,1003,3), sdo_ordinate_array (51,146, 59,149, 50,145, 60,150)) ); INSERT INTO t1 (i, d, g) VALUES ( 29, 'Crescent (straight lines) * INVALID 13349', sdo_geometry (2003, null, null, sdo_elem_info_array (1,1003,1), sdo_ordinate_array (10,175, 10,165, 20,165, 15,170, 25,170, 20,165, 30,165, 30,175, 10,175)) ); INSERT INTO t1 (i, d, g) VALUES ( 30, 'Crescent (arcs) * INVALID 13349', sdo_geometry (2003, null, null, sdo_elem_info_array (1,1003,2), sdo_ordinate_array (14,180, 10,184, 14,188, 18,184, 14,180, 16,182, 14,184, 12,182, 14,180)) ); INSERT INTO t1 (i, d, g) VALUES ( 31, 'Heterogeneous collection', sdo_geometry (2004, null, null, sdo_elem_info_array (1,1,1, 3,2,1, 7,1003,1), sdo_ordinate_array (10,5, 10,10, 20,10, 10,105, 15,105, 20,110, 10,110, 10,105)) ); INSERT INTO t1 (i, d, g) VALUES ( 32, 'Polygon+void+island touch', sdo_geometry (2007, null, null, sdo_elem_info_array (1,1003,1, 11,2003,1, 31,1003,1), sdo_ordinate_array (50,168, 50,160, 55,160, 55,168, 50,168, 51,167, 54,167, 54,161, 51,161, 51,162, 52,163, 51,164, 51,165, 51,166, 51,167, 52,166, 52,162, 53,162, 53,166, 52,166)) ); COMMIT; SELECT i, d, SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT (g, 0.5) FROM t1;
The geometry metadata describing the dimensions, lower and upper bounds, and tolerance in each dimension is stored in a global table owned by MDSYS (which users should never directly update). Each Spatial user has the following views available in the schema associated with that user:
USER_SDO_GEOM_METADATA contains metadata information for all spatial tables owned by the user (schema). This is the only view that you can update, and it is the one in which Spatial users must insert metadata related to spatial tables.
ALL_SDO_GEOM_METADATA contains metadata information for all spatial tables on which the user has SELECT permission.
Spatial users are responsible for populating these views. For each spatial column, you must insert an appropriate row into the USER_SDO_GEOM_METADATA view. Oracle Spatial ensures that the ALL_SDO_GEOM_METADATA view is also updated to reflect the rows that you insert into USER_SDO_GEOM_METADATA.
Note: These views were new for release 8.1.6. If you are upgrading from an earlier release of Spatial, see Appendix A and the information about the SDO_MIGRATE.TO_CURRENT procedure in Chapter 17. 
Each metadata view has the following definition:
( TABLE_NAME VARCHAR2(32), COLUMN_NAME VARCHAR2(32), DIMINFO SDO_DIM_ARRAY, SRID NUMBER );
In addition, the ALL_SDO_GEOM_METADATA view has an OWNER column identifying the schema that owns the table specified in TABLE_NAME.
The following considerations apply to schema, table, and column names that are stored in any Oracle Spatial metadata views:
The name must contain only letters, numbers, and underscores. For example, the name cannot contain a space ( ), an apostrophe ('
), a quotation mark ("
), or a comma (,
).
All letters in the names are converted to uppercase before the names are stored in geometry metadata views or before the tables are accessed. This conversion also applies to any schema name specified with the table name.
The TABLE_NAME column contains the name of a feature table, such as COLA_MARKETS, that has a column of type SDO_GEOMETRY.
The table name is stored in the spatial metadata views in all uppercase characters.
The table name cannot contain spaces or mixedcase letters in a quoted string when inserted into the USER_SDO_GEOM_METADATA view, and it cannot be in a quoted string when used in a query (unless it is in all uppercase characters).
The spatial feature table cannot be an indexorganized table if you plan to create a spatial index on the spatial column.
The COLUMN_NAME column contains the name of the column of type SDO_GEOMETRY. For the COLA_MARKETS table, this column is called SHAPE.
The column name is stored in the spatial metadata views in all uppercase characters.
The column name cannot contain spaces or mixedcase letters in a quoted string when inserted into the USER_SDO_GEOM_METADATA view, and it cannot be in a quoted string when used in a query (unless it is in all uppercase characters).
The DIMINFO column is a varying length array of an object type, ordered by dimension, and has one entry for each dimension. The SDO_DIM_ARRAY type is defined as follows:
Create Type SDO_DIM_ARRAY as VARRAY(4) of SDO_DIM_ELEMENT;
The SDO_DIM_ELEMENT type is defined as:
Create Type SDO_DIM_ELEMENT as OBJECT ( SDO_DIMNAME VARCHAR2(64), SDO_LB NUMBER, SDO_UB NUMBER, SDO_TOLERANCE NUMBER);
The SDO_DIM_ARRAY instance is of size n if there are n dimensions. That is, DIMINFO contains 2 SDO_DIM_ELEMENT instances for twodimensional geometries, 3 instances for threedimensional geometries, and 4 instances for fourdimensional geometries. Each SDO_DIM_ELEMENT instance in the array must have valid (not null) values for the SDO_LB, SDO_UB, and SDO_TOLERANCE attributes.
Note: The number of dimensions reflected in the DIMINFO information must match the number of dimensions of each geometry object in the layer. 
For an explanation of tolerance and how to determine the appropriate SDO_TOLERANCE value, see Section 1.5.5, especially Section 1.5.5.1.
Spatial assumes that the varying length array is ordered by dimension. The DIMINFO varying length array must be ordered by dimension in the same way the ordinates for the points in SDO_ORDINATES varying length array are ordered. For example, if the SDO_ORDINATES varying length array contains {X1, Y1, ..., Xn, Yn}, then the first DIMINFO entry must define the X dimension and the second DIMINFO entry must define the Y dimension.
Example 21 in Section 2.1 shows the use of the SDO_GEOMETRY and SDO_DIM_ARRAY types. This example demonstrates how geometry objects (hypothetical market areas for colas) are represented, and how the COLA_MARKETS feature table and the USER_SDO_GEOM_METADATA view are populated with the data for those objects.
The SRID column should contain either of the following: the SRID value for the coordinate system for all geometries in the column, or NULL if no specific coordinate system should be associated with the geometries. (For information about coordinate systems, see Chapter 6.)
This section describes the structure of the tables containing the spatial index data and metadata. Concepts and usage notes for spatial indexing are explained in Section 1.7. The spatial index data and metadata are stored in tables that are created and maintained by the Spatial indexing routines. These tables are created in the schema of the owner of the feature (underlying) table that has a spatial index created on a column of type SDO_GEOMETRY.
There are two sets of spatial index metadata views for each schema (user): xxx_SDO_INDEX_INFO and xxx_SDO_INDEX_METADATA, where xxx can be USER or ALL. These views are readonly to users; they are created and maintained by the Spatial indexing routines.
The following views contain basic information about spatial indexes:
USER_SDO_INDEX_INFO contains index information for all spatial tables owned by the user.
ALL_SDO_INDEX_INFO contains index information for all spatial tables on which the user has SELECT permission.
The USER_SDO_INDEX_INFO and ALL_SDO_INDEX_INFO views contain the same columns, as shown Table 24, except that the USER_SDO_INDEX_INFO view does not contain the SDO_INDEX_OWNER column. (The columns are listed in their order in the view definition.)
Table 24 Columns in the xxx_SDO_INDEX_INFO Views
Column Name  Data Type  Purpose 

SDO_INDEX_OWNER 
VARCHAR2 
Owner of the index (ALL_SDO_INDEX_INFO views only). 
INDEX_NAME 
VARCHAR2 
Name of the index. 
TABLE_NAME 
VARCHAR2 
Name of the table containing the column on which this index is built. 
COLUMN_NAME 
VARCHAR2 
Name of the column on which this index is built. 
SDO_INDEX_TYPE 
VARCHAR2 
Contains QTREE (for a quadtree index) or RTREE (for an Rtree index). 
SDO_INDEX_TABLE 
VARCHAR2 
Name of the spatial index table (described in Section 2.7.2). 
SDO_INDEX_STATUS 
VARCHAR2 
(Deprecated; reserved for Oracle use.) 
The following views contain detailed information about spatial index metadata:
USER_SDO_INDEX_METADATA contains index information for all spatial tables owned by the user. (USER_SDO_INDEX_METADATA is the same as SDO_INDEX_METADATA, which was the only metadata view for Oracle Spatial release 8.1.5.)
ALL_SDO_INDEX_METADATA contains index information for all spatial tables on which the user has SELECT permission.
Note: These views were new for release 8.1.6. If you are upgrading from an earlier release of Spatial, see Appendix A. 
The USER_SDO_INDEX_METADATA and ALL_SDO_INDEX_METADATA views contain the same columns, as shown Table 25. (The columns are listed in their order in the view definition.)
Table 25 Columns in the xxx_SDO_INDEX_METADATA Views
Column Name  Data Type  Purpose 

SDO_INDEX_OWNER 
VARCHAR2 
Owner of the index. 
SDO_INDEX_TYPE 
VARCHAR2 
Contains QTREE (for a quadtree index) or RTREE (for an Rtree index). 
SDO_LEVEL 
NUMBER 
The fixed tiling level at which to tile all objects in the geometry column for a quadtree index. 
SDO_NUMTILES 
NUMBER 
Suggested number of tiles per object that should be used to approximate the shape for a quadtree index. 
SDO_MAXLEVEL 
NUMBER 
Maximum level for any tile for any object for a quadtree index. It will always be greater than the SDO_LEVEL value. 
SDO_COMMIT_INTERVAL 
NUMBER 
Number of geometries (rows) to process, during index creation, before committing the insertion of spatial index entries into the SDOINDEX table. (Applies to quadtree indexes only.) 
SDO_INDEX_TABLE 
VARCHAR2 
Name of the spatial index table (described in Section 2.7.2). 
SDO_INDEX_NAME 
VARCHAR2 
Name of the index. 
SDO_INDEX_PRIMARY 
NUMBER 
Indicates if this is a primary or secondary index. 1 = primary, 2 = secondary. 
SDO_TSNAME 
VARCHAR2 
Schema name of the SDO_INDEX_TABLE. 
SDO_COLUMN_NAME 
VARCHAR2 
Name of the column on which this index is built. 
SDO_RTREE_HEIGHT 
NUMBER 
Height of the Rtree. 
SDO_RTREE_NUM_NODES 
NUMBER 
Number of nodes in the Rtree. 
SDO_RTREE_DIMENSIONALITY 
NUMBER 
Number of dimensions used internally by Spatial. This may be different from the number of dimensions indexed, which is controlled by the 
SDO_RTREE_FANOUT 
NUMBER 
Maximum number of children in each Rtree node. 
SDO_RTREE_ROOT 
VARCHAR2 
Rowid corresponding to the root node of the Rtree in the index table. 
SDO_RTREE_SEQ_NAME 
VARCHAR2 
Sequence name associated with the Rtree. 
SDO_FIXED_META 
RAW 
If applicable, this column contains the metadata portion of the SDO_GROUPCODE or SDO_CODE for a fixedlevel index. 
SDO_TABLESPACE 
VARCHAR2 
Same as in the SQL CREATE TABLE statement. Tablespace in which to create the SDOINDEX table. 
SDO_INITIAL_EXTENT 
VARCHAR2 
Same as in the SQL CREATE TABLE statement. 
SDO_NEXT_EXTENT 
VARCHAR2 
Same as in the SQL CREATE TABLE statement. 
SDO_PCTINCREASE 
NUMBER 
Same as in the SQL CREATE TABLE statement. 
SDO_MIN_EXTENTS 
NUMBER 
Same as in the SQL CREATE TABLE statement. 
SDO_MAX_EXTENTS 
NUMBER 
Same as in the SQL CREATE TABLE statement. 
SDO_INDEX_DIMS 
NUMBER 
Number of dimensions of the geometry objects in the column on which this index is built, as determined by the value of the 
SDO_LAYER_GTYPE 
VARCHAR2 
Contains DEFAULT if the layer can contain both point and polygon data, or a value from the Geometry Type column of Table 21 in Section 2.2.1. 
SDO_RTREE_PCTFREE 
NUMBER 
Minimum percentage of slots in each index tree node to be left empty when an Rtree index is created. 
SDO_INDEX_PARTITION 
VARCHAR2 
For a partitioned index, name of the index partition. 
SDO_PARTITIONED 
NUMBER 
Contains 0 if the index is not partitioned or 1 if the index is partitioned. 
SDO_RTREE_QUALITY 
NUMBER 
Quality score for an index. See the information about Rtree quality in Section 1.7.2. 
SDO_INDEX_VERSION 
NUMBER 
Internal version number of the index. 
SDO_INDEX_GEODETIC 
VARCHAR2 
Contains TRUE if the index is geodetic (see Section 4.1.1) and FALSE if the index is not geodetic. 
SDO_INDEX_STATUS 
VARCHAR2 
(Deprecated; reserved for Oracle use.) 
SDO_NL_INDEX_TABLE 
VARCHAR2 
Name of a separate index table (with a name in the form MDNT_...$) for nonleaf nodes of the index. For more information, see the description of the 
SDO_DML_BATCH_SIZE 
NUMBER 
Number of index updates to be processed in each batch of updates after a commit operation. For more information, see the description of the 
SDO_RTREE_EXT_XPND 
NUMBER 
(Reserved for future use.) 
SDO_ROOT_MBR 
SDO_GEOMETRY 
Minimum bounding rectangle of the maximum extent of the spatial layer. This is greater than or equal to the MBR of the current extent, and is reset to reflect the current extent when the index is rebuilt. 
For an Rtree index, a spatial index table (each SDO_INDEX_TABLE entry as described in Table 25 in Section 2.7.1.2) contains the columns shown in Table 26.
Table 26 Columns in an RTree Spatial Index Data Table
Column Name  Data Type  Purpose 

NODE_ID 
NUMBER 
Unique ID number for this node of the tree. 
NODE_LEVEL 
NUMBER 
Level of the node in the tree. Leaf nodes (nodes whose entries point to data items in the base table) are at level 1, their parent nodes are at level 2, and so on. 
INFO 
BLOB 
Other information in a node. Includes an array of 
Each Rtree spatial index table has an associated sequence object (SDO_RTREE_SEQ_NAME in the USER_SDO_INDEX_METADATA view, described in Table 25 in Section 2.7.1.2). The sequence is used to ensure that simultaneous updates can be performed to the index by multiple concurrent users.
The sequence name is the index table name with the letter S replacing the letter T before the underscore (for example, the sequence object MDRS_5C01$ is associated with the index table MDRT_5C01$).
Geometry functions that involve measurement allow an optional unit
parameter to specify the unit of measurement for a specified distance or area, if a georeferenced coordinate system (SDO_SRID value) is associated with the input geometry or geometries. The unit
parameter is not valid for geometries with a null SDO_SRID value (that is, an orthogonal Cartesian system). For information about support for coordinate systems, see Chapter 6.
The default unit of measure is the one associated with the georeferenced coordinate system. The unit of measure for most coordinate systems is the meter, and in these cases the default unit for distances is meter and the default unit for areas is square meter. By using the unit
parameter, however, you can have Spatial automatically convert and return results that are more meaningful to application users, for example, displaying the distance to a restaurant in miles.
The unit
parameter must be enclosed in single quotation marks and contain the string unit=
and a valid UNIT_OF_MEAS_NAME value from the SDO_UNITS_OF_MEASURE table (described in Section 6.6.27). For example, 'unit=KM' in the following example (using data and definitions from Example 67 in Section 6.11) specifies kilometers as the unit of measurement:
SELECT c.name, SDO_GEOM.SDO_LENGTH(c.shape, m.diminfo, 'unit=KM') FROM cola_markets_cs c, user_sdo_geom_metadata m WHERE m.table_name = 'COLA_MARKETS_CS' AND m.column_name = 'SHAPE';
Spatial uses the information in the SDO_UNITS_OF_MEASURE table (described in Section 6.6.27) to determine which unit names are valid and what ratios to use in comparing or converting between different units. For convenience, you can also use the following legacy views to see the angle, area, and distance units of measure:
MDSYS.SDO_ANGLE_UNITS (described in Section 6.7.2)
MDSYS.SSDO_AREA_UNITS (described in Section 6.7.3)
MDSYS.SSDO_DIST_UNITS (described in Section 6.7.5)
User's Guide and Reference
10g Release 2 (10.2)
B1425503
March 2006
Provides usage and reference information for indexing and storing spatial data and for developing spatial applications using Oracle Spatial and Oracle Locator.
Oracle Spatial User's Guide and Reference, 10g Release 2 (10.2)
B1425503
Copyright © 1999, 2006, Oracle. All rights reserved.
Primary Author: Chuck Murray
Contributors: Dan Abugov, Nicole Alexander, Bruce Blackwell, Janet Blowney, Dan Geringer, Albert Godfrind, Mike Horhammer, Ravi Kothuri, Richard Pitts, Vishal Rao, Siva Ravada, Jack Wang, Ji Yang
The Programs (which include both the software and documentation) contain proprietary information; they are provided under a license agreement containing restrictions on use and disclosure and are also protected by copyright, patent, and other intellectual and industrial property laws. Reverse engineering, disassembly, or decompilation of the Programs, except to the extent required to obtain interoperability with other independently created software or as specified by law, is prohibited.
The information contained in this document is subject to change without notice. If you find any problems in the documentation, please report them to us in writing. This document is not warranted to be errorfree. Except as may be expressly permitted in your license agreement for these Programs, no part of these Programs may be reproduced or transmitted in any form or by any means, electronic or mechanical, for any purpose.
If the Programs are delivered to the United States Government or anyone licensing or using the Programs on behalf of the United States Government, the following notice is applicable:
U.S. GOVERNMENT RIGHTS Programs, software, databases, and related documentation and technical data delivered to U.S. Government customers are "commercial computer software" or "commercial technical data" pursuant to the applicable Federal Acquisition Regulation and agencyspecific supplemental regulations. As such, use, duplication, disclosure, modification, and adaptation of the Programs, including documentation and technical data, shall be subject to the licensing restrictions set forth in the applicable Oracle license agreement, and, to the extent applicable, the additional rights set forth in FAR 52.22719, Commercial Computer Software—Restricted Rights (June 1987). Oracle Corporation, 500 Oracle Parkway, Redwood City, CA 94065
The Programs are not intended for use in any nuclear, aviation, mass transit, medical, or other inherently dangerous applications. It shall be the licensee's responsibility to take all appropriate failsafe, backup, redundancy and other measures to ensure the safe use of such applications if the Programs are used for such purposes, and we disclaim liability for any damages caused by such use of the Programs.
Oracle, JD Edwards, PeopleSoft, and Retek are registered trademarks of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
The Programs may provide links to Web sites and access to content, products, and services from third parties. Oracle is not responsible for the availability of, or any content provided on, thirdparty Web sites. You bear all risks associated with the use of such content. If you choose to purchase any products or services from a third party, the relationship is directly between you and the third party. Oracle is not responsible for: (a) the quality of thirdparty products or services; or (b) fulfilling any of the terms of the agreement with the third party, including delivery of products or services and warranty obligations related to purchased products or services. Oracle is not responsible for any loss or damage of any sort that you may incur from dealing with any third party.
G
q!x..byGyy ugy0
ahȧ
I#Rq8ax') }2h2 ?獈Ғ
aLqē):4V3D瓖*ُЀ424)Lj߄iiAibHÔG"IPfjі3xur^4I:47y/:{i]iG{H'c!1;퀋I+H֓6Giu$ѳxfNVdXpMg%y0ٗ$ZY\oFEB9o"Ɔ9&t:&n)Q_=??'"8'*^XnyGədlvvZs؛Pk)2tI)IV@wi4g jsW頒F +:dW訡#,W!5֠)d?) ]'epBu=*wzEZĖχ% DN`BԤ97yRjd>rz&:oZ'T٦cQQ}z#R&ڥ4bBbd"HVNJSf0hHhI$To>%F1Tt^ٚ+Y hr,ǟ~
EsCͺjśz]ѥAʠʭ۸\$tzWjyZ<
+
!x:
Z;bYn[%
['&[G 5#W۩qaVg暭++mد>s6)*{W}pѬ:г6A+2;ETZB#Kf*/H;K
&{^ZKѵ${Yzhk+m(>v:}˷}+ ~KmGr
EPW«E
_;(bOI{RQ*j*tDcӺˎ>˰BM44x)jPXk@JX $;@d8ʚc1JdJ/KTƫ{ɻBI/m[;B
T{
[RĤj#,[Np&eFfX^[ZfԻjA;"M4vdiuX+:>dxU,r[W#ۧ.t04C뵎:SK
B"D?S;,A8EjNS] \_q sLoܪ:cĠ˼V,,I['@<
,JܽbҮ<ȝȴK1kkAɰlɱɣ<ˎlًʸɠȧOlL0˶;̼lLќE!?ܼ\ˢTy This chapter contains reference and usage information for the spatial aggregate functions, which are listed in Table 121. Table 121 Spatial Aggregate Functions Returns a geometry object that is the centroid ("center of gravity") of the specified geometry objects. Returns a geometry that concatenates the specified line or multiline geometries. Returns a geometry object that is the convex hull of the specified geometry objects. Returns an LRS geometry object that concatenates specified LRS geometry objects. Returns the minimum bounding rectangle of the specified geometries. Returns a geometry object that is the topological union (OR operation) of the specified geometry objects. See the usage information about spatial aggregate functions in Section 1.10. Most of these aggregate functions accept a parameter of type SDOAGGRTYPE, which is described in Section 1.10.1. Format SDO_AGGR_CENTROID( AggregateGeometry SDOAGGRTYPE ) RETURN SDO_GEOMETRY; Description Returns a geometry object that is the centroid ("center of gravity") of the specified geometry objects. Parameters An object of type SDOAGGRTYPE (see Section 1.10.1) that specifies the geometry column and dimensional array. Usage Notes The behavior of the function depends on whether the geometry objects are all polygons, all points, or a mixture of polygons and points: If the geometry objects are all polygons, the centroid of all the objects is returned. If the geometry objects are all points, the centroid of all the objects is returned. If the geometry objects are a mixture of polygons and points (specifically, if they include at least one polygon and at least one point), any points are ignored, and the centroid of all the polygons is returned. The result is weighted by the area of each polygon in the geometry objects. If the geometry objects are a mixture of polygons and points, the points are not used in the calculation of the centroid. If the geometry objects are all points, the points have equal weight. See also the information about the SDO_GEOM.SDO_CENTROID function in Chapter 15. Examples The following example returns the centroid of the geometry objects in the COLA_MARKETS table. (The example uses the definitions and data from Section 2.1.) Format SDO_AGGR_CONCAT_LINES( geom SDO_GEOMETRY ) RETURN SDO_GEOMETRY; Description Returns a geometry that concatenates the specified line or multiline geometries. Parameters Geometry objects. Usage Notes Each input geometry must be a twodimensional line or multiline geometry (that is, the SDO_GTYPE value must be 2002 or 2006). This function is not supported for LRS geometries. To perform an aggregate concatenation of LRS geometric segments, use the SDO_AGGR_LRS_CONCAT spatial aggregate function. The input geometries must be line strings whose vertices are connected by straight line segments. Circular arcs and compound line strings are not supported. If any input geometry is a multiline geometry, the elements of the geometry must be disjoint. If they are not disjoint, this function may return incorrect results. The topological relationship between the geometries in each pair of geometries to be concatenated must be DISJOINT or TOUCH; and if the relationship is TOUCH, the geometries must intersect only at two end points. You can use the SDO_UTIL.CONCAT_LINES function (described in Chapter 20) to concatenate two line or multiline geometries. An exception is raised if any input geometries are not line or multiline geometries, or if not all input geometries are based on the same coordinate system. Examples The following example inserts two line geometries in the COLA_MARKETS table, and then returns the aggregate concatenation of these geometries. (The example uses the data definitions from Section 2.1.) Format SDO_AGGR_CONVEXHULL( AggregateGeometry SDOAGGRTYPE ) RETURN SDO_GEOMETRY; Description Returns a geometry object that is the convex hull of the specified geometry objects. Parameters An object of type SDOAGGRTYPE (see Section 1.10.1) that specifies the geometry column and dimensional array. Usage Notes See also the information about the SDO_GEOM.SDO_CONVEXHULL function in Chapter 15. Examples The following example returns the convex hull of the geometry objects in the COLA_MARKETS table. (The example uses the definitions and data from Section 2.1.) Format SDO_AGGR_LRS_CONCAT( AggregateGeometry SDOAGGRTYPE ) RETURN SDO_GEOMETRY; Description Returns an LRS geometry that concatenates specified LRS geometries. Parameters An object of type SDOAGGRTYPE (see Section 1.10.1) that specifies the geometry column and dimensional array. Usage Notes This function performs an aggregate concatenation of any number of LRS geometries. If you want to control the order in which the geometries are concatenated, you must use a subquery with the NO_MERGE optimizer hint and the ORDER BY clause. (See the examples.) The direction of the resulting segment is the same as the direction of the first geometry in the concatenation. A 3D format of this function (SDO_AGGR_LRS_CONCAT_3D) is available. For information about 3D formats of LRS functions, see Section 7.4.) For information about the Spatial linear referencing system, see Chapter 7. Examples The following example adds an LRS geometry to the LRS_ROUTES table, and then performs two queries that concatenate the LRS geometries in the table. The first query does not control the order of concatenation, and the second query controls the order of concatenation. Notice the difference in direction of the two segments: the segment resulting from the second query has decreasing measure values because the first segment in the concatenation ( Format SDO_AGGR_MBR( geom SDO_GEOMETRY ) RETURN SDO_GEOMETRY; Description Returns the minimum bounding rectangle (MBR) of the specified geometries, that is, a single rectangle that minimally encloses the geometries. Parameters Geometry objects. Usage Notes All input geometries must have 4digit SDO_GTYPE values (explained in Section 2.2.1). This function does not return an MBR geometry if a proper MBR cannot be constructed. Specifically: If the input geometries are all null, the function returns a null geometry. If all data in the input geometries is on a single point, the function returns the point. If all data in the input geometries consists of points on a straight line, the function returns a twopoint line. The SDO_TUNE.EXTENT_OF function, documented in Chapter 19, also returns the MBR of geometries. The SDO_TUNE.EXTENT_OF function has better performance than the SDO_AGGR_MBR function if the data is nongeodetic and if a spatial index is defined on the geometry column; however, the SDO_TUNE.EXTENT_OF function is limited to twodimensional geometries, whereas the SDO_AGGR_MBR function is not. In addition, the SDO_TUNE.EXTENT_OF function computes the extent for all geometries in a table; by contrast, the SDO_AGGR_MBR function can operate on subsets of rows. Examples The following example returns the minimum bounding rectangle of the geometry objects in the COLA_MARKETS table. (The example uses the definitions and data from Section 2.1.) Format SDO_AGGR_UNION( AggregateGeometry SDOAGGRTYPE ) RETURN SDO_GEOMETRY; Description Returns a geometry object that is the topological union (OR operation) of the specified geometry objects. Parameters An object of type SDOAGGRTYPE (see Section 1.10.1) that specifies the geometry column and dimensional array. Usage Notes Do not use SDO_AGGR_UNION to merge line string or multiline string geometries; instead, use the SDO_AGGR_CONCAT_LINES spatial aggregate function. See also the information about the SDO_GEOM.SDO_UNION function in Chapter 15. Examples The following example returns the union of the first three geometry objects in the COLA_MARKETS table (that is, all except See also the more complex SDO_AGGR_UNION example in Section D.4. attribute Descriptive information characterizing a geographical feature such as a point, line, or area. attribute data Nondimensional data that provides additional descriptive information about multidimensional data, for example, a class or feature such as a bridge or a road. batch geocoding An operation that simultaneously geocodes many records from one table. See also geocoding. boundary The lower or upper extent of the range of a dimension, expressed by a numeric value. The line representing the outline of a polygon. Cartesian coordinate system A coordinate system in which the location of a point in ndimensional space is defined by distances from the point to the reference plane. Distances are measured parallel to the planes intersecting a given reference plane. See also coordinate system. colocation The presence of two or more spatial objects at the same location or at significantly close distances from each other. contain A geometric relationship where one object encompasses another and the inner object does not touch any boundaries of the outer. The outer object contains the inner object. See also inside. coordinate reference system Synonymous with coordinate system in Oracle Spatial documentation. The term coordinate reference system is used extensively by the European Petroleum Survey Group (EPSG). coordinate system A reference system for the unique definition for the location of a point in ndimensional space. Also called a spatial reference system. See also Cartesian coordinate system, geodetic coordinates, projected coordinates, and local coordinates. cover A geometric relationship in which one object encompasses another and the inner object touches the boundary of the outer object in one or more places. data dictionary A repository of information about data. A data dictionary stores relational information on all objects in a database. dimensional data Data that has one or more dimensional components and is described by multiple values. direction The direction of an LRS geometric segment is indicated from the start point of the geometric segment to the end point. Measures of points on a geometric segment always increase along the direction of the geometric segment. disjoint A geometric relationship where two objects do not interact in any way. Two disjoint objects do not share any element or piece of their geometry. equal A geometric relationship in which two objects are considered to represent the same geometric figure. The two objects must be composed of the same number of points; however, the ordering of the points defining geometries of the two objects may differ (clockwise or counterclockwise). extent A rectangle bounding a map, the size of which is determined by the minimum and maximum map coordinates. geocoding The process of converting tables of address data into standardized address, location, and possibly other data. See also batch geocoding. geodetic coordinates Angular coordinates (longitude and latitude) closely related to spherical polar coordinates and defined relative to a particular Earth geodetic datum. Also referred to as geographic coordinates. geodetic datum A means of representing the figure of the Earth, usually as an oblate ellipsoid of revolution, that approximates the surface of the Earth locally or globally, and is the reference for the system of geodetic coordinates. geographic information system (GIS) A computerized database management system used for the capture, conversion, storage, retrieval, analysis, and display of spatial data. geometric segment (LRS segment) An LRS element that contains start and end measures for its start and end points, and that can contain measures for other points on the segment. geometry The geometric representation of the shape of a spatial feature in some coordinate space. A geometry is an ordered sequence of vertices that are connected by straight line segments or circular arcs. grid A data structure composed of points located at the nodes of an imaginary grid. The spacing of the nodes is constant in both the horizontal and vertical directions. hole A subelement of a polygon that negates a section of its interior. For example, consider a polygon representing a map of buildable land with an inner polygon (a hole) representing where a lake is located. hyperspatial data In mathematics, any space having more than the three standard X, Y, and Z dimensions. Sometimes referred to as multidimensional data. inside A geometric relationship where one object is surrounded by a larger object and the inner object does not touch the boundary of the outer. The smaller object is inside the larger. See also contain. latitude North/south position of a point on the Earth defined as the angle between the normal to the Earth's surface at that point and the plane of the equator. line A geometric object represented by a series of points, or inferred as existing between two coordinate points. longitude East/west position of a point on the Earth defined as the angle between the plane of a reference meridian and the plane of a meridian passing through an arbitrary point. LRS point A point with linear measure information along a geometric segment. See also geometric segment (LRS segment). measure The linear distance (in the LRS measure dimension) to a point measured from the start point (for increasing values) or end point (for decreasing values) of the geometric segment. minimum bounding rectangle (MBR) A single rectangle that minimally encloses a geometry or a collection of geometries. multiline string A geometry object made up of nonconnected line string elements (for example, a street with a gap caused by a city park, such as Sixth Avenue in New York City with Central Park as the gap). See also line string. multipolygon A polygon collection geometry in which rings must be grouped by polygon, and the first ring of each polygon must be the exterior ring. offset The perpendicular distance between a point along a geometric segment and the geometric segment. Offsets are positive if the points are on the left side along the segment direction and are negative if they are on the right side. Points are on a geometric segment if their offsets to the segment are zero. oriented point A special type of point geometry that includes coordinates representing the locations of the point and a virtual end point, to indicate an orientation vector that can be used for rotating a symbol at the point or extending a label from the point polygon A class of spatial objects having a nonzero area and perimeter, and representing a closed boundary region of uniform characteristics. primary filter The operation that permits fast selection of candidate records to pass along to the secondary filter. The primary filter compares geometry approximations to reduce computation complexity and is considered a lowercost filter. Because the primary filter compares geometric approximations, it returns a superset of the exact result set. See also secondary filter and twotier query model. projected coordinates Planar Cartesian coordinates that result from performing a mathematical mapping from a point on the Earth's surface to a plane. There are many such mathematical mappings, each used for a particular purpose. query A set of conditions or questions that form the basis for the retrieval of information from a database. query window Area within which the retrieval of spatial information and related attributes is performed. recursion A process, function, or routine that executes continuously until a specified condition is met. Relational Database Management System (RDBMS) A computer program designed to store and retrieve shared data. In a relational system, data is stored in tables consisting of one or more rows, each containing the same set of columns. Oracle Database is an objectrelational database management system. Other types of database systems are called hierarchical or network database systems. scale The ratio of the distance on a map, photograph, or image to the corresponding image on the ground, all expressed in the same units. secondary filter The operation that applies exact computations to geometries that result from the primary filter. The secondary filter yields an accurate answer to a spatial query. The secondary filter operation is computationally expensive, but it is only applied to the primary filter results, not the entire data set. See also primary filter and twotier query model. shape points Points that are specified when an LRS segment is constructed, and that are assigned measure information. sort The operation of arranging a set of items according to a key that determines the sequence and precedence of items. spatial binning The process of discretizing the location values into a small number of groups associated with geographical areas. Also referred to as spatial discretization. spatial correlation The phenomenon of the location of a specific object in an area affecting some nonspatial attribute of the object. Also referred to as neighborhood influence. spatial data Data that is referenced by its location in ndimensional space. The position of spatial data is described by multiple values. See also hyperspatial data. spatial data structures A class of data structures designed to store spatial information and facilitate its manipulation. spatial join A query in which each of the geometries in one layer is compared with each of the geometries in the other layer. Comparable to a spatial cross product. spatial query A query that includes criteria for which selected features must meet location conditions. spatiotemporal data Data that contains time or location (or both) components as one of its dimensions, also referred to as geographically referenced data or georeferenced data. tolerance The distance that two points can be apart and still be considered the same (for example, to accommodate rounding errors). The tolerance value must be a positive number greater than zero. The significance of the value depends on whether or not the spatial data is associated with a geodetic coordinate system. touch A geometric relationship where two objects share a common point on their boundaries, but their interiors do not intersect. transformation The conversion of coordinates from one coordinate system to another coordinate system. If the coordinate system is georeferenced, transformation can involve datum transformation: the conversion of geodetic coordinates from one geodetic datum to another geodetic datum, usually involving changes in the shape, orientation, and center position of the reference ellipsoid. twotier query model The query model used by Spatial to resolve spatial queries and spatial joins. Two distinct filtering operations (primary and secondary) are performed to resolve queries. The output of both operations yields the exact result set. See also primary filter and secondary filter. This chapter shows how to create and use spatial indexes on objects other than a geometry column. In other chapters, the focus is on indexing and querying spatial data that is stored in a single column of type SDO_GEOMETRY. This chapter shows how to: Embed an SDO_GEOMETRY object in a userdefined object type, and index the geometry attribute of that type (see Section 9.1) Create and use a functionbased index where the function returns an SDO_GEOMETRY object (see Section 9.2) The techniques in this chapter are intended for experienced and knowledgeable application developers. You should be familiar with the Spatial concepts and techniques described in other chapters. You should also be familiar with, or able to learn about, relevant Oracle database features, such as userdefined data types and functionbased indexing. The SDO_GEOMETRY type can be embedded in a userdefined data type definition. The procedure is very similar to that for using the SDO_GEOMETRY type for a spatial data column: Create the userdefined data type. Create a table with a column based on that data type. Insert data into the table. Update the USER_SDO_GEOM_METADATA view. Create the spatial index on the geometry attribute. Perform queries on the data. For example, assume that you want to follow the cola markets scenario in the simplified example in Section 2.1, but want to incorporate the market name attribute and the geometry attribute in a single type. First, create the userdefined data type, as in the following example that creates an object type named MARKET_TYPE: Create a table that includes a column based on the userdefined type. The following example creates a table named COLA_MARKETS_2 that will contain the same information as the COLA_MARKETS table used in the example in Section 2.1. Insert data into the table, using the object type name as a constructor. For example: Update the USER_SDO_GEOM_METADATA view, using dotnotation to specify the column name and spatial attribute. The following example specifies MARKET.SHAPE as the COLUMN_NAME (explained in Section 2.6.2) in the metadata view. Create the spatial index, specifying the column name and spatial attribute using dotnotation. For example. Perform queries on the data, using dotnotation to refer to attributes of the userdefined type. The following simple query returns information associated with the cola market named The following query returns information associated with all geometries that have any spatial interaction with a specified query window, namely, the rectangle with lowerleft coordinates (4,6) and upperright coordinates (8,8). A functionbased spatial index facilitates queries that use locational information (of type SDO_GEOMETRY) returned by a function or expression. In this case, the spatial index is created based on the precomputed values returned by the function or expression. If you are not already familiar with functionbased indexes, see the following for detailed explanations of their benefits, options, and requirements, as well as usage examples: The procedure for using an SDO_GEOMETRY object in a functionbased index is as follows: Create the function that returns an SDO_GEOMETRY object. The function must be declared as DETERMINISTIC. If the spatial data table does not already exist, create it, and insert data into the table. Update the USER_SDO_GEOM_METADATA view. Create the spatial index. For a functionbased spatial index, the number of parameters must not exceed 32. Perform queries on the data. The rest of this section describes two examples of using functionbased indexes. In both examples, a function is created that returns an SDO_GEOMETRY object, and a spatial index is created on that function. In the first example, the input parameters to the function are a standard Oracle data type (NUMBER). In the second example, the input to the function is a userdefined object type. In the following example, the input parameters to the function used for the functionbased index are standard numeric values (longitude and latitude). Assume that you want to create a function that returns the longitude and latitude of a point and to use that function in a spatial index. First, create the function, as in the following example that creates a function named GET_LONG_LAT_PT: If the spatial data table does not already exist, create the table and add data to it, as in the following example that creates a table named LONG_LAT_TABLE: Update the USER_SDO_GEOM_METADATA view, using dotnotation to specify the schema name and function name. The following example specifies SCOTT.GET_LONG_LAT_PT(LONGITUDE,LATITUDE) as the COLUMN_NAME (explained in Section 2.6.2) in the metadata view. Create the spatial index, specifying the function name with parameters. For example: Perform queries on the data. In the following example, the two queries accomplish the same thing; however, the first query does not use a userdefined function (instead using a constructor to specify the point), whereas the second query uses the function to specify the point. In the following example, the input parameter to the function used for the functionbased index is an object of a userdefined type that includes the longitude and latitude. Assume that you want to create a function that returns the longitude and latitude of a point and to create a spatial index on that function. First, create the userdefined data type, as in the following example that creates an object type named LONG_LAT and its member function GetGeometry: If the spatial data table does not already exist, create the table and add data to it, as in the following example that creates a table named TEST_LONG_LAT: Update the USER_SDO_GEOM_METADATA view, using dotnotation to specify the schema name, table name, and function name and parameter value. The following example specifies SCOTT.LONG_LAT.GetGeometry(LOCATION) as the COLUMN_NAME (explained in Section 2.6.2) in the metadata view. Create the spatial index, specifying the column name and function name using dotnotation. For example: Perform queries on the data. The following query performs a primary filter operation, asking for the names of geometries that are likely to interact spatially with point (10,10). The SDO_MIGRATE.TO_CURRENT subprogram described in this chapter has both procedure and function interfaces. As a procedure, it lets you upgrade spatial geometry tables from previous releases of Spatial; and as a function, it lets you upgrade a single SDO_GEOMETRY object. SDO_MIGRATE.TO_CURRENT is the only procedure that you should use for upgrading tables. Do not use the SDO_MIGRATE.TO_81X, SDO_MIGRATE.FROM_815_TO_81X, or SDO_MIGRATE.TO_734 procedures, which were documented in previous Spatial releases but are no longer supported. Format (Any ObjectRelational Model Implementation to Current) SDO_MIGRATE.TO_CURRENT( tabname IN VARCHAR2 [, column_name IN VARCHAR2]); or SDO_MIGRATE.TO_CURRENT( tabname IN VARCHAR2, column_name IN VARCHAR2 [, commit_int IN NUMBER]); Format (Single ObjectRelational Model Geometry to Current) SDO_MIGRATE.TO_CURRENT( geom IN SDO_GEOMETRY, dim IN SDO_DIM_ARRAY ) RETURN SDO_GEOMETRY; Format (Any Relational Model Implementation to Current) SDO_MIGRATE.TO_CURRENT( layer IN VARCHAR2, newtabname IN VARCHAR2, gidcolumn IN VARCHAR2, geocolname IN VARCHAR2, layer_gtype IN VARCHAR2, updateflag IN VARCHAR2); Description Upgrades data from a previous Spatial release to the current release. As a procedure, TO_CURRENT upgrades an entire layer (all geometries in a column); as a function, TO_CURRENT upgrades a single geometry object, which must be of type SDO_GEOMETRY. For upgrading a layer, the procedure format depends on whether you are upgrading from the Spatial relational model (release 8.1.5 or earlier) or objectrelational model (release 8.1.6 or later). See the Usage Notes for the model that applies to you. You should use this procedure for any spatial layer upgrade. Do not use the SDO_MIGRATE.TO_81X, SDO_MIGRATE.FROM_815_TO_81X, or SDO_MIGRATE.TO_734 procedures, which were documented in previous Spatial releases but are no longer supported. Parameters Table with geometry objects. Column in Number of geometries to upgrade before Spatial performs an internal commit operation. If If you specify a Single geometry object to be upgraded to the current release. Dimensional information array for the geometry object to be upgraded. The SDO_DIM_ARRAY type is explained in Section 2.6.3. Name of the layer to be upgraded. Name of the new table to which you are upgrading the data. Name of the column in which to store the GID from the old table. Name of the column in the new table where the geometry objects will be inserted. One of the following values: POINT or NOTPOINT (default). If the layer you are upgrading is composed solely of point data, set this parameter to POINT for optimal performance; otherwise, set this parameter to NOTPOINT. If you set the value to POINT and the layer contains any nonpoint geometries, the upgrade might produce invalid data. One of the following values: UPDATE or INSERT (default). If you are upgrading the layer into an existing populated attribute table, set this parameter to UPDATE; otherwise, set this parameter to INSERT. Usage Notes for ObjectRelational Model Layer and Single Geometry Upgrade The specified geometry or all geometry objects in the specified layer are upgraded so that their SDO_GTYPE and SDO_ETYPE values are in the format of the current release: SDO_GTYPE values of 4 digits are created, using the format (dltt) shown in Table 21 in Section 2.2.1. SDO_ETYPE values are as discussed in Section 2.2.4. Geometries are ordered so that exterior rings are followed by their interior rings, and coordinates are saved in the correct rotation (counterclockwise for exterior rings, and clockwise for interior rings). Usage Notes for Relational Model Upgrade Consider the following when using this procedure: The new table must be created before you call this procedure. If the data to be upgraded is geodetic, the tolerance value (SDO_TOLERANCE column value in the <layername>_SDODIM table or view) must be expressed in decimal degrees (for example, 0.00000005). The procedure converts geometries from the relational model to the objectrelational model. A commit operation is performed by this procedure. If any of the upgrade steps fails, nothing is upgraded for the layer. The old SDO_GID is stored in SDO_GTYPE values of 4 digits are created, using the format (dltt) shown in Table 21 in Section 2.2.1. SDO_ETYPE values are created, using the values discussed in Section 2.2.4. The procedure orders geometries so that exterior rings are followed by their interior rings, and it saves coordinates in the correct rotation (counterclockwise for exterior rings, and clockwise for interior rings). Examples The following example changes the definitions of geometry objects in the ROADS table from the release 8.1.5 or later format to the format of the current release. Oracle Spatial User's Guide and Reference provides usage and reference information for indexing and storing spatial data and for developing spatial applications using Oracle Spatial and Oracle Locator. Oracle Spatial requires the Enterprise Edition of Oracle Database 10g. It is a foundation for the deployment of enterprisewide spatial information systems, and Webbased and wireless locationbased applications requiring complex spatial data management. Oracle Locator is a feature of the Standard and Enterprise Editions of Oracle Database 10g. It offers a subset of Oracle Spatial capabilities (see Appendix B for a list of Locator features) typically required to support Internet and wireless service applications and partnerbased geographic information system (GIS) solutions. The Standard and Enterprise Editions of Oracle Database 10g have the same basic features. However, several advanced features, such as extended data types, are available only with the Enterprise Edition, and some of these features are optional. For example, to use Oracle Database 10g table partitioning, you must have the Enterprise Edition and the Partitioning Option. For information about the differences between Oracle Database 10g Standard Edition and Oracle Database 10g Enterprise Edition and the features and options that are available to you, see Oracle Database New Features. Note: This guide is intended for anyone who needs to store spatial data in an Oracle database. Our goal is to make Oracle products, services, and supporting documentation accessible, with good usability, to the disabled community. To that end, our documentation includes features that make information available to users of assistive technology. This documentation is available in HTML format, and contains markup to facilitate access by the disabled community. Accessibility standards will continue to evolve over time, and Oracle is actively engaged with other marketleading technology vendors to address technical obstacles so that our documentation can be accessible to all of our customers. For more information, visit the Oracle Accessibility Program Web site at Accessibility of Code Examples in Documentation Screen readers may not always correctly read the code examples in this document. The conventions for writing code require that closing braces should appear on an otherwise empty line; however, some screen readers may not always read a line of text that consists solely of a bracket or brace. Accessibility of Links to External Web Sites in Documentation This documentation may contain links to Web sites of other companies or organizations that Oracle does not own or control. Oracle neither evaluates nor makes any representations regarding the accessibility of these Web sites. TTY Access to Oracle Support Services Oracle provides dedicated Text Telephone (TTY) access to Oracle Support Services within the United States of America 24 hours a day, seven days a week. For TTY support, call 800.446.2398. For more information, see the following documents: Oracle Database Application Developer's Guide  Fundamentals Oracle Database Error Messages  Spatial messages are in the range of 13000 to 13499. Oracle error message documentation is only available in HTML. If you only have access to the Oracle Documentation CD, you can browse the error messages by range. Once you find the specific range, use your browser's "find in page" feature to locate the specific message. When connected to the Internet, you can search for a specific error message using the error message search feature of the Oracle online documentation. Printed documentation is available for sale in the Oracle Store at To download free release notes, installation documentation, white papers, or other collateral, go to the Oracle Technology Network (OTN). You must register online before using OTN; registration is free and can be done at If you already have a user name and password for OTN, then you can go directly to the documentation section of the OTN Web site at The following text conventions are used in this document: p+@B2G1"G@
# CJ0Jꑑtbr8Ȃ,$@:yO!
sʭ,gIZ̥.M]
0F.ph2I/\z`gJ6nz8ǹ/T_&YM/ dM63Iz3L?MBss&:P ,пeT!C?N2$ a 0X,B L@hx@wZF~4
x0"U L (<zJA0u~0/K>, $x_w={1_DE
(hD lA
Ն^A@* @MA
ǄE
@@`F!b0!A(e`\ŀԠo@9D@z!
B@HF aZqlA%
a2!`9R$@Gy߱ This section describes major new and changed Oracle Spatial features for the current release. Coordinate system support in Spatial is now based on, but is not identical to, the data model and data provided by the European Petroleum Survey Group (EPSG), as explained in Section 6.4. Applications that depend on the data model from previous releases (the "legacy" model) continue to be fully supported; however, the EPSG model bases Spatial on a widely accepted standard and enables greater flexibility for users who want to perform customized datum transformations. Chapter 6 describes coordinate system concepts, Section 6.5 explains the new TFM_PLAN object type used for transformation plans, and Section 6.6 describes the new EPSGbased tables and views. The SDO_CS package (described in Chapter 13) contains the following new subprograms to support the EPSG model: The SDO_GEOMETRY object type has the following new methods (member functions): Get_WKB, Get_WKT, ST_CoordDim, and ST_IsValid. The SDO_GEOMETRY methods are described in Section 2.3. (The methods were described in a separate chapter in the previous release of this guide.) The SDO_GEOMETRY object type has new constructors for creating a geometry object from a wellknown text (WKT) string in CLOB or VARCHAR2 format, or from a wellknown binary (WKT) object in BLOB format. These constructors are described in Section 2.4. The SDO_FILTER, SDO_RELATE, and SDO_WITHIN_DISTANCE operators accept the following new optional keywords in their last parameter: The Spatial operators are described in Chapter 11. The new This parameter is part of a change for this release in how Spatial updates the spatial index when rows are inserted, updated, or deleted in the spatial table. In previous releases, Spatial updated the index after each DML (insert, update, or delete) operation on the table. In the current release, Spatial does not update the index until after the commit operation completes the transaction, and it updates the index in batches of operations determined by the As a result of this change in spatial index update behavior, as well as other internal improvements, you are no longer encouraged to perform commit operations after each spatial table insert or update operation. Instead, for better performance (especially with large numbers of operations), perform the commit operation after a number of insert or update operations that is greater than the The SDO_GCDR package (described in Chapter 14) contains the following new subprograms: The SDO_UTIL package (described in Chapter 20) contains the following new subprograms: Spatial now supports the conversion of point locations between the U.S. National Grid format and the SDO_GEOMETRY point format. Support for the U.S. National Grid point representation format is described in Section 6.10. The Spatial now includes a routing engine, which enables you to host an XMLbased Web service that provides information about a single driving route or multiple routes. The Spatial routing engine is described in Appendix C. Effective with release 10.2.0.3, the new SDO_LRS.LRS_INTERSECTION function (described in Chapter 16) enables you to return an LRS geometry object that is the topological intersection (AND operation) of an LRS geometric segment and another geometry object. This chapter contains descriptions of the spatial utility subprograms shown in Table 201. Table 201 Spatial Utility Subprograms Appends one geometry to another geometry to create a new geometry. Returns the polygon geometry that approximates and is covered by a specified circle. Concatenates two line or multiline twodimensional geometries to create a new geometry. Converts values from one angle, area, or distance unit of measure to another. Returns the polygon geometry that approximates and is covered by a specified ellipse. Returns the geometry that represents a specified element (and optionally a ring) of the input geometry. Converts a geometry in the wellknown binary (WKB) format to a Spatial geometry object. Converts a geometry in the wellknown text (WKT) format to a Spatial geometry object. Returns the number of elements in the input geometry. Returns the number of vertices in the input geometry. Returns the coordinates of the vertices of the input geometry. SDO_UTIL.INITIALIZE_INDEXES_FOR_TTS Initializes all spatial indexes in a tablespace that was transported to another database. Returns a point geometry that is at the specified distance and bearing from the start point. Converts all polygontype elements in a geometry to linetype elements, and sets the SDO_GTYPE value accordingly. Prepares a tablespace to be transported to another database, so that spatial indexes will be preserved during the transport operation. Fixes certain problems with the input geometry, and returns a valid geometry. SDO_UTIL.REMOVE_DUPLICATE_VERTICES Removes duplicate (redundant) vertices from a geometry. Returns a line string geometry with the vertices of the input geometry in reverse order. Simplifies the input geometry, based on a threshold value, using the DouglasPeucker algorithm. Converts a Spatial geometry object to a geography markup language (GML 2.0) fragment based on the geometry types defined in the Open GIS Converts a Spatial geometry object to the wellknown binary (WKB) format. Converts a Spatial geometry object to the wellknown text (WKT) format. Validates the input geometry, which is in the standard wellknown binary (WKB) format; returns the string Validates the input geometry, which is of type CLOB or VARCHAR2 and in the standard wellknown text (WKT) format; returns the string Format SDO_UTIL.APPEND( geom1 IN SDO_GEOMETRY, geom2 IN SDO_GEOMETRY ) RETURN SDO_GEOMETRY; Description Appends one geometry to another geometry to create a new geometry. Parameters Geometry object to which Geometry object to append to Usage Notes This function should be used only on geometries that do not have any spatial interaction (that is, on disjoint objects). If the input geometries are not disjoint, the resulting geometry might be invalid. This function does not perform a union operation or any other computational geometry operation. To perform a union operation, use the SDO_GEOM.SDO_UNION function, which is described in Chapter 15. The APPEND function executes faster than the SDO_GEOM.SDO_UNION function. The geometry type (SDO_GTYPE value) of the resulting geometry reflects the types of the input geometries and the append operation. For example, if the input geometries are twodimensional polygons (SDO_GTYPE = 2003), the resulting geometry is a twodimensional multipolygon (SDO_GTYPE = 2007). An exception is raised if Examples The following example appends the Related Topics Format SDO_UTIL.CIRCLE_POLYGON( center_longitude IN NUMBER, center_latitude IN NUMBER, radius IN NUMBER, arc_tolerance IN NUMBER ) RETURN SDO_GEOMETRY; Description Returns the polygon geometry that approximates and is covered by a specified circle. Parameters Center longitude (in degrees) of the circle to be used to create the returned geometry. Center latitude (in degrees) of the circle to be used to create the returned geometry. Length (in meters) of the radius of the circle to be used to create the returned geometry. A numeric value to be used to construct the polygon geometry. The Usage Notes This function is useful for creating a circlelike polygon around a specified center point when a true circle cannot be used (a circle is not valid for geodetic data with Oracle Spatial). The returned geometry has an SDO_SRID value of 8307 (for Examples The following example returns a circlelike polygon around a point near the center of Concord, Massachusetts. A Related Topics Format SDO_UTIL.CONCAT_LINES( geom1 IN SDO_GEOMETRY, geom2 IN SDO_GEOMETRY ) RETURN SDO_GEOMETRY; Description Concatenates two line or multiline twodimensional geometries to create a new geometry. Parameters First geometry object for the concatenation operation. Second geometry object for the concatenation operation. Usage Notes Each input geometry must be a twodimensional line or multiline geometry (that is, the SDO_GTYPE value must be 2002 or 2006). This function is not supported for LRS geometries. To concatenate LRS geometric segments, use the SDO_LRS.CONCATENATE_GEOM_SEGMENTS function (described in Chapter 16). The input geometries must be line strings whose vertices are connected by straight line segments. Circular arcs and compound line strings are not supported. If an input geometry is a multiline geometry, the elements of the geometry must be disjoint. If they are not disjoint, this function may return incorrect results. The topological relationship between You can use the SDO_AGGR_CONCAT_LINES spatial aggregate function (described in Chapter 12) to concatenate multiple twodimensional line or multiline geometries. An exception is raised if Examples The following example concatenates two simple line string geometries. Related Topics Format SDO_UTIL.CONVERT_UNIT( input_value IN NUMBER, from_unit IN VARCHAR2, to_unit IN VARCHAR2 ) RETURN NUMBER; Description Converts values from one angle, area, or distance unit of measure to another. Parameters Number of units to be converted. For example, to convert 10 decimal degrees to radians, specify The unit of measure from which to convert the input value. Must be a value from the SDO_UNIT column of the MDSYS.SDO_ANGLE_UNITS table (described in Section 6.7.2), the MDSYS.SDO_AREA_UNITS table (described in Section 2.8), or the MDSYS.SDO_DIST_UNITS table (described in Section 2.8). For example, to convert decimal degrees to radians, specify The unit of measure into which to convert the input value. Must be a value from the SDO_UNIT column of the same table used for Usage Notes The value returned by this function might not be correct at an extremely high degree of precision because of the way internal mathematical operations are performed, especially if they involve small numbers or irrational numbers (such as pi). For example, converting 1 decimal degree into decimal minutes results in the value 60.0000017. Examples The following example converts 1 radian into decimal degrees. Related Topics None. Format SDO_UTIL.ELLIPSE_POLYGON( center_longitude IN NUMBER, center_latitude IN NUMBER, semi_major_axis IN NUMBER, semi_minor_axis IN NUMBER, azimuth IN NUMBER, arc_tolerance IN NUMBER ) RETURN SDO_GEOMETRY; Description Returns the polygon geometry that approximates and is covered by a specified ellipse. Parameters Center longitude (in degrees) of the ellipse to be used to create the returned geometry. Center latitude (in degrees) of the ellipse to be used to create the returned geometry. Length (in meters) of the semimajor axis of the ellipse to be used to create the returned geometry. Length (in meters) of the semiminor axis of the ellipse to be used to create the returned geometry. Number of degrees of the azimuth (clockwise rotation of the major axis from north) of the ellipse to be used to create the returned geometry. Must be from 0 to 180. The returned geometry is rotated by the specified number of degrees. A numeric value to be used to construct the polygon geometry. The Usage Notes This function is useful for creating an ellipselike polygon around a specified center point when a true ellipse cannot be used (an ellipse is not valid for geodetic data with Oracle Spatial). The returned geometry has an SDO_SRID value of 8307 (for Examples The following example returns an ellipselike polygon, oriented eastwest ( Related Topics Format SDO_UTIL.EXTRACT( geometry IN SDO_GEOMETRY, element IN NUMBER [, ring IN NUMBER] ) RETURN SDO_GEOMETRY; Description Returns the geometry that represents a specified element (and optionally a ring) of the input geometry. Parameters Geometry from which to extract the geometry to be returned. Number of the element in the geometry: 1 for the first element, 2 for the second element, and so on. Geometries with SDO_GTYPE values (explained in Section 2.2.1) ending in 1, 2, or 3 have one element; geometries with SDO_GTYPE values ending in 4, 5, 6, or 7 can have more than one element. For example, a multipolygon with an SDO_GTYPE of 2007 might contain three elements (polygons). Number of the subelement (ring) within For a polygon with holes, its first subelement is its exterior ring, its second subelement is its first interior ring, its third subelement is its second interior ring, and so on. For example, in the polygon with a hole shown in Figure 23 in Section 2.5.2, the exterior ring is subelement 1 and the interior ring (the hole) is subelement 2. For a point cluster, its first subelement is the first point in the point cluster, its second subelement is the second point in the point cluster, and so on. The default is 0, which causes the entire element to be extracted. Usage Notes This function is useful for extracting a specific element or subelement from a complex geometry. For example, if you have identified a geometry as invalid by using the SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT function or the SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT procedure (both of which are documented in Chapter 15), you can use the EXTRACT function to extract the invalid geometry in order to examine it. For a polygon with one or more holes, the returned geometry representing an extracted interior ring is reoriented so that its vertices are presented in counterclockwise order (as opposed to the clockwise order within an interior ring). If An exception is raised if Examples The following example extracts the first (and only) element in the The following example inserts a polygon with a hole (using the same INSERT statement as in Example 25 in Section 2.5.2), and extracts the geometry representing the hole (the second subelement). Notice that in the geometry returned by the EXTRACT function, the vertices are in counterclockwise order, as opposed to the clockwise order in the hole (second subelement) in the input geometry. Related Topics Format SDO_UTIL.FROM_WKBGEOMETRY( geometry IN BLOB ) RETURN SDO_GEOMETRY; Description Converts a geometry in the wellknown binary (WKB) format to a Spatial geometry object. Parameters Geometry in WKB format to be converted to SDO_GEOMETRY format. Usage Notes The input geometry must be in the wellknown binary (WKB) format, as defined by the Open Geospatial Consortium and the International Organization for Standardization (ISO). This function is patterned after the SQL Multimedia recommendations in ISO 132493, Information technology  Database languages  SQL Multimedia and Application Packages  Part 3: Spatial. To convert an SDO_GEOMETRY object to WKB format, use the SDO_UTIL.TO_WKBGEOMETRY function. Examples The following example shows conversion to and from WKB and WKT format, and validation of WKB and WKT geometries. (The example uses the definitions and data from Section 2.1, specifically the Related Topics Format SDO_UTIL.FROM_WKTGEOMETRY( geometry IN CLOB ) RETURN SDO_GEOMETRY; or SDO_UTIL.FROM_WKTGEOMETRY( geometry IN VARCHAR2 ) RETURN SDO_GEOMETRY; Description Converts a geometry in the wellknown text (WKT) format to a Spatial geometry object. Parameters Geometry in WKT format to be converted to SDO_GEOMETRY format. Usage Notes The input geometry must be in the wellknown text (WKT) format, as defined by the Open Geospatial Consortium and the International Organization for Standardization (ISO). This function is patterned after the SQL Multimedia recommendations in ISO 132493, Information technology  Database languages  SQL Multimedia and Application Packages  Part 3: Spatial. To convert an SDO_GEOMETRY object to a CLOB in WKT format, use the SDO_UTIL.TO_WKTGEOMETRY function. (You can use the SQL function TO_CHAR to convert the resulting CLOB to VARCHAR2 type.) Examples The following example shows conversion to and from WKB and WKT format, and validation of WKB and WKT geometries. (The example uses the definitions and data from Section 2.1, specifically the Related Topics Format SDO_UTIL.GETNUMELEM( geometry IN SDO_GEOMETRY ) RETURN NUMBER; Description Returns the number of elements in the input geometry. Parameters Geometry for which to return the number of elements. Usage Notes None. Examples The following example returns the number of elements for each geometry in the SHAPE column of the COLA_MARKETS table. (The example uses the definitions and data from Section 2.1.) Related Topics Format SDO_UTIL.GETNUMVERTICES( geometry IN SDO_GEOMETRY ) RETURN NUMBER; Description Returns the number of vertices in the input geometry. Parameters Geometry for which to return the number of vertices. Usage Notes None. Examples The following example returns the number of vertices for each geometry in the SHAPE column of the COLA_MARKETS table. (The example uses the definitions and data from Section 2.1.) Related Topics Format SDO_UTIL.GETVERTICES( geometry IN SDO_GEOMETRY ) RETURN VERTEX_SET_TYPE; Description Returns the coordinates of the vertices of the input geometry. Parameters Geometry for which to return the coordinates of the vertices. Usage Notes This function returns an object of VERTEX_SET_TYPE, which consists of a table of objects of VERTEX_TYPE. Oracle Spatial defines the type VERTEX_SET_TYPE as: Oracle Spatial defines the object type VERTEX_TYPE as: This function can be useful in finding a vertex that is causing a geometry to be invalid. For example, if you have identified a geometry as invalid by using the SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT function or the SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT procedure (both of which are documented in Chapter 15), you can use the GETVERTICES function to view the vertices in tabular format. Examples The following example returns the X and Y coordinates and Related Topics Format SDO_UTIL.INITIALIZE_INDEX_FOR_TTS; Description Initializes all spatial indexes in a tablespace that was transported to another database. Parameters None. Usage Notes This procedure is part of the support for using the Oracle transportable tablespace feature with tablespaces that contain any spatial indexes. Use this procedure after the import operation is completed; each user that has a spatial index in the tablespace must call the procedure. You must also have called the SDO_UTIL.PREPARE_FOR_TTS procedure just before performing the export operation. See the Usage Notes for the SDO_UTIL.PREPARE_FOR_TTS procedure for more information about using the transportable tablespace feature with spatial data. For detailed information about transportable tablespaces and transporting tablespaces to other databases, see Oracle Database Administrator's Guide. Examples The following example initializes all spatial indexes in a tablespace that was transported to another database. Related Topics Format SDO_UTIL.POINT_AT_BEARING( start_point IN SDO_GEOMETRY, bearing IN NUMBER, distance IN NUMBER ) RETURN SDO_GEOMETRY; Description Returns a point geometry that is at the specified distance and bearing from the start point. Parameters Point geometry object from which to compute the distance at the specified bearing, to locate the desired point. The point geometry must be based on a geodetic coordinate system. Number of radians, measured clockwise from North. Must be in the range of either pi to pi or 0 to 2*pi. (Either convention on ranges will work). Number of meters from Usage Notes The input point geometry must be based on a geodetic coordinate system. If it is based on a nongeodetic coordinate system, this function returns a null value. To convert decimal degrees to radians or nonmetric distances to meters, you can use the SDO_UTIL.CONVERT_UNIT function. Examples The following example returns the point 100 kilometers at a bearing of 1 radian from the point with the longitude and latitude coordinates (72, 43). Related Topics Format SDO_UTIL.POLYGONTOLINE( geometry IN SDO_GEOMETRY ) RETURN SDO_GEOMETRY; Description Converts all polygontype elements in a geometry to linetype elements, and sets the SDO_GTYPE value accordingly. Parameters Geometry to convert. Usage Notes The order of the vertices of each resulting linetype element is the same as in the associated polygontype element, and the start and end points of each linetype segment are the same point. If the input geometry is a line, it is returned. Examples The following example converts the input polygon geometry, which is the same geometry as cola_b (see Figure 21 and Example 21 in Section 2.1), to a line string geometry. In the returned geometry, the SDO_GTYPE value (2002) indicates a twodimensional LINE geometry, and the SDO_ETYPE value (2) and SDO_INTERPRETATION value (1) in the SDO_ELEM_INFO array indicate a line string whose vertices are connected by straight line segments. Related Topics None. Format SDO_UTIL.PREPARE_FOR_TTS( table_space IN VARCHAR2); Description Prepares a tablespace to be transported to another database, so that spatial indexes will be preserved during the transport operation. Parameters Tablespace to be transported. Usage Notes Before Oracle Database 10g release 1 (10.1), the Oracle transportable tablespace feature could not be used with tablespaces that contained any spatial indexes. Effective with Oracle Database 10g release 1 (10.1), you can transport tablespaces that contain spatial indexes; however, you must call the PREPARE_FOR_TTS procedure just before you perform the export operation, and you must call it for each user that has a spatial index in the specified tablespace. Transportable tablespaces containing spatial indexes are not supported across endian format platforms (bigendian to littleendian, or littleendian to bigendian). After the export operation is complete, you must call the SDO_UTIL.INITIALIZE_INDEXES_FOR_TTS procedure to initialize all spatial indexes in the transported tablespace. For detailed information about transportable tablespaces and transporting tablespaces to other databases, see Oracle Database Administrator's Guide. Examples The following example prepares a tablespace named Related Topics Format SDO_UTIL.RECTIFY_GEOMETRY( geometry IN SDO_GEOMETRY, tolerance IN NUMBER ) RETURN SDO_GEOMETRY; Description Fixes certain problems with the input geometry, and returns a valid geometry. Parameters Geometry to be checked for problems that can be fixed. Tolerance value (see Section 1.5.5). Usage Notes This function checks for the following problems that can make a geometry invalid, and fixes the problems in the returned geometry: Duplicate vertices Polygon boundary intersecting itself Incorrect orientation of exterior or interior rings (or both) of a polygon If the input geometry has any other problem that makes it invalid, the function raises an exception. If the input geometry is valid, the function returns a geometry that is identical to the input geometry. This function is used internally by the SDO_UTIL.SIMPLIFY function as part of the geometry simplification process. Examples The following example checks the Related Topics Format SDO_UTIL.REMOVE_DUPLICATE_VERTICES geometry IN SDO_GEOMETRY, tolerance IN NUMBER ) RETURN SDO_GEOMETRY; Description Removes duplicate (redundant) vertices from a geometry. Parameters Geometry from which to remove duplicate vertices. Tolerance value (see Section 1.5.5). Usage Notes When two consecutive vertices in a geometry are the same or within the tolerance value associated with the geometry, Spatial considers the geometry to be invalid. The Spatial geometry validation functions return the error ORA13356 in these cases. You can use the REMOVE_DUPLICATE_VERTICES function to change such invalid geometries into valid geometries. If the input geometry does not contain any duplicate vertices, it is returned. Examples The following example removes a duplicate vertex from the input geometry, which is the same geometry as cola_b (see Figure 21 and Example 21 in Section 2.1) except that it has been deliberately made invalid by adding a third vertex that is the same point as the second vertex (8,1). Related Topics None. Format SDO_UTIL.REVERSE_LINESTRING( geometry IN SDO_GEOMETRY ) RETURN SDO_GEOMETRY; Description Returns a line string geometry with the vertices of the input geometry in reverse order. Parameters Line string geometry whose vertices are to be reversed in the output geometry. The SDO_GTYPE value of the input geometry must be 2002. (Section 2.2.1 explains SDO_GTYPE values.) Usage Notes Because the SDO_GTYPE value of the input geometry must be 2002, this function cannot be used to reverse LRS geometries. To reverse an LRS geometry, use the SDO_LRS.REVERSE_GEOMETRY function, which is described in Chapter 16. Examples The following example returns a line string geometry that reverses the vertices of the input geometry. Related Topics Format SDO_UTIL.SIMPLIFY( geometry IN SDO_GEOMETRY, threshold IN NUMBER tolerance IN NUMBER DEFAULT 0.0000005 ) RETURN SDO_GEOMETRY; Description Simplifies the input geometry, based on a threshold value, using the DouglasPeucker algorithm. Parameters Geometry to be simplified. Threshold value to be used for the geometry simplification. Should be a positive number. (Zero causes the input geometry to be returned.) If the input geometry is geodetic, the value is the number of meters; if the input geometry is nongeodetic, the value is the number of units associated with the data. As the threshold value is decreased, the returned geometry is likely to be closer to the input geometry; as the threshold value is increased, fewer points are likely to be in the returned geometry. See the Usage Notes for more information. Tolerance value (see Section 1.5.5). Must not be greater than Usage Notes This function also convert arcs to line stings, eliminates duplicate vertices, and corrects many overlapping edge polygon problems. The reason this function sometimes fixes problems is that it internally calls the SDO_UTIL.RECTIFY_GEOMETRY function at the end of the simplification process to ensure that a valid geometry is returned. This function is useful when you want a geometry with less fine resolution than the original geometry. For example, if the display resolution cannot show the hundreds or thousands of turns in the course of a river or in a political boundary, better performance might result if the geometry were simplified to show only the major turns. If you use this function with geometries that have more than two dimensions, only the first two dimensions are used in processing the query, and only the first two dimensions in the returned geometry are to be considered valid and meaningful. For example, the measure values in a returned LRS geometry will probably not reflect actual measures in that geometry. In this case, depending on your application needs, you might have several options after the simplification operation, such as ignoring the new measure values or redefining the new LRS geometry to reset the measure values. This function uses the DouglasPeucker algorithm, which is explained in several cartography textbooks and reference documents. (In some explanations, the term tolerance is used instead of threshold; however, this is different from the Oracle Spatial meaning of tolerance.) The returned geometry can be a polygon, line, or point, depending on the geometry definition and the threshold value. The following considerations apply: A polygon can simplify to a line or a point and a line can simplify to a point, if the threshold value associated with the geometry is sufficiently large. For example, a thin rectangle will simplify to a line if the distance between the two parallel long sides is less then the threshold value, and a line will simplify to a point if the distance between the start and end points is less than the threshold value. In a polygon with a hole, if the exterior ring or the interior ring (the hole) simplifies to a line or a point, the interior ring disappears from (is not included in) the resulting geometry. Topological characteristics of the input geometry might not be maintained after simplification. For a collection geometry, the number of elements might increase, to prevent overlapping of individual elements. In all cases, this function will not return an invalid geometry. Examples The following example simplifies the road shown in Figure 720 in Section 7.7. Because the threshold value (6) is fairly large given the input geometry, the resulting LRS line string has only three points: the start and end points, and (12, 4,12). The measure values in the returned geometry are not meaningful, because this function considers only two dimensions. Figure 201 shows the result of this example. In Figure 201, the thick solid black line is the resulting geometry, the thin solid light line between the start and end points is the input geometry, and the thin dashed line with the arrowhead at the end shows the direction of the segment. Related Topics Format SDO_UTIL.TO_GMLGEOMETRY( thegeom IN SDO_GEOMETRY ) RETURN CLOB; Description Converts a Spatial geometry object to a geography markup language (GML 2.0) fragment based on the geometry types defined in the Open GIS Parameters Geometry for which to return the GML fragment. Usage Notes This function does not convert circles, geometries containing any circular arcs, LRS geometries, or geometries with an SDO_ETYPE value of 0 (type 0 elements); it returns an empty CLOB in these cases. This function converts the input geometry to a GML fragment based on some GML geometry types defined in the Open GIS Implementation Specification. The input geometry must have a 4digit SDO_GTYPE value. Polygons must be defined using the conventions for Oracle9i and later releases of Spatial. That is, the outer boundary is stored first (with ETYPE=1003) followed by zero or more inner boundary elements (ETYPE=2003). For a polygon with holes, the outer boundary must be stored first in the SDO_ORDINATES definition, followed by coordinates of the inner boundaries. LRS geometries must be converted to standard geometries (using the SDO_LRS.CONVERT_TO_STD_GEOM or SDO_LRS.CONVERT_TO_STD_LAYER function) before being passed to the TO_GMLGEOMETRY function. (See the Examples section for an example that uses CONVERT_TO_STD_GEOM with the TO_GMLGEOMETRY function.) Any circular arcs or circles must be densified (using the SDO_GEOM.SDO_ARC_DENSIFY function) or represented as polygons (using the SDO_GEOM.SDO_BUFFER function) before being passed to the TO_GMLGEOMETRY function. (See the Examples section for an example that uses SDO_ARC_DENSIFY with the TO_GMLGEOMETRY function.) Label points are discarded. That is, if a geometry has a value for the SDO_POINT field and values in SDO_ELEM_INFO and SDO_ORDINATES, the SDO_POINT is not output in the GML fragment. The SDO_SRID value is output in the form Coordinates are always output using the The GML output is not formatted; there are no line breaks or indentation of tags. To see the contents of the returned CLOB in SQL*Plus, use the TO_CHAR() function or set the SQL*Plus parameter LONG to a suitable value (for example, Examples The following example returns the GML fragment for the The following example returns the GML fragment for the arc densification of the The following example converts an LRS geometry to a standard geometry and returns the GML fragment for the geometry. (The example uses the definitions and data from Section 7.7.) The following examples return GML fragments for a variety of geometry types. The following example uses the TO_GMLGEOMETRY function with the Oracle XML DB XMLTYPE data type and the XMLELEMENT and XMLFOREST functions. Related Topics None. Format SDO_UTIL.TO_WKBGEOMETRY( geometry IN SDO_GEOMETRY ) RETURN BLOB; Description Converts a Spatial geometry object to the wellknown binary (WKB) format. Parameters SDO_GEOMETRY object to be converted to WKB format. Usage Notes The input geometry is converted to the wellknown binary (WKB) format, as defined by the Open Geospatial Consortium and the International Organization for Standardization (ISO). This function is patterned after the SQL Multimedia recommendations in ISO 132493, Information technology  Database languages  SQL Multimedia and Application Packages  Part 3: Spatial. To convert a geometry in WKB format to an SDO_GEOMETRY object, use the SDO_UTIL.FROM_WKBGEOMETRY function. Examples The following example shows conversion to and from WKB and WKT format, and validation of WKB and WKT geometries. (The example uses the definitions and data from Section 2.1, specifically the Related Topics Format SDO_UTIL.TO_WKTGEOMETRY( geometry IN SDO_GEOMETRY ) RETURN CLOB; Description Converts a Spatial geometry object to the wellknown text (WKT) format. Parameters SDO_GEOMETRY object to be converted to WKT format. Usage Notes The input geometry is converted to the wellknown text (WKT) format, as defined by the Open Geospatial Consortium and the International Organization for Standardization (ISO). This function is patterned after the SQL Multimedia recommendations in ISO 132493, Information technology  Database languages  SQL Multimedia and Application Packages  Part 3: Spatial. To convert a geometry in WKT format to an SDO_GEOMETRY object, use the SDO_UTIL.FROM_WKTGEOMETRY function. Examples The following example shows conversion to and from WKB and WKT format, and validation of WKB and WKT geometries. (The example uses the definitions and data from Section 2.1, specifically the Related Topics Format SDO_UTIL.VALIDATE_WKBGEOMETRY( geometry IN BLOB ) RETURN VARCHAR2; Description Validates the input geometry, which is in the standard wellknown binary (WKB) format; returns the string Parameters Geometry in WKB format to be checked for validity. Usage Notes To be valid, the input geometry must be in the wellknown binary (WKB) format, as defined by the Open Geospatial Consortium and the International Organization for Standardization (ISO). This function is patterned after the SQL Multimedia recommendations in ISO 132493, Information technology  Database languages  SQL Multimedia and Application Packages  Part 3: Spatial. To validate a geometry in the wellknown text (WKT) format, use the SDO_UTIL.VALIDATE_WKTGEOMETRY function. Examples The following example shows conversion to and from WKB and WKT format, and validation of WKB and WKT geometries. (The example uses the definitions and data from Section 2.1, specifically the Related Topics Format SDO_UTIL.VALIDATE_WKTGEOMETRY( geometry IN CLOB ) RETURN VARCHAR2; or SDO_UTIL.VALIDATE_WKTGEOMETRY( geometry IN VARCHAR2 ) RETURN VARCHAR2; Description Validates the input geometry, which is of type CLOB or VARCHAR2 and in the standard wellknown text (WKT) format; returns the string Parameters Geometry in WKT format to be checked for validity. Usage Notes To be valid, the input geometry must be in the wellknown text (WKT) format, as defined by the Open Geospatial Consortium and the International Organization for Standardization (ISO). This function is patterned after the SQL Multimedia recommendations in ISO 132493, Information technology  Database languages  SQL Multimedia and Application Packages  Part 3: Spatial. To validate a geometry in the wellknown binary (WKB) format, use the SDO_UTIL.VALIDATE_WKBGEOMETRY function. Examples The following example shows conversion to and from WKB and WKT format, and validation of WKB and WKT geometries. (The example uses the definitions and data from Section 2.1, specifically the Related Topics The MDSYS.SDO_GCDR package contains subprograms for geocoding address data. To use the subprograms in this chapter, you must understand the conceptual and usage information about geocoding in Chapter 5. Table 141 lists the geocoding subprograms. Table 141 Subprograms for Geocoding Address Data Geocodes an unformatted address and returns an SDO_GEOR_ADDR object. Geocodes an input address using attributes in an SDO_GEO_ADDR object, and returns the first matched address as an SDO_GEO_ADDR object. Geocodes an input address using attributes in an SDO_GEO_ADDR object, and returns matching addresses as an SDO_ADDR_ARRAY object. Geocodes all addresses associated with an unformatted address and returns the result as an SDO_ADDR_ARRAY object. Geocodes an unformatted address and returns an SDO_GEOMETRY object. Reverse geocodes a location, specified by its spatial geometry object and country, and returns an SDO_GEO_ADDR object. The rest of this chapter provides reference information on the subprograms, listed in alphabetical order. Format SDO_GCDR.GEOCODE( username IN VARCHAR2, addr_lines IN SDO_KEYWORDARRAY, country IN VARCHAR2, match_mode IN VARCHAR2 ) RETURN SDO_GEO_ADDR; Description Geocodes an unformatted address and returns the result as an SDO_GEO_ADDR object. Parameters Name of the user that owns the tables containing the geocoding data. An array of quoted strings representing the unformatted address to be geocoded. The SDO_KEYWORDARRAY type is described in Section 5.2.3. Country name or ISO country code. Match mode for the geocoding operation. Match modes are explained in Section 5.1.2. Usage Notes This function returns an object of type SDO_GEOR_ADDR, which is described in Section 5.2.1. It performs the same operation as the SDO_GCDR.GEOCODE_AS_GEOMETRY function; however, that function returns an SDO_GEOMETRY object. Examples The following example geocodes the address of City Hall in San Francisco, California, using the Format SDO_GCDR.GEOCODE_ADDR( gc_username IN VARCHAR2, address IN SDO_GEO_ADDR ) RETURN SDO_GEO_ADDR; Description Geocodes an input address using attributes in an SDO_GEO_ADDR object, and returns the first matched address as an SDO_GEO_ADDR object. Parameters Name of the user that owns the tables containing the geocoding data. An SDO_GEO_ADDR object with one or more attributes set. The SDO_GEO_ADDR type is described in Section 5.2.1. Usage Notes This function enables you to specify as many attributes in the input SDO_GEO_ADDR object as you can or want to set. It finds the first matching address, and returns an SDO_GEO_ADDR object with all possible attributes set. Unlike the SDO_GCDR.GEOCODE function, which geocodes input addresses specified by unformatted address lines, the SDO_GCDR.GEOCODE_ADDR function input addresses specified by individual addressing fields defined in SDO_GEO_ADDR objects. When you use unformatted address lines, you rely on the geocoding software to parse the input address and decompose it into individual address fields. This process usually works well, but it can produce undesirable results if the input addresses are not well formatted. By contrast, when you specify parts of the input address as SDO_GEO_ADDR object attributes, you can reduce the chance of geocoding errors and produce more desirable results. For examples of the SDO_GCDR.GEOCODE_ADDR function, see Example 52 and Example 53 in Section 5.4. See also the SDO_GCDR.GEOCODE_ADDR_ALL function, which performs the same operation as this function, but which can return more than one address. Examples The following example returns the geocoded result for a point of interest named Format SDO_GCDR.GEOCODE_ADDR_ALL( gc_username IN VARCHAR2, address IN SDO_GEO_ADDR, max_res_num IN NUMBER DEFAULT 4000 ) RETURN SDO_ADDR_ARRAY; Description Geocodes an input address using attributes in an SDO_GEO_ADDR object, and returns matching addresses as an SDO_ADDR_ARRAY object (described in Section 5.2.2). Parameters Name of the user that owns the tables containing the geocoding data. An SDO_GEO_ADDR object with one or more attributes set. The SDO_GEO_ADDR type is described in Section 5.2.1. Maximum number of results to return in the SDO_ADDR_ARRAY object. The default value is 4000. Usage Notes This function enables you to specify as many attributes in the input SDO_GEO_ADDR object as you can or want to set. It finds matching addresses (up to 4000 or the limit specified in the This function performs the same operation as the SDO_GCDR.GEOCODE_ADDR function, except that it can return more than one address. See the Usage Notes for the SDO_GCDR.GEOCODE_ADDR function for more information. Examples The following example returns up to three geocoded results for a point of interest named Format SDO_GCDR.GEOCODE_ALL( gc_username IN VARCHAR2, addr_lines IN SDO_KEYWORDARRAY, country IN VARCHAR2, match_mode IN VARCHAR2 ) RETURN SDO_ADDR_ARRAY; Description Geocodes all addresses associated with an unformatted address and returns the result as an SDO_ADDR_ARRAY object. Parameters Name of the user that owns the tables containing the geocoding data. An array of quoted strings representing the unformatted address to be geocoded. The SDO_KEYWORDARRAY type is described in Section 5.2.3. Country name or ISO country code. Match mode for the geocoding operation. Match modes are explained in Section 5.1.2. Usage Notes This function returns an object of type SDO_ADDR_ARRAY, which is described in Section 5.2.2. It performs the same operation as the SDO_GCDR.GEOCODE function; however, it can return results for multiple addresses, in which case the returned SDO_ADDR_ARRAY object contains multiple SDO_GEO_ADDR objects. If your application needs to select one of the addresses for some further operations, you can use the information about each returned address to help you make that selection. Each SDO_GEO_ADDR object in the returned SDO_ADDR_ARRAY array represents the center point of each street segment that matches the criteria in the Examples The following example returns an array of geocoded results, each result reflecting the center point of Clay Street in all postal codes in San Francisco, California, in which the street extends. The resulting array includes four SDO_GEOR_ADDR objects, each reflecting the house at the center point of the Clay Street segment in each of the four postal codes (94108, 94115, 94118, and 94109) into which Clay Street extends. Format SDO_GCDR.GEOCODE_AS_GEOMETRY( username IN VARCHAR2, addr_lines IN SDO_KEYWORDARRAY, country IN VARCHAR2 ) RETURN SDO_GEOMETRY; Description Geocodes an unformatted address and returns the result as an SDO_GEOMETRY object. Parameters Name of the user that owns the tables containing the geocoding data. An array of quoted strings representing the unformatted address to be geocoded. The SDO_KEYWORDARRAY type is described in Section 5.2.3. Country name or ISO country code. Usage Notes This function returns an object of type SDO_GEOMETRY. It performs the same operation as the SDO_GCDR.GEOCODE function; however, that function returns an SDO_GEOR_ADDR object. This function uses a match mode of Examples The following example geocodes the address of City Hall in San Francisco, California. It returns an SDO_GEOMETRY object in which the longitude and latitude coordinates of this address are 122.41815 and 37.7784183, respectively. Format SDO_GCDR.REVERSE_GEOCODE( username IN VARCHAR2, location IN SDO_GEOMETRY, country IN VARCHAR2 ) RETURN SDO_GEO_ADDR; Description Reverse geocodes a location, specified by its spatial geometry object and country, and returns the result as an SDO_GEO_ADDR object. Parameters Name of the user that owns the tables containing the geocoding data. An SDO_GEOMETRY object that specifies the point location to be reverse geocoded. Country name or ISO country code. Usage Notes This function returns an object of type SDO_GEOR_ADDR, which is described in Section 5.2.1. A spatial index must be created on the table GC_ROAD_SEGMENT_<tablesuffix>. Examples The following example reverse geocodes a point with the longitude and latitude values (122.41815, 37.7784183). For this example, a spatial index was created on the GEOMETRY column in the GC_WORD_SEGMENT_US table. This chapter describes how to load spatial data into a database, including storing the data in a table with a column of type SDO_GEOMETRY. After you have loaded spatial data, you can create a spatial index for it and perform queries on it, as described in Chapter 4. The process of loading data can be classified into two categories: Bulk loading of data (see Section 3.1) This process is used to load large volumes of data into the database and uses the SQL*Loader utility to load the data. Transactional insert operations (see Section 3.2) This process is typically used to insert relatively small amounts of data into the database using the INSERT statement in SQL. Bulk loading can import large amounts of data into an Oracle database. Bulk loading is accomplished with the SQL*Loader utility. (For information about SQL*Loader, see Oracle Database Utilities.) Example 31 is the SQL*Loader control file for loading four geometries. When this control file is used with SQL*Loader, it loads the same cola market geometries that are inserted using SQL statements in Example 21 in Section 2.1. Example 31 Control File for a Bulk Load of Cola Market Geometries Notes on Example 31: The In the data after Example 32 assumes that a table named POLY_4PT was created as follows: Assume that the ASCII data consists of a file with delimited columns and separate rows fixed by the limits of the table with the following format: The coordinates in the GEOMETRY column represent polygons. Example 32 shows the control file for loading the data. Example 32 Control File for a Bulk Load of Polygons Example 33 shows a control file for loading a table with point data. Example 33 Control File for a Bulk Load of PointOnly Data Oracle Spatial uses standard Oracle tables that can be accessed or loaded with standard SQL syntax. This section contains examples of transactional insertions into columns of type SDO_GEOMETRY. This process is typically used to add relatively small amounts of data into the database. The INSERT statement in Oracle SQL has a limit of 999 arguments. Therefore, you cannot create a variablelength array of more than 999 elements using the SDO_GEOMETRY constructor inside a transactional INSERT statement; however, you can insert a geometry using a host variable, and the host variable can be built using the SDO_GEOMETRY constructor with more than 999 values in the SDO_ORDINATE_ARRAY specification. (The host variable is an OCI, PL/SQL, or Java program variable.) To perform transactional insertions of geometries, you can create a procedure to insert a geometry, and then invoke that procedure on each geometry to be inserted. Example 34 creates a procedure to perform the insert operation. Example 34 Procedure to Perform a Transactional Insert Operation Using the procedure created in Example 34, you can insert data by using a PL/SQL block, such as the one in Example 35, which loads a geometry into the variable named Example 35 PL/SQL Block Invoking a Procedure to Insert a Geometry For additional examples with various geometry types, see the following: Rectangle: Example 24 in Section 2.5.1 Polygon with a hole: Example 25 in Section 2.5.2 Compound line string: Example 26 in Section 2.5.3 Compound polygon: Example 27 in Section 2.5.4 Point: Example 28 and Example 29 in Section 2.5.5 Oriented point: Example 210 in Section 2.5.6 Type 0 (zero) element: Example 212 in Section 2.5.7 The MDSYS.SDO_LRS package contains subprograms that create, modify, query, and convert linear referencing elements. These subprograms do not change the state of the database. Most LRS subprograms are functions. To use the subprograms in this chapter, you must understand the linear referencing system (LRS) concepts and techniques described in Chapter 7. Table 161 lists subprograms related to creating and editing geometric segments. Table 161 Subprograms for Creating and Editing Geometric Segments Defines a geometric segment. Populates the measures of all shape points of a geometric segment based on the start and end measures, overriding any previously assigned measures between the start point and end point. Clips a geometric segment (synonym of SDO_LRS.DYNAMIC_SEGMENT). Clips a geometric segment (synonym of SDO_LRS.CLIP_GEOM_SEGMENT). SDO_LRS.CONCATENATE_GEOM_SEGMENTS Concatenates two geometric segments into one segment. Returns an LRS geometry object that is the topological intersection (AND operation) of two geometry objects where one or both are LRS geometries. Returns the geometric segment at a specified offset from a geometric segment. Splits a geometric segment into two segments. Sets all measures of a geometric segment, including the start and end measures, to null values, overriding any previously assigned measures. Sets the measure value of a specified point. Returns a new geometric segment by reversing the measure values, but not the direction, of the original geometric segment. Returns a new geometric segment by translating the original geometric segment (that is, shifting the start and end measures by a specified value). Returns a new geometric segment by reversing the measure values and the direction of the original geometric segment. Table 162 lists subprograms related to querying geometric segments. Table 162 Subprograms for Querying and Validating Geometric Segments Checks if a geometric segment is valid. Checks if an LRS point is valid. Checks if a measure falls within the measure range of a geometric segment. SDO_LRS.CONNECTED_GEOM_SEGMENTS Checks if two geometric segments are spatially connected. Returns the length of a geometric segment. Returns the start point of a geometric segment. Returns the end point of a geometric segment. SDO_LRS.GEOM_SEGMENT_START_MEASURE Returns the start measure of a geometric segment. SDO_LRS.GEOM_SEGMENT_END_MEASURE Returns the end measure of a geometric segment. Returns the measure of an LRS point. Returns the next shape point on a geometric segment after a specified measure value or LRS point. SDO_LRS.GET_NEXT_SHAPE_PT_MEASURE Returns the measure value of the next shape point on a geometric segment after a specified measure value or LRS point. Returns the previous shape point on a geometric segment before a specified measure value or LRS point. SDO_LRS.GET_PREV_SHAPE_PT_MEASURE Returns the measure value of the previous shape point on a geometric segment before a specified measure value or LRS point. SDO_LRS.IS_GEOM_SEGMENT_DEFINED Checks if an LRS segment is defined correctly. Checks if the measure values along an LRS segment are decreasing (that is, descending in numerical value). Checks if the measure values along an LRS segment are increasing (that is, ascending in numerical value). Checks if a specified measure value is associated with a shape point on a geometric segment. Returns the measure range of a geometric segment, that is, the difference between the start measure and end measure. Returns the percentage (0 to 100) that a specified measure is of the measure range of a geometric segment. Returns the measure value of a specified percentage (0 to 100) of the measure range of a geometric segment. Returns the point located at a specified distance from the start of a geometric segment. Returns the projection point of a specified point. The projection point is on the geometric segment. Returns the position of the measure dimension within the SDO_DIM_ARRAY structure for a specified SDO_GEOMETRY column. Returns the measure of the closest point on a segment to a specified projection point. Returns the signed offset (shortest distance) from a point to a geometric segment. Checks if an LRS geometry is valid. Table 163 lists subprograms related to converting geometric segments. Table 163 Subprograms for Converting Geometric Segments SDO_LRS.CONVERT_TO_LRS_DIM_ARRAY Converts a standard dimensional array to an LRS dimensional array by creating a measure dimension. Converts a standard SDO_GEOMETRY line string to an LRS geometric segment by adding measure information. Converts all geometry objects in a column of type SDO_GEOMETRY from standard line string geometries without measure information to LRS geometric segments with measure information, and updates the metadata. SDO_LRS.CONVERT_TO_STD_DIM_ARRAY Converts an LRS dimensional array to a standard dimensional array by removing the measure dimension. Converts an LRS geometric segment to a standard SDO_GEOMETRY line string by removing measure information. Converts all geometry objects in a column of type SDO_GEOMETRY from LRS geometric segments with measure information to standard line string geometries without measure information, and updates the metadata. For more information about conversion subprograms, see Section 7.5.10. The rest of this chapter provides reference information on the subprograms, listed in alphabetical order. Format SDO_LRS.CLIP_GEOM_SEGMENT( geom_segment IN SDO_GEOMETRY, start_measure IN NUMBER, end_measure IN NUMBER, tolerance IN NUMBER DEFAULT 1.0e8 ) RETURN SDO_GEOMETRY; or SDO_LRS.CLIP_GEOM_SEGMENT( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, start_measure IN NUMBER, end_measure IN NUMBER ) RETURN SDO_GEOMETRY; Description Returns the geometry object resulting from a clip operation on a geometric segment. Note: Parameters Cartographic representation of a linear feature. Dimensional information array corresponding to Start measure of the geometric segment. End measure of the geometric segment. Tolerance value (see Section 1.5.5 and Section 7.6). The default value is 0.00000001. Usage Notes An exception is raised if The direction and measures of the resulting geometric segment are preserved (that is, they reflect the original segment). The _3D format of this function (SDO_LRS.CLIP_GEOM_SEGMENT_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. For more information about clipping geometric segments, see Section 7.5.3. Examples The following example clips the geometric segment representing Route 1, returning the segment from measures 5 through 10. This segment might represent a construction zone. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.CONCATENATE_GEOM_SEGMENTS( geom_segment_1 IN SDO_GEOMETRY, geom_segment_2 IN SDO_GEOMETRY, tolerance IN NUMBER DEFAULT 1.0e8 ) RETURN SDO_GEOMETRY; or SDO_LRS.CONCATENATE_GEOM_SEGMENTS( geom_segment_1 IN SDO_GEOMETRY, dim_array_1 IN SDO_DIM_ARRAY, geom_segment_2 IN SDO_GEOMETRY, dim_array_2 IN SDO_DIM_ARRAY ) RETURN SDO_GEOMETRY; Description Returns the geometry object resulting from the concatenation of two geometric segments. Parameters First geometric segment to be concatenated. Dimensional information array corresponding to Second geometric segment to be concatenated. Dimensional information array corresponding to Tolerance value (see Section 1.5.5 and Section 7.6). The default value is 0.00000001. Usage Notes An exception is raised if The direction of the first geometric segment is preserved, and all measures of the second segment are shifted so that its start measure is the same as the end measure of the first segment. The geometry type of The _3D format of this function (SDO_LRS.CONCATENATE_GEOM_SEGMENTS_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. For more information about concatenating geometric segments, see Section 7.5.5. Examples The following example defines the geometric segment, splits it into two segments, then concatenates those segments. (This example uses the definitions from the example in Section 7.7. The definitions of Format SDO_LRS.CONNECTED_GEOM_SEGMENTS( geom_segment_1 IN SDO_GEOMETRY, geom_segment_2 IN SDO_GEOMETRY, tolerance IN NUMBER DEFAULT 1.0e8 ) RETURN VARCHAR2; or SDO_LRS.CONNECTED_GEOM_SEGMENTS( geom_segment_1 IN SDO_GEOMETRY, dim_array_1 IN SDO_DIM_ARRAY, geom_segment_2 IN SDO_GEOMETRY, dim_array_2 IN SDO_DIM_ARRAY ) RETURN VARCHAR2; Description Checks if two geometric segments are spatially connected. Parameters First of two geometric segments to be checked. Dimensional information array corresponding to Second of two geometric segments to be checked. Dimensional information array corresponding to Tolerance value (see Section 1.5.5 and Section 7.6). The default value is 0.00000001. Usage Notes This function returns TRUE if the geometric segments are spatially connected and FALSE if the geometric segments are not spatially connected. An exception is raised if The _3D format of this function (SDO_LRS.CONNECTED_GEOM_SEGMENTS_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example checks if two geometric segments (results of a previous split operation) are spatially connected. Format SDO_LRS.CONVERT_TO_LRS_DIM_ARRAY( dim_array IN SDO_DIM_ARRAY [, lower_bound IN NUMBER, upper_bound IN NUMBER, tolerance IN NUMBER] ) RETURN SDO_DIM_ARRAY; or SDO_LRS.CONVERT_TO_LRS_DIM_ARRAY( dim_array IN SDO_DIM_ARRAY, dim_name IN VARCHAR2 [, lower_bound IN NUMBER, upper_bound IN NUMBER, tolerance IN NUMBER] ) RETURN SDO_DIM_ARRAY; or SDO_LRS.CONVERT_TO_LRS_DIM_ARRAY( dim_array IN SDO_DIM_ARRAY, dim_name IN VARCHAR2, dim_pos IN INTEGER [, lower_bound IN NUMBER, upper_bound IN NUMBER, tolerance IN NUMBER] ) RETURN SDO_DIM_ARRAY; Description Converts a standard dimensional array to an LRS dimensional array by creating a measure dimension. Parameters Dimensional information array corresponding to the layer (column of geometries) to be converted, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6). Name of the measure dimension ( Position of the measure dimension (the last SDO_DIM_ELEMENT object position in the SDO_DIM_ARRAY, if not otherwise specified). Lower bound (SDO_LB value in the SDO_DIM_ELEMENT definition) of the ordinate in the measure dimension. Upper bound (SDO_UB value in the SDO_DIM_ELEMENT definition) of the ordinate in the measure dimension. Tolerance value (see Section 1.5.5 and Section 7.6). The default value is 0.00000001. Usage Notes This function converts a standard dimensional array to an LRS dimensional array by creating a measure dimension. Specifically, it adds an SDO_DIM_ELEMENT object at the end of the current SDO_DIM_ELEMENT objects in the SDO_DIM_ARRAY for the dimensional array (unless another If The _3D format of this function (SDO_LRS.CONVERT_TO_LRS_DIM_ARRAY_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. For more information about conversion functions, see Section 7.5.10. Examples The following example converts the dimensional array for the LRS_ROUTES table to LRS format. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.CONVERT_TO_LRS_GEOM( standard_geom IN SDO_GEOMETRY [, start_measure IN NUMBER, end_measure IN NUMBER] ) RETURN SDO_GEOMETRY; or SDO_LRS.CONVERT_TO_LRS_GEOM( standard_geom IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY [, start_measure IN NUMBER, end_measure IN NUMBER] ) RETURN SDO_GEOMETRY; or SDO_LRS.CONVERT_TO_LRS_GEOM( standard_geom IN SDO_GEOMETRY, m_pos IN INTEGER [, start_measure IN NUMBER, end_measure IN NUMBER] ) RETURN SDO_GEOMETRY; Description Converts a standard SDO_GEOMETRY line string to an LRS geometric segment by adding measure information. Parameters Line string geometry that does not contain measure information. Dimensional information array corresponding to Position of the measure dimension. If specified, must be 3 or 4. By default, the measure dimension is the last dimension in the SDO_DIM_ARRAY. Distance measured from the start point of a geometric segment to the start point of the linear feature. The default is 0. Distance measured from the end point of a geometric segment to the start point of the linear feature. The default is the cartographic length (for example, 75 if the cartographic length is 75 and the unit of measure is miles). Usage Notes This function returns an LRS geometric segment with measure information, with measure information provided for all shape points. An exception is raised if The _3D format of this function (SDO_LRS.CONVERT_TO_LRS_GEOM_3D) is available; however, the For more information about conversion functions, see Section 7.5.10. Examples The following example converts the geometric segment representing Route 1 to LRS format. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.CONVERT_TO_LRS_LAYER( table_name IN VARCHAR2, column_name IN VARCHAR2 [, lower_bound IN NUMBER, upper_bound IN NUMBER, tolerance IN NUMBER] ) RETURN VARCHAR2; or SDO_LRS.CONVERT_TO_LRS_LAYER( table_name IN VARCHAR2, column_name IN VARCHAR2, dim_name IN VARCHAR2, dim_pos IN INTEGER [, lower_bound IN NUMBER, upper_bound IN NUMBER, tolerance IN NUMBER] ) RETURN VARCHAR2; Description Converts all geometry objects in a column of type SDO_GEOMETRY (that is, converts a layer) from standard line string geometries without measure information to LRS geometric segments with measure information, and updates the metadata in the USER_SDO_GEOM_METADATA view. Parameters Table containing the column with the SDO_GEOMETRY objects. Column in Name of the measure dimension. If this parameter is null, Position of the measure dimension within the SDO_DIM_ARRAY structure for the specified SDO_GEOMETRY column. If this parameter is null, the number corresponding to the last position is assumed. Lower bound (SDO_LB value in the SDO_DIM_ELEMENT definition) of the ordinate in the measure dimension. Upper bound (SDO_UB value in the SDO_DIM_ELEMENT definition) of the ordinate in the measure dimension. Tolerance value (see Section 1.5.5 and Section 7.6). The default value is 0.00000001. Usage Notes This function returns TRUE if the conversion was successful or if the layer already contains measure information, and the function returns an exception if the conversion was not successful. An exception is raised if the existing dimensional information for the table is invalid. The measure values are assigned based on a start measure of zero and an end measure of the cartographic length. If a spatial index already exists on The _3D format of this function (SDO_LRS.CONVERT_TO_LRS_LAYER_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. For more information about conversion functions, see Section 7.5.10. Examples The following example converts the geometric segments in the ROUTE_GEOMETRY column of the LRS_ROUTES table to LRS format. (This example uses the definitions from the example in Section 7.7.) The SELECT statement shows that dimensional information has been added (that is, Format SDO_LRS.CONVERT_TO_STD_DIM_ARRAY( dim_array IN SDO_DIM_ARRAY [, m_pos IN INTEGER] ) RETURN SDO_DIM_ARRAY; Description Converts an LRS dimensional array to a standard dimensional array by removing the measure dimension. Parameters Dimensional information array corresponding to the layer (column of geometries) to be converted, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6). Position of the measure dimension. If specified, must be 3 or 4. By default, the measure dimension is the last dimension in the SDO_DIM_ARRAY. Usage Notes This function converts an LRS dimensional array to a standard dimensional array by removing the measure dimension. Specifically, it removes the SDO_DIM_ELEMENT object at the end of the current SDO_DIM_ELEMENT objects in the SDO_DIM_ARRAY for the An exception is raised if If The _3D format of this function (SDO_LRS.CONVERT_TO_STD_DIM_ARRAY_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. For more information about conversion functions, see Section 7.5.10. Examples The following example converts the dimensional array for the LRS_ROUTES table to standard format. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.CONVERT_TO_STD_GEOM( lrs _geom IN SDO_GEOMETRY [, dim_array IN SDO_DIM_ARRAY] ) RETURN SDO_GEOMETRY; Description Converts an LRS geometric segment to a standard SDO_GEOMETRY line string by removing measure information. Parameters LRS geometry that contains measure information. Dimensional information array corresponding to Usage Notes This function returns an SDO_GEOMETRY object in which all measure information is removed. The _3D format of this function (SDO_LRS.CONVERT_TO_STD_GEOM_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. For more information about conversion functions, see Section 7.5.10. Examples The following example converts the geometric segment representing Route 1 to standard format. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.CONVERT_TO_STD_LAYER( table_name IN VARCHAR2, column_name IN VARCHAR2 ) RETURN VARCHAR2; Description Converts all geometry objects in a column of type SDO_GEOMETRY (that is, converts a layer) from LRS geometric segments with measure information to standard line string geometries without measure information, and updates the metadata in the USER_SDO_GEOM_METADATA view. Parameters Table containing the column with the SDO_GEOMETRY objects. Column in Usage Notes This function returns TRUE if the conversion was successful or if the layer already is a standard layer (that is, contains geometries without measure information), and the function returns an exception if the conversion was not successful. If a spatial index already exists on The _3D format of this function (SDO_LRS.CONVERT_TO_STD_LAYER_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. For more information about conversion functions, see Section 7.5.10. Examples The following example converts the geometric segments in the ROUTE_GEOMETRY column of the LRS_ROUTES table to standard format. (This example uses the definitions from the example in Section 7.7.) The SELECT statement shows that dimensional information has been removed (that is, no Format SDO_LRS.DEFINE_GEOM_SEGMENT( geom_segment IN OUT SDO_GEOMETRY [, start_measure IN NUMBER, end_measure IN NUMBER]); or SDO_LRS.DEFINE_GEOM_SEGMENT( geom_segment IN OUT SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY [, start_measure IN NUMBER, end_measure IN NUMBER]); Description Defines a geometric segment by assigning start and end measures to a geometric segment, and assigns values to any null measures. Parameters Cartographic representation of a linear feature. Dimensional information array corresponding to Distance measured from the start point of a geometric segment to the start point of the linear feature. The default is the existing value (if any) in the measure dimension; otherwise, the default is 0. Distance measured from the end point of a geometric segment to the start point of the linear feature. The default is the existing value (if any) in the measure dimension; otherwise, the default is the cartographic length of the segment. Usage Notes An exception is raised if All unassigned measures of the geometric segment will be populated automatically. To store the resulting geometric segment ( The _3D format of this procedure (SDO_LRS.DEFINE_GEOM_SEGMENT_3D) is available. For information about _3D formats of LRS functions and procedures, see Section 7.4. For more information about defining a geometric segment, see Section 7.5.1. Examples The following example defines the geometric segment, splits it into two segments, then concatenates those segments. (This example uses the definitions from the example in Section 7.7. The definitions of Format SDO_LRS.DYNAMIC_SEGMENT( geom_segment IN SDO_GEOMETRY, start_measure IN NUMBER, end_measure IN NUMBER, tolerance IN NUMBER DEFAULT 1.0e8 ) RETURN SDO_GEOMETRY; or SDO_LRS.DYNAMIC_SEGMENT( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, start_measure IN NUMBER, end_measure IN NUMBER ) RETURN SDO_GEOMETRY; Description Returns the geometry object resulting from a clip operation on a geometric segment. Note: Parameters Cartographic representation of a linear feature. Dimensional information array corresponding to Start measure of the geometric segment. End measure of the geometric segment. Tolerance value (see Section 1.5.5 and Section 7.6). The default value is 0.00000001. Usage Notes An exception is raised if The direction and measures of the resulting geometric segment are preserved. For more information about clipping a geometric segment, see Section 7.5.3. Examples The following example clips the geometric segment representing Route 1, returning the segment from measures 5 through 10. This segment might represent a construction zone. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.FIND_LRS_DIM_POS( table_name IN VARCHAR2, column_name IN VARCHAR2 ) RETURN INTEGER; Description Returns the position of the measure dimension within the SDO_DIM_ARRAY structure for a specified SDO_GEOMETRY column. Parameters Table containing the column with the SDO_GEOMETRY objects. Column in Usage Notes None. Examples The following example returns the position of the measure dimension within the SDO_DIM_ARRAY structure for geometries in the ROUTE_GEOMETRY column of the LRS_ROUTES table. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.FIND_MEASURE( geom_segment IN SDO_GEOMETRY, point IN SDO_GEOMETRY ) RETURN NUMBER; or SDO_LRS.FIND_MEASURE( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, point IN SDO_GEOMETRY ) RETURN NUMBER; Description Returns the measure of the closest point on a segment to a specified projection point. Parameters Cartographic representation of a linear feature. This function returns the measure of the point on this segment that is closest to the projection point. Dimensional information array corresponding to Projection point. This function returns the measure of the point on Usage Notes This function returns the measure of the point on An exception is raised if The _3D format of this function (SDO_LRS.FIND_MEASURE_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example finds the measure for the point on the geometric segment representing Route 1 that is closest to the point (10, 7). (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.FIND_OFFSET( geom_segment IN SDO_GEOMETRY, point IN SDO_GEOMETRY, tolerance IN NUMBER DEFAULT 1.0e8 ) RETURN NUMBER; or SDO_LRS.FIND_OFFSET( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, point IN SDO_GEOMETRY [, point_dim_array IN SDO_GEOMETRY] ) RETURN NUMBER; Description Returns the signed offset (shortest distance) from a point to a geometric segment. Parameters Geometric segment to be checked for distance from Point whose shortest distance from Tolerance value (see Section 1.5.5 and Section 7.6). The default value is 0.00000001. Dimensional information array corresponding to Dimensional information array corresponding to Usage Notes This function calls the SDO_LRS.PROJECT_PT function format that includes the An exception is raised if For more information about offsets to a geometric segment, see Section 7.1.5. Examples The following example returns the offset of point (9,3,NULL) from the geometric segment representing Route 1. (This example uses the definitions from the example in Section 7.7.) As you can see from Figure 720 in Section 7.7, the point at (9,3,NULL) is on the right side along the segment, and therefore the offset has a negative value, as explained in Section 7.1.5. The point at (9,3.NULL) is one distance unit away from the point at (9,4,NULL), which is on the segment. Format SDO_LRS.GEOM_SEGMENT_END_MEASURE( geom_segment IN SDO_GEOMETRY [, dim_array IN SDO_DIM_ARRAY] ) RETURN NUMBER; Description Returns the end measure of a geometric segment. Parameters Geometric segment whose end measure is to be returned. Dimensional information array corresponding to Usage Notes This function returns the end measure of An exception is raised if The _3D format of this function (SDO_LRS.GEOM_SEGMENT_END_MEASURE_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example returns the end measure of the geometric segment representing Route 1. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.GEOM_SEGMENT_END_PT( geom_segment IN SDO_GEOMETRY [, dim_array IN SDO_DIM_ARRAY] ) RETURN SDO_GEOMETRY; Description Returns the end point of a geometric segment. Parameters Geometric segment whose end point is to be returned. Dimensional information array corresponding to Usage Notes This function returns the end point of An exception is raised if The _3D format of this function (SDO_LRS.GEOM_SEGMENT_END_PT_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example returns the end point of the geometric segment representing Route 1. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.GEOM_SEGMENT_LENGTH( geom_segment IN SDO_GEOMETRY [, dim_array IN SDO_DIM_ARRAY] ) RETURN NUMBER; Description Returns the length of a geometric segment. Parameters Geometric segment whose length is to be calculated. Dimensional information array corresponding to Usage Notes This function returns the length of An exception is raised if The _3D format of this function (SDO_LRS.GEOM_SEGMENT_LENGTH_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example returns the length of the geometric segment representing Route 1. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.GEOM_SEGMENT_START_MEASURE( geom_segment IN SDO_GEOMETRY [, dim_array IN SDO_DIM_ARRAY] ) RETURN NUMBER; Description Returns the start measure of a geometric segment. Parameters Geometric segment whose start measure is to be returned. Dimensional information array corresponding to Usage Notes This function returns the start measure of An exception is raised if The _3D format of this function (SDO_LRS.GEOM_SEGMENT_START_MEASURE_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example returns the start measure of the geometric segment representing Route 1. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.GEOM_SEGMENT_START_PT( geom_segment IN SDO_GEOMETRY [, dim_array IN SDO_DIM_ARRAY] ) RETURN SDO_GEOMETRY; Description Returns the start point of a geometric segment. Parameters Geometric segment whose start point is to be returned. Dimensional information array corresponding to Usage Notes This function returns the start point of An exception is raised if The _3D format of this function (SDO_LRS.GEOM_SEGMENT_START_PT_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example returns the start point of the geometric segment representing Route 1. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.GET_MEASURE( point IN SDO_GEOMETRY [, dim_array IN SDO_DIM_ARRAY] ) RETURN NUMBER; Description Returns the measure of an LRS point. Parameters Point whose measure is to be returned. Dimensional information array corresponding to Usage Notes This function returns the measure of an LRS point. If Contrast this function with SDO_LRS.PROJECT_PT, which accepts as input a point that is not necessarily on the geometric segment, but which returns a point that is on the geometric segment, as opposed to a measure value. As the following example shows, the SDO_LRS.GET_MEASURE function can be used to return the measure of the projected point returned by SDO_LRS.PROJECT_PT. The _3D format of this function (SDO_LRS.GET_MEASURE_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example returns the measure of a projected point. In this case, the point resulting from the projection is 9 units from the start of the segment. Format SDO_LRS.GET_NEXT_SHAPE_PT( geom_segment IN SDO_GEOMETRY, measure IN NUMBER ) RETURN SDO_GEOMETRY; or SDO_LRS.GET_NEXT_SHAPE_PT( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, measure IN NUMBER ) RETURN SDO_GEOMETRY; or SDO_LRS.GET_NEXT_SHAPE_PT( geom_segment IN SDO_GEOMETRY, point IN SDO_GEOMETRY ) RETURN SDO_GEOMETRY; or SDO_LRS.GET_NEXT_SHAPE_PT( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, point IN SDO_GEOMETRY ) RETURN SDO_GEOMETRY; Description Returns the next shape point on a geometric segment after a specified measure value or LRS point. Parameters Geometric segment. Measure value on the geometric segment for which to return the next shape point. Point for which to return the next shape point. If Dimensional information array corresponding to Usage Notes If An exception is raised if Contrast this function with SDO_LRS.GET_PREV_SHAPE_PT, which returns the previous shape point on a geometric segment before a specified measure value or LRS point. The _3D format of this function (SDO_LRS.GET_NEXT_SHAPE_PT_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example returns the next shape point after measure 14 on the geometric segment representing Route 1. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.GET_NEXT_SHAPE_PT_MEASURE( geom_segment IN SDO_GEOMETRY, measure IN NUMBER ) RETURN NUMBER; or SDO_LRS.GET_NEXT_SHAPE_PT_MEASURE( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, measure IN NUMBER ) RETURN NUMBER; or SDO_LRS.GET_NEXT_SHAPE_PT_MEASURE( geom_segment IN SDO_GEOMETRY, point IN SDO_GEOMETRY ) RETURN NUMBER; or SDO_LRS.GET_NEXT_SHAPE_PT_MEASURE( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, point IN SDO_GEOMETRY ) RETURN NUMBER; Description Returns the measure value of the next shape point on a geometric segment after a specified measure value or LRS point. Parameters Geometric segment. Measure value on the geometric segment for which to return the measure value of the next shape point. Point for which to return the measure value of the next shape point. If Dimensional information array corresponding to Usage Notes If An exception is raised if Contrast this function with SDO_LRS.GET_PREV_SHAPE_PT_MEASURE, which returns the measure value of the previous shape point on a geometric segment before a specified measure value or LRS point. The _3D format of this function (SDO_LRS.GET_NEXT_SHAPE_PT_MEASURE_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example returns the measure value of the next shape point after measure 14 on the geometric segment representing Route 1. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.GET_PREV_SHAPE_PT( geom_segment IN SDO_GEOMETRY, measure IN NUMBER ) RETURN SDO_GEOMETRY; or SDO_LRS.GET_PREV_SHAPE_PT( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, measure IN NUMBER ) RETURN SDO_GEOMETRY; or SDO_LRS.GET_PREV_SHAPE_PT( geom_segment IN SDO_GEOMETRY, point IN SDO_GEOMETRY ) RETURN SDO_GEOMETRY; or SDO_LRS.GET_PREV_SHAPE_PT( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, point IN SDO_GEOMETRY ) RETURN SDO_GEOMETRY; Description Returns the previous shape point on a geometric segment before a specified measure value or LRS point. Parameters Geometric segment. Measure value on the geometric segment for which to return the previous shape point. Point for which to return the previous shape point. If Dimensional information array corresponding to Usage Notes If An exception is raised if Contrast this function with SDO_LRS.GET_NEXT_SHAPE_PT, which returns the next shape point on a geometric segment after a specified measure value or LRS point. The _3D format of this function (SDO_LRS.GET_PREV_SHAPE_PT_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example returns the closest shape point to measure 14 and before measure 14 on the geometric segment representing Route 1. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.GET_PREV_SHAPE_PT_MEASURE( geom_segment IN SDO_GEOMETRY, measure IN NUMBER ) RETURN NUMBER; or SDO_LRS.GET_PREV_SHAPE_PT_MEASURE( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, measure IN NUMBER ) RETURN NUMBER; or SDO_LRS.GET_PREV_SHAPE_PT_MEASURE( geom_segment IN SDO_GEOMETRY, point IN SDO_GEOMETRY ) RETURN NUMBER; or SDO_LRS.GET_PREV_SHAPE_PT_MEASURE( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, point IN SDO_GEOMETRY ) RETURN NUMBER; Description Returns the measure value of the previous shape point on a geometric segment before a specified measure value or LRS point. Parameters Geometric segment. Measure value on the geometric segment for which to return the measure value of the previous shape point. Point for which to return the measure value of the previous shape point. If Dimensional information array corresponding to Usage Notes If An exception is raised if Contrast this function with SDO_LRS.GET_NEXT_SHAPE_PT_MEASURE, which returns the measure value of the next shape point on a geometric segment after a specified measure value or LRS point. The _3D format of this function (SDO_LRS.GET_PREV_SHAPE_PT_MEASURE_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example returns the measure value of the closest shape point to measure 14 and before measure 14 on the geometric segment representing Route 1. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.IS_GEOM_SEGMENT_DEFINED( geom_segment IN SDO_GEOMETRY [, dim_array IN SDO_DIM_ARRAY] ) RETURN VARCHAR2; Description Checks if an LRS segment is defined correctly. Parameters Geometric segment to be checked. Dimensional information array corresponding to Usage Notes This function returns TRUE if The start and end measures of The _3D format of this function (SDO_LRS.IS_GEOM_SEGMENT_DEFINED_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. See also the SDO_LRS.VALID_GEOM_SEGMENT function. Examples The following example checks if the geometric segment representing Route 1 is defined. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.IS_MEASURE_DECREASING( geom_segment IN SDO_GEOMETRY [, dim_array IN SDO_DIM_ARRAY] ) RETURN VARCHAR2; Description Checks if the measure values along an LRS segment are decreasing (that is, descending in numerical value). Parameters Geometric segment to be checked. Dimensional information array corresponding to Usage Notes This function returns TRUE if the measure values along an LRS segment are decreasing and FALSE if the measure values along an LRS segment are not decreasing. The start and end measures of The _3D format of this function (SDO_LRS.IS_MEASURE_DECREASING_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. See also the SDO_LRS.IS_MEASURE_INCREASING function. Examples The following example checks if the measure values along the geometric segment representing Route 1 are decreasing. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.IS_MEASURE_INCREASING( geom_segment IN SDO_GEOMETRY [, dim_array IN SDO_DIM_ARRAY] ) RETURN VARCHAR2; Description Checks if the measure values along an LRS segment are increasing (that is, ascending in numerical value). Parameters Geometric segment to be checked. Dimensional information array corresponding to Usage Notes This function returns TRUE if the measure values along an LRS segment are increasing and FALSE if the measure values along an LRS segment are not increasing. The start and end measures of The _3D format of this function (SDO_LRS.IS_MEASURE_INCREASING_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. See also the SDO_LRS.IS_MEASURE_DECREASING function. Examples The following example checks if the measure values along the geometric segment representing Route 1 are increasing. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.IS_SHAPE_PT_MEASURE( geom_segment IN SDO_GEOMETRY, measure IN NUMBER ) RETURN VARCHAR2; or SDO_LRS.IS_SHAPE_PT_MEASURE( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, measure IN NUMBER ) RETURN VARCHAR2; Description Checks if a specified measure value is associated with a shape point on a geometric segment. Parameters Geometric segment to be checked. Measure value on the geometric segment to check if it is a shape point. Dimensional information array corresponding to Usage Notes This function returns TRUE if the specified measure value is associated with a shape point and FALSE if the measure value is not associated with a shape point. An exception is raised if The _3D format of this function (SDO_LRS.IS_SHAPE_PT_MEASURE_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example checks if measure 14 on the geometric segment representing Route 1 is a shape point. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.LOCATE_PT( geom_segment IN SDO_GEOMETRY, measure IN NUMBER [, offset IN NUMBER ) RETURN SDO_GEOMETRY; or SDO_LRS.LOCATE_PT( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, measure IN NUMBER [, offset IN NUMBER] ) RETURN SDO_GEOMETRY; Description Returns the point located at a specified distance from the start of a geometric segment. Parameters Geometric segment to be checked to see if it falls within the measure range of Dimensional information array corresponding to Distance to measure from the start point of Distance to measure perpendicularly from the point that is located at Usage Notes This function returns the referenced point. For example, on a highway, the point might represent the location of an accident. The unit of measurement for With geodetic data using the WGS 84 coordinate system, this function can be used to return the longitude and latitude coordinates of any point on or offset from the segment. An exception is raised if The _3D format of this function (SDO_LRS.LOCATE_PT_3D) is available; however, the For more information about locating a point on a geometric segment, see Section 7.5.8. Examples The following example creates a table for automobile accident data, inserts a record for an accident at the point at measure 9 and on (that is, offset 0) the geometric segment representing Route 1, and displays the data. (The accident table is deliberately oversimplified. This example also uses the route definition from the example in Section 7.7.) Format SDO_LRS.LRS_INTERSECTION( geom_1 IN SDO_GEOMETRY, dim_array_1 IN SDO_DIM_ARRAY, geom_2 IN SDO_GEOMETRY, dim_array_2 IN SDO_DIM_ARRAY ) RETURN SDO_GEOMETRY; or SDO_LRS.LRS_INTERSECTION( geom_1 IN SDO_GEOMETRY, geom_2 IN SDO_GEOMETRY, tolerance IN NUMBER ) RETURN SDO_GEOMETRY; Description Returns an LRS geometry object that is the topological intersection (AND operation) of two geometry objects where one or both are LRS geometries. Parameters Geometry object. Dimensional information array corresponding to Geometry object. Dimensional information array corresponding to Tolerance value (see Section 1.5.5). Usage Notes Note: This function performs essentially the same intersection operation as the SDO_GEOM.SDO_INTERSECTION function (described in Chapter 15), except that SDO_LRS.LRS_INTERSECTION is designed to return a valid LRS geometry (point, line string, or multiline string) where one or both of the geometryrelated input parameters are LRS geometries. (If neither input geometry is an LRS geometry, this function operates the same as the SDO_GEOM.SDO_INTERSECTION function.). The returned geometry is an LRS line string, multiline string, or point geometry that includes measure dimension information. The measure values reflect those in the first LRS geometry specified as an input parameter. The first LRS geometry specified as an input parameter must not be a polygon; it must be a line string, multiline string, or point. If an LRS line string (geometric segment) intersects a line string (LRS or standard), the result is an LRS point; if an LRS line string intersects a polygon, the result is an LRS line string. If the function format with An exception is raised if Examples The following example shows an LRS geometric segment (illustrated in Figure 720 in Section 7.7) intersected by a vertical line from (8,2) to (8,6). The result is an LRS point geometry, in which the measure value (8) reflects the measure for that point (designated as Exit 3 in Figure 720) in the The following example shows an LRS geometric segment (illustrated in Figure 720 in Section 7.7) intersected by a vertical line from (12,2) to (12,6). The result is an LRS line string geometry, in which the measure values (12 and 14) reflect measures for points (the first of which is designated as Exit 4 in Figure 720) in the Format SDO_LRS.MEASURE_RANGE( geom_segment IN SDO_GEOMETRY [, dim_array IN SDO_DIM_ARRAY] ) RETURN NUMBER; Description Returns the measure range of a geometric segment, that is, the difference between the start measure and end measure. Parameters Cartographic representation of a linear feature. Dimensional information array corresponding to Usage Notes This function subtracts the start measure of The _3D format of this function (SDO_LRS.MEASURE_RANGE_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example returns the measure range of the geometric segment representing Route 1. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.MEASURE_TO_PERCENTAGE( geom_segment IN SDO_GEOMETRY, measure IN NUMBER ) RETURN NUMBER; or SDO_LRS.MEASURE_TO_PERCENTAGE( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, measure IN NUMBER ) RETURN NUMBER; Description Returns the percentage (0 to 100) that a specified measure is of the measure range of a geometric segment. Parameters Cartographic representation of a linear feature. Dimensional information array corresponding to Measure value. This function returns the percentage that this measure value is of the measure range. Usage Notes This function returns a number (0 to 100) that is the percentage of the measure range that the specified measure represents. (The measure range is the end measure minus the start measure.) For example, if the measure range of This function performs the reverse of the SDO_LRS.PERCENTAGE_TO_MEASURE function, which returns the measure that corresponds to a percentage value. An exception is raised if Examples The following example returns the percentage that 5 is of the measure range of the geometric segment representing Route 1. (This example uses the definitions from the example in Section 7.7.) The measure range of this segment is 27, and 5 is approximately 18.5 percent of 27. Format SDO_LRS.OFFSET_GEOM_SEGMENT( geom_segment IN SDO_GEOMETRY, start_measure IN NUMBER, end_measure IN NUMBER, offset IN NUMBER, tolerance IN NUMBER DEFAULT 1.0e8 [, unit IN VARCHAR2] ) RETURN SDO_GEOMETRY; or SDO_LRS.OFFSET_GEOM_SEGMENT( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, start_measure IN NUMBER, end_measure IN NUMBER, offset IN NUMBER [, unit IN VARCHAR2] ) RETURN SDO_GEOMETRY; Description Returns the geometric segment at a specified offset from a geometric segment. Parameters Cartographic representation of a linear feature. Dimensional information array corresponding to Start measure of End measure of Distance to measure perpendicularly from the points along Tolerance value (see Section 1.5.5 and Section 7.6). The default value is 0.00000001. Unit of measurement specification: a quoted string with one or both of the following keywords: For example: 'unit=km arc_tolerance=0.05' If the input geometry is geodetic data, this parameter is required, and If this parameter is not specified for a Cartesian or projected geometry, or if the Usage Notes The direction and measures of the resulting geometric segment are preserved (that is, they reflect the original segment). The geometry type of An exception is raised if Examples The following example returns the geometric segment 2 distance units to the left (positive offset 2) of the segment from measures 5 through 10 of Route 1. Note in SDO_ORDINATE_ARRAY of the returned segment that the Y values (6) are 2 greater than the Y values (4) of the relevant part of the original segment. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.PERCENTAGE_TO_MEASURE( geom_segment IN SDO_GEOMETRY, percentage IN NUMBER ) RETURN NUMBER; or SDO_LRS.PERCENTAGE_TO_MEASURE( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, percentage IN NUMBER ) RETURN NUMBER; Description Returns the measure value of a specified percentage (0 to 100) of the measure range of a geometric segment. Parameters Cartographic representation of a linear feature. Dimensional information array corresponding to Percentage value. Must be from 0 to 100. This function returns the measure value corresponding to this percentage of the measure range. Usage Notes This function returns the measure value corresponding to the specified percentage of the measure range. (The measure range is the end measure minus the start measure.) For example, if the measure range of This function performs the reverse of the SDO_LRS.MEASURE_TO_PERCENTAGE function, which returns the percentage value that corresponds to a measure. An exception is raised if Examples The following example returns the measure that is 50 percent of the measure range of the geometric segment representing Route 1. (This example uses the definitions from the example in Section 7.7.) The measure range of this segment is 27, and 50 percent of 27 is 13.5. Format SDO_LRS.PROJECT_PT( geom_segment IN SDO_GEOMETRY, point IN SDO_GEOMETRY, tolerance IN NUMBER DEFAULT 1.0e8 [, offset OUT NUMBER] ) RETURN SDO_GEOMETRY; or SDO_LRS.PROJECT_PT( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, point IN SDO_GEOMETRY [, point_dim_array IN SDO_DIM_ARRAY] ) RETURN SDO_GEOMETRY; or SDO_LRS.PROJECT_PT( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, point IN SDO_GEOMETRY, point_dim_array IN SDO_DIM_ARRAY [, offset OUT NUMBER] ) RETURN SDO_GEOMETRY; Description Returns the projection point of a specified point. The projection point is on the geometric segment. Parameters Geometric segment to be checked. Dimensional information array corresponding to Point to be projected. Tolerance value (see Section 1.5.5 and Section 7.6). The default value is 0.00000001. Dimensional information array corresponding to Offset (shortest distance) from the point to the geometric segment. Usage Notes This function returns the projection point (including its measure) of a specified point ( If multiple projection points exist, the first projection point encountered from the start point is returned. If you specify the output parameter An exception is raised if The _3D format of this function (SDO_LRS.PROJECT_PT_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. For more information about projecting a point onto a geometric segment, see Section 7.5.9. Examples The following example returns the point (9,4,9) on the geometric segment representing Route 1 that is closest to the specified point (9,3,NULL). (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.REDEFINE_GEOM_SEGMENT( geom_segment IN OUT SDO_GEOMETRY [, start_measure IN NUMBER, end_measure IN NUMBER]); or SDO_LRS.REDEFINE_GEOM_SEGMENT( geom_segment IN OUT SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY [, start_measure IN NUMBER, end_measure IN NUMBER]); Description Populates the measures of all shape points based on the start and end measures of a geometric segment, overriding any previously assigned measures between the start point and end point. Parameters Cartographic representation of a linear feature. Dimensional information array corresponding to Distance measured from the start point of a geometric segment to the start point of the linear feature. The default is the existing value (if any) in the measure dimension; otherwise, the default is 0. Distance measured from the end point of a geometric segment to the start point of the linear feature. The default is the existing value (if any) in the measure dimension; otherwise, the default is the cartographic length of the segment. Usage Notes An exception is raised if The _3D format of this procedure (SDO_LRS.REDEFINE_GEOM_SEGMENT_3D) is available. For information about _3D formats of LRS functions and procedures, see Section 7.4. For more information about redefining a geometric segment, see Section 7.5.2. Examples The following example redefines a geometric segment, effectively converting miles to kilometers in the measure values. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.RESET_MEASURE( geom_segment IN OUT SDO_GEOMETRY [, dim_array IN SDO_DIM_ARRAY]); Description Sets all measures of a geometric segment, including the start and end measures, to null values, overriding any previously assigned measures. Parameters Cartographic representation of a linear feature. Dimensional information array corresponding to Usage Notes An exception is raised if Examples The following example sets all measures of a geometric segment to null values. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.REVERSE_GEOMETRY( geom IN SDO_GEOMETRY [, dim_array IN SDO_DIM_ARRAY] ) RETURN SDO_GEOMETRY; Description Returns a new geometric segment by reversing the measure values and the direction of the original geometric segment. Parameters Cartographic representation of a linear feature. Dimensional information array corresponding to Usage Notes This function: Reverses the measure values of That is, the start measure of Reverses the direction of Compare this function with SDO_LRS.REVERSE_MEASURE, which reverses only the measure values (not the direction) of a geometric segment. To reverse the vertices of a nonLRS line string geometry, use the SDO_UTIL.REVERSE_LINESTRING function, which is described in Chapter 20. An exception is raised if The _3D format of this function (SDO_LRS.REVERSE_GEOMETRY_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example reverses the measure values and the direction of the geometric segment representing Route 1. (This example uses the definitions from the example in Section 7.7.) Note in the returned segment that the M values (measures) now go in descending order from 27 to 0, and the segment start and end points have the opposite X and Y values as in the original segment (5,14 and 2,2 here, as opposed to 2,2 and 5,14 in the original). Format SDO_LRS.REVERSE_MEASURE( geom_segment IN SDO_GEOMETRY [, dim_array IN SDO_DIM_ARRAY] ) RETURN SDO_GEOMETRY; Description Returns a new geometric segment by reversing the measure values, but not the direction, of the original geometric segment. Parameters Cartographic representation of a linear feature. Dimensional information array corresponding to Usage Notes This function: Reverses the measure values of That is, the start measure of Does not affect the direction of Compare this function with SDO_LRS.REVERSE_GEOMETRY, which reverses both the direction and the measure values of a geometric segment. An exception is raised if The _3D format of this function (SDO_LRS.REVERSE_MEASURE_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Note: Examples The following example reverses the measure values of the geometric segment representing Route 1, but does not affect the direction. (This example uses the definitions from the example in Section 7.7.) Note in the returned segment that the M values (measures) now go in descending order from 27 to 0, but the segment start and end points have the same X and Y values as in the original segment (2,2 and 5,14). Format SDO_LRS.SET_PT_MEASURE( geom_segment IN OUT SDO_GEOMETRY, point IN SDO_GEOMETRY, measure IN NUMBER) RETURN VARCHAR2; or SDO_LRS.SET_PT_MEASURE( geom_segment IN OUT SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, point IN SDO_GEOMETRY, pt_dim_array IN SDO_DIM_ARRAY, measure IN NUMBER) RETURN VARCHAR2; or SDO_LRS.SET_PT_MEASURE( point IN OUT SDO_GEOMETRY, measure IN NUMBER) RETURN VARCHAR2; or SDO_LRS.SET_PT_MEASURE( point IN OUT SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, measure IN NUMBER) RETURN VARCHAR2; Description Sets the measure value of a specified point. Parameters Geometric segment containing the point. Dimensional information array corresponding to Point for which the measure value is to be set. Dimensional information array corresponding to Measure value to be assigned to the specified point. Usage Notes The function returns TRUE if the measure value was successfully set, and FALSE if the measure value was not set. If both If If The _3D format of this function (SDO_LRS.SET_PT_MEASURE_3D) is available; however, only the formats that include the An exception is raised if Examples The following example sets the measure value of point (8,10) to 20. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.SPLIT_GEOM_SEGMENT( geom_segment IN SDO_GEOMETRY, split_measure IN NUMBER, segment_1 OUT SDO_GEOMETRY, segment_2 OUT SDO_GEOMETRY); or SDO_LRS.SPLIT_GEOM_SEGMENT( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, split_measure IN NUMBER, segment_1 OUT SDO_GEOMETRY, segment_2 OUT SDO_GEOMETRY); Description Splits a geometric segment into two geometric segments. Parameters Geometric segment to be split. Dimensional information array corresponding to Distance measured from the start point of a geometric segment to the split point. First geometric segment: from the start point of Second geometric segment: from the split point to the end point of Usage Notes An exception is raised if The directions and measures of the resulting geometric segments are preserved. The _3D format of this procedure (SDO_LRS.SPLIT_GEOM_SEGMENT_3D) is available. For information about _3D formats of LRS functions and procedures, see Section 7.4. For more information about splitting a geometric segment, see Section 7.5.4. Examples The following example defines the geometric segment, splits it into two segments, then concatenates those segments. (This example uses the definitions from the example in Section 7.7. The definitions of Format SDO_LRS.TRANSLATE_MEASURE( geom_segment IN SDO_GEOMETRY, translate_m IN NUMBER ) RETURN SDO_GEOMETRY; or SDO_LRS.TRANSLATE_MEASURE( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, translate_m IN NUMBER ) RETURN SDO_GEOMETRY; Description Returns a new geometric segment by translating the original geometric segment (that is, shifting the start and end measures by a specified value). Parameters Cartographic representation of a linear feature. Dimensional information array corresponding to Distance measured from the start point of a geometric segment to the start point of the linear feature. Usage Notes This function adds An exception is raised if The _3D format of this function (SDO_LRS.TRANSLATE_MEASURE_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example translates (shifts) by 10 the geometric segment representing Route 1. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.VALID_GEOM_SEGMENT( geom_segment IN SDO_GEOMETRY [, dim_array IN SDO_DIM_ARRAY] ) RETURN VARCHAR2; Description Checks if a geometry object is a valid geometric segment. Parameters Geometric segment to be checked for validity. Dimensional information array corresponding to Usage Notes This function returns TRUE if Measure information is assumed to be stored in the last element of the SDO_DIM_ARRAY in the Oracle Spatial metadata. This function only checks for geometry type and number of dimensions of the geometric segment. To further validate measure information, use the SDO_LRS.IS_GEOM_SEGMENT_DEFINED function. The _3D format of this function (SDO_LRS.VALID_GEOM_SEGMENT_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example checks if the geometric segment representing Route 1 is valid. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.VALID_LRS_PT( point IN SDO_GEOMETRY [, dim_array IN SDO_DIM_ARRAY] ) RETURN VARCHAR2; Description Checks if an LRS point is valid. Parameters Point to be checked for validity. Dimensional information array corresponding to Usage Notes This function returns TRUE if This function checks if All LRS point data must be stored in the SDO_ELEM_INFO_ARRAY and SDO_ORDINATE_ARRAY, and cannot be stored in the SDO_POINT field in the SDO_GEOMETRY definition of the point. The _3D format of this function (SDO_LRS.VALID_LRS_PT_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example checks if point (9,3,NULL) is a valid LRS point. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.VALID_MEASURE( geom_segment IN SDO_GEOMETRY, measure IN NUMBER ) RETURN VARCHAR2; or SDO_LRS.VALID_MEASURE( geom_segment IN SDO_GEOMETRY, dim_array IN SDO_DIM_ARRAY, measure IN NUMBER ) RETURN VARCHAR2; Description Checks if a measure falls within the measure range of a geometric segment. Parameters Geometric segment to be checked to see if Dimensional information array corresponding to Measure value to be checked to see if it falls within the measure range of Usage Notes This function returns TRUE if An exception is raised if The _3D format of this function (SDO_LRS.VALID_MEASURE_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example checks if 50 is a valid measure on the Route 1 segment. The function returns FALSE because the measure range for that segment is 0 to 27. For example, if the route is 27 miles long with mile markers at 1mile intervals, there is no 50mile marker because the last marker is the 27mile marker. (This example uses the definitions from the example in Section 7.7.) Format SDO_LRS.VALIDATE_LRS_GEOMETRY( geom_segment IN SDO_GEOMETRY [, dim_array IN SDO_DIM_ARRAY] ) RETURN VARCHAR2; Description Checks if an LRS geometry is valid. Parameters Geometric segment to be checked. Dimensional information array corresponding to Usage Notes This function returns TRUE if ORA13331 (invalid LRS segment) ORA13335 (measure information not defined) The _3D format of this function (SDO_LRS.VALIDATE_LRS_GEOMETRY_3D) is available. For information about _3D formats of LRS functions, see Section 7.4. Examples The following example checks if the Route 1 segment is a valid LRS geometry. (This example uses the definitions from the example in Section 7.7.) This chapter contains descriptions of the geometryrelated PL/SQL subprograms in the SDO_GEOM package, which can be grouped into the following categories: Relationship (True/False) between two objects: RELATE, WITHIN_DISTANCE Validation: VALIDATE_GEOMETRY_WITH_CONTEXT, VALIDATE_LAYER_WITH_CONTEXT Singleobject operations: SDO_ARC_DENSIFY, SDO_AREA, SDO_BUFFER, SDO_CENTROID, SDO_CONVEXHULL, SDO_LENGTH, SDO_MAX_MBR_ORDINATE, SDO_MIN_MBR_ORDINATE, SDO_MBR, SDO_POINTONSURFACE Twoobject operations: SDO_DISTANCE, SDO_DIFFERENCE, SDO_INTERSECTION, SDO_UNION, SDO_XOR The geometry subprograms are listed Table 151, and some usage information follows the table. Table 151 Geometry Subprograms Determines how two objects interact. Changes each circular arc into an approximation consisting of straight lines, and each circle into a polygon consisting of a series of straight lines that approximate the circle. Computes the area of a twodimensional polygon. Generates a buffer polygon around or inside a geometry. Returns the centroid of a polygon. Returns a polygontype object that represents the convex hull of a geometry object. Returns a geometry object that is the topological difference (MINUS operation) of two geometry objects. Computes the distance between two geometry objects. Returns a geometry object that is the topological intersection (AND operation) of two geometry objects. Computes the length or perimeter of a geometry. Returns the maximum value for the specified ordinate (dimension) of the minimum bounding rectangle of a geometry object. Returns the minimum bounding rectangle of a geometry. Returns the minimum value for the specified ordinate (dimension) of the minimum bounding rectangle of a geometry object. Returns a point that is guaranteed to be on the surface of a polygon. Returns a geometry object that is the topological union (OR operation) of two geometry objects. Returns a geometry object that is the topological symmetric difference (XOR operation) of two geometry objects. SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT Determines if a geometry is valid, and returns context information if the geometry is invalid. SDO_GEOM.VALIDATE_LAYER_WITH_CONTEXT Determines if all geometries stored in a column are valid, and returns context information about any invalid geometries. Determines if two geometries are within a specified distance from one another. The following usage information applies to the geometry subprograms. (See also the Usage Notes under the reference information for each subprogram.) Certain combinations of input parameters and operations can return a null value, that is, an empty geometry. For example, requesting the intersection of two disjoint geometry objects returns a null value. A null value (empty geometry) as an input parameter to a geometry function (for example, SDO_GEOM.RELATE) produces an error. Certain operations can return a geometry of a different type than one or both input geometries. For example, the intersection of a line and an overlapping polygon returns a line; the intersection of two lines returns a point; and the intersection of two tangent polygons returns a line. Format SDO_GEOM.RELATE( geom1 IN SDO_GEOMETRY, dim1 IN SDO_DIM_ARRAY, mask IN VARCHAR2, geom2 IN SDO_GEOMETRY, dim2 IN SDO_DIM_ARRAY ) RETURN VARCHAR2; or SDO_GEOM.RELATE( geom1 IN SDO_GEOMETRY, mask IN VARCHAR2, geom2 IN SDO_GEOMETRY, tol IN NUMBER ) RETURN VARCHAR2; Description Examines two geometry objects to determine their spatial relationship. Parameters Geometry object. Dimensional information array corresponding to Specifies a list of relationships to check. See the list of keywords in the Usage Notes. Geometry object. Dimensional information array corresponding to Tolerance value (see Section 1.5.5). Usage Notes For better performance, use the SDO_RELATE operator or one of its convenience operator formats (all described in Chapter 11) instead of the The If you pass a If you pass the DETERMINE keyword in If you pass the ANYINTERACT keyword in The following ANYINTERACT: Returns TRUE if the objects are not disjoint. CONTAINS: Returns CONTAINS if the second object is entirely within the first object and the object boundaries do not touch; otherwise, returns FALSE. COVEREDBY: Returns COVEREDBY if the first object is entirely within the second object and the object boundaries touch at one or more points; otherwise, returns FALSE. COVERS: Returns COVERS if the second object is entirely within the first object and the boundaries touch in one or more places; otherwise, returns FALSE. DISJOINT: Returns DISJOINT if the objects have no common boundary or interior points; otherwise, returns FALSE. EQUAL: Returns EQUAL if the objects share every point of their boundaries and interior, including any holes in the objects; otherwise, returns FALSE. INSIDE: Returns INSIDE if the first object is entirely within the second object and the object boundaries do not touch; otherwise, returns FALSE. ON: Returns ON if the boundary and interior of a line (the first object) is completely on the boundary of a polygon (the second object); otherwise, returns FALSE. OVERLAPBDYDISJOINT: Returns OVERLAPBDYDISJOINT if the objects overlap, but their boundaries do not interact; otherwise, returns FALSE. OVERLAPBDYINTERSECT: Returns OVERLAPBDYINTERSECT if the objects overlap, and their boundaries intersect in one or more places; otherwise, returns FALSE. TOUCH: Returns TOUCH if the two objects share a common boundary point, but no interior points; otherwise, returns FALSE. Values for If the function format with An exception is raised if Examples The following example finds the relationship between each geometry in the SHAPE column and the Related Topics SDO_RELATE operator Format SDO_GEOM.SDO_ARC_DENSIFY( geom IN SDO_GEOMETRY, dim IN SDO_DIM_ARRAY params IN VARCHAR2 ) RETURN SDO_GEOMETRY; or SDO_GEOM.SDO_ARC_DENSIFY( geom IN SDO_GEOMETRY, tol IN NUMBER params IN VARCHAR2 ) RETURN SDO_GEOMETRY; Description Returns a geometry in which each circular arc in the input geometry is changed into an approximation of the circular arc consisting of straight lines, and each circle is changed into a polygon consisting of a series of straight lines that approximate the circle. Parameters Geometry object. Dimensional information array corresponding to Tolerance value (see Section 1.5.5). A quoted string containing an arc tolerance value and optionally a unit value. See the Usage Notes for an explanation of the format and meaning. Usage Notes If you have geometries in a projected coordinate system that contain circles or circular arcs, you can use this function to densify them into regular polygons. You can then use the resulting straightline polygon geometries for any Spatial operations, or you can transform them to any projected or geodetic coordinate system. The The The If the If the function format with Examples The following example returns the geometry that results from the arc densification of Related Topics Format SDO_GEOM.SDO_AREA( geom IN SDO_GEOMETRY, dim IN SDO_DIM_ARRAY [, unit IN VARCHAR2] ) RETURN NUMBER; or SDO_GEOM.SDO_AREA( geom IN SDO_GEOMETRY, tol IN NUMBER [, unit IN VARCHAR2] ) RETURN NUMBER; Description Returns the area of a twodimensional polygon. Parameters Geometry object. Dimensional information array corresponding to Unit of measurement: a quoted string with If this parameter is not specified, the unit of measurement associated with the data is assumed. For geodetic data, the default unit of measurement is square meters. Tolerance value (see Section 1.5.5). Usage Notes This function works with any polygon, including polygons with holes. Lines that close to form a ring have no area. If the function format with Examples The following example returns the areas of geometry objects stored in the COLA_MARKETS table. The first statement returns the areas of all objects; the second returns just the area of Related Topics None. Format SDO_GEOM.SDO_BUFFER( geom IN SDO_GEOMETRY, dim IN SDO_DIM_ARRAY, dist IN NUMBER [, params IN VARCHAR2] ) RETURN SDO_GEOMETRY; or SDO_GEOM.SDO_BUFFER( geom IN SDO_GEOMETRY, dist IN NUMBER, tol IN NUMBER [, params IN VARCHAR2] ) RETURN SDO_GEOMETRY; Description Generates a buffer polygon around or inside a geometry object. Parameters Geometry object. Dimensional information array corresponding to Distance value. If the value is positive, the buffer is generated around the geometry; if the value is negative (valid only for polygons), the buffer is generated inside the geometry. The absolute value of this parameter must be greater than the tolerance value, as specified in the dimensional array ( Tolerance value (see Section 1.5.5). A quoted string that can contain one or both of the following keywords: For example: If the input geometry is geodetic data and if If this parameter is not specified for a Cartesian or projected geometry, or if the Usage Notes This function returns a geometry object representing the buffer polygon. This function creates a rounded buffer around a point, line, or polygon, or inside a polygon. The buffer within a void is also rounded, and is the same distance from the inner boundary as the outer buffer is from the outer boundary. See Figure 17 for an illustration. If the buffer polygon geometry is in a projected coordinate system, it will contain arcs; and if you want to transform that geometry to a geodetic coordinate system, you must first densify it using the SDO_GEOM.SDO_ARC_DENSIFY function, and then transform the densified geometry. If the function format with With geodetic data, this function is supported by approximations, as explained in Section 6.9.3. Examples The following example returns a polygon representing a buffer of 1 around The following example returns a polygon representing a buffer of 1 around Related Topics Format SDO_GEOM.SDO_CENTROID( geom1 IN SDO_GEOMETRY, dim1 IN SDO_DIM_ARRAY ) RETURN SDO_GEOMETRY; or SDO_GEOM.SDO_CENTROID( geom1 IN SDO_GEOMETRY, tol IN NUMBER ) RETURN SDO_GEOMETRY; Description Returns a point geometry that is the centroid of a polygon, multipolygon, point, or point cluster. (The centroid is also known as the "center of gravity.") For an input geometry consisting of multiple objects, the result is weighted by the area of each polygon in the geometry objects. If the geometry objects are a mixture of polygons and points, the points are not used in the calculation of the centroid. If the geometry objects are all points, the points have equal weight. Parameters Geometry object. Dimensional information array corresponding to Tolerance value (see Section 1.5.5). Usage Notes The function returns a null value if If If the function format with With geodetic data, this function is supported by approximations, as explained in Section 6.9.3. Depending on the shape and complexity of the input geometry, the returned point might not be on the surface of the input geometry. Examples The following example returns a geometry object that is the centroid of Related Topics None. Format SDO_GEOM.SDO_CONVEXHULL( geom1 IN SDO_GEOMETRY, dim1 IN SDO_DIM_ARRAY ) RETURN SDO_GEOMETRY; or SDO_GEOM.SDO_CONVEXHULL( geom1 IN SDO_GEOMETRY, tol IN NUMBER ) RETURN SDO_GEOMETRY; Description Returns a polygontype object that represents the convex hull of a geometry object. Parameters Geometry object. Dimensional information array corresponding to Tolerance value (see Section 1.5.5). Usage Notes The convex hull is a simple convex polygon that completely encloses the geometry object. Spatial uses as few straightline sides as possible to create the smallest polygon that completely encloses the specified object. A convex hull is a convenient way to get an approximation of a complex geometry object. If the geometry ( The function returns a null value if If the function format with With geodetic data, this function is supported by approximations, as explained in Section 6.9.3. Examples The following example returns a geometry object that is the convex hull of Related Topics None. Format SDO_GEOM.SDO_DIFFERENCE( geom1 IN SDO_GEOMETRY, dim1 IN SDO_DIM_ARRAY, geom2 IN SDO_GEOMETRY, dim2 IN SDO_DIM_ARRAY ) RETURN SDO_GEOMETRY; or SDO_GEOM.SDO_DIFFERENCE( geom1 IN SDO_GEOMETRY, geom2 IN SDO_GEOMETRY, tol IN NUMBER ) RETURN SDO_GEOMETRY; Description Returns a geometry object that is the topological difference (MINUS operation) of two geometry objects. Parameters Geometry object. Dimensional information array corresponding to Geometry object. Dimensional information array corresponding to Tolerance value (see Section 1.5.5). Usage Notes In Figure 152, the shaded area represents the polygon returned when SDO_DIFFERENCE is used with a square ( If the function format with An exception is raised if Examples The following example returns a geometry object that is the topological difference (MINUS operation) of Note that in the returned polygon, the SDO_ORDINATE_ARRAY starts and ends at the same point (1, 7). Related Topics Format SDO_GEOM.SDO_DISTANCE( geom1 IN SDO_GEOMETRY, dim1 IN SDO_DIM_ARRAY, geom2 IN SDO_GEOMETRY, dim2 IN SDO_DIM_ARRAY [, unit IN VARCHAR2] ) RETURN NUMBER; or SDO_GEOM.SDO_DISTANCE( geom1 IN SDO_GEOMETRY, geom2 IN SDO_GEOMETRY, tol IN NUMBER [, unit IN VARCHAR2] ) RETURN NUMBER; Description Computes the distance between two geometry objects. The distance between two geometry objects is the distance between the closest pair of points or segments of the two objects. Parameters Geometry object whose distance from Dimensional information array corresponding to Geometry object whose distance from Dimensional information array corresponding to Unit of measurement: a quoted string with If this parameter is not specified, the unit of measurement associated with the data is assumed. Tolerance value (see Section 1.5.5). Usage Notes If the function format with An exception is raised if Examples The following example returns the shortest distance between Related Topics Format SDO_GEOM.SDO_INTERSECTION( geom1 IN SDO_GEOMETRY, dim1 IN SDO_DIM_ARRAY, geom2 IN SDO_GEOMETRY, dim2 IN SDO_DIM_ARRAY ) RETURN SDO_GEOMETRY; or SDO_GEOM.SDO_INTERSECTION( geom1 IN SDO_GEOMETRY, geom2 IN SDO_GEOMETRY, tol IN NUMBER ) RETURN SDO_GEOMETRY; Description Returns a geometry object that is the topological intersection (AND operation) of two geometry objects. Parameters Geometry object. Dimensional information array corresponding to Geometry object. Dimensional information array corresponding to Tolerance value (see Section 1.5.5). Usage Notes In Figure 153, the shaded area represents the polygon returned when SDO_INTERSECTION is used with a square ( If the function format with An exception is raised if Examples The following example returns a geometry object that is the topological intersection (AND operation) of Note that in the returned polygon, the SDO_ORDINATE_ARRAY starts and ends at the same point (4, 5). Related Topics Format SDO_GEOM.SDO_LENGTH( geom IN SDO_GEOMETRY, dim IN SDO_DIM_ARRAY [, unit IN VARCHAR2] ) RETURN NUMBER; or SDO_GEOM.SDO_LENGTH( geom IN SDO_GEOMETRY, tol IN NUMBER [, unit IN VARCHAR2] ) RETURN NUMBER; Description Returns the length or perimeter of a geometry object. Parameters Geometry object. Dimensional information array corresponding to Unit of measurement: a quoted string with If this parameter is not specified, the unit of measurement associated with the data is assumed. For geodetic data, the default unit of measurement is meters. Tolerance value (see Section 1.5.5). Usage Notes If the input polygon contains one or more holes, this function calculates the perimeters of the exterior boundary and all holes. It returns the sum of all perimeters. If the function format with Examples The following example returns the perimeters of geometry objects stored in the COLA_MARKETS table. The first statement returns the perimeters of all objects; the second returns just the perimeter of Related Topics None. Format SDO_GEOM.SDO_MAX_MBR_ORDINATE( geom IN SDO_GEOMETRY, ordinate_pos IN NUMBER ) RETURN NUMBER; or SDO_GEOM.SDO_MAX_MBR_ORDINATE( geom IN SDO_GEOMETRY, dim IN SDO_DIM_ARRAY, ordinate_pos IN NUMBER ) RETURN NUMBER; Description Returns the maximum value for the specified ordinate (dimension) of the minimum bounding rectangle of a geometry object. Parameters Geometry object. Dimensional information array corresponding to Position of the ordinate (dimension) in the definition of the geometry object: 1 for the first ordinate, 2 for the second ordinate, and so on. For example, if Usage Notes None. Examples The following example returns the maximum X (first) ordinate value of the minimum bounding rectangle of the Related Topics Format SDO_GEOM.SDO_MBR( geom IN SDO_GEOMETRY [, dim IN SDO_DIM_ARRAY] ) RETURN SDO_GEOMETRY; Description Returns the minimum bounding rectangle of a geometry object, that is, a single rectangle that minimally encloses the geometry. Parameters Geometry object. Dimensional information array corresponding to Usage Notes This function does not return an MBR geometry if a proper MBR cannot be constructed. Specifically: If the input geometry is null, the function returns a null geometry. If the input geometry is a point, the function returns the point. If the input geometry consists of points all on a straight line, the function returns a twopoint line. If the input geometry has three dimensions but all Z dimension values are the same, the function returns a threedimensional line. Examples The following example returns the minimum bounding rectangle of the Related Topics Format SDO_GEOM.SDO_MIN_MBR_ORDINATE( geom IN SDO_GEOMETRY, ordinate_pos IN NUMBER ) RETURN NUMBER; or SDO_GEOM.SDO_MIN_MBR_ORDINATE( geom IN SDO_GEOMETRY, dim IN SDO_DIM_ARRAY, ordinate_pos IN NUMBER ) RETURN NUMBER; Description Returns the minimum value for the specified ordinate (dimension) of the minimum bounding rectangle of a geometry object. Parameters Geometry object. Dimensional information array corresponding to Position of the ordinate (dimension) in the definition of the geometry object: 1 for the first ordinate, 2 for the second ordinate, and so on. For example, if Usage Notes None. Examples The following example returns the minimum X (first) ordinate value of the minimum bounding rectangle of the Related Topics Format SDO_GEOM.SDO_POINTONSURFACE( geom1 IN SDO_GEOMETRY, dim1 IN SDO_DIM_ARRAY ) RETURN SDO_GEOMETRY; or SDO_GEOM.SDO_POINTONSURFACE( geom1 IN SDO_GEOMETRY, tol IN NUMBER ) RETURN SDO_GEOMETRY; Description Returns a point that is guaranteed to be on the surface of a polygon geometry object. Parameters Polygon geometry object. Dimensional information array corresponding to Tolerance value (see Section 1.5.5). Usage Notes This function returns a point geometry object representing a point that is guaranteed to be on the surface of The returned point can be any point on the surface. You should not make any assumptions about where on the surface the returned point is, or about whether the point is the same or different when the function is called multiple times with the same input parameter values. If the function format with Examples The following example returns a geometry object that is a point on the surface of Related Topics None. Format SDO_GEOM.SDO_UNION( geom1 IN SDO_GEOMETRY, dim1 IN SDO_DIM_ARRAY, geom2 IN SDO_GEOMETRY, dim2 IN SDO_DIM_ARRAY ) RETURN SDO_GEOMETRY; or SDO_GEOM.SDO_UNION( geom1 IN SDO_GEOMETRY, geom2 IN SDO_GEOMETRY, tol IN NUMBER ) RETURN SDO_GEOMETRY; Description Returns a geometry object that is the topological union (OR operation) of two geometry objects. Parameters Geometry object. Dimensional information array corresponding to Geometry object. Dimensional information array corresponding to Tolerance value (see Section 1.5.5). Usage Notes In Figure 154, the shaded area represents the polygon returned when SDO_UNION is used with a square ( If the function format with If it is sufficient to append one geometry to another geometry without performing a topological union operation, and if both geometries are disjoint, using the SDO_UTIL.APPEND function (described in Chapter 20) is faster than using the SDO_UNION function. An exception is raised if Examples The following example returns a geometry object that is the topological union (OR operation) of Note that in the returned polygon, the SDO_ORDINATE_ARRAY starts and ends at the same point (5, 5). Related Topics Format SDO_GEOM.SDO_XOR( geom1 IN SDO_XOR, dim1 IN SDO_DIM_ARRAY, geom2 IN SDO_GEOMETRY, dim2 IN SDO_DIM_ARRAY ) RETURN SDO_GEOMETRY; or SDO_GEOM.SDO_XOR( geom1 IN SDO_GEOMETRY, geom2 IN SDO_GEOMETRY, tol IN NUMBER ) RETURN SDO_GEOMETRY; Description Returns a geometry object that is the topological symmetric difference (XOR operation) of two geometry objects. Parameters Geometry object. Dimensional information array corresponding to Geometry object. Dimensional information array corresponding to Tolerance value (see Section 1.5.5). Usage Notes In Figure 155, the shaded area represents the polygon returned when SDO_XOR is used with a square ( If the function format with An exception is raised if Examples The following example returns a geometry object that is the topological symmetric difference (XOR operation) of Note that the returned polygon is a multipolygon (SDO_GTYPE = 2007), and the SDO_ORDINATE_ARRAY describes two polygons: one starting and ending at (1, 7) and the other starting and ending at (5, 5). Related Topics Format SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT( theGeometry IN SDO_GEOMETRY, theDimInfo IN SDO_DIM_ARRAY ) RETURN VARCHAR2; or SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT( theGeometry IN SDO_GEOMETRY, tolerance IN NUMBER ) RETURN VARCHAR2; Description Performs a consistency check for valid geometry types and returns context information if the geometry is invalid. The function checks the representation of the geometry from the tables against the element definitions. Parameters Geometry object. Dimensional information array corresponding to Tolerance value (see Section 1.5.5). Usage Notes If the geometry is valid, this function returns TRUE. (For a userdefined geometry, that is, a geometry with an SDO_GTYPE value of 2000, this function returns the string NULL.) If the geometry is not valid, this function returns the following: An Oracle error message number based on the specific reason the geometry is invalid, or FALSE if the geometry fails for some other reason The context of the error (the coordinate, edge, or ring that causes the geometry to be invalid). (See "Context of Errors: Details" in this section.) This function checks for type consistency and geometry consistency. For type consistency, the function checks for the following: The SDO_GTYPE is valid. The SDO_ETYPE values are consistent with the SDO_GTYPE value. For example, if the SDO_GTYPE is 2003, there should be at least one element of type POLYGON in the geometry. The SDO_ELEM_INFO_ARRAY has valid triplet values. For geometry consistency, the function checks for the following, as appropriate for the specific geometry type: Polygons have at least four points, which List of Examples
12 Spatial Aggregate Functions
Method Description
SDO_AGGR_CENTROID
SELECT SDO_AGGR_CENTROID(SDOAGGRTYPE(shape, 0.005))
FROM cola_markets;
SDO_AGGR_CENTROID(SDOAGGRTYPE(SHAPE,0.005))(SDO_GTYPE, SDO_SRID, SDO_POINT

SDO_GEOMETRY(2001, NULL, SDO_POINT_TYPE(5.21295938, 5.00744233, NULL), NULL, NUL
L)
SDO_AGGR_CONCAT_LINES
 First, insert two line geometries.
INSERT INTO cola_markets VALUES(1001, 'line_1', SDO_GEOMETRY(2002, NULL, NULL,
SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(1,1, 5,1)));
INSERT INTO cola_markets VALUES(1002, 'line_2', SDO_GEOMETRY(2002, NULL, NULL,
SDO_ELEM_INFO_ARRAY(1,2,1), SDO_ORDINATE_ARRAY(5,1, 8,1)));
 Perform aggregate concatenation of all line geometries in layer.
SELECT SDO_AGGR_CONCAT_LINES(c.shape) FROM cola_markets c
WHERE c.mkt_id > 1000;
SDO_AGGR_CONCAT_LINES(C.SHAPE)(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM

SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
1, 1, 5, 1, 8, 1))
SDO_AGGR_CONVEXHULL
SELECT SDO_AGGR_CONVEXHULL(SDOAGGRTYPE(shape, 0.005))
FROM cola_markets;
SDO_AGGR_CONVEXHULL(SDOAGGRTYPE(SHAPE,0.005))(SDO_GTYPE, SDO_SRID, SDO_POI

SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
AY(8, 1, 10, 7, 10, 11, 8, 11, 6, 11, 1, 7, 1, 1, 8, 1))
SDO_AGGR_LRS_CONCAT
Route0
) has decreasing measure values. (This example uses the definitions from the example in Section 7.7.) Add a segment with route_id less than 1 (here, zero).
INSERT INTO lrs_routes VALUES(
0,
'Route0',
SDO_GEOMETRY(
3302,  Line string; 3 dimensions (X,Y,M); 3rd is measure dimension.
NULL,
NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),  One line string, straight segments
SDO_ORDINATE_ARRAY(
5,14,5,  Starting point  5 is measure from start.
10,14,0)  Ending point  0 measure (decreasing measure)
)
);
1 row created.
 Concatenate all routes (no ordering specified).
SELECT SDO_AGGR_LRS_CONCAT(SDOAGGRTYPE(route_geometry, 0.005))
FROM lrs_routes;
SDO_AGGR_LRS_CONCAT(SDOAGGRTYPE(ROUTE_GEOMETRY,0.005))(SDO_GTYPE, SDO_SRID

SDO_GEOMETRY(3302, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
2, 2, 0, 2, 4, 2, 8, 4, 8, 12, 4, 12, 12, 10, 18, 8, 10, 22, 5, 14, 27, 10, 14,
32))
 Aggregate concatenation using subquery for ordering.
SELECT
SDO_AGGR_LRS_CONCAT(SDOAGGRTYPE(route_geometry, 0.005))
FROM (
SELECT /*+ NO_MERGE */ route_geometry
FROM lrs_routes
ORDER BY route_id);
SDO_AGGR_LRS_CONCAT(SDOAGGRTYPE(ROUTE_GEOMETRY,0.005))(SDO_GTYPE, SDO_SRID

SDO_GEOMETRY(3302, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
2, 2, 32, 2, 4, 30, 8, 4, 24, 12, 4, 20, 12, 10, 14, 8, 10, 10, 5, 14, 5, 10, 14
, 0))
SDO_AGGR_MBR
SELECT SDO_AGGR_MBR(shape) FROM cola_markets;
SDO_AGGR_MBR(C.SHAPE)(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SD

SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 3), SDO_ORDINATE_ARR
AY(1, 1, 10, 11))
SDO_AGGR_UNION
cola_d
). (The example uses the definitions and data from Section 2.1.)SELECT SDO_AGGR_UNION(
SDOAGGRTYPE(c.shape, 0.005))
FROM cola_markets c
WHERE c.name < 'cola_d';
SDO_AGGR_UNION(SDOAGGRTYPE(C.SHAPE,0.005))(SDO_GTYPE, SDO_SRID, SDO_POINT(

SDO_GEOMETRY(2007, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 2, 11, 1003, 1), SDO
_ORDINATE_ARRAY(8, 11, 6, 9, 8, 7, 10, 9, 8, 11, 1, 7, 1, 1, 5, 1, 8, 1, 8, 6, 5
, 7, 1, 7))
Glossary
9 Extending Spatial Indexing Capabilities
9.1 SDO_GEOMETRY Objects in UserDefined Type Definitions
CREATE OR REPLACE TYPE market_type AS OBJECT
(name VARCHAR2(32), shape SDO_GEOMETRY);
/
CREATE TABLE cola_markets_2 (
mkt_id NUMBER PRIMARY KEY,
market MARKET_TYPE);
INSERT INTO cola_markets_2 VALUES(
1,
MARKET_TYPE('cola_a',
SDO_GEOMETRY(
2003,  twodimensional polygon
NULL,
NULL,
SDO_ELEM_INFO_ARRAY(1,1003,3),  one rectangle (1003 = exterior)
SDO_ORDINATE_ARRAY(1,1, 5,7)  only 2 points needed to
 define rectangle (lower left and upper right)
)
)
);
INSERT INTO user_sdo_geom_metadata
(TABLE_NAME,
COLUMN_NAME,
DIMINFO,
SRID)
VALUES (
'cola_markets_2',
'market.shape',
SDO_DIM_ARRAY(  20X20 grid
SDO_DIM_ELEMENT('X', 0, 20, 0.005),
SDO_DIM_ELEMENT('Y', 0, 20, 0.005)
),
NULL  SRID
);
CREATE INDEX cola_spatial_idx_2
ON cola_markets_2(market.shape)
INDEXTYPE IS MDSYS.SPATIAL_INDEX;
cola_a
.SELECT c.mkt_id, c.market.name, c.market.shape
FROM cola_markets_2 c
WHERE c.market.name = 'cola_a';
SELECT c.mkt_id, c.market.name, c.market.shape
FROM cola_markets_2 c
WHERE SDO_RELATE(c.market.shape,
SDO_GEOMETRY(2003, NULL, NULL,
SDO_ELEM_INFO_ARRAY(1,1003,3),
SDO_ORDINATE_ARRAY(4,6, 8,8)),
'mask=anyinteract' = 'TRUE';
9.2 SDO_GEOMETRY Objects in FunctionBased Indexes
9.2.1 Example: Function with Standard Types
 Create a function to return a point geometry (SDO_GTYPE = 2001) with
 input of 2 numbers: longitude and latitude (SDO_SRID = 8307, for
 "Longitude / Latitude (WGS 84)", probably the most widely used
 coordinate system, and the one used for GPS devices.
 Specify DETERMINISTIC for the function.
create or replace function get_long_lat_pt(longitude in number,
latitude in number)
return SDO_GEOMETRY deterministic is
begin
return sdo_geometry(2001, 8307,
sdo_point_type(longitude, latitude, NULL),NULL, NULL);
end;
/
create table LONG_LAT_TABLE
(longitude number, latitude number, name varchar2(32));
insert into LONG_LAT_TABLE values (10,10, 'Place1');
insert into LONG_LAT_TABLE values (20,20, 'Place2');
insert into LONG_LAT_TABLE values (30,30, 'Place3');
 Set up the metadata entry for this table.
 The column name sets up the function on top
 of the two columns used in this function,
 along with the owner of the function.
insert into user_sdo_geom_metadata values('LONG_LAT_TABLE',
'scott.get_long_lat_pt(longitude,latitude)',
sdo_dim_array(
sdo_dim_element('Longitude', 180, 180, 0.005),
sdo_dim_element('Latitude', 90, 90, 0.005)), 8307);
create index LONG_LAT_TABLE_IDX on
LONG_LAT_TABLE(get_long_lat_pt(longitude,latitude))
indextype is mdsys.spatial_index;
 First query: call sdo_filter with an SDO_GEOMETRY constructor
select name from LONG_LAT_TABLE a
where sdo_filter(get_long_lat_pt(a.longitude,a.latitude),
sdo_geometry(2001, 8307,
sdo_point_type(10,10,NULL), NULL, NULL)
)='TRUE';
 Second query: call sdo_filter with the function that returns an sdo_geometry
select name from LONG_LAT_TABLE a
where sdo_filter(get_long_lat_pt(a.longitude,a.latitude),
get_long_lat_pt(10,10)
)='TRUE';
9.2.2 Example: Function with a UserDefined Object Type
create type long_lat as object (
longitude number,
latitude number,
member function GetGeometry(SELF in long_lat)
RETURN SDO_GEOMETRY DETERMINISTIC)
/
create or replace type body long_lat as
member function GetGeometry(self in long_lat)
return SDO_GEOMETRY is
begin
return sdo_geometry(2001, 8307,
sdo_point_type(longitude, latitude, NULL), NULL,NULL);
end;
end;
/
create table test_long_lat
(location long_lat, name varchar2(32));
insert into test_long_lat values (long_lat(10,10), 'Place1');
insert into test_long_lat values (long_lat(20,20), 'Place2');
insert into test_long_lat values (long_lat(30,30), 'Place3');
insert into user_sdo_geom_metadata values('test_long_lat',
'scott.long_lat.GetGeometry(location)',
sdo_dim_array(
sdo_dim_element('Longitude', 180, 180, 0.005),
sdo_dim_element('Latitude', 90, 90, 0.005)), 8307);
create index test_long_lat_idx on test_long_lat(location.GetGeometry())
indextype is mdsys.spatial_index;
SELECT a.name FROM test_long_lat a
WHERE SDO_FILTER(a.location.GetGeometry(),
SDO_GEOMETRY(2001, 8307,
SDO_POINT_TYPE(10,10,NULL), NULL, NULL)
) = 'TRUE';
17 SDO_MIGRATE Package (Upgrading)
SDO_MIGRATE.TO_CURRENT
tabname
that contains geometry objects. If column_name
is not specified or is specified as null, the column containing geometry objects is upgraded.commit_int
is not specified, no internal commit operations are performed during the upgrade.commit_int
value, you can use a smaller rollback segment than would otherwise be needed.layer
is the underlying layer name, without the _SDOGEOM suffix.gidcolumn
.EXECUTE SDO_MIGRATE.TO_CURRENT('ROADS');
Preface
Audience
Documentation Accessibility
http://www.oracle.com/accessibility/
Related Documents
http://oraclestore.oracle.com/
http://www.oracle.com/technology/membership
http://www.oracle.com/technology/documentation
Conventions
Convention Meaning boldface Boldface type indicates graphical user interface elements associated with an action, or terms defined in text or the glossary. italic Italic type indicates book titles, emphasis, or placeholder variables for which you supply particular values. monospace
Monospace type indicates commands within a paragraph, URLs, code in examples, text that appears on the screen, or text that you enter. Index
A B C D E F G H I J L M N O P Q R S T U V W X Z
Numerics
A
B
C
D
E
F
G
H
I
J
L
M
N
O
P
Q
R
S
T
U
V
W
X
Z
What's New in Oracle Spatial?
Coordinate System Support Based on EPSG Model
Subprogram Description SDO_CS.ADD_PREFERENCE_FOR_OP Adds a preference for an operation between a source coordinate system and a target coordinate system. SDO_CS.CONVERT_NADCON_TO_XML Converts a NADCON (North American Datum Conversion) grid in ASCII format to an Oracle Spatial XML representation. SDO_CS.CONVERT_NTV2_TO_XML Converts an NTv2 (National Transformation Version 2) grid in ASCII format to an Oracle Spatial XML representation. SDO_CS.CONVERT_XML_TO_NADCON Converts an Oracle Spatial XML representation of a NADCON (North American Datum Conversion) grid to NADCON ASCII format. SDO_CS.CONVERT_XML_TO_NTV2 Converts an Oracle Spatial XML representation of an NTv2 (National Transformation Version 2) grid to NTv2 ASCII format. SDO_CS.CREATE_CONCATENATED_OP Creates a concatenated operation. SDO_CS.CREATE_OBVIOUS_EPSG_RULES Creates a basic set of EPSG rules to be applied in certain transformations. SDO_CS.CREATE_PREF_CONCATENATED_OP Creates a concatenated operation, associating it with a transformation plan and making it preferred either systemwide or for a specified use case. SDO_CS.DELETE_ALL_EPSG_RULES Deletes the basic set of EPSG rules to be applied in certain transformations. SDO_CS.DELETE_OP Deletes a concatenated operation. SDO_CS.DETERMINE_CHAIN Returns the query chain, based on the system rule set, to be used in transformations from one coordinate reference system to another coordinate reference system. SDO_CS.DETERMINE_DEFAULT_CHAIN Returns the default chain of SRID values in transformations from one coordinate reference system to another coordinate reference system. SDO_CS.FIND_GEOG_CRS Returns the SRID values of geodetic (geographic) coordinate reference systems that have the same wellknown text (WKT) numeric values as the coordinate reference system with the specified reference SRID value. SDO_CS.FIND_PROJ_CRS Returns the SRID values of geodetic (geographic) coordinate reference systems that have the same wellknown text (WKT) numeric values as the coordinate reference system with the specified reference SRID value. SDO_CS.FROM_OGC_SIMPLEFEATURE_SRS Returns the SRID values of projected coordinate reference systems that have the same wellknown text (WKT) numeric values as the coordinate reference system with the specified reference SRID value. SDO_CS.MAP_EPSG_SRID_TO_ORACLE Returns the EPSG SRID value corresponding to the specified Oracle Spatial SRID value. SDO_CS.REVOKE_PREFERENCE_FOR_OP Revokes a preference for an operation between a source coordinate system and a target coordinate system. SDO_CS.TO_OGC_SIMPLEFEATURE_SRS Converts a wellknown text string from the Open Geospatial Consortium simple feature format that includes the TOWGS84
keyword to the format without the TOWGS84
keyword.New SDO_GEOMETRY Methods and Constructors
New min_resolution and max_resolution Keywords
min_resolution
includes only geometries for which at least one side of the geometry's MBR is equal to or greater than the specified value. For example, min_resolution=10
includes only geometries for which the width or the height (or both) of the geometry's MBR is at least 10. (This keyword can be used to exclude geometries that are too small to be of interest.)max_resolution
includes only geometries for which at least one side of the geometry's MBR is less than or equal to the specified value. For example, max_resolution=10
includes only geometries for which the width or the height (or both) of the geometry's MBR is less than or equal to 10. (This keyword can be used to exclude geometries that are too large to be of interest.)New sdo_dml_batch_size Parameter
sdo_dml_batch_size
parameter for the CREATE INDEX statement can affect the performance of applications that insert or update spatial data. This parameter specifies the number of index updates to be processed in each batch of updates after a commit operation. The default value is 1000. See the CREATE INDEX statement reference information and Usage Note in Chapter 10 for details.sdo_dml_batch_size
value. The result is faster processing of each DML operation and some extra time required after the commit operation, but a substantial overall performance improvement.sdo_dml_batch_size
value. There is no longer a risk of deadlocks or other locking problems if you delay performing the commit operation, even if multiple users in the same session are updating the spatial table.New Geocoding Subprograms
Subprogram Description SDO_GCDR.GEOCODE_ADDR Geocodes an input address using attributes in an SDO_GEO_ADDR object, and returns the first matched address as an SDO_GEO_ADDR object. SDO_GCDR.GEOCODE_ADDR_ALL Geocodes an input address using attributes in an SDO_GEO_ADDR object, and returns matching addresses as an SDO_ADDR_ARRAY object. SDO_GCDR.REVERSE_GEOCODE Reverse geocodes a location, specified by its spatial geometry object and country, and returns an SDO_GEO_ADDR object. New Utility Subprograms
Subprogram Description SDO_UTIL.FROM_WKBGEOMETRY Converts a geometry in the wellknown binary (WKB) format to a Spatial geometry object. SDO_UTIL.FROM_WKTGEOMETRY Converts a geometry in the wellknown text (WKT) format to a Spatial geometry object. SDO_UTIL.RECTIFY_GEOMETRY Fixes certain problems with the input geometry, and returns a valid geometry. SDO_UTIL.TO_WKBGEOMETRY Converts a Spatial geometry object to the wellknown binary (WKB) format. SDO_UTIL.TO_WKTGEOMETRY Converts a Spatial geometry object to the wellknown text (WKT) format. SDO_UTIL.VALIDATE_WKBGEOMETRY Validates the input geometry, which is in the standard wellknown binary (WKB) format; returns the string TRUE
if the geometry is valid or FALSE
if the geometry is not valid.SDO_UTIL.VALIDATE_WKTGEOMETRY Validates the input geometry, which is of type CLOB or VARCHAR2 and in the standard wellknown text (WKT) format; returns the string TRUE
if the geometry is valid or FALSE
if the geometry is not valid.U.S. National Grid Support
Unknown and NaC Coordinate Reference Systems
unknown CRS
(SRID 999999) and NaC
(SRID 999998) coordinate reference systems have been added for Oracle internal use and other possible special uses. These coordinate reference systems are described in Section 6.9.4.Spatial Routing Engine
LRS_INTERSECTION Function
ḚІBH&p"u
20 SDO_UTIL Package (Utility)
Subprogram Description
geometry.xsd
schema document.
TRUE
if the geometry is valid or FALSE
if the geometry is not valid.
TRUE
if the geometry is valid or FALSE
if the geometry is not valid.
SDO_UTIL.APPEND
geom2
is to be appended.geom1
.geom1
and geom2
are based on different coordinate systems.cola_a
and cola_c
geometries. (The example uses the definitions and data from Section 2.1.)SELECT SDO_UTIL.APPEND(c_a.shape, c_c.shape)
FROM cola_markets c_a, cola_markets c_c
WHERE c_a.name = 'cola_a' AND c_c.name = 'cola_c';
SDO_UTIL.APPEND(C_A.SHAPE,C_C.SHAPE)(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SD

SDO_GEOMETRY(2007, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 3, 5, 1003, 1), SDO_
ORDINATE_ARRAY(1, 1, 5, 7, 3, 3, 6, 3, 6, 5, 4, 5, 3, 3))
SDO_UTIL.CIRCLE_POLYGON
arc_tolerance
parameter value has the same meaning and usage guidelines as the arc_tolerance
keyword value in the params
parameter string for the SDO_GEOM.SDO_ARC_DENSIFY function. The unit of measurement associated with the geometry is associated with the arc_tolerance
parameter value. (For more information, see the Usage Notes for the SDO_GEOM.SDO_ARC_DENSIFY function in Chapter 15.)Longitude / Latitude (WGS 84)
).radius
value of 100 meters and an arc_tolerance
value of 5 meters are used in computing the polygon vertices.SELECT SDO_UTIL.CIRCLE_POLYGON(71.34937, 42.46101, 100, 5)
FROM DUAL;
SDO_UTIL.CIRCLE_POLYGON(71.34937,42.46101,100,5)(SDO_GTYPE, SDO_SRID, SDO_POINT

SDO_GEOMETRY(2003, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
AY(71.34937, 42.4601107, 71.348653, 42.4602824, 71.348211, 42.4607321, 71.34
8211, 42.4612879, 71.348653, 42.4617376, 71.34937, 42.4619093, 71.350087, 42.
4617376, 71.350529, 42.4612879, 71.350529, 42.4607321, 71.350087, 42.4602824,
71.34937, 42.4601107))
SDO_UTIL.CONCAT_LINES
geom1
and geom2
must be DISJOINT or TOUCH; and if the relationship is TOUCH, the geometries must intersect only at two end points.geom1
and geom2
are based on different coordinate systems. Concatenate two touching lines: one from (1,1) to (5,1) and the
 other from (5,1) to (8,1).
SELECT SDO_UTIL.CONCAT_LINES(
SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(1,1, 5,1)),
SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(5,1, 8,1))
) FROM DUAL;
SDO_UTIL.CONCAT_LINES(SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,2,1),SDO

SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
1, 1, 5, 1, 8, 1))
SDO_UTIL.CONVERT_UNIT
10
.Degree
.from_unit
. For example, to convert decimal degrees to radians, specify Radian
.SQL> SELECT SDO_UTIL.CONVERT_UNIT(1, 'Radian', 'Degree') FROM DUAL;
SDO_UTIL.CONVERT_UNIT(1,'RADIAN','DEGREE')

57.2957796
SDO_UTIL.ELLIPSE_POLYGON
arc_tolerance
parameter value has the same meaning and usage guidelines as the arc_tolerance
keyword value in the params
parameter string for the SDO_GEOM.SDO_ARC_DENSIFY function. The unit of measurement associated with the geometry is associated with the arc_tolerance
parameter value. (For more information, see the Usage Notes for the SDO_GEOM.SDO_ARC_DENSIFY function in Chapter 15.)Longitude / Latitude (WGS 84)
).azimuth
= 90), around a point near the center of Concord, Massachusetts. An arc_tolerance
value of 5 meters is used in computing the polygon vertices.SELECT SDO_UTIL.ELLIPSE_POLYGON(71.34937, 42.46101, 100, 50, 90, 5)
FROM DUAL;
SDO_UTIL.ELLIPSE_POLYGON(71.34937,42.46101,100,50,90,5)(SDO_GTYPE, SDO_SRID, SD

SDO_GEOMETRY(2003, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
AY(71.350589, 42.46101, 71.350168, 42.4606701, 71.349708, 42.460578, 71.3493
7, 42.4605603, 71.349032, 42.460578, 71.348572, 42.4606701, 71.348151, 42.461
01, 71.348572, 42.4613499, 71.349032, 42.461442, 71.34937, 42.4614597, 71.34
9708, 42.461442, 71.350168, 42.4613499, 71.350589, 42.46101))
SDO_UTIL.EXTRACT
element
: 1 for the first subelement, 2 for the second subelement, and so on. This parameter is valid only for specifying a subelement of a polygon with one or more holes or of a point cluster:geometry
is null or has an SDO_GTYPE value ending in 0, this function returns a null geometry.geometry
cannot contain a type 0 (zero) element. Type 0 elements are described in Section 2.5.7.element
or ring
is an invalid number for geometry
.cola_c
geometry. (The example uses the definitions and data from Section 2.1.)SELECT c.name, SDO_UTIL.EXTRACT(c.shape, 1)
FROM cola_markets c WHERE c.name = 'cola_c';
NAME

SDO_UTIL.EXTRACT(C.SHAPE,1)(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_IN

cola_c
SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
AY(3, 3, 6, 3, 6, 5, 4, 5, 3, 3))
 Insert polygon with hole.
INSERT INTO cola_markets VALUES(
10,
'polygon_with_hole',
SDO_GEOMETRY(
2003,  twodimensional polygon
NULL,
NULL,
SDO_ELEM_INFO_ARRAY(1,1003,1, 19,2003,1),  polygon with hole
SDO_ORDINATE_ARRAY(2,4, 4,3, 10,3, 13,5, 13,9, 11,13, 5,13, 2,11, 2,4,
7,5, 7,10, 10,10, 10,5, 7,5)
)
);
1 row created.
 Extract the hole geometry (second subelement).
SELECT SDO_UTIL.EXTRACT(c.shape, 1, 2)
FROM cola_markets c WHERE c.name = 'polygon_with_hole';
SDO_UTIL.EXTRACT(C.SHAPE,1,2)(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_

SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
AY(7, 5, 10, 5, 10, 10, 7, 10, 7, 5))
SDO_UTIL.FROM_WKBGEOMETRY
cola_b
geometry from the COLA_MARKETS table.)DECLARE
wkbgeom BLOB;
wktgeom CLOB;
val_result VARCHAR2(5);
geom_result SDO_GEOMETRY;
geom SDO_GEOMETRY;
BEGIN
SELECT c.shape INTO geom FROM cola_markets c WHERE c.name = 'cola_b';
 To WBT/WKT geometry
wkbgeom := SDO_UTIL.TO_WKBGEOMETRY(geom);
wktgeom := SDO_UTIL.TO_WKTGEOMETRY(geom);
DBMS_OUTPUT.PUT_LINE('To WKT geometry result = '  TO_CHAR(wktgeom));
 From WBT/WKT geometry
geom_result := SDO_UTIL.FROM_WKBGEOMETRY(wkbgeom);
geom_result := SDO_UTIL.FROM_WKTGEOMETRY(wktgeom);
 Validate WBT/WKT geometry
val_result := SDO_UTIL.VALIDATE_WKBGEOMETRY(wkbgeom);
DBMS_OUTPUT.PUT_LINE('WKB validation result = '  val_result);
val_result := SDO_UTIL.VALIDATE_WKTGEOMETRY(wktgeom);
DBMS_OUTPUT.PUT_LINE('WKT validation result = '  val_result);
END;/
To WKT geometry result = POLYGON ((5.0 1.0, 8.0 1.0, 8.0 6.0, 5.0 7.0, 5.0 1.0))
WKB validation result = TRUE
WKT validation result = TRUE
SDO_UTIL.FROM_WKTGEOMETRY
cola_b
geometry from the COLA_MARKETS table.)DECLARE
wkbgeom BLOB;
wktgeom CLOB;
val_result VARCHAR2(5);
geom_result SDO_GEOMETRY;
geom SDO_GEOMETRY;
BEGIN
SELECT c.shape INTO geom FROM cola_markets c WHERE c.name = 'cola_b';
 To WBT/WKT geometry
wkbgeom := SDO_UTIL.TO_WKBGEOMETRY(geom);
wktgeom := SDO_UTIL.TO_WKTGEOMETRY(geom);
DBMS_OUTPUT.PUT_LINE('To WKT geometry result = '  TO_CHAR(wktgeom));
 From WBT/WKT geometry
geom_result := SDO_UTIL.FROM_WKBGEOMETRY(wkbgeom);
geom_result := SDO_UTIL.FROM_WKTGEOMETRY(wktgeom);
 Validate WBT/WKT geometry
val_result := SDO_UTIL.VALIDATE_WKBGEOMETRY(wkbgeom);
DBMS_OUTPUT.PUT_LINE('WKB validation result = '  val_result);
val_result := SDO_UTIL.VALIDATE_WKTGEOMETRY(wktgeom);
DBMS_OUTPUT.PUT_LINE('WKT validation result = '  val_result);
END;/
To WKT geometry result = POLYGON ((5.0 1.0, 8.0 1.0, 8.0 6.0, 5.0 7.0, 5.0 1.0))
WKB validation result = TRUE
WKT validation result = TRUE
SDO_UTIL.GETNUMELEM
SELECT c.name, SDO_UTIL.GETNUMELEM(c.shape)
FROM cola_markets c;
NAME SDO_UTIL.GETNUMELEM(C.SHAPE)
 
cola_a 1
cola_b 1
cola_c 1
cola_d 1
SDO_UTIL.GETNUMVERTICES
SELECT c.name, SDO_UTIL.GETNUMVERTICES(c.shape)
FROM cola_markets c;
NAME SDO_UTIL.GETNUMVERTICES(C.SHAPE)
 
cola_a 2
cola_b 5
cola_c 5
cola_d 3
SDO_UTIL.GETVERTICES
CREATE TYPE vertex_set_type as TABLE OF vertex_type;
CREATE TYPE vertex_type AS OBJECT
(x NUMBER,
y NUMBER,
z NUMBER,
w NUMBER,
id NUMBER);
ID
values of the vertices of the geometries in the SHAPE column of the COLA_MARKETS table. (The example uses the definitions and data from Section 2.1.)SELECT c.mkt_id, c.name, t.X, t.Y, t.id
FROM cola_markets c,
TABLE(SDO_UTIL.GETVERTICES(c.shape)) t
ORDER BY c.mkt_id, t.id;
MKT_ID NAME X Y ID
    
1 cola_a 1 1 1
1 cola_a 5 7 2
2 cola_b 5 1 1
2 cola_b 8 1 2
2 cola_b 8 6 3
2 cola_b 5 7 4
2 cola_b 5 1 5
3 cola_c 3 3 1
3 cola_c 6 3 2
3 cola_c 6 5 3
3 cola_c 4 5 4
3 cola_c 3 3 5
4 cola_d 8 7 1
4 cola_d 10 9 2
4 cola_d 8 11 3
15 rows selected.
SDO_UTIL.INITIALIZE_INDEXES_FOR_TTS
CALL SDO_UTIL.INITIALIZE_INDEX_FOR_TTS;
SDO_UTIL.POINT_AT_BEARING
start_point
and along the initial bearing direction to the computed destination point. Must be less than onehalf the circumference of the Earth.SELECT SDO_UTIL.POINT_AT_BEARING(
SDO_GEOMETRY(2001, 8307,
SDO_POINT_TYPE(72, 43, NULL), NULL, NULL),
1,  1 radian (57.296 degrees clockwise from North)
100000  100 kilometers
) FROM DUAL;
SDO_UTIL.POINT_AT_BEARING(SDO_GEOMETRY(2001,8307,SDO_POINT_TYPE(72,43,NULL),NUL

SDO_GEOMETRY(2001, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(
70.957053, 43.4811935))
SDO_UTIL.POLYGONTOLINE
SELECT SDO_UTIL.POLYGONTOLINE(
SDO_GEOMETRY(
2003,  twodimensional polygon
NULL,
NULL,
SDO_ELEM_INFO_ARRAY(1,1003,1),  one polygon (exterior polygon ring)
SDO_ORDINATE_ARRAY(5,1, 8,1, 8,6, 5,7, 5,1)
)
) FROM DUAL;
SDO_UTIL.POLYGONTOLINE(SDO_GEOMETRY(2003,TWODIMENSIONALPOLYGONNULL,NULL,SDO_E

SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
5, 1, 8, 1, 8, 6, 5, 7, 5, 1))
SDO_UTIL.PREPARE_FOR_TTS
TS1
to be transported to another database.CALL SDO_UTIL.PREPARE_FOR_TTS('TS1');
SDO_UTIL.RECTIFY_GEOMETRY
cola_b
geometry to see if it has problems that can be fixed. (In this case, the geometry is valid, so the input geometry is returned. The example uses the definitions and data from Section 2.1.)SELECT SDO_UTIL.RECTIFY_GEOMETRY(shape, 0.005) FROM COLA_MARKETS c WHERE c.name = 'cola_b';SDO_UTIL.RECTIFY_GEOMETRY(SHAPE,0.005)(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARRAY(5, 1, 8, 1, 8, 6, 5, 7, 5, 1))
SDO_UTIL.REMOVE_DUPLICATE_VERTICES
SELECT SDO_UTIL.REMOVE_DUPLICATE_VERTICES(
SDO_GEOMETRY(
2003,  twodimensional polygon
NULL,
NULL,
SDO_ELEM_INFO_ARRAY(1,1003,1),  one polygon (exterior polygon ring)
SDO_ORDINATE_ARRAY(5,1, 8,1, 8,1, 8,6, 5,7, 5,1)  2nd and 3rd points
 are duplicates.
),
0.005  tolerance value
) FROM DUAL;
SDO_UTIL.REMOVE_DUPLICATE_VERTICES(SDO_GEOMETRY(2003,TWODIMENSIONALPOLYGONNUL

SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
AY(5, 1, 8, 1, 8, 6, 5, 7, 5, 1))
SDO_UTIL.REVERSE_LINESTRING
SELECT SDO_UTIL.REVERSE_LINESTRING(
SDO_GEOMETRY(2002, 8307, NULL, SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(72,43, 71.5,43.5, 71,42, 70,40))
) FROM DUAL;
SDO_UTIL.REVERSE_LINESTRING(SDO_GEOMETRY(2002,8307,NULL,SDO_ELEM_INFO_ARRAY(1,2,

SDO_GEOMETRY(2002, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
70, 40, 71, 42, 71.5, 43.5, 72, 43))
SDO_UTIL.SIMPLIFY
threshold
; and for better performance, should not be the same as threshold
. If you do not specify a value, the default value is 0.0000005.SELECT SDO_UTIL.SIMPLIFY(
SDO_GEOMETRY(
3302,  line string, 3 dimensions (X,Y,M), 3rd is linear ref. dimension
NULL,
NULL,
SDO_ELEM_INFO_ARRAY(1,2,1),  one line string, straight segments
SDO_ORDINATE_ARRAY(
2,2,0,  Starting point  Exit1; 0 is measure from start.
2,4,2,  Exit2; 2 is measure from start.
8,4,8,  Exit3; 8 is measure from start.
12,4,12,  Exit4; 12 is measure from start.
12,10,NULL,  Not an exit; measure automatically calculated and filled.
8,10,22,  Exit5; 22 is measure from start.
5,14,27)  Ending point (Exit6); 27 is measure from start.
),
6,  threshold value for geometry simplification
0.5  tolerance
) FROM DUAL;
SDO_UTIL.SIMPLIFY(SDO_GEOMETRY(3302,LINESTRING,3DIMENSIONS(X,Y,M),3RDISLINEARR

SDO_GEOMETRY(3302, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
2, 2, 0, 12, 4, 12, 5, 14, 27))
SDO_UTIL.TO_GMLGEOMETRY
geometry.xsd
schema document.srsName="SDO:<srid>"
. For example, "SDO:8307"
indicates SDO_SRID 8307, and "SDO:"
indicates a null SDO_SRID value. No checks are made for the validity or consistency of the SDO_SRID value. For example, the value is not checked to see if it exists in the MDSYS.CS_SRS table or if it conflicts with the SRID value for the layer in the USER_SDO_GEOM_METADATA view.<coordinates>
tag and decimal='.'
, cs=','
(that is, with the comma as the coordinate separator), and ts=' '
(that is, with a space as the tuple separator), even if the NLS_NUMERIC_CHARACTERS setting has ','
(comma) as the decimal character.SET LONG 40000
). To get formatted GML output or to use the return value of TO_GMLGEOMETRY in SQLX or Oracle XML DB functions such as XMLELEMENT, use the XMLTYPE(clobval CLOB) constructor.cola_b
geometry in the COLA_MARKETS table. (The example uses the definitions and data from Section 2.1.) Convert cola_b geometry to GML fragment.
SELECT TO_CHAR(SDO_UTIL.TO_GMLGEOMETRY(shape)) AS GmlGeometry
FROM COLA_MARKETS c WHERE c.name = 'cola_b';
GMLGEOMETRY

<gml:Polygon srsName="SDO:" xmlns:gml="http://www.opengis.net/gml"><gml:outerBou
ndaryIs><gml:LinearRing><gml:coordinates decimal="." cs="," ts=" ">5,1 8,1 8,6 5
,7 5,1 </gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon>
cola_d
geometry in the COLA_MARKETS table. (The example uses the definitions and data from Section 2.1.)SET LONG 40000
SELECT XMLTYPE(SDO_UTIL.TO_GMLGEOMETRY(
SDO_GEOM.SDO_ARC_DENSIFY(c.shape, m.diminfo, 'arc_tolerance=0.05')))
AS GmlGeometry FROM cola_markets c, user_sdo_geom_metadata m
WHERE m.table_name = 'COLA_MARKETS' AND m.column_name = 'SHAPE'
AND c.name = 'cola_d';
GMLGEOMETRY

<gml:Polygon srsName="SDO:" xmlns:gml="http://www.opengis.net/gml"><gml:outerBou
ndaryIs><gml:LinearRing><gml:coordinates decimal="." cs="," ts=" ">8,7 8.7653668
6473018,7.15224093497743 9.4142135623731,7.58578643762691 9.84775906502257,8.234
63313526982 10,9 9.84775906502257,9.76536686473018 9.4142135623731,10.4142135623
731 8.76536686473018,10.8477590650226 8,11 7.23463313526982,10.8477590650226 6.5
8578643762691,10.4142135623731 6.15224093497743,9.76536686473018 6,9 6.152240934
97743,8.23463313526982 6.58578643762691,7.5857864376269 7.23463313526982,7.15224
093497743 8,7 </gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Pol
ygon>
SET LONG 40000
 Convert LRS geometry to standard geometry before using TO_GMLGEOMETRY.
SELECT XMLTYPE(SDO_UTIL.TO_GMLGEOMETRY(
SDO_LRS.CONVERT_TO_STD_GEOM(route_geometry)))
AS GmlGeometry FROM lrs_routes a WHERE a.route_id = 1;
GMLGEOMETRY

<gml:LineString srsName="SDO:" xmlns:gml="http://www.opengis.net/gml">
<gml:coordinates decimal="." cs="," ts=" ">2,2 2,4 8,4 12,4 12,10 8,10 5,14 </
gml:coordinates>
</gml:LineString>
 Point geometry with coordinates in SDO_ORDINATES. Note the
 coordinates in the GML are (10,10) and the values in the
 SDO_POINT field are discarded.
SELECT TO_CHAR(
SDO_UTIL.TO_GMLGEOMETRY(sdo_geometry(2001, 8307,
sdo_point_type(80, 70, null),
sdo_elem_info_array(1,1,1), sdo_ordinate_array(10, 10)))
)
AS GmlGeometry FROM DUAL;
GMLGEOMETRY

<gml:Point srsName="SDO:8307" xmlns:gml="http://www.opengis.net/gml"><gml:coordi
nates decimal="." cs="," ts=" ">10,10 </gml:coordinates></gml:Point>
 LRS geometry. An Empty CLOB is returned.
SELECT SDO_UTIL.TO_GMLGEOMETRY(
sdo_geometry(2306, 8307, null,
sdo_elem_info_array(1,1003,1, 13, 1003, 1, 23, 1003, 3),
sdo_ordinate_array(10.10,10.20, 20.50, 20.10, 30.30, 30.30, 40.10,
40.10, 30.50, 30.20, 10.10, 10.20,
5, 5, 5, 6, 6, 6, 6, 5, 5, 5, 7, 7, 8, 8 ))
) AS GmlGeometry FROM DUAL;
GMLGEOMETRY

 Rectangle (geodetic)
SELECT TO_CHAR(
SDO_UTIL.TO_GMLGEOMETRY(sdo_geometry(2003, 8307, null,
sdo_elem_info_array(1,1003,5),
sdo_ordinate_array(10.10,10.10, 20.10, 20.10 )))
)
AS GmlGeometry FROM DUAL;
GMLGEOMETRY

<gml:Box srsName="SDO:8307" xmlns:gml="http://www.opengis.net/gml"><gml:coordina
tes decimal="." cs="," ts=" ">10.1,10.1 20.1,20.1 </gml:coordinates></gml:Box>
 Polygon with holes
SELECT TO_CHAR(
SDO_UTIL.TO_GMLGEOMETRY(sdo_geometry(2003, 262152, null,
sdo_elem_info_array(1,1003,3, 5, 2003, 1, 13, 2003, 1),
sdo_ordinate_array(10.10,10.20, 40.50, 41.10, 30.30, 30.30, 30.30,
40.10, 40.10, 40.10, 30.30, 30.30, 5, 5, 5, 6, 6, 6, 6, 5, 5, 5 )))
)
AS GmlGeometry FROM DUAL;
GMLGEOMETRY

<gml:Polygon srsName="SDO:262152" xmlns:gml="http://www.opengis.net/gml"><gml:ou
terBoundaryIs><gml:LinearRing><gml:coordinates decimal="." cs="," ts=" ">10.1,10
.2, 40.5,10.2, 40.5,41.1, 10.1,41.1, 10.1,10.2 </gml:coordinates></gml:LinearRin
g></gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates de
cimal="." cs="," ts=" ">30.3,30.3 30.3,40.1 40.1,40.1 30.3,30.3 </gml:coordinate
s></gml:LinearRing></gml:innerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><g
ml:coordinates decimal="." cs="," ts=" ">5,5 5,6 6,6 6,5 5,5 </gml:coordinates><
/gml:LinearRing></gml:innerBoundaryIs></gml:Polygon>
 Creating an XMLTYPE from the GML fragment. Also useful for "pretty
 printing" the GML output.
SET LONG 40000
SELECT XMLTYPE(
SDO_UTIL.TO_GMLGEOMETRY(sdo_geometry(2003, 262152, null,
sdo_elem_info_array(1,1003,1, 11, 2003, 1, 21, 2003, 1),
sdo_ordinate_array(10.10,10.20, 40.50,10.2, 40.5,41.10, 10.1,41.1,
10.10, 10.20, 30.30,30.30, 30.30, 40.10, 40.10, 40.10, 40.10, 30.30,
30.30, 30.30, 5, 5, 5, 6, 6, 6, 6, 5, 5, 5 )))
)
AS GmlGeometry FROM DUAL;
GMLGEOMETRY

<gml:Polygon srsName="SDO:262152" xmlns:gml="http://www.opengis.net/gml"><gml:ou
terBoundaryIs><gml:LinearRing><gml:coordinates decimal="." cs="," ts=" ">10.1,10
.2 40.5,10.2 40.5,41.1 10.1,41.1 10.1,10.2 </gml:coordinates></gml:LinearRing></
gml:outerBoundaryIs><gml:innerBoundaryIs><gml:LinearRing><gml:coordinates decima
l="." cs="," ts=" ">30.3,30.3 30.3,40.1 40.1,40.1 40.1,30.3 30.3,30.3 </gml:coor
dinates></gml:LinearRing></gml:innerBoundaryIs><gml:innerBoundaryIs><gml:LinearR
ing><gml:coordinates decimal="." cs="," ts=" ">5,5 5,6 6,6 6,5 5,5 </gml:coordin
ates></gml:LinearRing></gml:innerBoundaryIs></gml:Polygon>
SELECT xmlelement("State", xmlattributes(
'http://www.opengis.net/gml' as "xmlns:gml"),
xmlforest(state as "Name", totpop as "Population",
xmltype(sdo_util.to_gmlgeometry(geom)) as "gml:geometryProperty"))
AS theXMLElements FROM states WHERE state_abrv in ('DE', 'UT');
THEXMLELEMENTS

<State xmlns:gml="http://www.opengis.net/gml">
<Name>Delaware</Name>
<Population>666168</Population>
<gml:geometryProperty>
<gml:Polygon srsName="SDO:" xmlns:gml="http://www.opengis.net/gml">
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">75.788704,39.721699 75.78
8704,39.6479 75.767014,39.377106 75.76033,39.296497 75.756294,39.24585 75.74
8016,39.143196 75.722961,38.829895 75.707695,38.635166 75.701912,38.560619 7
5.693871,38.460011 75.500336,38.454002 75.341614,38.451855 75.049339,38.45165
3 75.053841,38.538429 75.06015,38.605465 75.063263,38.611275 75.065308,38.62
949 75.065887,38.660919 75.078697,38.732403 75.082527,38.772045 75.091667,38
.801208 75.094185,38.803699 75.097572,38.802986 75.094116,38.793579 75.09926
6,38.78756 75.123619,38.781784 75.137962,38.782703 75.18692,38.803772 75.215
019,38.831547 75.23735,38.849014 75.260498,38.875 75.305908,38.914673 75.316
399,38.930309 75.317284,38.93676 75.312851,38.945576 75.312859,38.945618 75.
31205,38.967804 75.31778,38.986012 75.341431,39.021233 75.369606,39.041359 7
5.389229,39.051422 75.40181,39.06702 75.401306,39.097713 75.411369,39.148029
75.407845,39.175201 75.396271,39.187778 75.39225,39.203377 75.40181,39.23104
9 75.402817,39.253189 75.409355,39.264759 75.434006,39.290424 75.439041,39.3
13065 75.453125,39.317093 75.457657,39.326653 75.469231,39.330677 75.486336,
39.341743 75.494888,39.354324 75.504448,39.357346 75.51284,39.366291 75.5129
24,39.366482 75.523773,39.392052 75.538651,39.415707 75.56749,39.436436 75.5
9137,39.463696 75.592941,39.471806 75.590019,39.488026 75.587311,39.496136 7
5.5774,39.508076 75.554192,39.506947 75.528442,39.498005 75.530373,39.510303
75.527145,39.531326 75.52803,39.535168 75.53437,39.540592 75.519386,39.55528
6 75.512291,39.567505 75.515587,39.580639 75.528046,39.584 75.538269,39.5935
67 75.554016,39.601727 75.560143,39.622578 75.556602,39.6348 75.549599,39.63
7699 75.542397,39.645901 75.535507,39.647099 75.514999,39.668499 75.507523,3
9.69685 75.496597,39.701302 75.488914,39.714722 75.477997,39.714901 75.47550
2,39.733501 75.467972,39.746975 75.463707,39.761101 75.448494,39.773857 75.4
38301,39.783298 75.405701,39.796101 75.415405,39.801678 75.454102,39.820202 
75.499199,39.833199 75.539703,39.8381 75.5802,39.838417 75.594017,39.837345 
75.596107,39.837044 75.639488,39.82893 75.680145,39.813839 75.71096,39.796352
75.739716,39.772881 75.760689,39.74712 75.774101,39.721699 75.788704,39.721
699 </gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</gml:geometryProperty>
</State>
<State xmlns:gml="http://www.opengis.net/gml">
<Name>Utah</Name>
<Population>1722850</Population>
<gml:geometryProperty>
<gml:Polygon srsName="SDO:" xmlns:gml="http://www.opengis.net/gml">
<gml:outerBoundaryIs>
<gml:LinearRing>
<gml:coordinates decimal="." cs="," ts=" ">114.040871,41.993805 114.
038803,41.884899 114.041306,41 114.04586,40.116997 114.046295,39.906101 114.
046898,39.542801 114.049026,38.67741 114.049339,38.572968 114.049095,38.14864
114.0476,37.80946 114.05098,37.746284 114.051666,37.604805 114.052025,37.10
3989 114.049797,37.000423 113.484375,37 112.898598,37.000401 112.539604,37.0
00683 112,37.000977 111.412048,37.001514 111.133018,37.00079 110.75,37.00320
1 110.5,37.004265 110.469505,36.998001 110,36.997967 109.044571,36.999088 1
09.045143,37.375 109.042824,37.484692 109.040848,37.881176 109.041405,38.1530
27 109.041107,38.1647 109.059402,38.275501 109.059296,38.5 109.058868,38.719
906 109.051765,39 109.050095,39.366699 109.050697,39.4977 109.050499,39.6605
109.050156,40.222694 109.047577,40.653641 109.0494,41.000702 109.2313,41.00
2102 109.534233,40.998184 110,40.997398 110.047768,40.997696 110.5,40.994801
111.045982,40.998013 111.045815,41.251774 111.045097,41.579899 111.045944,4
2.001633 111.506493,41.999588 112.108742,41.997677 112.16317,41.996784 112.1
72562,41.996643 112.192184,42.001244 113,41.998314 113.875,41.988091 114.040
871,41.993805 </gml:coordinates>
</gml:LinearRing>
</gml:outerBoundaryIs>
</gml:Polygon>
</gml:geometryProperty>
</State>
SDO_UTIL.TO_WKBGEOMETRY
cola_b
geometry from the COLA_MARKETS table.)DECLARE
wkbgeom BLOB;
wktgeom CLOB;
val_result VARCHAR2(5);
geom_result SDO_GEOMETRY;
geom SDO_GEOMETRY;
BEGIN
SELECT c.shape INTO geom FROM cola_markets c WHERE c.name = 'cola_b';
 To WBT/WKT geometry
wkbgeom := SDO_UTIL.TO_WKBGEOMETRY(geom);
wktgeom := SDO_UTIL.TO_WKTGEOMETRY(geom);
DBMS_OUTPUT.PUT_LINE('To WKT geometry result = '  TO_CHAR(wktgeom));
 From WBT/WKT geometry
geom_result := SDO_UTIL.FROM_WKBGEOMETRY(wkbgeom);
geom_result := SDO_UTIL.FROM_WKTGEOMETRY(wktgeom);
 Validate WBT/WKT geometry
val_result := SDO_UTIL.VALIDATE_WKBGEOMETRY(wkbgeom);
DBMS_OUTPUT.PUT_LINE('WKB validation result = '  val_result);
val_result := SDO_UTIL.VALIDATE_WKTGEOMETRY(wktgeom);
DBMS_OUTPUT.PUT_LINE('WKT validation result = '  val_result);
END;/
To WKT geometry result = POLYGON ((5.0 1.0, 8.0 1.0, 8.0 6.0, 5.0 7.0, 5.0 1.0))
WKB validation result = TRUE
WKT validation result = TRUE
SDO_UTIL.TO_WKTGEOMETRY
cola_b
geometry from the COLA_MARKETS table.)DECLARE
wkbgeom BLOB;
wktgeom CLOB;
val_result VARCHAR2(5);
geom_result SDO_GEOMETRY;
geom SDO_GEOMETRY;
BEGIN
SELECT c.shape INTO geom FROM cola_markets c WHERE c.name = 'cola_b';
 To WBT/WKT geometry
wkbgeom := SDO_UTIL.TO_WKBGEOMETRY(geom);
wktgeom := SDO_UTIL.TO_WKTGEOMETRY(geom);
DBMS_OUTPUT.PUT_LINE('To WKT geometry result = '  TO_CHAR(wktgeom));
 From WBT/WKT geometry
geom_result := SDO_UTIL.FROM_WKBGEOMETRY(wkbgeom);
geom_result := SDO_UTIL.FROM_WKTGEOMETRY(wktgeom);
 Validate WBT/WKT geometry
val_result := SDO_UTIL.VALIDATE_WKBGEOMETRY(wkbgeom);
DBMS_OUTPUT.PUT_LINE('WKB validation result = '  val_result);
val_result := SDO_UTIL.VALIDATE_WKTGEOMETRY(wktgeom);
DBMS_OUTPUT.PUT_LINE('WKT validation result = '  val_result);
END;/
To WKT geometry result = POLYGON ((5.0 1.0, 8.0 1.0, 8.0 6.0, 5.0 7.0, 5.0 1.0))
WKB validation result = TRUE
WKT validation result = TRUE
SDO_UTIL.VALIDATE_WKBGEOMETRY
TRUE
if the geometry is valid or FALSE
if the geometry is not valid.cola_b
geometry from the COLA_MARKETS table.)DECLARE
wkbgeom BLOB;
wktgeom CLOB;
val_result VARCHAR2(5);
geom_result SDO_GEOMETRY;
geom SDO_GEOMETRY;
BEGIN
SELECT c.shape INTO geom FROM cola_markets c WHERE c.name = 'cola_b';
 To WBT/WKT geometry
wkbgeom := SDO_UTIL.TO_WKBGEOMETRY(geom);
wktgeom := SDO_UTIL.TO_WKTGEOMETRY(geom);
DBMS_OUTPUT.PUT_LINE('To WKT geometry result = '  TO_CHAR(wktgeom));
 From WBT/WKT! geometry
geom_result := SDO_UTIL.FROM_WKBGEOMETRY(wkbgeom);
geom_result := SDO_UTIL.FROM_WKTGEOMETRY(wktgeom);
 Validate WBT/WKT geometry
val_result := SDO_UTIL.VALIDATE_WKBGEOMETRY(wkbgeom);
DBMS_OUTPUT.PUT_LINE('WKB validation result = '  val_result);
val_result := SDO_UTIL.VALIDATE_WKTGEOMETRY(wktgeom);
DBMS_OUTPUT.PUT_LINE('WKT validation result = '  val_result);
END;/
To WKT geometry result = POLYGON ((5.0 1.0, 8.0 1.0, 8.0 6.0, 5.0 7.0, 5.0 1.0))
WKB validation result = TRUE
WKT validation result = TRUE
SDO_UTIL.VALIDATE_WKTGEOMETRY
TRUE
if the geometry is valid or FALSE
if the geometry is not valid.cola_b
geometry from the COLA_MARKETS table.)DECLARE
wkbgeom BLOB;
wktgeom CLOB;
val_result VARCHAR2(5);
geom_result SDO_GEOMETRY;
geom SDO_GEOMETRY;
BEGIN
SELECT c.shape INTO geom FROM cola_markets c WHERE c.name = 'cola_b';
 To WBT/WKT geometry
wkbgeom := SDO_UTIL.TO_WKBGEOMETRY(geom);
wktgeom := SDO_UTIL.TO_WKTGEOMETRY(geom);
DBMS_OUTPUT.PUT_LINE('To WKT geometry result = '  TO_CHAR(wktgeom));
 From WBT/WKT geometry
geom_result := SDO_UTIL.FROM_WKBGEOMETRY(wkbgeom);
geom_result := SDO_UTIL.FROM_WKTGEOMETRY(wktgeom);
 Validate WBT/WKT geometry
val_result := SDO_UTIL.VALIDATE_WKBGEOMETRY(wkbgeom);
DBMS_OUTPUT.PUT_LINE('WKB validation result = '  val_result);
val_result := SDO_UTIL.VALIDATE_WKTGEOMETRY(wktgeom);
DBMS_OUTPUT.PUT_LINE('WKT validation result = '  val_result);
END;/
To WKT geometry result = POLYGON ((5.0 1.0, 8.0 1.0, 8.0 6.0, 5.0 7.0, 5.0 1.0))
WKB validation result = TRUE
WKT validation result = TRUE
14 SDO_GCDR Package (Geocoding)
Subprogram Description
SDO_GCDR.GEOCODE
RELAX_BASE_NAME
match mode. It returns the longitude and latitude coordinates of this address as 122.41815 and 37.7784183, respectively.SELECT SDO_GCDR.GEOCODE('SCOTT', SDO_KEYWORDARRAY('1 Carlton B Goodlett Pl',
'San Francisco, CA 94102'), 'US', 'RELAX_BASE_NAME') FROM DUAL;
SDO_GCDR.GEOCODE('SCOTT',SDO_KEYWORDARRAY('1CARLTONBGOODLETTPL','SANFRANCISCO

SDO_GEO_ADDR(0, SDO_KEYWORDARRAY(), NULL, 'CARLTON B GOODLETT PL', NULL, NULL, '
SAN FRANCISCO', NULL, 'CA', 'US', '94102', NULL, '94102', NULL, '1', 'CARLTON B
GOODLETT', 'PL', 'F', 'F', NULL, NULL, 'L', .01, 23614360, 'nul?#ENUT?B281CP?',
1, 'DEFAULT', 122.41815, 37.7784183)
SDO_GCDR.GEOCODE_ADDR
CALIFORNIA PACIFIC MEDICAL CTR
. The example uses a userdefined function named create_addr_from_placename
(as defined in Example 52 in Section 5.4) to construct the input SDO_GEO_ADDR object.SELECT sdo_gcdr.geocode_addr('SCOTT',
create_addr_from_placename('CALIFORNIA PACIFIC MEDICAL CTR', 'US'))
FROM DUAL;
SDO_GCDR.GEOCODE_ADDR('SCOTT',CREATE_ADDR_FROM_PLACENAME('CALIFORNIAPACIFICME

SDO_GEO_ADDR(0, SDO_KEYWORDARRAY(), NULL, 'BUCHANAN ST', NULL, NULL, 'SAN FRANCI
SCO', NULL, 'CA', 'US', '94115', NULL, '94115', NULL, '2333', NULL, NULL, 'F', '
F', NULL, NULL, 'L', 0, 23599031, '??????????B281CP?', 4, 'DEFAULT', 122.43097,
37.79138)
SDO_GCDR.GEOCODE_ADDR_ALL
max_res_num
parameter), and returns an SDO_ADDR_ARRAY object in which each geocoded result has all possible attributes set.CALIFORNIA PACIFIC MEDICAL CTR
. (In this case only one result is returned, because the geocoding data contains only one address matching that point of interest.) The example uses a userdefined function named create_addr_from_placename
(as defined in Example 52 in Section 5.4) to construct the input SDO_GEO_ADDR object.SELECT sdo_gcdr.geocode_addr_all('SCOTT',
create_addr_from_placename('CALIFORNIA PACIFIC MEDICAL CTR', 'US'), 3)
FROM DUAL;
SDO_GCDR.GEOCODE_ADDR_ALL('SCOTT',CREATE_ADDR_FROM_PLACENAME('CALIFORNIAPACIF

SDO_ADDR_ARRAY(SDO_GEO_ADDR(0, SDO_KEYWORDARRAY(), 'CALIFORNIA PACIFIC MEDICAL C
TRSF', 'BUCHANAN ST', NULL, NULL, 'SAN FRANCISCO', NULL, 'CA', 'US', '94115', N
ULL, '94115', NULL, '2333', NULL, NULL, 'F', 'F', NULL, NULL, 'L', 0, 23599031,
'??????????B281CP?', 4, 'DEFAULT', 122.43097, 37.79138))
SDO_GCDR.GEOCODE_ALL
addr_lines
parameter. For example, if Main Street extends into two postal codes, or if there are two separate streets named Main Street in two separate postal codes, and if you specify Main Street and a city and state for this function, the returned SDO_ADDR_ARRAY array contains two SDO_GEO_ADDR objects, each reflecting the center point of Main Street in a particular postal code. The house or building number in each SDO_GEO_ADDR object is the house or building number located at the center point of the street segment, even if the input address contains no house or building number or a nonexistent number.SELECT SDO_GCDR.GEOCODE_ALL('SCOTT',
SDO_KEYWORDARRAY('Clay St', 'San Francisco, CA'),
'US', 'DEFAULT') FROM DUAL;
SDO_GCDR.GEOCODE_ALL('SCOTT',SDO_KEYWORDARRAY('CLAYST','SANFRANCISCO,CA'),'US

SDO_ADDR_ARRAY(SDO_GEO_ADDR(1, SDO_KEYWORDARRAY(), NULL, 'CLAY ST', NULL, NULL,
'SAN FRANCISCO', NULL, 'CA', 'US', '94108', NULL, '94108', NULL, '978', 'CLAY',
'ST', 'F', 'F', NULL, NULL, 'L', 0, 23600689, 'nul?#ENUT?B281CP?', 1, 'DEFAULT',
122.40904, 37.79385), SDO_GEO_ADDR(1, SDO_KEYWORDARRAY(), NULL, 'CLAY ST',
NULL, NULL, 'SAN FRANCISCO', NULL, 'CA', 'US', '94115', NULL, '94115', NULL, '27
98', 'CLAY', 'ST', 'F', 'F', NULL, NULL, 'L', 0, 23600709, 'nul?#ENUT?B281CP?',
1, 'DEFAULT', 122.43909, 37.79007), SDO_GEO_ADDR(1, SDO_KEYWORDARRAY(), NULL
, 'CLAY ST', NULL, NULL, 'SAN FRANCISCO', NULL, 'CA', 'US', '94118', NULL, '9411
8', NULL, '3698', 'CLAY', 'ST', 'F', 'F', NULL, NULL, 'L', 0, 23600718, 'nul?
#ENUT?B281CP?', 1, 'DEFAULT', 122.45372, 37.78822), SDO_GEO_ADDR(1, SDO_KEYWORD
ARRAY(), NULL, 'CLAY ST', NULL, NULL, 'SAN FRANCISCO', NULL, 'CA', 'US', '94109'
, NULL, '94109', NULL, '1698', 'CLAY', 'ST', 'F', 'F', NULL, NULL, 'L', 0, 23
600700, 'nul?#ENUT?B281CP?', 1, 'DEFAULT', 122.42093, 37.79236))
SDO_GCDR.GEOCODE_AS_GEOMETRY
'DEFAULT'
for the geocoding operation. Match modes are explained in Section 5.1.2.SELECT SDO_GCDR.GEOCODE_AS_GEOMETRY('SCOTT',
SDO_KEYWORDARRAY('1 Carlton B Goodlett Pl', 'San Francisco, CA 94102'),
'US') FROM DUAL;
SDO_GCDR.GEOCODE_AS_GEOMETRY('SCOTT',SDO_KEYWORDARRAY('1CARLTONBGOODLETTPL','

SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(122.41815, 37.7784183, NULL), NULL, NUL
L)
SDO_GCDR.REVERSE_GEOCODE
SELECT SDO_GCDR.REVERSE_GEOCODE('SCOTT',
SDO_GEOMETRY(2001, 8307,
SDO_POINT_TYPE(122.41815, 37.7784183, NULL), NULL, NULL),
'US') FROM DUAL;
SDO_GCDR.REVERSE_GEOCODE('SCOTT',SDO_GEOMETRY(2001,8307,SDO_POINT_TYPE(122.418

SDO_GEO_ADDR(0, SDO_KEYWORDARRAY(), NULL, 'POLK ST', NULL, NULL, 'SAN FRANCISCO'
, NULL, 'CA', 'US', '94102', NULL, '94102', NULL, '200', NULL, NULL, 'F', 'F', N
ULL, NULL, 'R', .00966633, 23614360, '', 1, 'DEFAULT', 122.41815, 37.7784177)
?1z Hr.:h
.0@xk\ԣTrJ +2Dh%0Ny:#,:PTYѨ< zR֦:)[iH{G@Ьb!DŸX@,38]5̈́úE0rT,ͮ@Al,zK_c0/^PF,F~ߋY}e1Zy\z1%%h$&kNרMViF쵞ĨHqY6EŠqDDL㝹8o8愎ŐQd#
DC&;hHY(=.rD~y@ .X9D쮌.~1£[v"
[YbΑ3&*@$T0l*
1Y@@*EU4x O8 !
z B=jAoɵ%,G\^27
F`B[,?L8&B>JA!^ a@TpCj
/JV~;nR@2~g*PHAry_C!p@x8$oRaZCr^6@Xe
@
H߳9?qtRi9l HKȨTNA@Pu'PUǢ^tYi+S"4r4CPuF )OSBЈVd>ݺvy^Ɓ7=\ ~23؈Qtcl@7}]*)HFl>^.'=ƸW^^%Vq2
?E7UV_ &o7g`g
}Fi>#
hd*~Zր^S5++v gb\;I@K<80=W&A
Ƕ}r5c4E d?4;ĆNpt&vh
m^7Bd?k*@uQ#p@!!G!?e,8G`Qb=pSOTET6P0F6փa Eh vE^uxt'a4OM@Q`Q¡RQ6ag8h5"P#aC⇃MDVGgÐy!ZNhboDgGDH7xt_dXpȍa!C@bĂ(C E(%aB
xRe_E&6Ѝٍxs@
8E^k+%6?@ZՐͅ3Pq b$YJe]= R1949 x` a#0 P_`2;_U,L eQtV ĕd_yaلp'afyXiSN%d9uI%Ɨ}i 3o ~
" yb3ɀ:10I3 )*3hb 3qP:r=.߇v EIe¹<93x
##S]ve@!P9ffhffqy
gItG@VI whhytD9POC03 DVF?Y pZF+@v@kv3,:
\F6 oyU(m$8f&ߦs@nK4n@
V䉘h
`qEP#p
pq`uQqqiN'D DTRh t<,0'@#s4w'1L'B:'?rtZpu>PGhup1=@9$u[ujG*'RwvzPRw 2Їy'tQ+ 4B
S7x#wǊ[T嫖sycJ
zD (pipzW7{K){gWev#טɡ!W"_a@" 0"PQ%*]%jtg Y ,j1QH@ΗA/M"Ea4F8*I 1 `KKdI3tJ*00dԵ0q;griBL/IFVN`,{
fk/@QR'CPR=8caʖ+ml`FVbEL#a)5.ҹDt@f&YY#R⽷o3
hk5#81
B*"?[Jp( U:kNoeJ@t3kb#,89F5y+9E&
JhR)"?%BTU;ĊAmS
U^@^@۪44x,W"ߊ2Vc1iHeN'`Hg6V%
`N6KQz)Nt4h0[nlO]СvIkUAJoMj۱C}pךܽvǐh+L(
3 Loading Spatial Data
3.1 Bulk Loading
3.1.1 Bulk Loading SDO_GEOMETRY Objects
LOAD DATA
INFILE *
TRUNCATE
CONTINUEIF NEXT(1:1) = '#'
INTO TABLE COLA_MARKETS
FIELDS TERMINATED BY ''
TRAILING NULLCOLS (
mkt_id INTEGER EXTERNAL,
name CHAR,
shape COLUMN OBJECT
(
SDO_GTYPE INTEGER EXTERNAL,
SDO_ELEM_INFO VARRAY TERMINATED BY '/'
(elements FLOAT EXTERNAL),
SDO_ORDINATES VARRAY TERMINATED BY '/'
(ordinates FLOAT EXTERNAL)
)
)
begindata
1cola_a
#2003110033/
#1157/
2cola_b
#2003110031/
#5181865751/
3cola_c
#2003110031/
#3363654533/
4cola_d
#2003110034/
#87109811/
EXTERNAL
keyword in the definition mkt_id INTEGER EXTERNAL
means that each value to be inserted into the MKT_ID column (1, 2, 3, and 4 in this example) is an integer in humanreadable form, not binary format.begindata
, each MKT_ID value is preceded by one space, because the CONTINUEIF NEXT(1:1) = '#'
specification causes the first position of each data line to be ignored unless it is the number sign (#) continuation character.CREATE TABLE POLY_4PT (GID VARCHAR2(32),
GEOMETRY SDO_GEOMETRY);
geometry rows: GID, GEOMETRY
LOAD DATA
INFILE *
TRUNCATE
CONTINUEIF NEXT(1:1) = '#'
INTO TABLE POLY_4PT
FIELDS TERMINATED BY ''
TRAILING NULLCOLS (
GID INTEGER EXTERNAL,
GEOMETRY COLUMN OBJECT
(
SDO_GTYPE INTEGER EXTERNAL,
SDO_ELEM_INFO VARRAY TERMINATED BY '/'
(elements FLOAT EXTERNAL),
SDO_ORDINATES VARRAY TERMINATED BY '/'
(ordinates FLOAT EXTERNAL)
)
)
begindata
12003110031/
#122.421537.7862122.42237.7869122.42137.789122.4237.7866
#122.421537.7862/
22003110031/
#122.401937.8052122.402737.8055122.403137.806122.401237.8052
#122.401937.8052/
32003110031/
#122.42637.803122.424237.8053122.4235537.8044122.423537.8025
#122.42637.803/
3.1.2 Bulk Loading PointOnly Data in SDO_GEOMETRY Objects
LOAD DATA
INFILE *
TRUNCATE
CONTINUEIF NEXT(1:1) = '#'
INTO TABLE POINT
FIELDS TERMINATED BY ''
TRAILING NULLCOLS (
GID INTEGER EXTERNAL,
GEOMETRY COLUMN OBJECT
(
SDO_GTYPE INTEGER EXTERNAL,
SDO_POINT COLUMN OBJECT
(X FLOAT EXTERNAL,
Y FLOAT EXTERNAL)
)
)
BEGINDATA
1 2001 122.4215 37.7862
2 2001 122.4019 37.8052
3 2001 122.426 37.803
4 2001 122.4171 37.8034
5 2001 122.416151 37.8027228
3.2 Transactional Insert Operations Using SQL
CREATE OR REPLACE PROCEDURE
INSERT_GEOM(GEOM SDO_GEOMETRY)
IS
BEGIN
INSERT INTO TEST_1 VALUES (GEOM);
COMMIT;
END;
/
geom
and then invokes the INSERT_GEOM procedure to insert that geometry.DECLARE
geom SDO_geometry :=
SDO_geometry (2003, null, null,
SDO_elem_info_array (1,1003,3),
SDO_ordinate_array (109,37,102,40));
BEGIN
INSERT_GEOM(geom);
COMMIT;
END;
/
16 SDO_LRS Package (Linear Referencing System)
Subprogram Description
Subprogram Description
Subprogram Description
SDO_LRS.CLIP_GEOM_SEGMENT
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
, start_measure
, or end_measure
is invalid.start_measure
and end_measure
can be any points on the geometric segment. They do not have to be in any specific order. For example, start_measure
and end_measure
can be 5 and 10, respectively, or 10 and 5, respectively.SELECT SDO_LRS.CLIP_GEOM_SEGMENT(route_geometry, 5, 10)
FROM lrs_routes WHERE route_id = 1;
SDO_LRS.CLIP_GEOM_SEGMENT(ROUTE_GEOMETRY,5,10)(SDO_GTYPE, SDO_SRID, SDO_POINT(X,

SDO_GEOMETRY(3302, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
5, 4, 5, 8, 4, 8, 10, 4, 10))
SDO_LRS.CONCATENATE_GEOM_SEGMENTS
geom_segment_1
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment_2
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment_1
or geom_segment_2
has an invalid geometry type or dimensionality, or if geom_segment_1
and geom_segment_2
are based on different coordinate systems.geom_segment_1
and geom_segment_2
must be line or multiline. Neither can be a polygon.result_geom_1
, result_geom_2
, and result_geom_3
are displayed in Example 73.)DECLARE
geom_segment SDO_GEOMETRY;
line_string SDO_GEOMETRY;
dim_array SDO_DIM_ARRAY;
result_geom_1 SDO_GEOMETRY;
result_geom_2 SDO_GEOMETRY;
result_geom_3 SDO_GEOMETRY;
BEGIN
SELECT a.route_geometry into geom_segment FROM lrs_routes a
WHERE a.route_name = 'Route1';
SELECT m.diminfo into dim_array from
user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY';
 Define the LRS segment for Route1.
SDO_LRS.DEFINE_GEOM_SEGMENT (geom_segment,
dim_array,
0,  Zero starting measure: LRS segment starts at start of route.
27);  End of LRS segment is at measure 27.
SELECT a.route_geometry INTO line_string FROM lrs_routes a
WHERE a.route_name = 'Route1';
 Split Route1 into two segments.
SDO_LRS.SPLIT_GEOM_SEGMENT(line_string,dim_array,5,result_geom_1,result_geom_2);
 Concatenate the segments that were just split.
result_geom_3 := SDO_LRS.CONCATENATE_GEOM_SEGMENTS(result_geom_1, dim_array, result_geom_2, dim_array);
 Insert geometries into table, to display later.
INSERT INTO lrs_routes VALUES(
11,
'result_geom_1',
result_geom_1
);
INSERT INTO lrs_routes VALUES(
12,
'result_geom_2',
result_geom_2
);
INSERT INTO lrs_routes VALUES(
13,
'result_geom_3',
result_geom_3
);
END;
/
SDO_LRS.CONNECTED_GEOM_SEGMENTS
geom_segment_1
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment_2
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment_1
or geom_segment_2
has an invalid geometry type or dimensionality, or if geom_segment_1
and geom_segment_2
are based on different coordinate systems. Are result_geom_1 and result_geom2 connected?
SELECT SDO_LRS.CONNECTED_GEOM_SEGMENTS(a.route_geometry,
b.route_geometry, 0.005)
FROM lrs_routes a, lrs_routes b
WHERE a.route_id = 11 AND b.route_id = 12;
SDO_LRS.CONNECTED_GEOM_SEGMENTS(A.ROUTE_GEOMETRY,B.ROUTE_GEOMETRY,0.005)

TRUE
SDO_LRS.CONVERT_TO_LRS_DIM_ARRAY
M
, if not otherwise specified).dim_pos
is specified), and sets the SDO_DIMNAME value in this added SDO_DIM_ELEMENT to M (unless another dim_name
is specified). It sets the other values in the added SDO_DIM_ELEMENT according to the values of the upper_bound
, lower_bound
, and tolerance
parameter values.dim_array
already contains dimensional information, the dim_array
is returned.SELECT SDO_LRS.CONVERT_TO_LRS_DIM_ARRAY(m.diminfo)
FROM user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY';
SDO_LRS.CONVERT_TO_LRS_DIM_ARRAY(M.DIMINFO)(SDO_DIMNAME, SDO_LB, SDO_UB, SDO_TOL

SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', 0, 20, .005), SDO_DIM_ELEMENT('Y', 0, 20, .00
5), SDO_DIM_ELEMENT('M', 0, 20, .005))
SDO_LRS.CONVERT_TO_LRS_GEOM
standard_geom
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).standard_geom
has an invalid geometry type or dimensionality, if m_pos
is less than 3 or greater than 4, or if start_measure
or end_measure
is out of range.m_pos
parameter is not available for SDO_LRS.CONVERT_TO_LRS_GEOM_3D. For information about _3D formats of LRS functions, see Section 7.4.SELECT SDO_LRS.CONVERT_TO_LRS_GEOM(a.route_geometry, m.diminfo)
FROM lrs_routes a, user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY'
AND a.route_id = 1;
SDO_LRS.CONVERT_TO_LRS_GEOM(A.ROUTE_GEOMETRY,M.DIMINFO)(SDO_GTYPE, SDO_SRID, SDO

SDO_GEOMETRY(3002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
2, 2, 0, 2, 4, 2, 8, 4, 8, 12, 4, 12, 12, 10, NULL, 8, 10, 22, 5, 14, 27))
SDO_LRS.CONVERT_TO_LRS_LAYER
table_name
containing the SDO_GEOMETRY objects.M
is assumed.column_name
, you must delete (drop) the index before converting the layer and create a new index after converting the layer. For information about deleting and creating indexes, see the DROP INDEX and CREATE INDEX statements in Chapter 10.SDO_DIM_ELEMENT('M', NULL, NULL, NULL)
is included in the definition).BEGIN
IF (SDO_LRS.CONVERT_TO_LRS_LAYER('LRS_ROUTES', 'ROUTE_GEOMETRY') = 'TRUE')
THEN
DBMS_OUTPUT.PUT_LINE('Conversion from STD_LAYER to LRS_LAYER succeeded.');
ELSE
DBMS_OUTPUT.PUT_LINE('Conversion from STD_LAYER to LRS_LAYER failed.');
END IF;
END;
.
/
Conversion from STD_LAYER to LRS_LAYER succeeded.
PL/SQL procedure successfully completed.
SQL> SELECT diminfo FROM user_sdo_geom_metadata WHERE table_name = 'LRS_ROUTES' AND column_name = 'ROUTE_GEOMETRY';
DIMINFO(SDO_DIMNAME, SDO_LB, SDO_UB, SDO_TOLERANCE)

SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', 0, 20, .005), SDO_DIM_ELEMENT('Y', 0, 20, .00
5), SDO_DIM_ELEMENT('M', NULL, NULL, NULL))
SDO_LRS.CONVERT_TO_STD_DIM_ARRAY
dim_array
.m_pos
is invalid (less than 3 or greater than 4).dim_array
is already a standard dimensional array (that is, does not contain dimensional information), the dim_array
is returned.SELECT SDO_LRS.CONVERT_TO_STD_DIM_ARRAY(m.diminfo)
FROM user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY';
SDO_LRS.CONVERT_TO_STD_DIM_ARRAY(M.DIMINFO)(SDO_DIMNAME, SDO_LB, SDO_UB, SDO_TOL

SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', 0, 20, .005), SDO_DIM_ELEMENT('Y', 0, 20, .00
5))
SDO_LRS.CONVERT_TO_STD_GEOM
lrs_geom
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).SELECT SDO_LRS.CONVERT_TO_STD_GEOM(a.route_geometry, m.diminfo)
FROM lrs_routes a, user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY'
AND a.route_id = 1;
SDO_LRS.CONVERT_TO_STD_GEOM(A.ROUTE_GEOMETRY,M.DIMINFO)(SDO_GTYPE, SDO_SRID, SDO

SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
2, 2, 2, 4, 8, 4, 12, 4, 12, 10, 8, 10, 5, 14))
SDO_LRS.CONVERT_TO_STD_LAYER
table_name
containing the SDO_GEOMETRY objects.column_name
, you must delete (drop) the index before converting the layer and create a new index after converting the layer. For information about deleting and creating indexes, see the DROP INDEX and CREATE INDEX statements in Chapter 10.SDO_DIM_ELEMENT('M', NULL, NULL, NULL)
is included in the definition).BEGIN
IF (SDO_LRS.CONVERT_TO_STD_LAYER('LRS_ROUTES', 'ROUTE_GEOMETRY') = 'TRUE')
THEN
DBMS_OUTPUT.PUT_LINE('Conversion from LRS_LAYER to STD_LAYER succeeded.');
ELSE
DBMS_OUTPUT.PUT_LINE('Conversion from LRS_LAYER to STD_LAYER failed.');
END IF;
END;
.
/
Conversion from LRS_LAYER to STD_LAYER succeeded.
PL/SQL procedure successfully completed.
SELECT diminfo FROM user_sdo_geom_metadata
WHERE table_name = 'LRS_ROUTES' AND column_name = 'ROUTE_GEOMETRY';
DIMINFO(SDO_DIMNAME, SDO_LB, SDO_UB, SDO_TOLERANCE)

SDO_DIM_ARRAY(SDO_DIM_ELEMENT('X', 0, 20, .005), SDO_DIM_ELEMENT('Y', 0, 20, .00
5))
SDO_LRS.DEFINE_GEOM_SEGMENT
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
has an invalid geometry type or dimensionality, or if start_measure
or end_measure
is out of range.geom_segment
) in the database, you must execute an UPDATE or INSERT statement, as appropriate.result_geom_1
, result_geom_2
, and result_geom_3
are displayed in Example 73.)DECLARE
geom_segment SDO_GEOMETRY;
line_string SDO_GEOMETRY;
dim_array SDO_DIM_ARRAY;
result_geom_1 SDO_GEOMETRY;
result_geom_2 SDO_GEOMETRY;
result_geom_3 SDO_GEOMETRY;
BEGIN
SELECT a.route_geometry into geom_segment FROM lrs_routes a
WHERE a.route_name = 'Route1';
SELECT m.diminfo into dim_array from
user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY';
 Define the LRS segment for Route1. This will populate any null measures.
SDO_LRS.DEFINE_GEOM_SEGMENT (geom_segment,
dim_array,
0,  Zero starting measure: LRS segment starts at start of route.
27);  End of LRS segment is at measure 27.
SELECT a.route_geometry INTO line_string FROM lrs_routes a
WHERE a.route_name = 'Route1';
 Split Route1 into two segments.
SDO_LRS.SPLIT_GEOM_SEGMENT(line_string,dim_array,5,result_geom_1,result_geom_2);
 Concatenate the segments that were just split.
result_geom_3 := SDO_LRS.CONCATENATE_GEOM_SEGMENTS(result_geom_1, dim_array, result_geom_2, dim_array);
 Update and insert geometries into table, to display later.
UPDATE lrs_routes a SET a.route_geometry = geom_segment
WHERE a.route_id = 1;
INSERT INTO lrs_routes VALUES(
11,
'result_geom_1',
result_geom_1
);
INSERT INTO lrs_routes VALUES(
12,
'result_geom_2',
result_geom_2
);
INSERT INTO lrs_routes VALUES(
13,
'result_geom_3',
result_geom_3
);
END;
/
SDO_LRS.DYNAMIC_SEGMENT
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
, start_measure
, or end_measure
is invalid.SELECT SDO_LRS.DYNAMIC_SEGMENT(route_geometry, 5, 10)
FROM lrs_routes WHERE route_id = 1;
SDO_LRS.DYNAMIC_SEGMENT(ROUTE_GEOMETRY,5,10)(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y

SDO_GEOMETRY(3302, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
5, 4, 5, 8, 4, 8, 10, 4, 10))
SDO_LRS.FIND_LRS_DIM_POS
table_name
containing the SDO_GEOMETRY objects.SELECT SDO_LRS.FIND_LRS_DIM_POS('LRS_ROUTES', 'ROUTE_GEOMETRY') FROM DUAL;
SDO_LRS.FIND_LRS_DIM_POS('LRS_ROUTES','ROUTE_GEOMETRY')

3
SDO_LRS.FIND_MEASURE
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
that is closest to the projection point.geom_segment
that is closest to the projection point. For example, if the projection point represents a shopping mall, the function could be used to find how far from the start of the highway is the point on the highway that is closest to the shopping mall.geom_segment
has an invalid geometry type or dimensionality, or if geom_segment
and point
are based on different coordinate systems. Find measure for point on segment closest to 10,7.
 Should return 15 (for point 12,7).
SELECT SDO_LRS.FIND_MEASURE(a.route_geometry, m.diminfo,
SDO_GEOMETRY(3001, NULL, NULL,
SDO_ELEM_INFO_ARRAY(1, 1, 1),
SDO_ORDINATE_ARRAY(10, 7, NULL)) )
FROM lrs_routes a, user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY'
AND a.route_id = 1;
SDO_LRS.FIND_MEASURE(A.ROUTE_GEOMETRY,M.DIMINFO,SDO_GEOMETRY(3001,NULL,NUL

15
SDO_LRS.FIND_OFFSET
point
.geom_segment
is to be returned.geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).point
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).offset
output parameter: it passes in the geometric segment and point information, and it returns the SDO_LRS.PROJECT_PT offset
parameter value. Thus, to find the offset of a point from a geometric segment, you can use either this function or the SDO_LRS.PROJECT_PT function with the offset
parameter.geom_segment
or point
has an invalid geometry type or dimensionality, or if geom_segment
and point
are based on different coordinate systems. Find the offset of point (9,3,NULL) from the road; should return 1.
SELECT SDO_LRS.FIND_OFFSET(route_geometry,
SDO_GEOMETRY(3301, NULL, NULL,
SDO_ELEM_INFO_ARRAY(1, 1, 1),
SDO_ORDINATE_ARRAY(9, 3, NULL)) )
FROM lrs_routes WHERE route_id = 1;
SDO_LRS.FIND_OFFSET(ROUTE_GEOMETRY,SDO_GEOMETRY(3301,NULL,NULL,SDO_ELEM_INFO_ARR

1
SDO_LRS.GEOM_SEGMENT_END_MEASURE
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
.geom_segment
has an invalid geometry type or dimensionality.SELECT SDO_LRS.GEOM_SEGMENT_END_MEASURE(route_geometry)
FROM lrs_routes WHERE route_id = 1;
SDO_LRS.GEOM_SEGMENT_END_MEASURE(ROUTE_GEOMETRY)

27
SDO_LRS.GEOM_SEGMENT_END_PT
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
.geom_segment
has an invalid geometry type or dimensionality.SELECT SDO_LRS.GEOM_SEGMENT_END_PT(route_geometry)
FROM lrs_routes WHERE route_id = 1;
SDO_LRS.GEOM_SEGMENT_END_PT(ROUTE_GEOMETRY)(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y,

SDO_GEOMETRY(3301, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(
5, 14, 27))
SDO_LRS.GEOM_SEGMENT_LENGTH
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
. The length is the geometric length, which is not the same as the total of the measure unit values. To determine how long a segment is in terms of measure units, subtract the result of an SDO_LRS.GEOM_SEGMENT_START_MEASURE operation from the result of an SDO_LRS.GEOM_SEGMENT_END_MEASURE operation.geom_segment
has an invalid geometry type or dimensionality.SELECT SDO_LRS.GEOM_SEGMENT_LENGTH(route_geometry)
FROM lrs_routes WHERE route_id = 1;
SDO_LRS.GEOM_SEGMENT_LENGTH(ROUTE_GEOMETRY)

27
SDO_LRS.GEOM_SEGMENT_START_MEASURE
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
.geom_segment
has an invalid geometry type or dimensionality.SELECT SDO_LRS.GEOM_SEGMENT_START_MEASURE(route_geometry)
FROM lrs_routes WHERE route_id = 1;
SDO_LRS.GEOM_SEGMENT_START_MEASURE(ROUTE_GEOMETRY)

0
SDO_LRS.GEOM_SEGMENT_START_PT
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
.geom_segment
has an invalid geometry type or dimensionality.SELECT SDO_LRS.GEOM_SEGMENT_START_PT(route_geometry)
FROM lrs_routes WHERE route_id = 1;
SDO_LRS.GEOM_SEGMENT_START_PT(ROUTE_GEOMETRY)(SDO_GTYPE, SDO_SRID, SDO_POINT(X,

SDO_GEOMETRY(3301, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(
2, 2, 0))
SDO_LRS.GET_MEASURE
point
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).point
is not valid, an "invalid LRS point" exception is raised.SELECT SDO_LRS.GET_MEASURE(
SDO_LRS.PROJECT_PT(a.route_geometry, m.diminfo,
SDO_GEOMETRY(3001, NULL, NULL,
SDO_ELEM_INFO_ARRAY(1, 1, 1),
SDO_ORDINATE_ARRAY(9, 3, NULL)) ),
m.diminfo )
FROM lrs_routes a, user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY'
AND a.route_id = 1;
SDO_LRS.GET_MEASURE(SDO_LRS.PROJECT_PT(A.ROUTE_GEOMETRY,M.DIMINFO,SDO_GEOM

9
SDO_LRS.GET_NEXT_SHAPE_PT
point
is not on geom_segment
, the point on the geometric segment closest to the specified point is computed, and the next shape point after that point is returned.geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).measure
or point
identifies the end point of the geometric segment, a null value is returned.measure
is not a valid value for geom_segment
or if point
is not a valid LRS point.SELECT SDO_LRS.GET_NEXT_SHAPE_PT(a.route_geometry, 14)
FROM lrs_routes a WHERE a.route_id = 1;
SDO_LRS.GET_NEXT_SHAPE_PT(A.ROUTE_GEOMETRY,14)(SDO_GTYPE, SDO_SRID, SDO_POINT(X,

SDO_GEOMETRY(3301, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(
12, 10, 18))
SDO_LRS.GET_NEXT_SHAPE_PT_MEASURE
point
is not on geom_segment
, the point on the geometric segment closest to the specified point is computed, and the measure value of the next shape point after that point is returned.geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).measure
or point
identifies the end point of the geometric segment, a null value is returned.measure
is not a valid value for geom_segment
or if point
is not a valid LRS point.SELECT SDO_LRS.GET_NEXT_SHAPE_PT_MEASURE(a.route_geometry, 14)
FROM lrs_routes a WHERE a.route_id = 1;
SDO_LRS.GET_NEXT_SHAPE_PT_MEASURE(A.ROUTE_GEOMETRY,14)

18
SDO_LRS.GET_PREV_SHAPE_PT
point
is not on geom_segment
, the point on the geometric segment closest to the specified point is computed, and the closest shape point before that point is returned.geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).measure
or point
identifies the start point of the geometric segment, a null value is returned.measure
is not a valid value for geom_segment
or if point
is not a valid LRS point.SELECT SDO_LRS.GET_PREV_SHAPE_PT(a.route_geometry, 14)
FROM lrs_routes a WHERE a.route_id = 1;
SDO_LRS.GET_PREV_SHAPE_PT(A.ROUTE_GEOMETRY,14)(SDO_GTYPE, SDO_SRID, SDO_POINT(X,

SDO_GEOMETRY(3301, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(
12, 4, 12))
SDO_LRS.GET_PREV_SHAPE_PT_MEASURE
point
is not on geom_segment
, the point on the geometric segment closest to the specified point is computed, and the measure value of the closest shape point before that point is returned.geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).measure
or point
identifies the start point of the geometric segment, a null value is returned.measure
is not a valid value for geom_segment
or if point
is not a valid LRS point.SELECT SDO_LRS.GET_PREV_SHAPE_PT_MEASURE(a.route_geometry, 14)
FROM lrs_routes a WHERE a.route_id = 1;
SDO_LRS.GET_PREV_SHAPE_PT_MEASURE(A.ROUTE_GEOMETRY,14)

12
SDO_LRS.IS_GEOM_SEGMENT_DEFINED
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
is defined correctly and FALSE if geom_segment
is not defined correctly.geom_segment
must be defined (cannot be null), and any measures assigned must be in an ascending or descending order along the segment direction.SELECT SDO_LRS.IS_GEOM_SEGMENT_DEFINED(route_geometry)
FROM lrs_routes WHERE route_id = 1;
SDO_LRS.IS_GEOM_SEGMENT_DEFINED(ROUTE_GEOMETRY)

TRUE
SDO_LRS.IS_MEASURE_DECREASING
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
must be defined (cannot be null).SELECT SDO_LRS.IS_MEASURE_DECREASING(a.route_geometry, m.diminfo)
FROM lrs_routes a, user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY'
AND a.route_id = 1;
SDO_LRS.IS_MEASURE_DECREASING(A.ROUTE_GEOMETRY,M.DIMINFO)

FALSE
SDO_LRS.IS_MEASURE_INCREASING
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
must be defined (cannot be null).SELECT SDO_LRS.IS_MEASURE_INCREASING(a.route_geometry, m.diminfo)
FROM lrs_routes a, user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY'
AND a.route_id = 1;
SDO_LRS.IS_MEASURE_INCREASING(A.ROUTE_GEOMETRY,M.DIMINFO)

TRUE
SDO_LRS.IS_SHAPE_PT_MEASURE
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).measure
is not a valid value for geom_segment
.SELECT SDO_LRS.IS_SHAPE_PT_MEASURE(a.route_geometry, 14)
FROM lrs_routes a WHERE a.route_id = 1;
SDO_LRS.IS_SHAPE_PT_MEASURE(A.ROUTE_GEOMETRY,14)

FALSE
SDO_LRS.LOCATE_PT
measure
.geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
.measure
units from the start point of geom_segment
. The default is 0 (that is, the point is on geom_segment
).offset
is the same as for the coordinate system associated with geom_segment
. For geodetic data, the default unit of measurement is meters.geom_segment
has an invalid geometry type or dimensionality, or if the location is out of range.offset
parameter is not available for SDO_LRS.LOCATE_PT_3D. For information about _3D formats of LRS functions, see Section 7.4. Create a table for accidents.
CREATE TABLE accidents (
accident_id NUMBER PRIMARY KEY,
route_id NUMBER,
accident_geometry SDO_GEOMETRY);
 Insert an accident record.
DECLARE
geom_segment SDO_GEOMETRY;
BEGIN
SELECT SDO_LRS.LOCATE_PT(a.route_geometry, 9, 0) into geom_segment
FROM lrs_routes a WHERE a.route_name = 'Route1';
INSERT INTO accidents VALUES(1, 1, geom_segment);
END;
/
SELECT * from accidents;
ACCIDENT_ID ROUTE_ID
 
ACCIDENT_GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_OR

1 1
SDO_GEOMETRY(3301, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(
9, 4, 9))
SDO_LRS.LRS_INTERSECTION
geom_1
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_2
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).
tolerance
is used, all geometry objects must be defined using 4digit SDO_GTYPE values (explained in Section 2.2.1).geom_1
and geom_2
are based on different coordinate systems.geom_1
geometry. (This example uses the definitions from the example in Section 7.7.) Intersection of LRS segment and standard line segment
SELECT SDO_LRS.LRS_INTERSECTION(route_geometry,
SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(8,2, 8,6)), 0.005)
FROM lrs_routes WHERE route_id = 1;
SDO_LRS.LRS_INTERSECTION(ROUTE_GEOMETRY,SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INF

SDO_GEOMETRY(3301, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(
8, 4, 8))
geom_1
geometry. (This example uses the definitions from the example in Section 7.7.)SELECT SDO_LRS.LRS_INTERSECTION(route_geometry,
SDO_GEOMETRY(2002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1,2,1),
SDO_ORDINATE_ARRAY(12,2, 12,6)), 0.005)
FROM lrs_routes WHERE route_id = 1;
SDO_LRS.LRS_INTERSECTION(ROUTE_GEOMETRY,SDO_GEOMETRY(2002,NULL,NULL,SDO_ELEM_INF

SDO_GEOMETRY(3302, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
12, 4, 12, 12, 6, 14))
SDO_LRS.MEASURE_RANGE
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
from the end measure of geom_segment
.SELECT SDO_LRS.MEASURE_RANGE(route_geometry)
FROM lrs_routes WHERE route_id = 1;
SDO_LRS.MEASURE_RANGE(ROUTE_GEOMETRY)

27
SDO_LRS.MEASURE_TO_PERCENTAGE
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
is 50 and measure
is 20, the function returns 40 (because 20/50 = 40%).geom_segment
or measure
is invalid.SELECT SDO_LRS.MEASURE_TO_PERCENTAGE(a.route_geometry, m.diminfo, 5)
FROM lrs_routes a, user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY'
AND a.route_id = 1;
SDO_LRS.MEASURE_TO_PERCENTAGE(A.ROUTE_GEOMETRY,M.DIMINFO,5)

18.5185185
SDO_LRS.OFFSET_GEOM_SEGMENT
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
at which to start the offset operation.geom_segment
at which to start the offset operation.geom_segment
. Positive offset values are to the left of geom_segment
; negative offset values are to the right of geom_segment
.unit
and an SDO_UNIT value from the MDSYS.SDO_DIST_UNITS table. See Section 2.8 for more information about unit of measurement specification.arc_tolerance
and an arc tolerance value. See the Usage Notes for the SDO_GEOM.SDO_ARC_DENSIFY function in Chapter 15 for more information about the arc_tolerance
keyword.arc_tolerance
must be specified. If the input geometry is Cartesian or projected data, arc_tolerance
has no effect and should not be specified.arc_tolerance
keyword is specified for a geodetic geometry but the unit
keyword is not specified, the unit of measurement associated with the data is assumed.start_measure
and end_measure
can be any points on the geometric segment. They do not have to be in any specific order. For example, start_measure
and end_measure
can be 5 and 10, respectively, or 10 and 5, respectively.geom_segment
must be line or multiline. For example, it cannot be a polygon.geom_segment
, start_measure
, or end_measure
is invalid. Create a segment offset 2 to the left from measures 5 through 10.
 First, display the original segment; then, offset.
SELECT a.route_geometry FROM lrs_routes a WHERE a.route_id = 1;
ROUTE_GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDIN

SDO_GEOMETRY(3302, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
2, 2, 0, 2, 4, 2, 8, 4, 8, 12, 4, 12, 12, 10, 18, 8, 10, 22, 5, 14, 27))
SELECT SDO_LRS.OFFSET_GEOM_SEGMENT(a.route_geometry, m.diminfo, 5, 10, 2)
FROM lrs_routes a, user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY'
AND a.route_id = 1;
SDO_LRS.OFFSET_GEOM_SEGMENT(A.ROUTE_GEOMETRY,M.DIMINFO,5,10,2)(SDO_GTYPE, SDO_SR

SDO_GEOMETRY(3302, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
5, 6, 5, 10, 6, 10))
SDO_LRS.PERCENTAGE_TO_MEASURE
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
is 50 and percentage
is 40, the function returns 20 (because 40% of 50 = 20).geom_segment
has an invalid geometry type or dimensionality, or if percentage
is less than 0 or greater than 100.SELECT SDO_LRS.PERCENTAGE_TO_MEASURE(a.route_geometry, m.diminfo, 50)
FROM lrs_routes a, user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY'
AND a.route_id = 1;
SDO_LRS.PERCENTAGE_TO_MEASURE(A.ROUTE_GEOMETRY,M.DIMINFO,50)

13.5
SDO_LRS.PROJECT_PT
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).point
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).point
). The projection point is on the geometric segment.offset
, the function stores the signed offset (shortest distance) from the point to the geometric segment. For more information about the offset to a geometric segment, see Section 7.1.5.geom_segment
or point
has an invalid geometry type or dimensionality, or if geom_segment
and point
are based on different coordinate systems. Point 9,3,NULL is off the road; should return 9,4,9.
SELECT SDO_LRS.PROJECT_PT(route_geometry,
SDO_GEOMETRY(3301, NULL, NULL,
SDO_ELEM_INFO_ARRAY(1, 1, 1),
SDO_ORDINATE_ARRAY(9, 3, NULL)) )
FROM lrs_routes WHERE route_id = 1;
SDO_LRS.PROJECT_PT(ROUTE_GEOMETRY,SDO_GEOMETRY(3301,NULL,NULL,SDO_EL

SDO_GEOMETRY(3301, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(
9, 4, 9))
SDO_LRS.REDEFINE_GEOM_SEGMENT
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
has an invalid geometry type or dimensionality, or if start_measure
or end_measure
is out of range. First, display the original segment; then, redefine.
SELECT a.route_geometry FROM lrs_routes a WHERE a.route_id = 1;
ROUTE_GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDIN

SDO_GEOMETRY(3302, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
2, 2, 0, 2, 4, 2, 8, 4, 8, 12, 4, 12, 12, 10, 18, 8, 10, 22, 5, 14, 27))
 Redefine geometric segment to "convert" miles to kilometers.
DECLARE
geom_segment SDO_GEOMETRY;
dim_array SDO_DIM_ARRAY;
BEGIN
SELECT a.route_geometry into geom_segment FROM lrs_routes a
WHERE a.route_name = 'Route1';
SELECT m.diminfo into dim_array from
user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY';
 "Convert" mile measures to kilometers (27 * 1.609 = 43.443).
SDO_LRS.REDEFINE_GEOM_SEGMENT (geom_segment,
dim_array,
0,  Zero starting measure: LRS segment starts at start of route.
43.443);  End of LRS segment. 27 miles = 43.443 kilometers.
 Update and insert geometries into table, to display later.
UPDATE lrs_routes a SET a.route_geometry = geom_segment
WHERE a.route_id = 1;
END;
/
PL/SQL procedure successfully completed.
 Display the redefined segment, with all measures "converted."
SELECT a.route_geometry FROM lrs_routes a WHERE a.route_id = 1;
ROUTE_GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDIN

SDO_GEOMETRY(3302, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
2, 2, 0, 2, 4, 3.218, 8, 4, 12.872, 12, 4, 19.308, 12, 10, 28.962, 8, 10, 35.398
, 5, 14, 43.443))
SDO_LRS.RESET_MEASURE
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
has an invalid geometry type or dimensionality. First, display the original segment; then, redefine.
SELECT a.route_geometry FROM lrs_routes a WHERE a.route_id = 1;
ROUTE_GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDIN

SDO_GEOMETRY(3302, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
2, 2, 0, 2, 4, 2, 8, 4, 8, 12, 4, 12, 12, 10, 18, 8, 10, 22, 5, 14, 27))
 Reset geometric segment measures.
DECLARE
geom_segment SDO_GEOMETRY;
BEGIN
SELECT a.route_geometry into geom_segment FROM lrs_routes a
WHERE a.route_name = 'Route1';
SDO_LRS.RESET_MEASURE (geom_segment);
 Update and insert geometries into table, to display later.
UPDATE lrs_routes a SET a.route_geometry = geom_segment
WHERE a.route_id = 1;
END;
/
PL/SQL procedure successfully completed.
 Display the segment, with all measures set to null.
SELECT a.route_geometry FROM lrs_routes a WHERE a.route_id = 1;
ROUTE_GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDIN

SDO_GEOMETRY(3302, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
2, 2, NULL, 2, 4, NULL, 8, 4, NULL, 12, 4, NULL, 12, 10, NULL, 8, 10, NULL, 5, 1
4, NULL))
SDO_LRS.REVERSE_GEOMETRY
geom
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom
geom
is the end measure of the returned geometric segment, the end measure of geom
is the start measure of the returned geometric segment, and all other measures are adjusted accordingly.geom
geom
has an invalid geometry type or dimensionality. The geometry type must be a line or multiline, and the dimensionality must be 3 (two dimensions plus the measure dimension). Reverse direction and measures (for example, to prepare for
 concatenating with another road).
 First, display the original segment; then, reverse.
SELECT a.route_geometry FROM lrs_routes a WHERE a.route_id = 1;
ROUTE_GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDIN

SDO_GEOMETRY(3302, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
2, 2, 0, 2, 4, 2, 8, 4, 8, 12, 4, 12, 12, 10, 18, 8, 10, 22, 5, 14, 27))
SELECT SDO_LRS.REVERSE_GEOMETRY(a.route_geometry, m.diminfo)
FROM lrs_routes a, user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY'
AND a.route_id = 1;
SDO_LRS.REVERSE_GEOMETRY(A.ROUTE_GEOMETRY,M.DIMINFO)(SDO_GTYPE, SDO_SRID, SDO_PO

SDO_GEOMETRY(3302, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
5, 14, 27, 8, 10, 22, 12, 10, 18, 12, 4, 12, 8, 4, 8, 2, 4, 2, 2, 2, 0))
SDO_LRS.REVERSE_MEASURE
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
geom_segment
is the end measure of the returned geometric segment, the end measure of geom_segment
is the start measure of the returned geometric segment, and all other measures are adjusted accordingly.geom_segment
geom_segment
has an invalid geometry type or dimensionality.
 First, display the original segment; then, reverse.
SELECT a.route_geometry FROM lrs_routes a WHERE a.route_id = 1;
ROUTE_GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDIN

SDO_GEOMETRY(3302, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
2, 2, 0, 2, 4, 2, 8, 4, 8, 12, 4, 12, 12, 10, 18, 8, 10, 22, 5, 14, 27))
SELECT SDO_LRS.REVERSE_MEASURE(a.route_geometry, m.diminfo)
FROM lrs_routes a, user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY'
AND a.route_id = 1;
SDO_LRS.REVERSE_MEASURE(A.ROUTE_GEOMETRY,M.DIMINFO)(SDO_GTYPE, SDO_SRID, SDO_POI

SDO_GEOMETRY(3302, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
2, 2, 27, 2, 4, 25, 8, 4, 19, 12, 4, 15, 12, 10, 9, 8, 10, 5, 5, 14, 0))
SDO_LRS.SET_PT_MEASURE
geom_segment
(in the second format) or point
(in the fourth format), usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).point
(in the second format), usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
and point
are specified, the behavior of the procedure depends on whether or not point
is a shape point on geom_segment
:point
is a shape point on geom_segment
, the measure value of point
is set.point
is not a shape point on geom_segment
, the shape point on geom_segment
that is nearest to point
is found, and the measure value of that shape point is set.geom_segment
parameter are available for SDO_LRS.SET_PT_MEASURE_3D. For information about _3D formats of LRS functions, see Section 7.4.geo
Km_segment
or point
is invalid. Set the measure value of point 8,10 to 20 (originally 22).
DECLARE
geom_segment SDO_GEOMETRY;
dim_array SDO_DIM_ARRAY;
result VARCHAR2(32);
BEGIN
SELECT a.route_geometry into geom_segment FROM lrs_routes a
WHERE a.route_name = 'Route1';
SELECT m.diminfo into dim_array from
user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY';
 Set the measure value of point 8,10 to 20 (originally 22).
result := SDO_LRS.SET_PT_MEASURE (geom_segment,
SDO_GEOMETRY(3301, NULL, NULL,
SDO_ELEM_INFO_ARRAY(1, 1, 1),
SDO_ORDINATE_ARRAY(8, 10, 22)),
20);
 Display the result.
DBMS_OUTPUT.PUT_LINE('Returned value = '  result);
END;
/
Returned value = TRUE
PL/SQL procedure successfully completed.
SDO_LRS.SPLIT_GEOM_SEGMENT
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
to the split point.geom_segment
.geom_segment
or split_measure
is invalid.result_geom_1
, result_geom_2
, and result_geom_3
are displayed in Example 73.)DECLARE
geom_segment SDO_GEOMETRY;
line_string SDO_GEOMETRY;
dim_array SDO_DIM_ARRAY;
result_geom_1 SDO_GEOMETRY;
result_geom_2 SDO_GEOMETRY;
result_geom_3 SDO_GEOMETRY;
BEGIN
SELECT a.route_geometry into geom_segment FROM lrs_routes a
WHERE a.route_name = 'Route1';
SELECT m.diminfo into dim_array from
user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY';
 Define the LRS segment for Route1.
SDO_LRS.DEFINE_GEOM_SEGMENT (geom_segment,
dim_array,
0,  Zero starting measure: LRS segment starts at start of route.
27);  End of LRS segment is at measure 27.
SELECT a.route_geometry INTO line_string FROM lrs_routes a
WHERE a.route_name = 'Route1';
 Split Route1 into two segments.
SDO_LRS.SPLIT_GEOM_SEGMENT(line_string,dim_array,5,result_geom_1,result_geom_2);
 Concatenate the segments that were just split.
result_geom_3 := SDO_LRS.CONCATENATE_GEOM_SEGMENTS(result_geom_1, dim_array, result_geom_2, dim_array);
 Insert geometries into table, to display later.
INSERT INTO lrs_routes VALUES(
11,
'result_geom_1',
result_geom_1
);
INSERT INTO lrs_routes VALUES(
12,
'result_geom_2',
result_geom_2
);
INSERT INTO lrs_routes VALUES(
13,
'result_geom_3',
result_geom_3
);
END;
/
SDO_LRS.TRANSLATE_MEASURE
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).translate_m
to the start and end measures of geom_segment
. For example, if geom_segment
has a start measure of 50 and an end measure of 100, and if translate_m
is 10, the returned geometric segment has a start measure of 60 and an end measure of 110, as shown in Figure 161.geom_segment
has an invalid geometry type or dimensionality.SELECT SDO_LRS.TRANSLATE_MEASURE(a.route_geometry, m.diminfo, 10)
FROM lrs_routes a, user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY'
AND a.route_id = 1;
SDO_LRS.TRANSLATE_MEASURE(A.ROUTE_GEOMETRY,M.DIMINFO,10)(SDO_GTYPE, SDO_SRID, SD

SDO_GEOMETRY(3002, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 2, 1), SDO_ORDINATE_ARRAY(
2, 2, 10, 2, 4, 12, 8, 4, 18, 12, 4, 22, 12, 10, 28, 8, 10, 32, 5, 14, 37))
SDO_LRS.VALID_GEOM_SEGMENT
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
is valid and FALSE if geom_segment
is not valid.SELECT SDO_LRS.VALID_GEOM_SEGMENT(route_geometry)
FROM lrs_routes WHERE route_id = 1;
SDO_LRS.VALID_GEOM_SEGMENT(ROUTE_GEOMETRY)

TRUE
SDO_LRS.VALID_LRS_PT
point
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).point
is valid and FALSE if point
is not valid.point
is a point with measure information, and it checks for the geometry type and number of dimensions for the point geometry.SELECT SDO_LRS.VALID_LRS_PT(
SDO_GEOMETRY(3301, NULL, NULL,
SDO_ELEM_INFO_ARRAY(1, 1, 1),
SDO_ORDINATE_ARRAY(9, 3, NULL)),
m.diminfo)
FROM lrs_routes a, user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY'
AND a.route_id = 1;
SDO_LRS.VALID_LRS_PT(SDO_GEOMETRY(3301,NULL,NULL,SDO_ELEM_INFO_ARRAY(1,1,1),SDO_

TRUE
SDO_LRS.VALID_MEASURE
measure
falls within its measure range.geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
.measure
falls within the measure range of geom_segment
and FALSE if measure
does not fall within the measure range of geom_segment
.geom_segment
has an invalid geometry type or dimensionality.SELECT SDO_LRS.VALID_MEASURE(route_geometry, 50)
FROM lrs_routes WHERE route_id = 1;
SDO_LRS.VALID_MEASURE(ROUTE_GEOMETRY,50)

FALSE
SDO_LRS.VALIDATE_LRS_GEOMETRY
geom_segment
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom_segment
is valid and one of the following errors if geom_segment
is not valid:SELECT SDO_LRS.VALIDATE_LRS_GEOMETRY(a.route_geometry, m.diminfo)
FROM lrs_routes a, user_sdo_geom_metadata m
WHERE m.table_name = 'LRS_ROUTES' AND m.column_name = 'ROUTE_GEOMETRY'
AND a.route_id = 1;
SDO_LRS.VALIDATE_LRS_GEOMETRY(A.ROUTE_GEOMETRY,M.DIMINFO)

TRUE
15 SDO_GEOM Package (Geometry)
Subprogram Description
SDO_GEOM.RELATE
geom1
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom2
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).SDO_GEOM.RELATE
function, unless you need to use the function. For example, the DETERMINE mask keyword does not apply with the SDO_RELATE operator. For more information about performance considerations with operators and functions, see Section 1.9.SDO_GEOM.RELATE
function can return the following types of answers:mask
listing one or more relationships, the function returns the name of the relationship if it is true for the pair of geometries. If all relationships are false, the procedure returns FALSE.mask
, the function returns the one relationship keyword that best matches the geometries.mask
, the function returns TRUE if the two geometries are not disjoint.mask
relationships can be tested:mask
can be combined using the logical Boolean operator OR. For example, 'INSIDE + TOUCH' returns 'INSIDE + TOUCH' or 'FALSE' depending on the outcome of the test.tol
is used, all geometry objects must be defined using 4digit SDO_GTYPE values (explained in Section 2.2.1).geom1
and geom2
are based on different coordinate systems.cola_b
geometry. (The example uses the definitions and data from Section 2.1. The output is reformatted for readability.)SELECT c.name,
SDO_GEOM.RELATE(c.shape, 'determine', c_b.shape, 0.005) relationship
FROM cola_markets c, cola_markets c_b WHERE c_b.name = 'cola_b';
NAME RELATIONSHIP
 cola_a TOUCH
cola_b EQUAL
cola_c OVERLAPBDYINTERSECT
cola_d DISJOINT
SDO_GEOM.SDO_ARC_DENSIFY
geom
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).params
parameter is a quoted string that can contain the arc_tolerance
keyword, as well as the unit
keyword to identify the unit of measurement associated with the arc_tolerance
value. For example:'arc_tolerance=0.05 unit=km'
arc_tolerance
keyword specifies, for each arc in the geometry, the maximum length of the perpendicular line between the surface of the arc and the straight line between the start and end points of the arc. Figure 151 shows a line whose length is the arc_tolerance
value for the arc between points A and B.arc_tolerance
keyword value must be greater than the tolerance value associated with the geometry. (The default value for arc_tolerance
is 20 times the tolerance value.) As you increase the arc_tolerance
keyword value, the resulting polygon has fewer sides and a smaller area; as you decrease the arc_tolerance
keyword value, the resulting polygon has more sides and a larger area (but never larger than the original geometry).unit
keyword is specified, the value must be an SDO_UNIT value from the MDSYS.SDO_DIST_UNITS table (for example, 'unit=KM'). If the unit
keyword is not specified, the unit of measurement associated with the geometry is used. See Section 2.8 for more information about unit of measurement specification.tol
is used, all geometry objects must be defined using 4digit SDO_GTYPE values (explained in Section 2.2.1).cola_d
, which is a circle. (The example uses the definitions and data from Section 2.1.) Arc densification of the circle cola_d
SELECT c.name, SDO_GEOM.SDO_ARC_DENSIFY(c.shape, m.diminfo,
'arc_tolerance=0.05')
FROM cola_markets c, user_sdo_geom_metadata m
WHERE m.table_name = 'COLA_MARKETS' AND m.column_name = 'SHAPE'
AND c.name = 'cola_d';
NAME

SDO_GEOM.SDO_ARC_DENSIFY(C.SHAPE,M.DIMINFO,'ARC_TOLERANCE=0.05')(SDO_GTYPE, SDO_

cola_d
SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
AY(8, 7, 8.76536686, 7.15224093, 9.41421356, 7.58578644, 9.84775907, 8.23463314,
10, 9, 9.84775907, 9.76536686, 9.41421356, 10.4142136, 8.76536686, 10.8477591,
8, 11, 7.23463314, 10.8477591, 6.58578644, 10.4142136, 6.15224093, 9.76536686, 6
, 9, 6.15224093, 8.23463314, 6.58578644, 7.58578644, 7.23463314, 7.15224093, 8,
7))
SDO_GEOM.SDO_AREA
geom
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).unit=
and an SDO_UNIT value from the MDSYS.SDO_AREA_UNITS table (for example, 'unit=SQ_KM'). See Section 2.8 for more information about unit of measurement specification.tol
is used, all geometry objects must be defined using 4digit SDO_GTYPE values (explained in Section 2.2.1).cola_a
. (The example uses the definitions and data from Section 2.1.) Return the areas of all cola markets.
SELECT name, SDO_GEOM.SDO_AREA(shape, 0.005) FROM cola_markets;
NAME SDO_GEOM.SDO_AREA(SHAPE,0.005)
 
cola_a 24
cola_b 16.5
cola_c 5
cola_d 12.5663706
 Return the area of just cola_a.
SELECT c.name, SDO_GEOM.SDO_AREA(c.shape, 0.005) FROM cola_markets c
WHERE c.name = 'cola_a';
NAME SDO_GEOM.SDO_AREA(C.SHAPE,0.005)
 
cola_a 24
SDO_GEOM.SDO_BUFFER
geom
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).dim
parameter) or in the tol
parameter.unit
and an SDO_UNIT value from the MDSYS.SDO_DIST_UNITS table. It identifies the unit of measurement associated with the dist
parameter value, and also with the arc tolerance value if the arc_tolerance
keyword is specified. See Section 2.8 for more information about unit of measurement specification.arc_tolerance
and an arc tolerance value. See the Usage Notes for the SDO_GEOM.SDO_ARC_DENSIFY function in this chapter for more information about the arc_tolerance
keyword.'unit=km arc_tolerance=0.05'
arc_tolerance
is not specified, the default value is the tolerance value multiplied by 20. Spatial uses the arc_tolerance
value to perform arc densification in computing the result. If the input geometry is Cartesian or projected data, arc_tolerance
has no effect and should not be specified.arc_tolerance
keyword is specified for a geodetic geometry but the unit
keyword is not specified, the unit of measurement associated with the data is assumed.tol
is used, all geometry objects must be defined using 4digit SDO_GTYPE values (explained in Section 2.2.1).cola_a
. Note the rounded corners (for example, at .292893219,.292893219) in the returned polygon. (The example uses the nongeodetic definitions and data from Section 2.1.) Generate a buffer of 1 unit around a geometry.
SELECT c.name, SDO_GEOM.SDO_BUFFER(c.shape, m.diminfo, 1)
FROM cola_markets c, user_sdo_geom_metadata m
WHERE m.table_name = 'COLA_MARKETS' AND m.column_name = 'SHAPE'
AND c.name = 'cola_a';
NAME

SDO_GEOM.SDO_BUFFER(C.SHAPE,M.DIMINFO,1)(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z)

cola_a
SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1005, 8, 1, 2, 2, 5, 2, 1,
7, 2, 2, 11, 2, 1, 13, 2, 2, 17, 2, 1, 19, 2, 2, 23, 2, 1), SDO_ORDINATE_ARRAY(
0, 1, .292893219, .292893219, 1, 0, 5, 0, 5.70710678, .292893219, 6, 1, 6, 7, 5.
70710678, 7.70710678, 5, 8, 1, 8, .292893219, 7.70710678, 0, 7, 0, 1))
cola_a
using the geodetic definitions and data from Section 6.11. Generate a buffer of 1 kilometer around a geometry.
SELECT c.name, SDO_GEOM.SDO_BUFFER(c.shape, m.diminfo, 1,
'unit=km arc_tolerance=0.05')
FROM cola_markets c, user_sdo_geom_metadata m
WHERE m.table_name = 'COLA_MARKETS'
AND m.column_name = 'SHAPE' AND c.name = 'cola_a';
NAME

SDO_GEOM.SDO_BUFFER(C.SHAPE,M.DIMINFO,1,'UNIT=KMARC_TOLERANCE=0.05')(SDO_GTYPE,

cola_a
SDO_GEOMETRY(2003, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
AY(.991023822, 1.00002073, .992223711, .995486419, .99551726, .99217077, 1.00001
929, .990964898, 4.99998067, .990964929, 5.00448268, .9921708, 5.00777624, .9954
86449, 5.00897618, 1.00002076, 5.00904194, 6.99997941, 5.00784065, 7.00450033, 5
.00454112, 7.00781357, 5.00002479, 7.009034, .999975166, 7.00903403, .995458814,
7.00781359, .992159303, 7.00450036, .990958058, 6.99997944, .991023822, 1.00002
073))
SDO_GEOM.SDO_CENTROID
geom
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom1
is not a polygon, multipolygon, point, or point cluster, as identified by the SDO_GTYPE value in the SDO_GEOMETRY object.geom1
is a point, the function returns the point (the input geometry).tol
is used, all geometry objects must be defined using 4digit SDO_GTYPE values (explained in Section 2.2.1).cola_c
. (The example uses the definitions and data from Section 2.1.) Return the centroid of a geometry.
SELECT c.name, SDO_GEOM.SDO_CENTROID(c.shape, m.diminfo)
FROM cola_markets c, user_sdo_geom_metadata m
WHERE m.table_name = 'COLA_MARKETS' AND m.column_name = 'SHAPE'
AND c.name = 'cola_c';
NAME

SDO_GEOM.SDO_CENTROID(C.SHAPE,M.DIMINFO)(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z)

cola_c
SDO_GEOMETRY(2001, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(
4.73333333, 3.93333333))
SDO_GEOM.SDO_CONVEXHULL
geom1
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom1
) contains any arc elements, the function calculates the minimum bounding rectangle (MBR) for each arc element and uses these MBRs in calculating the convex hull of the geometry. If the geometry object (geom1
) is a circle, the function returns a square that minimally encloses the circle.geom1
is of point type, has fewer than three points or vertices, or consists of multiple points all in a straight line.tol
is used, all geometry objects must be defined using 4digit SDO_GTYPE values (explained in Section 2.2.1).cola_c
. (The example uses the definitions and data from Section 2.1. This specific example, however, does not produce useful output—the returned polygon has the same vertices as the input polygon—because the input polygon is already a simple convex polygon.) Return the convex hull of a polygon.
SELECT c.name, SDO_GEOM.SDO_CONVEXHULL(c.shape, m.diminfo)
FROM cola_markets c, user_sdo_geom_metadata m
WHERE m.table_name = 'COLA_MARKETS' AND m.column_name = 'SHAPE'
AND c.name = 'cola_c';
NAME

SDO_GEOM.SDO_CONVEXHULL(C.SHAPE,M.DIMINFO)(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y,

cola_c
SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
AY(6, 3, 6, 5, 4, 5, 3, 3, 6, 3))
SDO_GEOM.SDO_DIFFERENCE
geom1
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom2
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom1
) and another polygon (geom2
).tol
is used, all geometry objects must be defined using 4digit SDO_GTYPE values (explained in Section 2.2.1).geom1
and geom2
are based on different coordinate systems.cola_a
and cola_c
. (The example uses the definitions and data from Section 2.1.) Return the topological difference of two geometries.
SELECT SDO_GEOM.SDO_DIFFERENCE(c_a.shape, m.diminfo, c_c.shape, m.diminfo)
FROM cola_markets c_a, cola_markets c_c, user_sdo_geom_metadata m
WHERE m.table_name = 'COLA_MARKETS' AND m.column_name = 'SHAPE'
AND c_a.name = 'cola_a' AND c_c.name = 'cola_c';
SDO_GEOM.SDO_DIFFERENCE(C_A.SHAPE,M.DIMINFO,C_C.SHAPE,M.DIMINFO)(SDO_GTYPE, SDO_

SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
AY(1, 7, 1, 1, 5, 1, 5, 3, 3, 3, 4, 5, 5, 5, 5, 7, 1, 7)
SDO_GEOM.SDO_DISTANCE
geom2
is to be computed.geom1
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom1
is to be computed.geom2
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).unit=
and an SDO_UNIT value from the MDSYS.SDO_DIST_UNITS table (for example, 'unit=KM'). See Section 2.8 for more information about unit of measurement specification.tol
is used, all geometry objects must be defined using 4digit SDO_GTYPE values (explained in Section 2.2.1).geom1
and geom2
are based on different coordinate systems.cola_b
and cola_d
. (The example uses the definitions and data from Section 2.1.) Return the distance between two geometries.
SELECT SDO_GEOM.SDO_DISTANCE(c_b.shape, c_d.shape, 0.005)
FROM cola_markets c_b, cola_markets c_d
WHERE c_b.name = 'cola_b' AND c_d.name = 'cola_d';
SDO_GEOM.SDO_DISTANCE(C_B.SHAPE,C_D.SHAPE,0.005)

.846049894
SDO_GEOM.SDO_INTERSECTION
geom1
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom2
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom1
) and another polygon (geom2
).tol
is used, all geometry objects must be defined using 4digit SDO_GTYPE values (explained in Section 2.2.1).geom1
and geom2
are based on different coordinate systems.cola_a
and cola_c
. (The example uses the definitions and data from Section 2.1.) Return the topological intersection of two geometries.
SELECT SDO_GEOM.SDO_INTERSECTION(c_a.shape, c_c.shape, 0.005)
FROM cola_markets c_a, cola_markets c_c
WHERE c_a.name = 'cola_a' AND c_c.name = 'cola_c';
SDO_GEOM.SDO_INTERSECTION(C_A.SHAPE,C_C.SHAPE,0.005)(SDO_GTYPE, SDO_SRID, SDO_PO

SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
AY(4, 5, 3, 3, 5, 3, 5, 5, 4, 5))
SDO_GEOM.SDO_LENGTH
geom
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).unit=
and an SDO_UNIT value from the MDSYS.SDO_DIST_UNITS table (for example, 'unit=KM'). See Section 2.8 for more information about unit of measurement specification.tol
is used, all geometry objects must be defined using 4digit SDO_GTYPE values (explained in Section 2.2.1).cola_a
. (The example uses the definitions and data from Section 2.1.) Return the perimeters of all cola markets.
SELECT c.name, SDO_GEOM.SDO_LENGTH(c.shape, m.diminfo)
FROM cola_markets c, user_sdo_geom_metadata m
WHERE m.table_name = 'COLA_MARKETS' AND m.column_name = 'SHAPE';
NAME SDO_GEOM.SDO_LENGTH(C.SHAPE,M.DIMINFO)
 
cola_a 20
cola_b 17.1622777
cola_c 9.23606798
cola_d 12.5663706
 Return the perimeter of just cola_a.
SELECT c.name, SDO_GEOM.SDO_LENGTH(c.shape, m.diminfo)
FROM cola_markets c, user_sdo_geom_metadata m
WHERE m.table_name = 'COLA_MARKETS' AND m.column_name = 'SHAPE'
AND c.name = 'cola_a';
NAME SDO_GEOM.SDO_LENGTH(C.SHAPE,M.DIMINFO)
 
cola_a 20
SDO_GEOM.SDO_MAX_MBR_ORDINATE
geom
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom
has X, Y ordinates, 1 identifies the X ordinate and 2 identifies the Y ordinate.cola_d
geometry in the COLA_MARKETS table. (The example uses the definitions and data from Section 2.1. The minimum bounding rectangle of cola_d
is returned in the example for the SDO_GEOM.SDO_MBR function.)SELECT SDO_GEOM.SDO_MAX_MBR_ORDINATE(c.shape, m.diminfo, 1)
FROM cola_markets c, user_sdo_geom_metadata m
WHERE m.table_name = 'COLA_MARKETS' AND m.column_name = 'SHAPE'
AND c.name = 'cola_d';
SDO_GEOM.SDO_MAX_MBR_ORDINATE(C.SHAPE,M.DIMINFO,1)

10
SDO_GEOM.SDO_MBR
geom
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).cola_d
geometry in the COLA_MARKETS table. (The example uses the definitions and data from Section 2.1. Because cola_d
is a circle, the minimum bounding rectangle in this case is a square.) Return the minimum bounding rectangle of cola_d (a circle).
SELECT SDO_GEOM.SDO_MBR(c.shape, m.diminfo)
FROM cola_markets c, user_sdo_geom_metadata m
WHERE m.table_name = 'COLA_MARKETS' AND m.column_name = 'SHAPE'
AND c.name = 'cola_d';
SDO_GEOM.SDO_MBR(C.SHAPE,M.DIMINFO)(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO

SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 3), SDO_ORDINATE_ARR
AY(6, 7, 10, 11))
SDO_GEOM.SDO_MIN_MBR_ORDINATE
geom
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom
has X, Y ordinates, 1 identifies the X ordinate and 2 identifies the Y ordinate.cola_d
geometry in the COLA_MARKETS table. (The example uses the definitions and data from Section 2.1. The minimum bounding rectangle of cola_d
is returned in the example for the SDO_GEOM.SDO_MBR function.)SELECT SDO_GEOM.SDO_MIN_MBR_ORDINATE(c.shape, m.diminfo, 1)
FROM cola_markets c, user_sdo_geom_metadata m
WHERE m.table_name = 'COLA_MARKETS' AND m.column_name = 'SHAPE'
AND c.name = 'cola_d';
SDO_GEOM.SDO_MIN_MBR_ORDINATE(C.SHAPE,M.DIMINFO,1)

6
SDO_GEOM.SDO_POINTONSURFACE
geom1
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom1
.tol
is used, all geometry objects must be defined using 4digit SDO_GTYPE values (explained in Section 2.2.1).cola_a
. (The example uses the definitions and data from Section 2.1.) Return a point on the surface of a geometry.
SELECT SDO_GEOM.SDO_POINTONSURFACE(c.shape, m.diminfo)
FROM cola_markets c, user_sdo_geom_metadata m
WHERE m.table_name = 'COLA_MARKETS' AND m.column_name = 'SHAPE'
AND c.name = 'cola_a';
SDO_GEOM.SDO_POINTONSURFACE(C.SHAPE,M.DIMINFO)(SDO_GTYPE, SDO_SRID, SDO_POINT(X,

SDO_GEOMETRY(2001, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1, 1), SDO_ORDINATE_ARRAY(
1, 1))
SDO_GEOM.SDO_UNION
geom1
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom2
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom1
) and another polygon (geom2
).tol
is used, all geometry objects must be defined using 4digit SDO_GTYPE values (explained in Section 2.2.1).geom1
and geom2
are based on different coordinate systems.cola_a
and cola_c
. (The example uses the definitions and data from Section 2.1.) Return the topological union of two geometries.
SELECT SDO_GEOM.SDO_UNION(c_a.shape, m.diminfo, c_c.shape, m.diminfo)
FROM cola_markets c_a, cola_markets c_c, user_sdo_geom_metadata m
WHERE m.table_name = 'COLA_MARKETS' AND m.column_name = 'SHAPE'
AND c_a.name = 'cola_a' AND c_c.name = 'cola_c';
SDO_GEOM.SDO_UNION(C_A.SHAPE,M.DIMINFO,C_C.SHAPE,M.DIMINFO)(SDO_GTYPE, SDO_SRID,

SDO_GEOMETRY(2003, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
AY(5, 5, 5, 7, 1, 7, 1, 1, 5, 1, 5, 3, 6, 3, 6, 5, 5, 5))
SDO_GEOM.SDO_XOR
geom1
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom2
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).geom1
) and another polygon (geom2
).tol
is used, all geometry objects must be defined using 4digit SDO_GTYPE values (explained in Section 2.2.1).geom1
and geom2
are based on different coordinate systems.cola_a
and cola_c
. (The example uses the definitions and data from Section 2.1.) Return the topological symmetric difference of two geometries.
SELECT SDO_GEOM.SDO_XOR(c_a.shape, m.diminfo, c_c.shape, m.diminfo)
FROM cola_markets c_a, cola_markets c_c, user_sdo_geom_metadata m
WHERE m.table_name = 'COLA_MARKETS' AND m.column_name = 'SHAPE'
AND c_a.name = 'cola_a' AND c_c.name = 'cola_c';
SDO_GEOM.SDO_XOR(C_A.SHAPE,M.DIMINFO,C_C.SHAPE,M.DIMINFO)(SDO_GTYPE, SDO_SRID, S

SDO_GEOMETRY(2007, NULL, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1, 19, 1003, 1), SDO
_ORDINATE_ARRAY(1, 7, 1, 1, 5, 1, 5, 3, 3, 3, 4, 5, 5, 5, 5, 7, 1, 7, 5, 5, 5, 3
, 6, 3, 6, 5, 5, 5))
SDO_GEOM.VALIDATE_GEOMETRY_WITH_CONTEXT
theGeometry
, usually selected from one of the xxx_SDO_GEOM_METADATA views (described in Section 2.6).