获取 SDO.GEOMETRY 折线的中点

Get midpoint of SDO.GEOMETRY polyline

我在 Oracle 18c 中有一个 table,它有一个带有折线的 SDO_GEOMETRY 列。

我想使用SQL查询折线中点的X和Y坐标。

有没有办法用 Oracle Spatial 做到这一点?

Oracle Spatial 有一个 linear referencing package called SDO_LRS。可用于求多段线的中点坐标。

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

奖励积分:

为了获取中点坐标,ESRI 的 SDE.ST_GEOMETRY 可以转换为 SDO_GEOMETRY:

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)

这个答案的灵感来自代码审查的一个答案:Calculate the midpoint of a polyline