首頁
云數(shù)據(jù)庫 RDS
RDS PostgreSQL數(shù)據(jù)庫
時(shí)空引擎(GanosBase)
Geometry SQL參考
線性參考
ST_LineInterpolatePoint
ST_LineInterpolatePoint
更新時(shí)間:
在LineString上指定位置插入點(diǎn)對(duì)象,并返回該點(diǎn)。
語法
geometry ST_LineInterpolatePoint(geometry aLinestring , float8 aFraction);
geography ST_LineInterpolatePoint(geography aLinestring , float8 aFraction);
參數(shù)
參數(shù)名稱 | 描述 |
aLinestring | 目標(biāo)LineString對(duì)象。 |
aFraction | 插入點(diǎn)位于該線段的百分比,是一個(gè)從0到1的浮點(diǎn)值。 |
描述
該函數(shù)支持3D對(duì)象,并且不會(huì)刪除Z坐標(biāo)。
該函數(shù)支持M坐標(biāo)。
使用地理坐標(biāo)系時(shí)會(huì)根據(jù)球面距離進(jìn)行計(jì)算。
示例
計(jì)算給定線段的中點(diǎn)坐標(biāo):
SELECT ST_AsText(ST_LineInterpolatePoint(geom, 0.5)) FROM (SELECT 'LINESTRING(0 0,2 2)'::geometry as geom) As test; st_astext ------------ POINT(1 1) (1 row) SELECT ST_AsText(ST_LineInterpolatePoint(geog, 0.5)) FROM (SELECT 'LINESTRING(0 0,2 2)'::geography as geog) As test; ------------------------------------------ POINT(0.99969732796684 1.00015638159834)
獲取線上距離某個(gè)Geometry對(duì)象最近的點(diǎn):
SELECT ST_AsText(ST_LineInterpolatePoint(geom, ST_LineLocatePoint(geom, 'POINT(1 1)'::geometry))) FROM (SELECT 'LINESTRING(0 0,0 2)'::geometry As geom) As test; st_astext ------------ POINT(0 1) (1 row) -- geography SELECT ST_AsText(ST_LineInterpolatePoint(geog, ST_LineLocatePoint(geog, 'POINT(1 1)'::geography))) FROM (SELECT 'LINESTRING(0 0,0 2)'::geography As geog) As test; --------------------------- POINT(0 1.00015229710421)
文檔內(nèi)容是否對(duì)您有幫助?