[geos-devel] Problem with returning Coordinate* from CoordinateList accessor
chodgson at refractions.net
chodgson at refractions.net
Fri Nov 15 13:25:43 EST 2002
Ok, I've been lurking on this list for a while now and I think I'd like to
contribute a thought.
My understanding is that the reason for the "CoordinateList" class is to
abstract the underlying data storage. However, the only reason for someone to
implement a subclass of coordinate list would be to make use of the complex
algorithms that JTS provides - all of which are going to need actual coordinate
objects to do their work, no? Perhaps we cannot afford to abstract the the data
access layer when our algorithms are going to be doing a LOT of data access.
It seems to me like it would be more efficient to copy all of one's points into
Coordinate objects, once and for all, right at the start (in the CoordinateList
constructor). Then, we could pass around references/pointers to the Coordinates
without worrying about someone else owning them.
The only time this would be inefficient, I suppose, is if you were doing a sub-
linear-time operation... do we do many of those? We could always implement a
subclass of coordinate list, with a different underlying data structure, which
created the Coordinate objects as they were requested (with gets) and just kept
a list of pointers to the Coordinates it allocated, so they could be destroyed
when the List was destroyed. It could even be "smart" and cache the Coordinate
objects in case they were retrieved again (unlikely to happen much in a sub-
linear-time operation).
Just my two cents.
More information about the geos-devel
mailing list