首頁
云原生數(shù)據(jù)庫(kù) PolarDB
云原生數(shù)據(jù)庫(kù)PolarDB PostgreSQL版
時(shí)空引擎(GanosBase)
Geometry SQL參考
線性參考
ST_LineInterpolatePoints
ST_LineInterpolatePoints
更新時(shí)間:
在LineString上指定位置插入一個(gè)或多個(gè)點(diǎn),并返回插入的點(diǎn)。
語法
geometry ST_LineInterpolatePoints(geometry aLinestring , float8 aFraction , boolean repeat);
geography ST_LineInterpolatePoints(geography aLinestring , float8 aFraction , boolean repeat);
參數(shù)
參數(shù)名稱 | 描述 |
aLinestring | 目標(biāo)LineString對(duì)象。 |
aFraction | 插入點(diǎn)位于該線段的百分比。是一個(gè)從0到1的浮點(diǎn)值。 |
repeat | 是否重復(fù)插入,默認(rèn)為true。 |
描述
如果repeat設(shè)為true。將會(huì)每隔指定的距離就創(chuàng)建一個(gè)點(diǎn)。
如果結(jié)果為0個(gè)或1個(gè)點(diǎn),則作為Point返回,否則以MultiPoint形式返回。
該函數(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_LineInterpolatePoints('LINESTRING(0 0,0 5)', 0.20)); st_astext --------------------------------- MULTIPOINT(0 1,0 2,0 3,0 4,0 5) (1 row) -- gepgraphy SELECT ST_AsText(ST_LineInterpolatePoints('LINESTRING(0 0,0 5)'::geography, 0.20)); st_astext ------------------------------------------------------------------------------------------------------- MULTIPOINT((0 1.00002443285827),(0 2.00004274948544),(0 3.00004884128919),(0 4.00003661494431),(0 5))
不重復(fù)插入:
SELECT ST_AsText(ST_LineInterpolatePoints('LINESTRING(0 0,0 5)', 0.20, false)); st_astext ------------ POINT(0 1) (1 row) SELECT ST_AsText(ST_LineInterpolatePoints('LINESTRING(0 0,0 5)'::geography, 0.20, false)); st_astext --------------------------- POINT(0 1.00002443285827) (1 row)
文檔內(nèi)容是否對(duì)您有幫助?