-
Notifications
You must be signed in to change notification settings - Fork 2
ST_AddPoint
Mark Johnson edited this page Apr 1, 2014
·
24 revisions
adding a point somewhere in a LINESTRING
-
View [[
spatialite 4.1.0 LINESTRING
|http://www.gaia-gis.it/gaia-sins/spatialite-sql-4.1.0.html#p7]] ST_AddPoint( line LineString , point Point [ , position Integer ] ) : Linestring * -
Display the result
SELECT name,SanitizeGeometry
(
ST_AddPoint
(
-- Parm 1: the line to set
(SELECT soldner_segment FROM berlin_ortsteil_segments WHERE id_segment = 406),
-- Parm 2: the line to take the point from
--- ST_PointN(base 1)
(SELECT ST_PointN(soldner_segment,43) FROM berlin_ortsteil_segments WHERE id_segment = 441),
-- Parm 3: Position to set the Point (0 based)
-- 0= add as first point ; -1 add as last point, otherwise a 0 based Position
0
)
)
FROM berlin_ortsteil_segments WHERE id_segment = 406;
- Update the Record
UPDATE berlin_ortsteil_segments
SET
soldner_segment = SanitizeGeometry
(
ST_AddPoint
(
-- Parm 1: the line to set
(SELECT soldner_segment FROM berlin_ortsteil_segments WHERE id_segment = 406),
-- Parm 2: the line to take the point from
--- ST_PointN(base 1)
(SELECT ST_PointN(soldner_segment,2) FROM berlin_ortsteil_segments WHERE id_segment = 441),
-- Parm 3: Position to set the Point (0 based)
-- 0= add as first point ; -1 add as last point, otherwise a 0 based Position
-1
)
)
WHERE id_segment = 406;