[gdal-dev] Accuracy of OGRLayer:SetSpatialFilter() API

Frank Warmerdam warmerdam at pobox.com
Mon Jun 11 17:13:58 PDT 2012


On Mon, Jun 11, 2012 at 4:48 PM, kedardeshpande87
<kedardeshpande87 at gmail.com> wrote:
>
> Frank Warmerdam wrote
>>
>> There is no externally defined ordering, though the implementation in
>> each driver will presumably have some implicit ordering.
>>
> I am reading a TIGER shapefile provided by US Census Bureau:
> ...
> ogr.RegisterAll();
> DataSource ds = ogr.open("path/to/shapefil");
> if(ds == null) {
>      System.out.println("open failed");
>      System.exit(1);
> }
> ....
> So, when I call ds.getDriver().getName(), it gives me "ESRI Shapefile".
> For this driver, looks like the implementation is in the ogrshapelayer.cpp
> file.
> I went through the implementation of GetNetxtFeature(geometry) function, it
> keeps looping over as long as features matching the criteria are found. From
> the implementation, the order is not quite obvious to figure out. If
> possible, can you please elaborate on this more (for ESRI Shapefile driver
> implementation)?

Kedar,

I believe if there is a spatial index it will return them in spatial
index traversal order.  If not they will be returned ordered by
shapeid.  I could be wrong about the spatial index though - even in
that case it might return them ordered by shapeid, I'm not sure.

> In my application, I want to retrieve a single feature which matches the
> criteria the closest.

Then you will need to compute this as some sort of post process.

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 Software Developer


More information about the gdal-dev mailing list