Reputation: 397
I have a SDO_GEOMETRY point:
--yields SDO_GEOMETRY type, which contains an SDO_POINT
select point from tbl
--yields a vertex_set_tye
select SDO_UTIL.GETVERTICES(point) from tbl
How can I extract the X coordinate value using: SDO_UTIL.GETVERTICES(point)
?
Upvotes: 0
Views: 4368
Reputation: 386
I think you can access the SDO_POINT object type
via the .x
attribute.
--generates test data; feel free to ignore:
with cte as (
select sdo_geometry(2001, NULL, SDO_POINT_TYPE(123, 456, NULL), NULL, NULL) as shape
from dual)
select
(shape).sdo_point.x as x,
(shape).sdo_point.y as y
from
cte
X Y
---------- ----------
123 456
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.
Important:
You can't just do this: shape.sdo_point.x
, since Oracle thinks shape
is a table alias.
You either need to create a table alias such as "a" and use it like this: a.shape.sdo_point.x
. Or wrap shape
in brackets so that Oracle knows it's not a table alias: (shape).sdo_point.x
.
Related:
Upvotes: 2
Reputation: 142733
This is my table and its contents; column GEOM
is SDO_GEOMETRY
.
SQL> desc test
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NOT NULL NUMBER
GEOM MDSYS.SDO_GEOMETRY
SQL> select id, geom from test where rownum = 1;
ID GEOM(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
---------- ------------------------------------------------------------------------------------------
1062937 SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(16,9176067, 46,2172763, NULL), NULL, NULL)
SQL>
Extracting X
and Y
coordinates is quite simple:
SQL> select a.x,
2 a.y
3 from test t cross join table(sdo_util.getvertices(t.geom)) a
4 where t.id = 1062937;
X Y
---------- ----------
16,9176067 46,2172763
SQL>
Upvotes: 1