On 11/26/2011 06:55 PM, Even Rouault wrote:
Le samedi 26 novembre 2011 14:21:35, Florent JITIAUX a écrit :
Hi,
first thanks for all tools and bidings.
I have a question about Gdalinfo.exe and gdal binding programs.
I have an USRP map but with some fields errors. When i try to load it with
the java Gdalinfo, the open failed (the dataset is null). When i use
gdalinfo.exe to read the map, the error mesage is the same but after
gdalinfo succeeds to identify the driver and get informations about the
map. I found the IdentyDriver method of Gdal class which is able to read
the driver of my map but impossible to find a way to read informations
with the java binding. That's why i say gdalinfo.exe is magic.
That's the same with Gdalbuildvrt. With the java binding it's impossible to
create a vrt because the dataset is null but it works with the .exe.
There's no magic here, but it is true that Java, Python and perhaps other
bindings will return none/null if an error is emitted in the Open() method of
the driver, even if it returned a non-null dataset. There was a rationale for
this. See http://trac.osgeo.org/gdal/changeset/11529 /
http://trac.osgeo.org/gdal/ticket/1635
It seems to me that a datasource can be opened using a datasource
(class) method or driver (object) method. Only the first tests for the
case ds not null and error, but usually the error state is always
checked after a call to GDAL internals in the bindings. The
UseExceptions/DontUseExceptions methods can perhaps be used to change
that (I'm not sure as I always have the UseExceptions on).
Change 11529 did not touch the case when such a dataset is opened with
OGR_Dr_Open. That might still be a bug.
In general I don't think it is a good practice to return a valid pointer
when there is an error, and it seems impossible to get a valid object
when using the bindings in such a case.
Ari
What should be done probably is turn the CE_Failure into a CE_Warning if the
dataset opened by gdalinfo is readable. What is the *exact* error message you
are seing ?
_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
_______________________________________________
gdal-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/gdal-dev