[postgis-devel] Re: [postgis-users] Modifying a linestring
strk at refractions.net
strk at refractions.net
Thu Aug 4 10:14:45 PDT 2005
On Thu, Aug 04, 2005 at 11:17:51AM -0400, Stephen Woodbridge wrote:
> 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.
Sounds complex... anyway we already used the ARRAY() method for
the Dump(geometry) function, so we might as well use that to
address complex geometries elements.
A simpler syntax would be:
UpdateExteriorRing(poly, line);
UpdateInteriorRingN(poly, ringN, line);
AddInteriorRing(poly, line); -- does position really matters ?
DeleteInteriorRingN(poly, ringN);
InsertGeometry(multi*, path); -- add before geom in path
AppendGeometry(multi*, path); -- add after geom in path
UpdateGeometry(multi*, path, single*);
GetGeometry(multi*, path);
Example:
geom := 'GEOMETRYCOLLECTION(
POINT(0 0),
MULTILINESTRING((0 0, 2 2),(1 1, 3 3))
)';
Paths:
[ SELECT path(Dump(geom), AsText(geom(Dump(geom)) AS geom ]
path geom
------+---------------------
{1} | POINT(0 0)
{2,1} | LINESTRING(0 0,2 2)
{2,2} | LINESTRING(1 1,3 3)
Update of first point of last linestring:
UpdateGeometry(geom,
{2,2},
UpdateLinePoint(
GetGeometry(geom, {2,2}),
1,
'POINT(3 3)'
)
);
These, as you say, would be less efficient, but more intuitive.
In your terms this would be easy:
UpdateGeomPoint(geom, {2,2}, 1, 'POINT(3 3)');
But how would it be to update the point of a polygon hole ?
--strk;
> 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.
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
More information about the postgis-devel
mailing list