[geos-devel] about getCoordinates()

strk strk at keybit.net
Tue Oct 14 06:10:39 EDT 2003


Since a CoordinateList object does not exists ready to be
returned for Point,Polygon and Collections, obtaining a
pointer to internal CoordinateList for modification does
only make sense for LineString classes and subs.

Now. Since getCoordinates() is a pure virtual method of
the Geometry class I made it a const method (won't modify
own object) and forced LineString to return a copy instead
of a direct pointer so to assure this could not be broken
(I could have getCoordinate() return a const CoordinateList
 instead reducing memory copy but I'd have introduced other
 overheads due to reference counting for those other Classes
 that would have made a copy anyway) 

Finally, since sometimes you really want a direct access to
a LineString CoordinateList (reducing duplicates, reversing
and the like) we have two chances to do this:

1) Implement all modification method in the LineString class
   itself.

2) Make CoordinateList *points public (from protected)

The second one would be faster since no function call would be
implied to get to the actual CoordinateList. We could also
continue to use static methods like
CoordinateList::removeRepeatedPoints(CoordinateList *) or
CoordinateList::reverse(CoordinateList *) instead of having
to make them non-static.

I opt for the second. Any suggestions on this ?



More information about the geos-devel mailing list