[Gdal-dev] Trapping coordinate transformation errors gracefully

Tim Sutton tim at linfiniti.com
Mon Jan 10 19:30:18 EST 2005


Dear Frank

Many thanks for your reply. I am still getting similar problems after 
following your suggestion...any other suggestions will be much appreciated. 
Also how do I use an error handler which does print to std::cout ?

Many thanks for your help

Tim

Updated code:

  CPLPushErrorHandler( CPLQuietErrorHandler );
  // Number of points to reproject---------------+
  //                                             | 
  //                                             V    
  int myResult1 = mDestToSourceXForm->Transform( 1, &x1, &y1 );
  int myResult2 = mDestToSourceXForm->Transform( 1, &x2, &y2 );
  CPLPopErrorHandler();

  if ( ! myResult1 || ! myResult2 )
  {
    //something bad happened....
    throw QgsCsException(QString("Coordinate inverse transform failed"));
  }
  else
  { etc ...

Backtrace:

#0  0xffffe410 in ?? ()
(gdb) bt
#0  0xffffe410 in ?? ()
#1  0xbfffdcb8 in ?? ()
#2  0x00000006 in ?? ()
#3  0x4129e529 in abort () from /lib/tls/libc.so.6
#4  0x41223c25 in __cxxabiv1::__terminate () from /usr//lib/libstdc++.so.5
#5  0x41223c62 in std::terminate () from /usr//lib/libstdc++.so.5
#6  0x41223da2 in __cxa_throw () from /usr//lib/libstdc++.so.5
#7  0x08100e80 in QgsCoordinateTransform::inverseTransform (this=Variable 
"this" is not available.
) at qshared.h:50
#8  0x080f8e6a in QgsMapCanvas::render (this=0x83ce620, theQPaintDevice=0x0) 
at memory:271


Std Out dump:

Rect projection...Xmin : -47765.6-->-154.781, Ymin: 741676 -->56.6804Xmax : 
129413-->-151.765, Ymax: 960485 -->58.6227
Transformed extent     -154.780832        56.680383,     -151.764776        
58.622733
Maplayer asked for coordinateTransform which is....valid
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
Rect inverse projection...
INPUT:
PROJCS["Alaska_Albers_Equal_Area_Conic",GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Albers_Conic_Equal_Area"],PARAMETER["False_Easting",0.0],PARAMETER["False_Northing",0.0],PARAMETER["longitude_of_center",-154.0],PARAMETER["Standard_Parallel_1",55.0],PARAMETER["Standard_Parallel_2",65.0],PARAMETER["latitude_of_center",50.0],UNIT["Meter",1.0]]
OUTPUT:
GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 
84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84
[0,0,0,0,0,0,0],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AXIS["Lat",NORTH],AXIS["Long",EAST],AUTHORITY["EPSG","4326"]]
INPUT RECT:
-23155.6,836058:70960.6,907537
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Aborted (core dumped)


-- 

Procrastination 
"Hard Work Often Pays Off After Time, but Laziness Always Pays Off Now." 



More information about the Gdal-dev mailing list