[geos-devel] Coordinate & Coordinate list

David Blasby dblasby at refractions.net
Thu Nov 14 15:00:06 EST 2002


I took a quick look at the CoordinateList class.

This seems like a fairly foundational class, and I think efficiency
improvements here would trickle up the system quite well.
Unfortunately,  changes could cause lots of changes to other portions of
code.

Java always passes things by reference, so in most cases it ought to be
okay to just move around pointers to objects instead of the object.
But, you'll have to be carefull about memory management & unexpected
changes to objects, and when to actually delete stuff.

In many cases, the objects are not allocated, de-allocated, or copied
often so it wouldnt be worth the effort to change them.

The obvious way to speed things up is to *never* copy coordinates if you
dont have to.  That means making the CoordinateList keep a list of
pointers to Coordinate, have set() take a pointer to a coordinate, and
get() return a pointer to coordinate.

How are things handled in objects like Linestring, linear ring, and
polygon.  Are they just carrying around a Coordinate list?  If so, it
should probably just be carrying around a pointer to a coordinate list.
That way copying, say, a linear ring would be very quick (just hard to
know when to actually delete the coordinate list).

Hopefully this will give us lots of speed ups and memory efficienty by
only changing a few things...


But I dont know what's actually using these things, so I could be
wrong.  What do you folks think?

dave
ps. a Geometry.DieDieDie() function might be needed to ensure that
memory is actually released.


{
Geometry *g1,*g2;

//make coodinates & coordinate lists

g1 = <create a geometry>
g2 = <create a geometry>

 IntersectionMatrix im(g1->relate(g2));

    //im will be released automagically when block ends

g1.DieDieDie();  // ensure that everything is actually released
g2.DieDieDie(); // including all the CoordinateList and Coordinates
}

We'll have to be careful that there are no "shared" Coordinates - ie. if
you union g1 and g2, the result should have all new coordinates instead
of re-using the old ones (because someone could de-allocate them when
you're not looking).





More information about the geos-devel mailing list