1

I am learning the oracle spatial database, but am stuck on SDO_GEOMETRY. Actually this object has the following structure:

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);

I shall quote the two attributes SDO_GTYPE and SDO_ELEM_INFO from the official oracle docs. SDO_GTYPE:

SDO_GTYPE 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.)

SDO_ELEM_INFO_ARRAY:

This attribute lets you know how to interpret the ordinates stored in the SDO_ORDINATES attribute

My problem is that I am not been able to differentiate one from the other. Is not the type of geometry actually how we interpret the coordinates? For example, look at the following insert query. It first says the geometry is a 2D polygon, and after few lines it asks to interpret the coordinates as circle:

INSERT INTO cola_markets VALUES(
 4,
 'cola_d',
 SDO_GEOMETRY(
  2003,  -- 2-dimensional polygon
  NULL,
  NULL,
  SDO_ELEM_INFO_ARRAY(1,1003,4), -- one circle
  SDO_ORDINATE_ARRAY(8,7, 10,9, 8,11)
 )
);

Kindly, tell me what is wrong in my perception. Thanks for reading.

Bishwajit Purkaystha
  • 1,975
  • 7
  • 22
  • 30

1 Answers1

2

Have a look at the following example (2-7 from http://docs.oracle.com/cd/E11882_01/appdev.112/e11830/sdo_objrelschema.htm#SPATL523)

SDO_GEOMETRY(
    2003,  -- two-dimensional 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)
  )

This is also a gtype 2003 but a different elem_info_array. Here the elem info tells us that the polygon has an outer ring and an inner ring. It also tells us where in the list of sdo_ordinates the coordinates of the outer ring stop and where the coordinates of the inner ring begin.

And while you are at it, have a look at the next example 2-8. Here a line is presented that has straight segments and circular arcs. Elem_info tells you where each of these start in the sdo_ordinate array.

Rene
  • 10,391
  • 5
  • 33
  • 46
  • It's understandable that _polygon with a hole is_ is a two dimensional polygon. But, how come the _circle_ be a two dimensional polygon? I don't really get the concept here. Rest is fine. Thanks for answering. – Bishwajit Purkaystha Dec 09 '16 at 12:13
  • 1
    The Oracle documentation speaks of 1003 and 2003 as polygons but it is actually any closed element with an inside and and outside space. – Rene Dec 10 '16 at 13:16