[geos-devel] about getCoordinates()
strk
strk at keybit.net
Wed Oct 15 05:54:34 EDT 2003
Ok, since I did not get any comment on this... that's what I've worked out:
I added a getCoordinatesRO() method for LineString class returning
the internal CoordinateList object as a const (ReadOnly).
In this way we gain performace for operations that only need read access
to CoordinateList.
Arbitrary modifications of a LineString Coordinates are still possible
using the public setPoints() method.
--strk;
strk wrote:
> 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 ?
>
> _______________________________________________
> geos-devel mailing list
> geos-devel at geos.refractions.net
> http://geos.refractions.net/mailman/listinfo/geos-devel
More information about the geos-devel
mailing list