名前

ST_AddPoint — ラインストリングに対して指定した<position>(0はじまり)の前にポイントを追加します。

概要

geometry ST_AddPoint(geometry linestring, geometry point);

geometry ST_AddPoint(geometry linestring, geometry point, integer position);

説明

ラインストリングに対して指定した<position>(0はじまり)の前にポイントを追加します。第3引数に-1を指定すると末尾に追加できます。

初出: 1.1.0

この関数は3次元に対応し、Z値を削除しません。

--guarantee all linestrings in a table are closed
                --by adding the start point of each linestring to the end of the line string
                --only for those that are not closed
                UPDATE sometable
                SET the_geom = ST_AddPoint(the_geom, ST_StartPoint(the_geom))
                FROM sometable
                WHERE ST_IsClosed(the_geom) = false;

                --Adding point to a 3-d line
                SELECT ST_AsEWKT(ST_AddPoint(ST_GeomFromEWKT('LINESTRING(0 0 1, 1 1 1)'), ST_MakePoint(1, 2, 3)));

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

関連情報

ST_RemovePoint, ST_SetPoint