Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#2498 closed defect (fixed)

OGRSpatialReference::Validate does not return correct error code in Python

Reported by: Mateusz Łoskot Owned by: Mateusz Łoskot
Priority: normal Milestone: 1.6.0
Component: OGR_SRS Version: svn-trunk
Severity: normal Keywords: python validate
Cc: hobu

Description (last modified by Mateusz Łoskot)

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.

Simple test:

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.

Attachments (1)

testing-osr-validate-with-python.patch (547 bytes) - added by Mateusz Łoskot 12 years ago.
Patch used to test and confirm that Python bindings of OGRSpatialReference::Validate function always return Zero, even if original implementation returns different error code

Download all attachments as: .zip

Change History (8)

Changed 12 years ago by Mateusz Łoskot

Patch used to test and confirm that Python bindings of OGRSpatialReference::Validate function always return Zero, even if original implementation returns different error code

comment:1 Changed 12 years ago by Mateusz Łoskot

Description: modified (diff)

comment:2 Changed 12 years ago by Mateusz Łoskot

Description: modified (diff)

comment:3 Changed 12 years ago by warmerdam

Cc: hobu added

The definition from osr.i seems straight forward. I wonder if this relates to special OGRErr handling rules? Adding hobu.

OGRErr Validate() {
    return OSRValidate(self);
  }

comment:4 Changed 12 years ago by Mateusz Łoskot

Owner: changed from warmerdam to hobu

comment:5 Changed 12 years ago by Mateusz Łoskot

Owner: changed from hobu to Mateusz Łoskot
Status: newassigned

comment:6 Changed 12 years ago by Mateusz Łoskot

Resolution: fixed
Status: assignedclosed

Howard has fixed this problem in trunk (r15011, r15020). I confirm the fix works so closing this ticket.

comment:7 Changed 12 years ago by Mateusz Łoskot

Milestone: 1.6.0
Note: See TracTickets for help on using tickets.