Date post: | 10-Apr-2015 |
Category: |
Documents |
Upload: | api-3831209 |
View: | 165 times |
Download: | 4 times |
Oracle Spatial New Features 1-1
Function-Based Indexes with Spatial Objects
Oracle Spatial New Features 1-2
Objectives
After completing this lesson, you should be able to:• Describe a function-based index• Use SQL commands to create a function-based index
with an SDO geometry
Oracle Spatial New Features 1-3
What Is a Spatial Function-Based Index?
• Currently Spatial function only works with an SDO geometry.
• Function-based index allows you to write a function that can return an SDO geometry derived from relational columns
• Spatial function-based indexes allow customers to use Spatial operators on data that is stored in relational columns
• Usage scenarios:– For on the fly queries, use the function in your
SQL statements– To spatial enable your table, build a spatial index
and use that in your queries
Oracle Spatial New Features 1-4
Function-Based Index Features
• All Spatial functions can be used to execute location queries against the customer tables, without having to: • Add an SDO_GEOMETRY type column to the
base table, or• Convert all longitude/latitude values to
populate an SDO_GEOMETRY column.
• The underlying data, currently stored geometries, can be in any format.
• A common usage is with relational latitude and longitude values, but you could also create functions to convert to other datatypes
Oracle Spatial New Features 1-5
PureIntegrate Support
• Customer has used Oracle PureIntegrate to cleanse their data warehouse’s customer tables.
• PureIntegrate creates two relational columns for longitude and latitude values.
• A simple function can allow runtime conversion of the longitude and latitude columns to an Oracle Spatial geometry.
• After the function is created, use it in a function based spatial index.
Oracle Spatial New Features 1-6
Function-Based Index Example
CREATE FUNCTION get_long_lat_pt (longitude IN NUMBER,latitude IN NUMBER )RETURN mdsys.sdo_geometryDETERMINISTIC ISBEGINRETURN mdsys.sdo_geometry (2001, 8307, mdsys.sdo_point_type (longitude, latitude, NULL ),
NULL, NULL );END;
This example creates a function that returns an SDO Geometry derived from two relational columns of longitude and latitude data. You must specify DETERMINISTIC for functions used in indexes.
This coordinate system is probably the most widely used coordinate system, and the one used for GPS devices.
Oracle Spatial New Features 1-7
Create Index Example
CREATE INDEX addr_geocode_idxON addr_geocode (
get_long_lat_pt(long,lat) )INDEXTYPE IS mdsys.spatial_index;
• Create a spatial index:– Index the longitude and latitude columns in table ADDR_GEOCODE
– Use the GET_LONG_LAT_PT function from the previous slide to convert to an SDO geometry
• All spatial functions can be used against the spatial index
Oracle Spatial New Features 1-8
Query Sample
Perform a primary filter operation, asking for the names of geometries that are likely to interact spatially with rectangle.
SELECT t.nameFROM test_long_lat tWHERE SDO_FILTER (
long_lat.GetGeometry(t.long,a.lat),MDSYS.SDO_GEOMETRY(2003,8307,NULL,
MDSYS.SDO_ELEM_INFO_ARRAY(1,1003,3),MDSYS.SDO_ORDINATES(10,10,20,20),'querytype=window') = 'TRUE';
Oracle Spatial New Features 1-9
Summary
In this lesson, you should have learned to:• Describe a function-based index• Use SQL commands to create a function-based
index with an SDO geometry
Oracle Spatial New Features 2-1
Coordinate Systems
Oracle Spatial New Features 2-2
Objectives
After completing this lesson, the student should be able to:• Describe user defined and local coordinate systems
support in Oracle9i Spatial• Describe Whole Earth Geometry support• Use coordinate systems in Spatial
Oracle Spatial New Features 2-3
Coordinate Systems Definition
• Now over 950 different pre-defined coordinate systems provided
• Coded using the notation defined by the Open GIS Consortium• Each coordinate system identified by unique number (SRID)• Definitions kept in table MDSYS.CS_SRS'PROJCS["Wyoming 4901, Eastern Zone (1983, meters)",
GEOGCS [ "GRS 80", DATUM ["GRS 80",
SPHEROID ["GRS 80", 6378137.000000, 298.257222]], PRIMEM [ "Greenwich", 0.000000 ], UNIT ["Decimal Degree", 0.01745329251994330]],
PROJECTION ["Transverse Mercator"], PARAMETER ["Scale_Factor", 0.999938],PARAMETER ["Central_Meridian", -105.166667], PARAMETER ["Latitude_Of_Origin", 40.500000], PARAMETER ["False_Easting", 200000.000000], UNIT ["Meter",1.000000000000]]'
'PROJCS["Wyoming 4901, Eastern Zone (1983, meters)", GEOGCS [ "GRS 80",
DATUM ["GRS 80", SPHEROID ["GRS 80", 6378137.000000, 298.257222]], PRIMEM [ "Greenwich", 0.000000 ], UNIT ["Decimal Degree", 0.01745329251994330]],
PROJECTION ["Transverse Mercator"], PARAMETER ["Scale_Factor", 0.999938],PARAMETER ["Central_Meridian", -105.166667], PARAMETER ["Latitude_Of_Origin", 40.500000], PARAMETER ["False_Easting", 200000.000000], UNIT ["Meter",1.000000000000]]'
Cartesian Coordinates Cartesian coordinates are coordinates that measure the position of a point from a defined origin along axes which are perpendicular in the represented two-dimensional or three-dimensional space.
Geodetic Coordinates 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.
Projected 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.
Geodetic Datum A geodetic datum is a means of representing the figure of the earth, usually as an oblate ellipsoid of revolution, which approximates the surface of the earth locally or globally, and is the reference for the system of geodetic coordinates.
Oracle Spatial New Features 2-4
Projected Geometries
Non projected Projected
The picture on the left shows a map of the United States on a flat Cartesian plane. The picture on the right shows map of United States projected to a Universal Transfer Mercator (UTM) taking into account the spherical shape of the earth
Oracle Spatial New Features 2-5
Projected CS Concepts
• Any two points are connected with a straight line– the shortest path between two points is through
that line• There is only one way to connect two points• A polygon can define only one closed area
Oracle Spatial New Features 2-6
Geodetic CS Concepts
• Any two points are connected with a great circle that goes through those two points
• Consider two points (180,5) and (0,5):– The shortest path connecting these two points
does not go through the latitude line at 5– The shortest path goes through the north pole
Oracle Spatial New Features 2-7
Geodetic CS Concepts
• A great circle goes through any two given points on the earth surface
• Any two points can be connected in two different ways:– Representing two arcs of the circle– The smaller piece is used as the intended line
Oracle Spatial New Features 2-8
Geodetic CS Concepts
• A polygon can define two closed areas• The smaller polygon is used as the intended
polygon• A polygon area is required to be less than half the
surface area of the earth
Oracle Spatial New Features 2-9
Geodetic Geometry Examples
Define a valid polygon:
MDSYS.SDO_GEOMETRY (2003, 8307, NULL,MDSYS.SDO_ELEM_INFO_ARRAY(1, 1003, 1),MDSYS.SDO_ORDINATE_ARRAY (
180,10,-110,10,0,10,110,10,180,10));
Oracle Spatial New Features 2-10
Whole Earth Geometry Model
Accurate operations using geodetic data• Before Oracle9i you needed to project geodetic data for
accurate length, distance, area calculations• In Oracle9i the whole earth model provides accurate
results in geodetic space• Number of LENGTH and AREA units supported for
geodetic data
Oracle Spatial New Features 2-11
Whole Earth Geometry Model
• No longer have to break geometries up into components that do not span the date-line meridian
• Buffer operations on geodetic data are supported. Data is automatically densified so no arcs or circles are generated - only geometries consisting of straight lines
• In order for whole earth geometry model to work, coordinate system bounds must be -180 to 180, -90 to 90. -360 to +360 (for longitude) will also work, but not recommended
Oracle Spatial New Features 2-12
Tolerance Revisited
• Tolerance always has some distance UNIT with it• In projected space, the tolerance has the same unit
as the data• In geodetic space, data unit and tolerance unit are
different– Data is in angular units (long/lat)– Tolerance should always be in METER
Oracle Spatial New Features 2-13
Datums
• A geodetic datum is a means of representing the figure of the Earth
• An oblate ellipsoid of revolution that approximates the surface of the Earth is used as a datum
• This ellipsoid is the reference for the system of geodetic coordinates
• MDSYS.SDO_DATUMS table lists the supporteddatums
Oracle Spatial New Features 2-14
Ellipsoids
• Defined by the– SEMI_MAJOR_AXIS– INVERSE_FLATTENING
• MDSYS.SDO_ELLIPSOIDS lists the supported ellipsoids
Oracle Spatial New Features 2-15
Projections
• MDSYS.SDO_PROJECTIONS Table lists the valid projections
• Examples– Polyconic– Universal Transverse Mercator– State Plane Coordinates– Albert Conical Equal Area
Oracle Spatial New Features 2-16
Indexing Geodetic Data
• A geodetic index is different from a 2D index– index has to handle geometries crossing the
discontinuous meridian line– index also has to handle the distances properly
for sdo_within_distance• Quad-tree indexing is disabled on geodetic data • Only R-tree indexing is supported. By default, a
geodetic index is created on geodetic data.
Oracle Spatial New Features 2-17
Indexing Geodetic Data
• A new key word GEODETIC is introduced in the CREATE INDEX syntax– By setting GEODETIC=FALSE , one can get a non
geodetic index on geodetic data– The only way to create a quad-tree index on
geodetic data• A non-geodetic index does not support SDO_WITHIN_DISTANCE and SDO_NN operators
Oracle Spatial New Features 2-18
UNIT Support in Spatial
• UNITs are supported for– SDO_LENGTH– SDO_AREA– SDO_BUFFER– SDO_WITHIN_DISTANCE
• All operations have default units– UNIT of the projection for projected CSs– METER for geodetic CSs– UNIT of specification for Local CS
Oracle Spatial New Features 2-19
User Defined Coordinate Systems
• Users can create their own coordinate systems (CS) based on the datums, ellipsoids, and projections provided by Oracle
• Oracle will provide a unique SRID for each user defined CS through an escrow mechanism. This process should be strictly followed to avoid any conflicts between different user defined CSs.
• The procedure for requesting an SRID is not yet finalized
Oracle Spatial New Features 2-20
Well-Known Text (WKT) for a CS
• A WKT:– Defines the CS in Spatial– Is in the WKTEXT column in the CS_SRS table
• Spatial uses a WKT which conforms to the OGC standard• The grammer for the WKT is given in the user guide• This grammer should be used for adding user defined
CSs
Oracle Spatial New Features 2-21
WKT Example
Geodetic CS
'GEOGCS [ "Longitude / Latitude (Old Hawaiian)", DATUM ["Old Hawaiian", SPHEROID["Clarke 1866", 6378206.400000, 294.978698]], PRIMEM [ "Greenwich", 0.000000 ],UNIT ["Decimal Degree", 0.01745329251994330]]'
Oracle Spatial New Features 2-22
WKT Example
Projected CS
'PROJCS["Wyoming 4901, Eastern Zone (1983, meters)", GEOGCS [ "GRS 80", DATUM ["GRS 80", SPHEROID ["GRS 80", 6378137.000000, 298.257222]], PRIMEM [ "Greenwich", 0.000000 ], UNIT ["Decimal Degree", 0.01745329251994330]], PROJECTION ["Transverse Mercator"], PARAMETER ["Scale_Factor", 0.999938], PARAMETER ["Central_Meridian", -105.166667], PARAMETER ["Latitude_Of_Origin", 40.500000], PARAMETER ["False_Easting", 200000.000000], UNIT ["Meter", 1.000000000000]]'
Oracle Spatial New Features 2-23
User Defined CS Procedure
• Pick an ellipsoid from the supported ellipsoids in MDSYS.SDO_ELLIPSOIDS table
• Pick a projection from the supported projections– 45 supported– MDSYS.SDO_PROJECTIONS table
• Pick a Datum– Can reuse a provided datum, 118 supported– MDSYS.SDO_DATUMS table
– Can create new datum, but can not duplicate datum names
Oracle Spatial New Features 2-24
User Defined CS Procedure
• Supported UNITS are in the following tables – MDSYS.SDO_DIST_UNITS – MDSYS.SDO_ANGLE_UNITS – MDSYS.SDO_AREA_UNITS
• Use SQL DML (insert/update/delete) statements to add/modify/delete coordinate systems entries in the MDSYS.CS_SRS table
Oracle Spatial New Features 2-25
Defining a New CS With a Datum Shift
-- use the number 1008307 for the new datumdelete from cs_srs where srid = 1008307; insert into cs_srs values ( 'Longitude / Latitude (WGS 90)', 1008307, 1008307, 'Oracle', 'GEOGCS [ "Longitude / Latitude (WGS 90)", DATUM ["WGS 90", SPHEROID ["WGS 90", 6378137.000000, 298.257224], 100, 100, 0, 0, 0,0, 0], PRIMEM [ "Greenwich", 0.000000 ], UNIT ["Decimal Degree", 0.01745329251994330]]',NULL);
-- compare this to the WKT for WGS 84( 'Longitude / Latitude (WGS 84)', 8307, 8307, 'Oracle', 'GEOGCS [ "Longitude / Latitude (WGS 84)", DATUM ["WGS 84", SPHEROID ["WGS 84", 6378137.000000, 298.257224]], PRIMEM [ "Greenwich", 0.000000 ], UNIT ["Decimal Degree", 0.01745329251994330]]',NULL);
Oracle Spatial New Features 2-26
User Defined CS Procedure
Defining a new CS with new projection parameters (UTM)
('UTM Zone 44.5, Northern Hemisphere (WGS 84)', 1082378, 1082378, 'Oracle', 'PROJCS["UTM Zone 44.5, Northern Hemisphere (WGS 84)", GEOGCS [ "WGS 84", DATUM ["WGS 84 ", SPHEROID ["WGS 84", 6378137.000000, 298.257224]], PRIMEM [ "Greenwich", 0.000000 ], UNIT ["Decimal Degree", 0.01745329251994330]], PROJECTION ["Transverse Mercator"], PARAMETER ["Scale_Factor", 0.999600], PARAMETER ["Central_Meridian", 84.000000], PARAMETER ["False_Easting", 500000.000000], UNIT ["Meter", 1.000000000000]]');
('UTM Zone 44, Northern Hemisphere (WGS 84)', 82378, 82378, 'Oracle', 'PROJCS["UTM Zone 44 Northern Hemisphere (WGS 84)", GEOGCS [ "WGS 84", DATUM ["WGS 84 ", SPHEROID ["WGS 84", 6378137.000000, 298.257224]], PRIMEM [ "Greenwich", 0.000000 ], UNIT ["Decimal Degree", 0.01745329251994330]], PROJECTION ["Transverse Mercator"], PARAMETER ["Scale_Factor", 0.999600], PARAMETER ["Central_Meridian", 81.000000], PARAMETER ["False_Easting", 500000.000000], UNIT ["Meter", 1.000000000000]]');
Oracle Spatial New Features 2-27
Local Coordinate Systems
• Use local coordinate system when no geographic reference is required, as with CAD systems, building drawings, field survey
• Allows Oracle Spatial to do unit conversions of geometries
• Many units supported including millimeters, centimeters, meters, kilometers, miles, nautical miles, feet, inches, chains, links, etc.
Oracle Spatial New Features 2-28
Local CS Example
INSERT INTO cs_srs VALUES ( 'Non-Earth (Meter)', 262144, 262144, 'Oracle', 'LOCAL_CS [ "Non-Earth (Meter)", LOCAL_DATUM ["Local Datum", 0], UNIT ["Meter", 1.0], AXIS ["X", EAST], AXIS["Y", NORTH]]' );
INSERT INTO cs_srs VALUES ( 'Non-Earth (Kilometer)', 262145, 262145, 'Oracle', 'LOCAL_CS [ "Non-Earth (Kilometer) ", LOCAL_DATUM ["Local Datum", 0], UNIT ["Kilometer", 1000.0], AXIS ["X", EAST], AXIS["Y", NORTH]]' );
Oracle Spatial New Features 2-29
Summary
In this lesson, the student should have learned to:• Describe user defined and local coordinate systems
support in Oracle9i Spatial• Describe Whole Earth Geometry support• Use coordinate systems in Spatial
Oracle Spatial New Features 3-1
Linear Referencing
Oracle Spatial New Features 3-2
Objectives
After completing this lesson, the student should be able to:• Describe SDO_GTYPE with Linear Referencing System
(LRS) support in Spatial• Use LRS with Spatial • Use SQL commands define and use LRS on geometries
Oracle Spatial New Features 3-3
What is Linear Referencing?
• A technique to associate events or attributes to locations or portions of a linear feature
• Used in:– Transportation systems, such as roads and
railroads– Utilities, for oil and gas pipelines
• Events or attributes located by a measure along the linear feature
Linear ReferencingLinear referencing is a natural and convenient means to associate attributes or events to locations or portions of a linear feature. It has been widely used in transportation applications (such as for highways, railroads, and transit routes) and utilities applications (such as for gas and oil pipelines). The major advantage of linear referencing is its capability of locating attributes and events along a linear feature with only one parameter (usually known as a measure) instead of two (such as latitude/longitude or x/y in Cartesian space). Sections of a linear feature can be referenced and created dynamically by indicating the start and end locations along the feature without explicitly storing them.
Linear Referencing System (LRS) Application Programming Interface (API) The linear referencing system (LRS) application programming interface (API) in Oracle9i Spatial provides server-side LRS capabilities at the cartographic level. The linear measure information is directly integrated into the Oracle Spatial geometry structure. The LRS API provides support for dynamic segmentation, and it serves as a groundwork for third-party or middle-tier application development virtually for any linear referencing methods and models in any coordinate systems.
Oracle Spatial New Features 3-4
Linear Referencing Implementation
• Use one more coordinates to define the measure of the point from the start of the linestring
• Needs a third dimension to be defined in the USER_SDO_GEOM_METADATA table
• In the example below, the third value at each node could be mile markers on a road
(5,10,0) (30,10,27)
(15,5,11.2) (40,5,38)
(50,15,53.8)
(55,20,60)
(45,10,44)
Geometric segments are basic LRS elements in Oracle Spatial. They are Oracle line string geometries. An Oracle line string is an ordered, non-branching, and continuous geometry. A geometric segment must contain at least start and end measures for its start and end points. Measures of points of interest (such as highway exits) on the geometric segments can also be assigned. These measures are either assigned by users or derived from existing geometric segments. The slide shows a geometric segment with four line segments and one arc. Points on the geometric segment are represented by triplets (x, y, m), where x and y describe the location and m denotes the measure.
Oracle Spatial New Features 3-5
Shape Points
• Shape points– Points along the line string that have measures– Can correspond to geometry points
• Direction of the segment is defined by the order in which the shape points are listed
(5,10,0) (30,10,27)
(15,5,?) (40,5,?)
(50,15,?)
(55,20,60)
(45,10,?)
Shape points are points that are specified when an LRS segment is constructed, and that are assigned measure information. In Oracle9i Spatial, a line segment is represented by its start and end points, and an arc is represented by three points: start, middle, and end points of the arc. You must specify these points as shape points, but you can also specify other points as shape points if you need measure information stored for these points. For example, an exit in the middle of a straight part of the highway.Thus, shape points can serve one or both of the following purposes:
• Indicate the direction of the segment (for example, a turn or curve)• Identify a point of interest for which measure information is to be stored.
Shape points might not directly relate to mileposts or reference posts in LRS; they are used as internal reference points. The measure information of shape points is automatically populated when the LRS segment is defined. The direction of a 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.
Oracle Spatial New Features 3-6
Measure and Offset of a Point
• Measure of a point: linear distance from the start point of the line feature
• Offset of a point: perpendicular distance from a segment of the line feature to a point outside the feature
Start point
Measure «left» ( - offset)
«right» (+ offset)
End point
Offset
Linear MeasureThe measure of a point along a geometric segment is the linear distance (in the measure dimension) measured from the start point of the geometric segment. The measure information does not necessarily have to be of the same scale as their Euclidean distance. However, the linear mapping relationship between measure and distance is always preserved. Some LRS functions use offset instead of measure to represent measured distance along linear features. Although some other linear referencing systems might use offset to mean what LRS refers to as measure, offset has a different meaning in LRS from measure.
OffsetThe offset of a point along a geometric segment is the perpendicular distance between the point and the geometric segment. Offsets are positive if points are on the right side along the segment direction and are negative if they are on the left side. Points are on a geometric segment if their offsets to the segment are zero.
Oracle Spatial New Features 3-7
Projection of a Point
• The point on the segment with the minimum distance to the outside point
• The projection operation returns the measure of the projected point
Start point
Measure «left» ( - offset)
«right» (+ offset)
End point
Offset
The projection of a point along a geometric segment is the point on the geometric segment with the minimum distance to the point. The measure information of the resulting point is also returned in the point geometry. Linear features are any spatial objects that can be treated as a logical set of linear segments. Examples of linear features are highways in transportation applications and pipelines in utility industry applications.
Oracle Spatial New Features 3-8
Defining LRS Structures
• Use the standard MDSYS.SDO_GEOMETRY object
• Define a third dimension in the metadata
INSERT INTO user_sdo_geom_metadata VALUES ('ROADS','GEOMETRY',MDSYS.SDO_DIM_ARRAY (
MDSYS.SDO_DIM_ELEMENT('Long', -180, 180, .005),
MDSYS.SDO_DIM_ELEMENT('Lat', -90, 90, .005),
MDSYS.SDO_DIM_ELEMENT('Measure', 0,1000, 0) ),
NULL );
INSERT INTO user_sdo_geom_metadata VALUES ('ROADS','GEOMETRY',MDSYS.SDO_DIM_ARRAY (
MDSYS.SDO_DIM_ELEMENT('Long', -180, 180, .005),
MDSYS.SDO_DIM_ELEMENT('Lat', -90, 90, .005),
MDSYS.SDO_DIM_ELEMENT('Measure', 0,1000, 0) ),
NULL );
The LRS data model incorporates measure information into its geometry representation at the point level. The measure information is directly integrated into the Oracle Spatial model. To accomplish this, an additional measure dimension must be added to the Oracle Spatial metadata. LRS affects the Spatial metadata and data (the geometries). The example in the slide shows how a measure dimension can be added to 2-dimensional geometries in the Spatial metadata. The measure dimension is assumed to be the last element of the SDO_DIM_ARRAY in a spatial object definition
Oracle Spatial New Features 3-9
Two Enhancements
• Associates linear referencing measure with a dimension in a geometry
• New methods on SDO_GTYPE to return:
– Number of Dimensions– Geometry Type– Linear Referencing Dimension
Oracle Spatial New Features 3-10
New Methods on SDO_GTYPE
GTYPE GTYPES - Determine Dimensionalityand which dimension is LRS
2D 3D 4D
0 UNKNOWN_GEOMETRY 2000 3x00 4y001 POINT 2001 3x01 4y012 LINESTRING 2002 3x02 4y023 POLYGON 2003 3x03 4y034 COLLECTION 2004 3x04 4y045 MULTIPOINT 2005 3x05 4y056 MULTILINESTRING 2006 3x06 4y067 MULTIPOLYGON 2007 3x07 4y07
x = 0 - No LRS or not known as suchx = 3 - LRS Measure is 3rd dimensiony = 0 - No LRS or not known as suchy = 3 - LRS Measure is 3rd dimensiony = 4 - LRS Measure is 4th dimension
Oracle Spatial New Features 3-11
New Methods on SDO_GTYPE
Return the number of dimensionsSQL> SELECT s.geom.get_dims() state_dims
2 FROM states s3 WHERE s.state = 'Delaware';
STATE_DIMS----------
2
Oracle Spatial New Features 3-12
New Methods on SDO_GTYPE
Return the geometry type
SQL> SELECT s.geom.get_gtype() state_gtype2 FROM states s3 WHERE s.state = 'Delaware';
STATE_GTYPE-----------
2
Oracle Spatial New Features 3-13
New Methods on SDO_GTYPE
Return the LRS dimension
SQL> SELECT s.geom.get_lrs_dim() 2 AS state_lrs_dim3 FROM states s4 WHERE s.state = 'Delaware';
STATE_LRS_DIM-------------
0
SQL> SELECT s.geom.get_lrs_dim() 2 AS state_lrs_dim3 FROM states s4 WHERE s.state = 'Delaware';
STATE_LRS_DIM-------------
0
Oracle Spatial New Features 3-14
Tolerance Revisited
• Tolerance always has some distance UNIT associated with it
• In projected space, the tolerance is in the same units as the data
• In geodetic space, data unit and tolerance unit are different– Data is in angular units (long/lat)– Currently tolerance is not used correctly– In Oracle9i tolerance must be in METERS
Oracle Spatial New Features 3-15
Summary
In this lesson, the student should have learned to:• Describe SDO_GTYPE with Linear Referencing support in
Spatial• Use LRS with Spatial • Use SQL commands define and use LRS on geometries
Oracle Spatial New Features 4-1
Spatial Function Enhancements
Oracle Spatial New Features 4-2
Objectives
After completing this lesson, the student should be able to:• Describe Spatial Function enhancements• Use SQL with Spatial Function enhancements
Oracle Spatial New Features 4-3
Functional Enhancements
• Minimum Bounding Rectangle Functions• Migration utility• SDO_VERSION()
• Arc densification• New views provide index information• Index types do not need to match for join queries
Oracle Spatial New Features 4-4
Functional Enhancements
• Minimum Bounding Rectangle Functions– SDO_GEOM.SDO_MBR returns a geometry object, the
optimized rectangle– SDO_GEOM.SDO_MIN_MBR_ORDINATE returns minimum
value for a dimension– SDO_GEOM.SDO_MAX_MBR_ORDINATE returns
maximum value for a dimension• MBR routines are only for non-geodetic data• Example:
SELECT SDO_GEOM.SDO_MBR(geom) FROM states sWHERE state = 'Wyoming';
Oracle Spatial New Features 4-5
More Functional Enhancements
• New Migration Procedure SDO_MIGRATE.TO_CURRENTmigrates:
– Relational to object-relational– Pre-Oracle9i Object-relational to Oracle9i object-
relational• SDO_VERSION() returns VARCHAR2 string with Oracle
Spatial version
Oracle Spatial New Features 4-6
More Functional Enhancements
• Arc densification routine:– Input geometry with arcs and/or circles– Output geometry with no arcs or circle, fills in with
lines• New views provide information about spatial indexes
– *_SDO_INDEX_INFO
– Index name, table name, column name, index type (rtree or quadtree), and index table name
Oracle Spatial New Features 4-7
More Functional Enhancements
Index types do not need to match for join queries• Can join tables indexed with quadtrees and tables
indexes with r-trees• Can also join tables indexed at different levels• Spatial matches the index of the second geometry
to the index of the first geometry• If using quadtrees, make sure the coordinate system
bounds match
Oracle Spatial New Features 4-8
In this lesson, the student should have learned to:• Describe Spatial Function enhancements• Use SQL with new Spatial Function enhancements
Summary
Oracle Spatial New Features 5-1
User Defined Aggregates
Oracle Spatial New Features 5-2
Objectives
After completing this lesson, the student should be able to:• Describe Spatial aggregate functions• Use SQL statements to utilize Spatial aggregate functions
in queries
Oracle Spatial New Features 5-3
Overview
• SQL has long had aggregate functions, which are used to aggregate results of a SQL query
• Example: Use SUM to aggregate salaries by department:
• Oracle Spatial aggregate functions:– Aggregate results involving geometry objects– Return a geometry object of type SDO_GEOMETRY
object, such as, SDO_UNION or SDO_BUFFER– Many have an input parameter of type SDOAGGRTYPE
SELECT SUM(salary), deptFROM employeesGROUP BY dept;
SELECT SUM(salary), deptFROM employeesGROUP BY dept;
Oracle9i Spatial aggregate functions Oracle9i Spatial aggregate functions provide a mechanism for defining aggregate functions over Geometry Objects. They are similar to scalar aggregates like SUM and AVG and can be used in SQL like the standard aggregate functions. An aggregate version is added for every function that returns a geometry where aggregation is meaningful.
SDOAGGRTYPE Object Type
Many spatial aggregate functions accept an input parameter of type SDOAGGRTYPE, which is defined as:
CREATE TYPE sdoaggrtype AS OBJECT (geometry MDSYS.SDO_GEOMETRY,diminfo MDSYS.SDO_DIM_ARRAY );
Oracle Spatial New Features 5-4
Spatial Aggregate Function Example
SELECT sdo_aggregate_union(a.geometry),a.state
FROM counties a,roads b
WHERE b.id = 'I93'AND sdo_relate(a.geometry, b.geometry,
'MASK=ANYINTERACTQUERYTYPE=WINDOW')='TRUE'
GROUP BY a.state;
SELECT sdo_aggregate_union(a.geometry),a.state
FROM counties a,roads b
WHERE b.id = 'I93'AND sdo_relate(a.geometry, b.geometry,
'MASK=ANYINTERACTQUERYTYPE=WINDOW')='TRUE'
GROUP BY a.state;
Find the union of county boundaries, by state, that overlap a given road.
The intent of this query is to return multiple geometries that represent the union of counties that have any interaction with I93 grouped by state. There is one aggregated geometry for each state.
Oracle Spatial New Features 5-5
Spatial Aggregate Union
I93
Interstate 93 travels through many state county boundaries. In the picture:• Each square represents a county• Each color represents a state
For example, each purple square is a different county, but they are all in the same state, and they are all of the counties in that single state.The picture on the left represents all counties in all of the states touched by I93. The picture on the right represents the results of the query which only returns the counties touched.
Oracle Spatial New Features 5-6
List of Spatial Aggregate Functions
• SDO_MBR• SDO_UNION• SDO_CENTROID• SDO_CONVEXHULL
• SDO_AGGR_MBR• SDO_AGGR_UNION• SDO_AGGR_CENTROID• SDO_AGGR_CONVEXHULL
Spatial Aggregate FunctionsIn the slide, the column on left presents the subset spatial functions that ship with Oracle8i Spatial, and the column on the right is the similar aggregate function in Oracle9i Spatial.
SDO_AGGR_MBR
Returns the minimum bounding rectangle (MBR) of the specified geometries, that is, a single rectangle that minimally encloses the geometries.
SDO_AGGR_UNION
Returns a geometry object that is the topological union (OR operation) of the specified geometry objects. SDO_AGGR_CENTROID
Returns a geometry object that is the centroid, or center of gravity, of the specified geometry objects.SDO_AGGR_CONVEXHULL
Returns a geometry object that is the convex hull of the specified geometry objects.
Oracle Spatial New Features 5-7
In this lesson, the student should have learned to:• Describe Spatial aggregate functions• Use SQL statements to utilize Spatial aggregate functions
in queries
Summary
Oracle Spatial New Features 6-1
Partitioning Support
Oracle Spatial New Features 6-2
Objectives
After completing this lesson, the student should be able to:• Describe how a Spatial table can be partitioned• To create local indices on a Spatial table• Use SQL statements to Create, Alter and Drop partitions
on a Spatial table
Oracle Spatial New Features 6-3
Oracle9i Table Partitioning
• Addresses the key problem of supporting very large tables and indexes :– Decompose tables and indexes into smaller pieces
called partitions– SQL statements can access and manipulate the
partitions rather than entire tables– The DBA can map table or indexes partitions to
different tablespaces• Supports Oracle range partitioning model
Extensible Indexing supports partitioning of domain indexes in Oracle9i. In this lesson, we describe how using these new features of Oracle9i. Oracle9i Spatial supports partitioned spatial indexes, and parallel processing of spatial indexes.These new features are expected to enhance the performance of the following operations on spatial indexes:
• Index creation• Join operations• Large window queries that access a substantial portion of the indexes. • Concurrent queries that access different partitions
Oracle9i supports creation and maintenance of domain-based indexes using the extensible indexing framework. Oracle9i Spatial supports a new datatype called SDO_GEOMETRYwhich models up to 4-dimensional geometries that occur in geographic and cad/cam applications. To index such geometries, Oracle9i Spatial defines a new type of domain index called the SPATIAL_INDEX. This INDEXTYPEbehaves as one of two well-known spatial indexes: a quadtree, or an R-Tree. All of these indexes are created based on the parameters specified by the user during index creation.Of the two variants, a quadtree indexes only 2-dimensional spatial geometries whereas an R-Tree can index more than 2-dimensional data.
Oracle Spatial New Features 6-4
Range Partitioning
• Example: SALES table– Columns: ACCT_NO, NAME, AMOUNT, WEEK_NO– Partitioned on: WEEK_NO
Week 0-3
Tablespace TS1
6,US steel,1000,17,Motorola,2000,2
...
Week 4-7
Tablespace TS2
6,US steel,7000,57,Motorola,4000,7
...
Week 48-51
Tablespace TS13
6,US steel,5000,487,Motorola,6000,49
...
Oracle Spatial New Features 6-5
Spatial Partitioned Index Example
• 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.
• To create a partitioned spatial index, you must specify the LOCAL keyword.
• 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.
• To create a partitioned spatial index, you must specify the LOCAL keyword.
CREATE INDEX counties_idxON counties(geometry)INDEXTYPE IS MDSYS.SPATIAL_INDEX LOCAL;
Oracle Spatial New Features 6-6
Why Partition Spatial Indexes?
• Reduce response times for long running queries: reduce disk I/O by partitioning
• Reduce response times for concurrent queries: concurrent I/O on each partition
• Ease of index maintenance: partition level creates and rebuilds
Oracle Spatial New Features 6-7
Restrictions of Spatial Index Partitioning
• The partition key for spatial tables should be a scalar value, that is, it should be non-spatial
• Only range partitioning is supported; hash partitioning is planned for a future release
Oracle Spatial New Features 6-8
Partitioning Extensions to Spatial Indexing
• Index Creation Commands• Index Modification Commands• Query Operations
Oracle Spatial New Features 6-9
Partitioned Spatial Indexes in Oracle9i
• Create local partitioned indexes for partitioned tables– Local partitioned indexes:
– The index is partitioned like the table– 1-to-1 relationship between table and index
partitions– Index partitioning is based on underlying table
partitioning– Only range partitioning is supported on the
underlying table (This is an extensible indexing limitation)
• If the base table has N partitions, there will be N logical spatial indexes, one for each partition
Spatial maintains two structures:• USER_SDO_INDEX_METADATAview that stores information concerning an entire index• SDO_INDEX_TABLE that stores the index information such as tiles for a quadtree, or hierarchical
tree nodes for an r-tree.For local partitioned spatial indexes, Oracle Spatial maintains one index_table per partition. The metadata view contains:
• partition-level entries: one row per partition specifying the metadata for the corresponding local index, identified by and stored in the index_table
• index-level entry: one row for the entire index. This row maintains the parameters specified in the global_params_str of a CREATE INDEX ...LOCALcommand.
Oracle Spatial New Features 6-10
Spatial Index Creation
Index parameters are divided into two groups• Storage Parameters
– Specify the storage characteristics for each partition– Can be different for each partition
• Spatial Parameters– Specify quadtree/R-Tree, level, and others– Should be the same for each partition
Oracle Spatial New Features 6-11
Index Modification
• Indexes on partitions can be rebuilt without effecting the queries on other partitions
• Storage parameters for each local index can be changed independent of other partitions
Oracle Spatial New Features 6-12
Querying Partitioned Tables
• Queries evaluated on each partition• sdo_relate, sdo_filter, sdo_within_distance
have the same semantics as for non-partitioned indexes
• sdo_nn has different semantics:
– k: number of neighbors requested– n: number of partitions for the index
Oracle Spatial New Features 6-13
In this lesson, the student should have learned to:• Describe how a Spatial table can be partitioned• To create local indices on a Spatial table• Use SQL statements to create, alter and drop partitions on
a spatial table
Summary
Oracle Spatial New Features 7-1
Performance and Tuning
Oracle Spatial New Features 7-2
Objectives
After completing this lesson, the student should be able to:• Describe what performance work is planned for
Oracle9i Spatial• Describe new features in the OEM Spatial Index Advisor
Oracle Spatial New Features 7-3
Performance
• Secondary Filter improvements• R Tree improvements: interior tile optimization• Analysis functions: Boolean operations
Performance and tuning features are planned for Oracle9i Spatial, but will not be delivered in the Beta kit.
Oracle Spatial New Features 7-4
Tuning - Spatial Index Advisor
Oracle Enterprise ManagerOracle Enterprise Manager is a java-based framework consisting of multiple components that integrateinto a powerful graphical user interface. Oracle Enterprise Manager combines a central console, agents, common services, and tools to provide an integrated, comprehensive systems management platform for managing an Oracle database environment. Including the Spatial Index Advisor.
What is the Spatial Index Advisor?The Spatial Index Advisor application helps database administrators to analyze and tune Oracle Spatial indexes, to achieve good performance for spatial queries. The application lets you analyze layers of spatial data (type SDO_GEOMETRY). The data represents objects such as rectangles, circles, polygons, and arcs, all of which are displayed graphically.
Spatial IndexesSpatial data can have a spatial index associated with it. A spatial index contains a set of tiles, and the DBA controls the size and number of tiles. The coverage of the geometries by the tiles has a direct impact on query performance. This application lets you see the interaction of the tiles with the geometries.
Oracle Spatial New Features 7-5
Spatial Index Advisor
• Supported zoom to and query geometries between two layers. For the first time, the tool can visualize the inter-relationship between two layers based on geometry query criteria.
• Supported zoom to and query geometries based on a set of table attributes instead of requiring the user to know the ROWID or GeomID.
• Added support for spatial data stored with Spatial Coordinate System
• Added support for multi-dimensional data and pure point data. • Enhanced the connection management of the tool. Now the tool
can successfully change database connection. • Added support for nearest neighbor query and primary filter
within distance query. • Fully supported connection through OMS using this tool.
Analyzing a Layer for Which You Have a Reference MapAssume that you have a layer that contains the block groups for the US Census Bureau for the entire United States. This information is stored in a table called US, in a column called GEOMETRY. The extents of this layer (in the USER_SDO_GEOM_METADATAview) are -90 to 90 and -180 to 180. You also have a simple world geometry. It is stored in a table called WORLD, in a column called GEOMETRY. It too has the extents of -90 to 90 and -180 to 180. Both of these layers are indexed.
You start the Spatial Index Advisor. In the Add Layer dialog box, you select the layer WORLD(GEOMETRY). The layer alias is set to WORLD and the color is set to black After you click OK, the application does the following:
• Labels the axes with the full extent of the WORLD layer• Makes WORLD the current layer in the choice box
• Displays information in the Tips area
Oracle Spatial New Features 7-6
Spatial Administration with DBAStudio
• Provide R-tree index administration • Support management of Spatial Coordinate System
on spatial table• Support management of multi-dimensional data
Oracle Spatial New Features 7-7
Additional Features
• Add unit support for Spatial Index Advisor and Spatial Administration
• Support for the tool to run inside a browser• For zoom to and query geometries, use the
aggregation feature to display all the selected geometries
Oracle Spatial New Features 7-8
In this lesson, the student should have learned to:• Describe what performance work is planned for Oracle9i
Spatial• Describe new features in the OEM Spatial Index Advisor
Summary
Oracle Spatial New Features 8-1
Competitive Information:Internal
Oracle Spatial New Features 8-2
Objectives
After completing this lesson, you should be able to list the differences between Oracle Spatial and similar products on the market
Oracle Spatial New Features 8-3
Oracle9i Spatial vs.IBM DB2 7.1 Spatial Extender
• We support and/or exceed all documented DB2 spatial capabilities except for angular unit support.
• Multi-platform: Oracle9i Spatial supports all standard Oracle8i platforms. DB2 Spatial Extender only supports AIX (4.2 or later) and NT (4.0 or later) platforms.
• More native Spatial data types. Oracle offers native support for arcs and circles, which DB2 does not.
• Java class libraries• R-Tree indexing method• Index Tuning Wizard• Open API for Geocoders
Oracle Spatial New Features 8-4
• Location enabling services for Mobile• Support by all leading GIS/Mapping vendors• Integration with our own CRM/ERP applications, development tools• Network analysis and management• Spatial aggregate functions in SQL• Spherical Geometry computations for accurate results in Geodetic System• We currently have a more feature rich, partner-friendly solution, which
better leverages our database server capabilities
Oracle9i Spatial vs.IBM DB2 7.1 Spatial Extender
Oracle Spatial New Features 8-5
Oracle9i Spatial vs.MicroSoft SQL Server 2000
• Native Spatial data types• Support by all leading GIS/Mapping vendors• Integration with our own CRM/ERP applications, development tools• Java class libraries• R-Tree indexing method• Index Tuning Wizard• Open API for Geocoders
Oracle Spatial New Features 8-6
• SQL Spatial Analysis functions• Network analysis and management• Spatial aggregate functions in SQL• Spherical Geometry computations for accurate results in Geodetic
System
Oracle9i Spatial vs.MicroSoft SQL Server 2000
Oracle Spatial New Features 8-7
Summary
In this lesson, you should have learned to list the differences between Oracle Spatial and similar products on the market