获取SDO.GEOMETRY折线的中点 [英] Get midpoint of SDO.GEOMETRY polyline
问题描述
我在Oracle 18c中有一个表,该表具有带折线的SDO_GEOMETRY列.
I have a table in Oracle 18c that has an SDO_GEOMETRY column with polylines.
我想使用SQL查询折线中点的X和Y坐标.
I want to query the X and Y coordinates of the polyline midpoints using SQL.
是否可以使用Oracle Spatial做到这一点?
Is there a way to do this with Oracle Spatial?
推荐答案
Oracle Spatial具有 SDO_LRS .可用于查找折线的中点坐标.
Oracle Spatial has a linear referencing package called SDO_LRS. It can be used to find the midpoint coordinates of a polyline.
--In this case, 'sdo' is the name of the sdo_geometry column.
sdo_lrs.convert_to_std_geom(sdo_lrs.locate_pt(sdo_lrs.convert_to_lrs_geom(sdo,3)
,sdo_geom.sdo_length(sdo,3)/2)).sdo_point.x as midpoint_x,
sdo_lrs.convert_to_std_geom(sdo_lrs.locate_pt(sdo_lrs.convert_to_lrs_geom(sdo,3)
,sdo_geom.sdo_length(sdo,3)/2)).sdo_point.y as midpoint_y
奖励积分:
For bonus points:
This is how ESRI's SDE.ST_GEOMETRY can be converted to SDO_GEOMETRY for the purpose of getting the midpoint coordinates:
select
sdo_lrs.convert_to_std_geom(sdo_lrs.locate_pt(sdo_lrs.convert_to_lrs_geom(sdo,3),sdo_geom.sdo_length(sdo,3)/2)).sdo_point.x as midpoint_x,
sdo_lrs.convert_to_std_geom(sdo_lrs.locate_pt(sdo_lrs.convert_to_lrs_geom(sdo,3),sdo_geom.sdo_length(sdo,3)/2)).sdo_point.y as midpoint_y
from
(select
sdo_util.from_wktgeometry(sde.st_astext(shape)) as sdo
from
roads)
此答案的灵感来自于代码审查的答案:计算折线的中点.
This answer was inspired by an answer on Code Review: Calculate the midpoint of a polyline.
这篇关于获取SDO.GEOMETRY折线的中点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!