[geos-devel] CoordSeq ADT and fine-grained ctors for C-API (was: GEOS C API Suggestions)

Frank Warmerdam warmerdam at pobox.com
Fri Oct 21 12:01:30 EDT 2005


On 10/21/05, strk at refractions.net <strk at refractions.net> wrote:
> About performance and isolation, do we really want
> all the copies to happen ?
>
> Consider a multipolygon construction, you'll have copies:
>         - of CoordSeq objects of the shell and each hole
>           at each of the corresponding object construction/copy
>         - of shell and hole geometry for each polygon
>           construction/copy
>         - of each polygon geometry at collection construction
> In practice it would take 3 copies of each involved CoordinateSequence.
>
> I'm thinking about making constructors take ownership of argument,
> and extractors (GetGeometryN, getExteriorRing, getCoordSeq..) return
> resources owned by the argument object...
>
> These changes would also allow changing any Ordinate value
> of any Geometry ...
>
>         GEOSGeom g1 = GEOSGetGeometryN(g, 2);
>         GEOSGeom hole3 = GEOSGetInteriorRingN(g1, 3);
>         GEOSCoordSeq s = GEOSGetCoordSeq(hole3);
>         GEOSCoordSeq_setX(s, 4);
>
> What do you think, is the advantage worth the danger ?

Strk,

If one of the rationales for the direct construction and query
support is to provide a "fastest" method of converting to and
from GEOS Geometries, then I think that avoiding copying
would be wise.  I don't immediately intend to use the new
api entries so it doesn't matter so much to me, but if we convert
mapserver to use the GEOS C API then it speed would be an
issue.

I would say that the advantage is worth the danger, but the
rules about internal references and taking of ownership need
to be made clear in the docs.

Best regards,
--
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the geos-devel mailing list