[Gdal-dev] OGRDataSource::ExecuteSQL() method returning inaccurate results

Frank Warmerdam warmerdam at pobox.com
Wed May 12 12:27:40 EDT 2004


Chapman, Martin wrote:
> I am using the OGRDataSource::ExecuteSQL() method to spatially filter a 
> esri shape file.  The results are inaccurate in that they return 
> features that do not intersect the filter.  Is this a known issue or 
> does it look like an error in my code?  I am using GDAL 119.  The 
> attached screen shot shows the spatial filter results and my code is 
> listed below:

Martin,

Your code looks ok, but it is hard for me to say.  In general what happens
is that OGR compares the MBR of a feature geometry against the MBR of the
spatial filter geometry.  If those MBRs overlap it returns the feature.

I assume the orange rectangle in the display was your query rectangle, and
the green states were returned?  To the left and above it seems to be
doing the right thing, but to the right and down there are problems.  It is
almost as if the bottom right corner of the internal MBR was +inf.

Can you reproduce the error with ogrinfo and it's -spat argument?  If so,
it should be easy for me to track down and fix.

A few other things to keep in mind.
  o While spatial filtering is currently MBR based, at some point it might
    do real intersection checks so using a propery polygon (as you do) is
    a good idea.
  o The spatial filtering logic is unaware of coordinate system issues,
    so make sure your spatial filter is in the same coordinate syste as the
    geometries of the layer which I assume is the case in this case.

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