名前

ST_AddPoint — ラインストリングにポイントを追加します。

概要

geometry ST_AddPoint(geometry linestring, geometry point);

geometry ST_AddPoint(geometry linestring, geometry point, integer position = -1);

説明

LINESTRINGのpositionの位置 (0はじまり)の前にポイントを追加します。positionパラメータが省略されるか-1の場合には、LINESTRINGの末尾に追加されます。

Availability: 1.1.0

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

3次元ラインの末尾へのポイントの追加

SELECT ST_AsEWKT(ST_AddPoint('LINESTRING(0 0 1, 1 1 1)', ST_MakePoint(1, 2, 3)));

    st_asewkt
    ----------
    LINESTRING(0 0 1,1 1 1,1 2 3)

テーブル内の全てのラインについて、閉じていないラインにだけ始端を末尾に追加することで、閉じていることを保証します。

UPDATE sometable
SET geom = ST_AddPoint(geom, ST_StartPoint(geom))
FROM sometable
WHERE ST_IsClosed(geom) = false;

関連情報

ST_RemovePoint, ST_SetPoint