ST_LineInterpolatePoint — Returns a point interpolated along a line at a fractional location.
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 를 참조하십시오.
|
|
|
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. |
|
|
|
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.
This example returns the point 20 percent along a line.
SELECT 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_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_LineInterpolatePoint(
line.geom,
ST_LineLocatePoint(line.geom, 'POINT(4 3)'))
FROM (SELECT 'LINESTRING(1 2,4 5,6 7)'::geometry As geom) AS line;
POINT(3 4)
An interpolated point can be offset to the left or right of a line by using ST_OffsetCurve before interpolation. This is useful for locating an address point beside a street centerline.
WITH street AS (
SELECT 'LINESTRING(0 0, 10 0)'::geometry AS geom,
100 AS from_num,
200 AS to_num
)
SELECT
ST_LineInterpolatePoint(
ST_OffsetCurve(geom, -2),
(160 - from_num)::float8 / (to_num - from_num)
) AS interpolated_offset_point
FROM street;
interpolated_offset_point --------------------------- POINT(6 -2)