[geos-devel] editing of geos geometries
mbdavis at refractions.net
Wed Sep 19 11:57:59 EDT 2007
Generally geometries are intended to be value objects. This is
*especially important* in C/C++, because memory aliasing can kill you
with bad pointer errors.
The approach in JTS is to use some helper classes such as GeometryEditor
and GeometryTransformer to perform "vertex surgery". Essentially they
drill down thru a geometry, add or delete points or components, and then
build a new geometry back up. I'm not sure if these have been ported to
It would probably also be nice to have some utility classes built on
these to do things like change vertices, add vertices, and delete
vertices. I may look at adding these to JTS, and they'd be easy to port
IMO filters and subclasses should NOT be used to change geometries,
since they can lead to aliasing problems. The exception would be for
things like afffine or projection transforms, where every coordinate in
a geometry is changed. In this case the developer can choose to modify
a geometry in-place if he knows that it is not referred to elsewhere.
Marco Hugentobler wrote:
> Dear geos devels,
> I' m looking into implementing geometry edits with geos classes, e.g. moving,
> adding, deleting vertices from geometries. I noticed that there is no
> possibility to directly change individual vertices in geos::geom::Geometry
> interface. Is this correct or did I overlook something?
> So I wonder what the best way is to implement such edits. Is it to
> -replace the whole geometry in case of a single vertex change?
> -implement subclasses and change the vertex coordinates of the geos class from
> -or is it possible to use/create filter classes for that purpose?
> Thanks for your advice,
Senior Technical Architect
Refractions Research, Inc.
More information about the geos-devel