文档

ST_LineInterpolatePoints

更新时间:

在LineString上指定位置插入一个或多个点,并返回插入的点。

语法

geometry  ST_LineInterpolatePoints(geometry  aLinestring , float8  aFraction , boolean  repeat);
geography  ST_LineInterpolatePoints(geography  aLinestring , float8  aFraction , boolean  repeat);

参数

参数名称

描述

aLinestring

目标LineString对象。

aFraction

插入点位于该线段的百分比。是一个从0到1的浮点值。

repeat

是否重复插入,默认为true。

描述

  • 如果repeat设为true。将会每隔指定的距离就创建一个点。

  • 如果结果为0个或1个点,则作为Point返回,否则以MultiPoint形式返回。

  • 该函数支持3D对象,并且不会删除Z坐标。

  • 该函数支持M坐标。

  • 使用地理坐标系时会根据球面距离进行计算。

示例

  • 计算给定线段上指定比例位置处的点坐标:

    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))
  • 不重复插入:

    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)
  • 本页导读 (0)
文档反馈