oracle spatial – creating spatial tables object relational model creating spatial tables

43
Oracle spatial – Creating spatial tables Object Relational Model Creating Spatial Tables

Post on 20-Dec-2015

254 views

Category:

Documents


1 download

TRANSCRIPT

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Object Relational ModelCreating Spatial Tables

Object Relational ModelCreating Spatial Tables

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

ConceptsConcepts

• Describe the schema associated with a spatial layer

• Explain how spatial data is stored using the Oracle8i Spatial object-relational model

• Create the table associated with a spatial layer

• Describe the schema associated with a spatial layer

• Explain how spatial data is stored using the Oracle8i Spatial object-relational model

• Create the table associated with a spatial layer

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

SDO_GEOMETRY ObjectSDO_GEOMETRY Object

SQL> CREATE TABLE states ( 2 state VARCHAR2(30), 3 totpop NUMBER(9), 4 geom MDSYS.SDO_GEOMETRY);

SQL> CREATE TABLE states ( 2 state VARCHAR2(30), 3 totpop NUMBER(9), 4 geom MDSYS.SDO_GEOMETRY);

ExampleExample

sdo_gtype NUMBERsdo_srid NUMBERsdo_point SDO_POINT_TYPEsdo_elem_info SDO_ELEM_INFO_ARRAYsdo_ordinates SDO_ORDINATE_ARRAY

sdo_gtype NUMBERsdo_srid NUMBERsdo_point SDO_POINT_TYPEsdo_elem_info SDO_ELEM_INFO_ARRAYsdo_ordinates SDO_ORDINATE_ARRAY

SDO_GEOMETRY ObjectSDO_GEOMETRY Object

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

SDO_GEOMETRY Object (cont.) SDO_GEOMETRY Object (cont.)

x NUMBERy NUMBERz NUMBER

x NUMBERy NUMBERz NUMBER

SDO_POINT_TYPESDO_POINT_TYPE

VARRAY (1048576) OF NUMBERVARRAY (1048576) OF NUMBERSDO_ORDINATE_ARRAYSDO_ORDINATE_ARRAY

VARRAY (1048576) OF NUMBERVARRAY (1048576) OF NUMBERSDO_ELEM_INFO_ARRAYSDO_ELEM_INFO_ARRAY

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

SDO_GTYPESDO_GTYPE

• Defines the kind of geometry stored in the object

• d = number of dimensions e.g. 2, 3 or 4

• Defines the kind of geometry stored in the object

• d = number of dimensions e.g. 2, 3 or 4GTYPE Explanation

d000 UNKNOWN_GEOMETRY Spatial ignores this geometry.d001 POINT Geometry contains one point.d002 LINESTRING Geometry contains one line string.d003 POLYGON Geometry contains one polygon.d004 HETEROGENEOUS COLLECTION Geometry is a collection of elements of

different types: points, lines, polygonsd005 MULTIPOINT Geometry has multiple points.d006 MULTILINESTRING Geometry has multiple line strings.d007 MULTIPOLYGON Geometry has multiple polygons

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

SDO_SRIDSDO_SRID

• Defines the coordinate system («Spatial Reference System») used for this geometry

• Integer value matching a Spatial Reference Id defined in the MDSYS.CS_SRS table

• If not specified, use the spatial reference system defined at layer level (in spatial metadata) - if any

• Defines the coordinate system («Spatial Reference System») used for this geometry

• Integer value matching a Spatial Reference Id defined in the MDSYS.CS_SRS table

• If not specified, use the spatial reference system defined at layer level (in spatial metadata) - if any

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

SDO_POINTSDO_POINT

• This type should not be used outside of the SDO_GEOMETRY object.

• Optimized space for storing points (not point clusters).

• Ignored if SDO_ELEM_INFO and SDO_ORDINATES are not NULL

• This type should not be used outside of the SDO_GEOMETRY object.

• Optimized space for storing points (not point clusters).

• Ignored if SDO_ELEM_INFO and SDO_ORDINATES are not NULL

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

SDO_ELEM_INFOSDO_ELEM_INFO

• Entries in the array should be considered in groups of three.

• The triplet values stored in the this array are interpreted as:

– Ordinate offset - The position of the first ordinate of an element in the sdo_ordinates array. Values start at 1.

– Element type

– Interpretation - Straight line, Circular arc or header

• Entries in the array should be considered in groups of three.

• The triplet values stored in the this array are interpreted as:

– Ordinate offset - The position of the first ordinate of an element in the sdo_ordinates array. Values start at 1.

– Element type

– Interpretation - Straight line, Circular arc or header

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

SDO_ORDINATESSDO_ORDINATES

• This is a simple array of numbers

• Contains the ordinates that make up geometry elements

• Elements stored in the SDO_ORDINATES array are defined in the SDO_ELEM_INFO array

• This is a simple array of numbers

• Contains the ordinates that make up geometry elements

• Elements stored in the SDO_ORDINATES array are defined in the SDO_ELEM_INFO array

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Element Example: PointElement Example: Point

• Point optimized for space

• Spatial index is 2 dimensional, x and y.

• To generate a spatial index on SDO_POINT, SDO_ELEM_INFO and SDO_ORDINATES must be NULL.

• Point optimized for space

• Spatial index is 2 dimensional, x and y.

• To generate a spatial index on SDO_POINT, SDO_ELEM_INFO and SDO_ORDINATES must be NULL.

(x, y, z)(x, y, z)

SQL> INSERT INTO telephone_poles 2> VALUES (attribute_1, …. attribute_n, 3> mdsys.sdo_geometry ( 4> 3001, null, 5> mdsys.sdo_point_type (43.7,-75.2,200), 6> null, null) 7> );

SQL> INSERT INTO telephone_poles 2> VALUES (attribute_1, …. attribute_n, 3> mdsys.sdo_geometry ( 4> 3001, null, 5> mdsys.sdo_point_type (43.7,-75.2,200), 6> null, null) 7> );

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Element Types in SDO_ELEM_INFOElement Types in SDO_ELEM_INFO

Element Types Interpretation 0 UNKNOWN_ELEMENT

1 POINT # of points in collection

2 LINESTRING 1 - Straight lines 2 - Circular arcs

n003 POLYGON 1 - Straight lines 2 - Circular arcs 3 - Optimized rectangle 4 - Circle

4 COMPOUND LINESTRING # of type 2 sub-elements that make up the linestring

n005 COMPOUND POLYGON # of type 2 sub-elements that make up the polygon

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Element Example: Line StringElement Example: Line String

Ordinate offset1

Element type2

Interpretation1

(x1,y1)(x1,y1)(x1,y1)(x1,y1)

(x2,y2)(x2,y2)(x2,y2)(x2,y2)

(x3,y3)(x3,y3)(x3,y3)(x3,y3) (x4,y4)(x4,y4)(x4,y4)(x4,y4)

• Line segments that close to form a ring have no implied interior

• Line segments must be contiguous

• Line segments that close to form a ring have no implied interior

• Line segments must be contiguous

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Element Example: Arc StringElement Example: Arc String

Ordinate offset1

Element type2

Interpretation2

(x7,y7)(x7,y7)(x1,y1)(x1,y1)

(x3,y3)(x3,y3)(x3,y3)(x3,y3)

(x4,y4)(x4,y4)(x2,y2)(x2,y2)

(x5,y5)(x5,y5)

(x6,y6)(x6,y6)

• Each arc is defined by three points on the circumference of a circle

• Last point from one arc is the first point of next arc

• Arcs that close to form a ring have no implied interior

• Arcs must be contiguous

• Each arc is defined by three points on the circumference of a circle

• Last point from one arc is the first point of next arc

• Arcs that close to form a ring have no implied interior

• Arcs must be contiguous

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Element Example: PolygonElement Example: Polygon

• Interpretation 1 - All line segments are straight lines

• Area is implied

• Line segments cannot cross each other

• Interpretation 1 - All line segments are straight lines

• Area is implied

• Line segments cannot cross each other

Ordinate offset1

Element type1003

Interpretation1

(x4,y4)(x4,y4)(x4,y4)(x4,y4)

(x5,y5)(x5,y5)

(x3,y3)(x3,y3)(x2,y2)(x2,y2)

(x6,y6)(x6,y6)

(x1,y1)(x1,y1)

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

In this lectureIn this lecture

• See more examples of possible geometries in Oracle Spatial

• Encoding polygons

• Constructing geometries

• Metadata

• Topology in Oracle Spatial

• See more examples of possible geometries in Oracle Spatial

• Encoding polygons

• Constructing geometries

• Metadata

• Topology in Oracle Spatial

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Element Example: Arc PolygonElement Example: Arc Polygon

(x8,y8)(x8,y8)

• Interpretation 2 - All line segments are circular arcs

• Area is implied

• Arcs can not cross each other

• Interpretation 2 - All line segments are circular arcs

• Area is implied

• Arcs can not cross each other

Ordinate offset1

Element type1003

Interpretation2

(x7,y7)(x7,y7)(x7,y7)(x7,y7)

(x8,y8)(x8,y8)

(x6,y6)(x6,y6)

(x5,y5)(x5,y5)

(x9,y9)(x9,y9)

(x2,y2)(x2,y2)

(x3,y3)(x3,y3)

(x4,y4)(x4,y4)

(x1,y1)(x1,y1)

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Element Example: RectangleElement Example: Rectangle

• Optimal storage - Defined by lower left point, upper right point

• Area is implied

• Optimal storage - Defined by lower left point, upper right point

• Area is implied

Ordinate offset1

Element type1003

Interpretation3

(x2,y2)(x2,y2)

(x1,y1)(x1,y1)

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Element Example: CircleElement Example: Circle

• Defined by any three points on the circumference

• Area is implied

• Defined by any three points on the circumference

• Area is implied

Ordinate Offset1

Element Type1003

Interpretation4

(x1,y1)(x1,y1)(x1,y1)(x1,y1)(x2,y2)(x2,y2)

(x3,y3)(x3,y3)

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Element Example: Compound Line String

Element Example: Compound Line String

• First triplet (header) defines the number of sub-elements

• Sub-elements must be contiguous

• Arcs and line segments of sub-elements can cross

• Element types 4 can ONLY contain element types 2

• First triplet (header) defines the number of sub-elements

• Sub-elements must be contiguous

• Arcs and line segments of sub-elements can cross

• Element types 4 can ONLY contain element types 2

(x6,y6)(x6,y6)

Element Type

4222

Ordinate Offset

115

13

(x3,y3)(x3,y3)

(x1,y1)(x1,y1)

(x5,y5)(x5,y5)

(x4,y4)(x4,y4)

(x2,y2)(x2,y2)

(x7,y7)(x7,y7)

(x8,y8)(x8,y8)

(x9,y9)(x9,y9)

Interpretation

3 1 2 1

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Element Example: Compound PolygonElement Example: Compound Polygon

• First triplet (header) defines the number of sub-elements

• Sub-elements must be contiguous

• Arcs and line segments of sub-elements can cross

• Element types 5 can ONLY contain element types 2

• Area is implied

• First triplet (header) defines the number of sub-elements

• Sub-elements must be contiguous

• Arcs and line segments of sub-elements can cross

• Element types 5 can ONLY contain element types 2

• Area is implied

Interpretation

212

Element Type

100522

Ordinate Offset

115

(x4,y4)(x4,y4)

(x5,y5)(x5,y5)

(x6,y6)(x6,y6)

(x7,y7)(x7,y7)

(x2,y2)(x2,y2)

(x3,y3)(x3,y3)(x1,y1)(x1,y1)

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Element Example: Unknown geometry Element Example: Unknown geometry

• Element type 0 is ignored by Oracle Spatial

• Element type 0 is for modeling unsupported element types (I.e. curves, splines etc…)

• A geometry with an element type 0 must contain at least one element of type 1,2,3,4 or 5. The non 0 element is an approximation of the unsupported geometry. The approximation is indexed by Oracle Spatial

• Element type 0 is ignored by Oracle Spatial

• Element type 0 is for modeling unsupported element types (I.e. curves, splines etc…)

• A geometry with an element type 0 must contain at least one element of type 1,2,3,4 or 5. The non 0 element is an approximation of the unsupported geometry. The approximation is indexed by Oracle Spatial

Ordinate Offset1

11

Element Type0

1003

Interpretation1324

3

(x1,y1)(x1,y1)(x2,y2)(x2,y2)

(x3,y3)(x3,y3)

(x4,y4)(x4,y4)(x5,y5)(x5,y5)

(x6,y6)(x6,y6)

(x7,y7)(x7,y7)

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Collection Example: Point clusterCollection Example: Point cluster

Ordinate Offset1

Element type1

Interpretation5

(x3,y3)(x3,y3)

(x5,y5)(x5,y5)(x2,y2)(x2,y2)

(x4,y4)(x4,y4)

(x1,y1)(x1,y1)

• Interpretation is the number of points in the cluster• Interpretation is the number of points in the cluster

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Collection Example: Multi Line StringCollection Example: Multi Line String

• Elements can be line strings, arc strings or compound line strings

• Elements can be line strings, arc strings or compound line strings

(x1,y1)(x1,y1)(x1,y1)(x1,y1)

(x2,y2)(x2,y2)(x2,y2)(x2,y2)

(x3,y3)(x3,y3)(x3,y3)(x3,y3) (x4,y4)(x4,y4)(x4,y4)(x4,y4) (x6,y6)(x6,y6)(x6,y6)(x6,y6)

Ordinate offset

1

7

Element type

2

2

Interpretation

1

2

(x5,y5)(x5,y5)(x5,y5)(x5,y5)

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Collection Example: Multi PolygonCollection Example: Multi Polygon

• Elements can be polygons, arcs polygons, or compound polygons

• Elements can be polygons, arcs polygons, or compound polygons

Ordinate offset

1

13

Element type

1003

1003

Interpretation

1

4

(x4,y4)(x4,y4)(x4,y4)(x4,y4)

(x5,y5)(x5,y5)

(x3,y3)(x3,y3)(x2,y2)(x2,y2)

(x6,y6)(x6,y6)

(x1,y1)(x1,y1)(x7,y7)(x7,y7)(x7,y7)(x7,y7)(x8,y8)(x8,y8)

(x9,y9)(x9,y9)

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Element example: Polygon with voidElement example: Polygon with void

• A void can be modeled with any combination of type 3 and type 5 elements

• Voids can contain islands and islands can contain voids

• Area is implied as the difference between the outer and inner polygons

• A void can be modeled with any combination of type 3 and type 5 elements

• Voids can contain islands and islands can contain voids

• Area is implied as the difference between the outer and inner polygons

(x4,y4)(x4,y4)(x4,y4)(x4,y4)

(x5,y5)(x5,y5)

(x3,y3)(x3,y3)(x2,y2)(x2,y2)

(x6,y6)(x6,y6)

(x1,y1)(x1,y1)

(x7,y7)(x7,y7)

(x8,y8)(x8,y8)

Ordinate offset

1

13

Element type

1003

2003

Interpretation

1

3

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Element example: Compound polygon with void

Element example: Compound polygon with void

• A void can be modeled with any combination of type 3 and type 5 elements

• Voids can contain islands and islands can contain voids

• Area is implied as the difference between the outer and inner polygons

• A void can be modeled with any combination of type 3 and type 5 elements

• Voids can contain islands and islands can contain voids

• Area is implied as the difference between the outer and inner polygons

Interpretation2123

Ordinate Offset117

17

Element Type1005

22

2003

(x5,y5)(x5,y5)

(x4,y4)(x4,y4)

(x3,y3)(x3,y3)

(x6,y6)(x6,y6)

(x7,y7)(x7,y7)

(x1,y1)(x1,y1)

(x2,y2)(x2,y2)(x9,y9)(x9,y9)

(x10,y10)(x10,y10)

(x8,y8)(x8,y8)

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Encoding polygons with voidsEncoding polygons with voids

Note:

• Order required for boundaries

• Orientation of coordinates:

Note:

• Order required for boundaries

• Orientation of coordinates:

is different from

A B

DE

CF

A F

DC

EBNot the same as

+ +

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Ring orderingRing ordering

• External ring must appear before internal ring

• Outer and inner rings identified by element type

• External ring must appear before internal ring

• Outer and inner rings identified by element type

must be constructed as

+

must be constructed as

+ +

1003

2003

10032003

1003

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Points orientationPoints orientation

• Counter-clockwise for exterior rings

• Clockwise for interior rings

• Counter-clockwise for exterior rings

• Clockwise for interior rings

A B

DE

CF

+

AB

ED

C F

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Constructing geometriesConstructing geometries

(10,10)(10,10)(10,10)(10,10)

(20,25)(20,25)(20,25)(20,25)

(30,10)(30,10)(30,10)(30,10) (40,10)(40,10)(40,10)(40,10)

SQL> INSERT INTO lines VALUES ( 2> attribute_1, …. attribute_n, 3> mdsys.sdo_geometry ( 4> 2002, null, null, 5> mdsys.sdo_elem_info_array (1,2,1), 6> mdsys.sdo_ordinate_array ( 7> 10,10, 20,25, 30,10, 40,10)) 8> );

SQL> INSERT INTO lines VALUES ( 2> attribute_1, …. attribute_n, 3> mdsys.sdo_geometry ( 4> 2002, null, null, 5> mdsys.sdo_elem_info_array (1,2,1), 6> mdsys.sdo_ordinate_array ( 7> 10,10, 20,25, 30,10, 40,10)) 8> );

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Constructing geometriesConstructing geometries

SQL> INSERT INTO PARKS VALUES( 2> attribute_1, …, attribute_n, 3> MDSYS.SDO_GEOMETRY( 4> 2003, null, null, 5> MDSYS.SDO_ELEM_INFO_ARRAY 6> (1,1005,2, 1,2,1, 7,2,2, 17,2003,3), 7> MDSYS.SDO_ORDINATE_ARRAY 8> (10,50,10,30,50,30,50,50,40,60, 9> 30,50,20,60,10,50,25,35,35,40 ));

SQL> INSERT INTO PARKS VALUES( 2> attribute_1, …, attribute_n, 3> MDSYS.SDO_GEOMETRY( 4> 2003, null, null, 5> MDSYS.SDO_ELEM_INFO_ARRAY 6> (1,1005,2, 1,2,1, 7,2,2, 17,2003,3), 7> MDSYS.SDO_ORDINATE_ARRAY 8> (10,50,10,30,50,30,50,50,40,60, 9> 30,50,20,60,10,50,25,35,35,40 ));

(x5,y5)(x5,y5)

(x4,y4)(x4,y4)

(x3,y3)(x3,y3)

(x6,y6)(x6,y6)

(x7,y7)(x7,y7)

(x1,y1)(x1,y1)

(x2,y2)(x2,y2)(x9,y9)(x9,y9)

(x10,y10)(x10,y10)

(x8,y8)(x8,y8)

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Element Types SummarizedElement Types Summarized

Element Types Interpretation 0 UNKNOWN_ELEMENT

1 POINT # of points in collection

2 LINESTRING 1 - Straight lines 2 - Circular arcs

3 POLYGON 1 - Straight lines 2 - Circular arcs 3 - Optimized rectangle 4 - Circle

4 COMPLEX LINESTRING # of type 2 elements that make up the linestring

5 COMPLEX POLYGON # of type 2 elements that make up the polygon

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Spatial MetadataSpatial Metadata

• The spatial routines require you to populate a table that contains metadata about SDO_GEOMETRY columns

• The metadata table is created under the Oracle user MDSYS during installation

• The metadata table is referenced via the view USER_SDO_GEOM_METADATA

• For every SDO_GEOMETRY column, insert a row in the USER_SDO_GEOM_METADATA view

• The spatial routines require you to populate a table that contains metadata about SDO_GEOMETRY columns

• The metadata table is created under the Oracle user MDSYS during installation

• The metadata table is referenced via the view USER_SDO_GEOM_METADATA

• For every SDO_GEOMETRY column, insert a row in the USER_SDO_GEOM_METADATA view

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

USER_SDO_GEOM_METADATAUSER_SDO_GEOM_METADATA

sdo_dimname VARCHAR2(32)

sdo_lb NUMBER

sdo_ub NUMBER

sdo_tolerance NUMBER

sdo_dimname VARCHAR2(32)

sdo_lb NUMBER

sdo_ub NUMBER

sdo_tolerance NUMBER

MDSYS.SDO_DIM_ELEMENT objectMDSYS.SDO_DIM_ELEMENT object

VARRAY(4) OF SDO_DIM_ELEMENTVARRAY(4) OF SDO_DIM_ELEMENTMDSYS.SDO_DIM_ARRAYMDSYS.SDO_DIM_ARRAY

table_name VARCHAR2(32),column_name VARCHAR2(32),diminfo MDSYS.SDO_DIM_ARRAYsrid NUMBER

table_name VARCHAR2(32),column_name VARCHAR2(32),diminfo MDSYS.SDO_DIM_ARRAYsrid NUMBER

USER_SDO_GEOM_METADATAUSER_SDO_GEOM_METADATA

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

USER_SDO_GEOM_METADATA (cont.)USER_SDO_GEOM_METADATA (cont.)

• SDO_DIMNAME – The dimension name

• SDO_LB– Lowest possible value for this dimension

• SDO_UB– Largest possible value for this dimension

• SDO_TOLERANCE – Round-off error value used by Oracle Spatial

indexing, operators and functions.

• SDO_SRID– Spatial Reference System id (optional)

• SDO_DIMNAME – The dimension name

• SDO_LB– Lowest possible value for this dimension

• SDO_UB– Largest possible value for this dimension

• SDO_TOLERANCE – Round-off error value used by Oracle Spatial

indexing, operators and functions.

• SDO_SRID– Spatial Reference System id (optional)

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Populating USER_SDO_GEOM_METADATA

Populating USER_SDO_GEOM_METADATA

SQL> INSERT INTO USER_SDO_GEOM_METADATA VALUES

2 (‘ROADS’,

3 ‘GEOMETRY’,

4 MDSYS.SDO_DIM_ARRAY (

5 MDSYS.SDO_DIM_ELEMENT(’Long’, -180, 180, .005),

6 MDSYS.SDO_DIM_ELEMENT(‘Lat’, -90, 90, .005)

7 ),

8 NULL

9 );

SQL> INSERT INTO USER_SDO_GEOM_METADATA VALUES

2 (‘ROADS’,

3 ‘GEOMETRY’,

4 MDSYS.SDO_DIM_ARRAY (

5 MDSYS.SDO_DIM_ELEMENT(’Long’, -180, 180, .005),

6 MDSYS.SDO_DIM_ELEMENT(‘Lat’, -90, 90, .005)

7 ),

8 NULL

9 );

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Notes on dimensionsNotes on dimensions

• You can place more than 2 dimensions in the SDO_DIM_ARRAY, but Oracle Spatial Operators, Functions and Indexing will only use the first 2 dimensions defined.

• All layers that you want to match MUST have the EXACT SAME bounds !

• You can place more than 2 dimensions in the SDO_DIM_ARRAY, but Oracle Spatial Operators, Functions and Indexing will only use the first 2 dimensions defined.

• All layers that you want to match MUST have the EXACT SAME bounds !

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

Support for topologySupport for topology

• Topology is not explicitly maintained in the DB

• Several topological operators and functions have been implemented for checking the relationships between two geometries

• Window and spatial join queries are also supported

• Topology is not explicitly maintained in the DB

• Several topological operators and functions have been implemented for checking the relationships between two geometries

• Window and spatial join queries are also supported

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

A

B

A

B

A

B

A

B

A

B

A red B green

A

B

B Inside AA Contains B

B Covered by A A Covers B

Touch

OverlapBoundaries Intersect

OverlapBoundaries Disjoint

Equal

Disjoint

Topological relationshipsTopological relationships

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

1.1. DISJOINTDISJOINT: boundaries and interiors do not intersect: boundaries and interiors do not intersect

2.2. TOUCH TOUCH: boundaries intersect but interiors do not intersect: boundaries intersect but interiors do not intersect

3.3. OVERLAPBDYDISJOINT OVERLAPBDYDISJOINT: interior of one object intersects : interior of one object intersects boundary and interior of other object, but two boundaries do boundary and interior of other object, but two boundaries do not intersect (example: a line originates outside a polygon not intersect (example: a line originates outside a polygon and ends inside the polygon)and ends inside the polygon)

4.4. OVERLAPBDYINTERSECT OVERLAPBDYINTERSECT: boundaries and interiors of the : boundaries and interiors of the two objects intersecttwo objects intersect

5.5. EQUAL EQUAL: the two objects have the same boundary and interior: the two objects have the same boundary and interior

TopologicalTopological relationshipsrelationships

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

6. 6. CONTAINSCONTAINS: interior and boundary of one object is : interior and boundary of one object is completely contained in the interior of other objectcompletely contained in the interior of other object

7. 7. COVERSCOVERS: interior of one object is completely contained in : interior of one object is completely contained in interior of other object and their boundaries intersectinterior of other object and their boundaries intersect

8. 8. INSIDEINSIDE: opposite of CONTAINS; A INSIDE B implies B : opposite of CONTAINS; A INSIDE B implies B CONTAINS ACONTAINS A

9. 9. COVEREDBYCOVEREDBY: opposite of COVERS; A COVEREDBY B : opposite of COVERS; A COVEREDBY B implies B COVERS Aimplies B COVERS A

10. 10. ANYINTERACTANYINTERACT: the objects are non-disjoint: the objects are non-disjoint

Topological relationships (cont.d)Topological relationships (cont.d)

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

SDO_RELATESDO_RELATE

MASK: identifies the topological relationMASK: identifies the topological relation

Topological operators: SDO_RELATETopological operators: SDO_RELATE

boolean := SDO_RELATE ( <geometry-1>, <geometry-2>, ‘MASK=<mask> QUERYTYPE=<querytype> [other optional parameters]’ )

boolean := SDO_RELATE ( <geometry-1>, <geometry-2>, ‘MASK=<mask> QUERYTYPE=<querytype> [other optional parameters]’ )

Oracle spatial – Creating spatial tablesOracle spatial – Creating spatial tables

SummarySummary

• Oracle Spatial data model: elements, geometries and layers

• SDO_GEOMETRY object type

• Constructing geometries

• Associated Metadata

• Support for Topology

• Oracle Spatial data model: elements, geometries and layers

• SDO_GEOMETRY object type

• Constructing geometries

• Associated Metadata

• Support for Topology