Ticket #2498 (closed defect: fixed)
OGRSpatialReference::Validate does not return correct error code in Python
|Reported by:||mloskot||Owned by:||mloskot|
Description (last modified by mloskot) (diff)
I'm trying to use the Validate method of osgeo.osr.SpatialReference? class but I'm experiencing strange problem. Regardless of what WKT is validated - valid or invalid - the Validate() function always returns Zero.
wkt = ... # invalid WKT srs = osr.SpatialReference() srs.ImportFromWkt(wkt) print srs.Validate() # always returns Zero
To be 100% of that, I patched the C++ implementation of OGRSpatialReference::Validate to always return OGRERR_CORRUPT_DATA (integer value 5), regardless of WKT being validated.
Testing the patched GDAL has confirmed that Zero is returned, always:
mloskot@vm-ubuntu704ora:~/dev/gdal/bugs/1183$ python Python 2.5.1 (r251:54863, Mar 7 2008, 03:41:45) [GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import osgeo.osr as osr >>> srs = osr.SpatialReference() >>> srs.ImportFromWkt("xxx") 0 >>> srs.Validate() OSR: XXX 0 >>>
Here, xxx can be ie. Oracle WKT of correct format but unrecognized nodes/values, etc.