[postgis-users] Modifying a linestring

Stephen Woodbridge woodbri at swoodbridge.com
Thu Aug 4 08:17:51 PDT 2005


strk at refractions.net wrote:
> On Thu, Aug 04, 2005 at 11:29:52AM +0300, Ehud Shabtai wrote:
> 
>>Hi,
>>
>>I need to modify a linestring (actually change the first or last
>>point), in a postgres trigger. Is there a simple way to do it using
>>the sql language?
> 
> 
> Nope, but it would probably be useful.
> 
> The interface might be something like:
> 
> 	UpdateLinePoint(line, pointN, point);
> 	InsertLinePoint(line, pointN, point); -- add before pointN
> 	AppendLinePoint(line, pointN, point); -- add after pointN
> 	DeleteLinePoint(line, pointN, point);
> 
> Similar editing functions would be nice to have for
> polygons as well.
> 
> Comments ? Volunteers ? Founders ?

Comment :)

Why would you not want to make this generic like:
	UpdateGeomPoint(geometry, itemN, pointN, point);
	AddPointBefore(geometry, itemN, pointN, point);
	AddPointAfter(geometry, itemN, pointN, point);
	DeleteGeomPoint(geometry, itemN, pointN, point);

where itemN would be a ring or item in MULTI*, well it is obvious that 
you can create objects that are too complex for this to work, but itemN 
could also be an ARRAY() of indexes to select a simple geometry.

In general this speaks to having general purpose constructors and 
de-constructors for all geometry objects that are fast and efficient. 
Most of the pieces are there for this, but it is not always obvious how 
to do this otherwise the response would be you modify the a line by:

   points := getLinePoints(line);
   points[0] := new_point;
   line := makeline(points);

or something to this effect.

-Steve W.



More information about the postgis-users mailing list