Oracle 18c 10.7.1 EGDB:
I want to write a SQL query that has rows with the XY coordinates of each vertex of an SDE.ST_GEOMETRY polygon feature class.
I can do it for a line FC using a cross join, a numbers table, and ST_PointN:
select a.objectid, b.number_ as vertex_id, a.sde.st_x(sde.st_pointn(a.shape, b.number_)) as x, a.sde.st_y(sde.st_pointn(a.shape, b.number_)) as y from infrastr.active_transportation a cross join infrastr.numbers b where b.number_ <= sde.st_numpoints(a.shape) and a.objectid = 14113
But if I run that query on a polygon FC instead of a line FC, then I get an error:
ORA-20003: ST_Geometry type must be an ST_LINESTRING or ST_MULTIPOINT type. ORA-06512: at "SDE.ST_GEOMETRY_OPERATORS", line 2614
If I comment out the lines that use ST_PointN, then the query runs successfully:
select a.objectid, b.number_ as vertex_id --a.sde.st_x(sde.st_pointn(a.shape, b.number_)) as x, --a.sde.st_y(sde.st_pointn(a.shape, b.number_)) as y from infrastr.bc_polygons a cross join infrastr.numbers b where b.number_ <= sde.st_numpoints(a.shape)
So, that tells me that the problem is with ST_PointN. ST_PointN appears to only work for lines:
ST_PointN takes an ST_LineString and an integer index and returns a point that is the nth vertex in the ST_LineString's path.
Can a function be added to ST_GEOMETRY to get a specific vertex of a polygon?
I did the following MS SQL for my boundary on my database to get the vertices of a polygon:
SELECT a.OBJECTID,
t.number as Vertice,
a.Shape.STPointN(t.number).STX as Longitude,
a.Shape.STPointN(t.number).STY as Latitude
FROM DB1.sde.Boundary a
JOIN
(
SELECT number
FROM DB1.sde.Boundary a
join
(
SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS number
FROM master..spt_values
) n on ( n.number BETWEEN 1 AND a.SHAPE.STNumPoints() )
where a.objectid = 401
) t on (t.number <= a.SHAPE.STNumPoints())
where a.objectid = 401
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.