[Gdal-dev] Error propagation from GDAL.Dataset.GetGeoTransform() in C#

Frank Warmerdam warmerdam at pobox.com
Tue Nov 18 10:58:51 EST 2008


yonil wrote:
> I'm trying to use the following code to detect a possible error caused 
> by the GetGeoTransform() call, but it reports no error has occurred, and
> does not raise an exception.
> 
> Making this call on the same dataset from native C code returns 
> CE_Failure from GDALGetGeoTransform().
> 
> Here's the C# snippet:
> 
> _dataset.GetGeoTransform(temp); // returns normally with default values
> OSGeo.GDAL.CPLErr err = Gdal.GetLastErrorType();
> if (OSGeo.GDAL.CPLErr.CE_None != err)
> {
>      throw new ApplicationException("GetGeoTransform() failed.");
> }
> 
> Am I doing anything wrong, or is it somehow a problem with the C# 
> bindings? I've built the C# bindings from the GDAL v1.5.3 release, 
> running on Win32.

Yonil,

There are some places in the GDAL code that return CE_Failure without
issuing an error via CPLError().  I presume you were expecting
GetLastErrorType() to return something other than CE_None if GetGeoTransform()
returned an error?

If you can provide details of the driver being used I may be able to correct
the code to issue a CPLError before returning CE_Failure but this is a
problem that is fairly widespread in the code.

PS. Doesn't the C# GetGeoTransform() method return the error indicator?

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent



More information about the gdal-dev mailing list