ST_AddPoint — Adds a Point to a LineString before point N.
geometry ST_AddPoint(
bytea
LineString, bytea Point)
;
geometry ST_AddPoint(
bytea
LineString, bytea Point, integer N)
;
Adds a Point to a LineString before point N. N index starts at 0.
The parameter N is optional. If not specified or set to -1, it appends the Point to the end of the Line.
Also works with MultiLineStrings and GeometryCollections with Lines |
2D | 3D | M |
---|---|---|
OGC SFS for SQL. 1.1 (1999) | OGC SFS for SQL. 1.1.0 (2005) | OGC SFS for SQL. 1.2.0 (2006) | SQL-MM Part 3 |
---|---|---|---|
- | - | - | - |
SELECT ST_AsEWKT(ST_AddPoint(ST_GeomFromEWKT('LINESTRING (0 0 15, 10 10 25, 20 10 35)'), ST_GeomFromEWKT('POINT (-5 5 15)'))); --Result LINESTRING (0 0 15, 10 10 25, 20 10 35, -5 5 15) SELECT ST_AsEWKT(ST_AddPoint(ST_GeomFromEWKT('LINESTRING (0 0, 10 10, 20 10)'), ST_GeomFromEWKT('POINT (-5 5)'),1)); --Result LINESTRING (0 0, -5 5, 10 10, 20 10) SELECT ST_AsEWKT(AddPoint(ST_GeomFromEWKT('MULTILINESTRING ((0 0, 10 10, 20 10),(30 30, 40 40, 50 40))'), ST_GeomFromEWKT('POINT (-5 5 15 -2)'),3)); --Result MULTILINESTRING ((0 0, 10 10, 20 10), (-5 5, 30 30, 40 40, 50 40))