Name

ST_LineInterpolatePoint — Returns a point interpolated along a line at a fractional location.

Synopsis

geometry ST_LineInterpolatePoint(geometry a_linestring, float8 a_fraction);

geography ST_LineInterpolatePoint(geography a_linestring, float8 a_fraction, boolean use_spheroid = true);

설명

라인을 따라 보간된 포인트를 반환합니다. 첫 번째 인수는 라인스트링이어야 합니다. 두 번째 인수는 0과 1 사이의 Float8 데이터형으로 라인스트링의 전체 길이에서 포인트가 위치해야 하는 비율을 의미합니다.

포인트에 가장 가까운 라인의 위치를 계산하는 방법에 대해서는 ST_LineLocatePoint 를 참조하십시오.

[Note]

This function computes points in 2D and then interpolates values for Z and M, while ST_3DLineInterpolatePoint computes points in 3D and only interpolates the M value.

[Note]

1.1.1 배포판부터 이 함수는 M 및 Z값(이 있을 경우)도 보간합니다. 이전 배포판에서는 두 값을 0.0으로 고정시켰습니다.

0.8.2 버전부터 사용할 수 있습니다. 1.1.1 버전에서 Z과 M 좌표를 지원합니다.

변경 사항: 2.1.0 미만 버전, 즉 2.0.x 버전까지 이 함수의 명칭은 ST_Line_Interpolate_Point였습니다.

This function supports 3d and will not drop the z-index.

예시

20% 위치 (0.20)에 있는 보간된 포인트를 가진 라인스트링

-- The point 20% along a line

SELECT ST_AsEWKT(  ST_LineInterpolatePoint(
        'LINESTRING(25 50, 100 125, 150 190)',
        0.2 ));
----------------
 POINT(51.5974135047432 76.5974135047432)

The mid-point of a 3D line:

SELECT ST_AsEWKT(  ST_LineInterpolatePoint('
        LINESTRING(1 2 3, 4 5 6, 6 7 8)',
        0.5 ));
--------------------
 POINT(3.5 4.5 5.5)

The closest point on a line to a point:

SELECT ST_AsText( ST_LineInterpolatePoint( line.geom,
                      ST_LineLocatePoint( line.geom, 'POINT(4 3)')))
FROM (SELECT ST_GeomFromText('LINESTRING(1 2, 4 5, 6 7)') As geom) AS line;
------------
 POINT(3 4)