ST_Geometry in Oracle

ST_Geometry in Oracle

The Esri ST_Geometry spatial data type is available for Oracle databases with and without geodatabases. In addition, spatial data can be integrated with other types of commercial data, so multi-user databases can benefit from adding geographic components to analytics and data products. Storing spatial data with other business objects also simplifies multi-user access to the data, manages it, and enhances security by reducing the amount of data storage resources to manage.

The Esri ST_Geometry spatial data type is the default geometry storage type for Oracle Geodatabases. The ST_Geometry type can also be installed in an Oracle database using the Create Spatial Type geoprocessing tool.

Note:

The ST_Geometry type is not supported for Oracle XA transactions.

To create a geodatabase in Oracle DBMS and use ST_Geometry type and domain indexes, the geodatabase administrator user (sde) must be granted the correct system privileges to instantiate types, operators, and stored procedures. See Privileges for  Geodatabases in Oracle for information on required privileges . To install the ST_Geometry type in an Oracle database, the sde user must also exist and must be granted specific permissions to instantiate types, operators, and stored procedures. For more information, see Adding the ST_Geometry Type to an Oracle Database .

Using the Esri ST_Geometry spatial type in a geodatabase in Oracle or Oracle Database provides access to spatial data through SQL functions that implement the ISO SQL/MM Spatial Standard and OGC's Simple Feature Specification. You can then use SQL commands to store, retrieve, and manipulate spatial features like any other type of data. Spatial data can be retrieved and analyzed using a long list of standardized functions through SQL commands and stored procedures. Accessing data through SQL allows users to use other applications to access data created in Oracle.

To access spatial features through SQL, the ST_Geometry library must be installed on the same server as the Oracle instance. Make sure that the operating system of the Oracle server is supported by the ST_Geometry library .

You must also configure Oracle extproc  to use SQL to access tables that contain ST_Geometry spatial types.

How ST_Geometry stores spatial data

The following is a description of ST_Geometry in Oracle:

name Types of

ENTITY

NUMBER(38)

NUMPTS

NUMBER(38)

MINX

FLOAT(64)

MINES

FLOAT(64)

MAXX

FLOAT(64)

MAXY

FLOAT(64)

MINZ

FLOAT(64)

MAXZ

FLOAT(64)

MINM

FLOAT(64)

MAXM

FLOAT(64)

AREA

FLOAT(64)

LEN

FLOAT(64)

SRID

NUMBER(38)

POINTS

BLOB

Properties of a space type represent the following information:

  • Entity: The type of geometry (linestring, multilinestring, multipoint, multipolygon, point, or polygon) stored in the spatial column, whose value is a bitmask obtained from the st_geom_util stored procedure.
  • Numpts: Defines the number of points in the geometry; for multipart geometries, also includes separators between parts, one for each separator.
  • Minx, miny, maxx, maxy: the spatial envelope rectangle of the geometry
  • Area: the area of ​​the geometry
  • Len: the perimeter of the geometry
  • SRID: Contains the identifier of the geometry, which is used to link the geometry to the spatial reference (coordinate system) record in the ST_Spatial_References table with which it is associated
  • Points: a byte stream containing the coordinates of the points defining the geometry

Like other object types, the ST_Geometry data type contains a constructor method and functions. A constructor method is a function that returns a new instance (object) of a data type and sets its property values.

The constructor name is the same as the type (ST_Geometry) name. When an object of type ST_Geometry is instantiated, its constructor method can be called. E.g:

CREATE TABLE hazardous_sites (name        varchar2(128),
                              location    st_geometry);

The following ST_Geometry accessor functions take a single ST_Geometry as input and return the requested attribute value as a number.

  • The ST_Area member function returns the area of ​​the geometry.
  • ST_Len returns the length of the geometry.
  • ST_Entity returns a number containing a bitmask describing the entity type.
  • ST_NumPoints returns the number of points (vertices) that define the geometry.
  • ST_MinM, ST_MinX, ST_MinY, and ST_MinZ return the minimum coordinates required by the geometry.
  • ST_MaxM, ST_MaxX, ST_MaxY, and ST_MaxZ return the maximum coordinates required by the geometry.
  • ST_SRID returns the spatial reference identifier of the geometry.
  • Get_release is a static member function that can be used internally for space type management (ie upgrades and patches).

For example, the following query returns the names and areas of states in the United States.

SELECT name, sde.st_area(geometry)
FROM us_states
ORDER BY name;

ST_LineString, ST_MultiLineString, ST_MultiPoint, ST_MultiPolygon, ST_Point, and ST_Polygon are all subtypes (or subclasses) of ST_Geometry. ST_Geometry and its subtypes share common properties and functions. The constructor definitions for ST_LineString, ST_MultiLineString, ST_MultiPoint, ST_MultiPolygon, ST_Point and ST_Polygon are the same. The constructor name is the same as the type name it constructs.

Since ST_Point is a finite object (single point value), it can also be created by the following methods.

This method uses coordinate points and SRIDs.

METHOD
 FINAL CONSTRUCTOR FUNCTION ST_POINT RETURNS SELF AS RESULT
 Argument Name                  Type                    In/Out Default?
 PT_X                           NUMBER                  IN
 PT_Y                           NUMBER                  IN
 SRID                           NUMBER                  IN
SQL> INSERT INTO sample_pt VALUES (sde.ST_Point (10, 20, 1) );

This method allows specifying coordinate points and an elevation value for each point.

METHOD
 FINAL CONSTRUCTOR FUNCTION ST_POINT RETURNS SELF AS RESULT
 Argument Name                  Type                    In/Out Default?
 
 PT_X                           NUMBER                  IN
 PT_Y                           NUMBER                  IN
 PT_Z                           NUMBER                  IN
 SRID                           NUMBER                  IN
SQL> INSERT INTO sample_pt VALUES (sde.ST_Point (10, 20, 5, 1) );

In addition, this newest method of ST_Point can specify a measure value as part of the created point object.

METHOD
 FINAL CONSTRUCTOR FUNCTION ST_POINT RETURNS SELF AS RESULT
 Argument Name                  Type                    In/Out Default?
 PT_X                           NUMBER                  IN
 PT_Y                           NUMBER                  IN
 PT_Z                           NUMBER                  IN
 MEASURE                        NUMBER                  IN
 SRID                           NUMBER                  IN
SQL> INSERT INTO sample_pt VALUES (sde.ST_Point (10, 20, 5, 401, 1) );

metadata schema

Oracle's ST_Geometry type and metadata tables are owned by the SDE schema. This schema definition is the base table description of the metadata table used to define and describe column/table types, spatial indexes (ST_Spatial_Index field indexes), and spatial reference information. Definitions, packages, and metadata tables for all types and domain index types are created in the SDE schema.

Since the definition of ST_Geometry is owned by the SDE user, do not drop the SDE user from the database if a table with the ST_Geometry column exists in the database. If deleted, these tables will become inaccessible.

As mentioned in the Oracle Application Developer's Guide, when dropping a user from the database, one of the drop statements executed was DROP TYPE with the FORCE option. This statement removes all types belonging to the user so that the user can be removed from the database. DROP TYPE FORCE drops all types, even if they have dependent types or tables associated with them. After the deletion is complete, the associated table will be marked invalid and the data in the table will be rendered inaccessible.

See  Geodatabase System Tables in Oracle for descriptions of the following ST_Geometry metadata tables :

  • ST_COORDINATE_SYSTEMS
  • ST_GEOMETRY_COLUMNS
  • ST_GEOMETRY_INDEX
  • ST_SPATIAL_REFERENCES
start to act:

Additionally, the following database objects are created to maintain ST_Geometry metadata:

  • SDE database user
  • Default tablespace for SDE users
  • ST_Geometry function
  • ST_Geometry view
    • ALL_ST_GEOMETRY_COLUMNS_V
    • USER_ST_GEOMETRY_COLUMNS_V
    • USER_ST_GEOM_INDEX_V
  • ST_Geometry trigger
    • DB_EV_DROP_ST_METADATA
    • DB_EV_ALTER_ST_METADATA
    • DB_EV_RENAME_ST_METADATA
    • TG_ST_SPATIAL_REF_SRID
    • TG_ST_CREF_SYS
    • TG_GCOL_NAME
    • TG_ST_GEOMINDEX_NAME
  • SPX_UTIL package and package body
  • SDEXMLTOTEXT operator
  • ST_Geometry type
    • BLOB_ARRAY_TAB
    • INT_ARRAY_TAB
    • FLT_ARRAY_TAB
    • BND_ROWID_TAB
    • SP_GRID_INFO

      SP_Grid_Info can be used as the data type of the field GRID in the ST_Geometry_Index table. It contains grid-level information for the spatial index.

Creating Feature Classes Using ST_Geometry Storage in Oracle

In a database with the ST_Geometry spatial data type installed, specify ST_Geometry as the storage type when creating a feature class.

In a geodatabase, the type of geometry storage used for a feature class is determined by the GEOMETRY_STORAGE setting in the configuration keyword specified when the feature class was created.

Set ST_Geometry as the default storage type for new geodatabase feature classes

In Oracle's new geodatabase, ST_Geometry is the default storage type for feature classes. This means that the GEOMETRY_STORAGE parameter in the DEFAULTS  configuration keyword will be set to ST_GEOMETRY.

If a geodatabase created with a version prior to ArcGIS 9.3 has been upgraded and you now want all new feature classes to be created with the ST_Geometry storage type by default, you must set the GEOMETRY_STORAGE parameter under the DEFAULTS keyword to ST_GEOMETRY. For instructions, see Changing configuration keywords .

Use ST_Geometry storage for some geodatabase feature classes

Geodatabases in Oracle support many different geometry storage types - these different types can be used together in the same database. Although there can only be one default geometry storage type, individual tables can be created with different data types.

If you only want some feature classes to be stored using the ST_Geometry spatial type, you can set DEFAULTS GEOMETRY_STORAGE to a different storage type and create a separate key for ST_Geometry storage. For example, you can add a configuration keyword (similar to the following configuration keywords for geodatabases):

##ST_GEOMETRY
GEOMETRY_STORAGE    "ST_GEOMETRY"
ATTRIBUTE_BINARY    "BLOB"
RASTER_STORAGE	    "BLOB"
ST_GEOM_LOB_STORAGE  " STORE AS (
#               TABLESPACE <tablespace_name>
                ENABLE STORAGE IN ROW CHUNK 8K RETENTION CACHE)"
UI_TEXT             "User Interface text description for ST_GEOMETRY"
COMMENT             "Any general comment for ST_GEOMETRY keyword"
END

After adding the keyword, you can use this keyword when creating feature classes stored using the ST_Geometry data type. For example, if you have a small subset of data that must be accessed using SQL, simply create that subset of feature classes to use the ST_Geometry spatial data type for geometry storage.

What database objects are created for feature classes?

When using ArcGIS to create a feature class that uses the ST_Geometry storage type, three database objects are created. The objects and configuration parameters used to control their storage are listed in the following table :

database object Store parameters

Table with ST_Geometry column

The B_STORAGE parameter defines the storage type of the table.

The ST_GEOM_LOB_STORAGE parameter defines the storage type of the LOB segment in the table.

Spatial index

The S_STORAGE parameter defines the spatial index storage type.

Index on the ObjectID column

The B_INDEX_ROWID parameter defines the storage type for this index.

Set storage type of LOB segment

The ST_GEOM_LOB_STORAGE parameter under the DEFAULTS keyword list can be changed. However, when added to the DEFAULTS keyword, the LOB section name should not be included in the parameter definition. If a LOB segment name is included, creation of the second feature will fail unless its name value is changed, since each LOB segment name must be unique for a given schema. The following example of the ST_GEOM_LOB_STORAGE parameter does not contain object names, thus avoiding name conflicts within the same schema:

ST_GEOM_LOB_STORAGE  " STORE AS (
  ENABLE STORAGE IN ROW CHUNK 8K RETENTION CACHE)"

The following are examples of valid ST_GEOM_LOB_STORAGE parameter values:

##ST_GEOMETRY
GEOMETRY_STORAGE    "ST_GEOMETRY"
ATTRIBUTE_BINARY    "BLOB"
RASTER_STORAGE	    "BLOB"
ST_GEOM_LOB_STORAGE  " STORE AS (TABLESPACE TERRA_NDX ENABLE STORAGE IN ROW CHUNK 8K
 RETENTION CACHE)"
UI_TEXT             "User Interface text description for ST_GEOMETRY"
COMMENT             "Any general comment for ST_GEOMETRY keyword"
END

##ST_GEOMETRY
GEOMETRY_STORAGE    "ST_GEOMETRY"
ATTRIBUTE_BINARY    "BLOB"
RASTER_STORAGE	    "BLOB"
ST_GEOM_LOB_STORAGE  " STORE AS (ENABLE STORAGE IN ROW CHUNK 8K RETENTION CACHE)"
UI_TEXT             "User Interface text description for ST_GEOMETRY"
COMMENT             "Any general comment for ST_GEOMETRY keyword"
END

As stated earlier in this section, if LOB and LOB index tablespace names are defined, these values ​​must be changed before each feature class is created. If this requirement is not followed, subsequent feature class creation will fail because each segment name must be unique.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325781097&siteId=291194637