[geos-devel] Issue with returning Coordinate * rather than value
David Blasby
dblasby at refractions.net
Fri Nov 15 12:21:07 EST 2002
Martin Davis wrote:
> Yep, that's what I meant. Ok, I guess I can live with that...
>
> On a philosophical note, I always prefer solutions that help save programmers from shooting themselves in the foot... seems to me that most of the history of the development of programming languages is concerned with doing exactly that, and it's nice to learn from that trend. But timelines are short - next release, I guess. The nasty thing is that once this horse is out of the door, it's disappeared around the bend never to be seen again...
I agree with you here martin, but I am really wanting to get performance up.
When would modifying internal structures be a problem?
{
Geometry *g1;
Geometry *g2;
Geometry *g3;
g1 = ....;
g2 = ...;
g3 = g1->intersect(g2);
// mess around with some of g1's coordinates BAD ME
CoordinateList coords = g1->getPoints().toCoordinateList(); //or whatever it is
coords.getAt(1)->x = 25; // EVIL LAUGH
delete g3;
g3 = g1->intersect(g2);
double len = g1->length();
}
This shouldnt give any funny results unless you're storing meta-information (like an index or graph) inside the geometries that would require re-calculating if the internal coordinate change.
We could have an alternate structure to CoordinateList that has an interface more like:
Coordinate *getAt(int i); // fast but a little dangerous
Coordinate getAtSafe(int i); // or some such thing for evil programmers.
dave
More information about the geos-devel
mailing list