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

Chapman, Martin MChapman at sanz.com
Wed May 12 12:54:13 EDT 2004


Frank,

Thanks for the quick answer.  I just replied to my own question saying
that I found the error.  It was in my code (as usual).  I was passing in
the x,y points as y,x... so the filter does work.  You are correct that
the orange box is my aoi rectangle.  

I did notice what you mentioned below about using the MBR of the
feature.  I know how to write the intersection functions needed to
filter n-gons, do you think it would be difficult to modify the
ExecuteSQL to use the geometry instead of the MBR for the filtering?  If
you don't think that would be hard, what source code file would I make
the mod in?  Or, has someone done that already?

Thanks,
Martin 

-----Original Message-----
From: Frank Warmerdam [mailto:warmerdam at pobox.com] 
Sent: Wednesday, May 12, 2004 10:28 AM
To: gdal-dev at remotesensing.org
Subject: Re: [Gdal-dev] OGRDataSource::ExecuteSQL() method returning
inaccurate results


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

_______________________________________________
Gdal-dev mailing list
Gdal-dev at remotesensing.org
http://remotesensing.org/mailman/listinfo/gdal-dev



More information about the Gdal-dev mailing list