> As you can see the second time I set an attribute filter in the loop it > returns all 341 features on the layer, not only the 321 that match the > filter. In all other cases it seems to work fine. > > Did I go something wrong with in my code? Do I need to call some other > commands maybe before I apply the SetAttributeFilter?
Arno, I've managed to reproduce your issue and I've understood what happens. This is due to a performance optimization done in the OSM driver to avoid useless ResetReading() to discard already cached features. I've pushed into GDAL trunk a fix for that issue. There are 2 workarounds : * the recommanded one is to set attribute filters on all needed layers before starting iterating over any of them. Indeed, when you read a OSM file it will collect features for all layers, so while collecting points, it might also collect lines and apply the attribute filter that was currently set on that layer. If you apply another one afterwards, it is too late. * a simple one, but potentially less efficient in terms of performance : just insert a call to lay.GetNextFeature() between lay.SetAttributeFilter("highway IS NOT NULL") and lay.ResetReading(). This will cause the ResetReading() to effectively ResetReading(). Even -- Geospatial professional services http://even.rouault.free.fr/services.html _______________________________________________ gdal-dev mailing list gdal-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/gdal-dev