copying OGRSpatialReference

Ben Discoe ben at v...
Sun Jul 15 18:29:01 EDT 2001


I'm unclear on how to copy a OGRSpatialReference value. If i just use the
default assignment operator, like this:

OGRSpatialReference test1;
test1.SetProjCS("UTM Zone 12, Northern Hemisphere");
OGRSpatialReference test2 = test1;

then it crashes when both are deleted, presumably because it's a shallow
rather than deep copy.

The "Clone" method looks like it's provided to be used instead, but when i
try:

OGRSpatialReference test1;
OGRSpatialReference *test2 = test1.Clone();

it crashes as well. Actually, Clone() seems to work as long as the source
has some nodes, so perhaps is it just a little bug with empty projections.

-Ben





More information about the Gdal-dev mailing list