Bug report #20098

getFeatures() can't be run twice on an OSM file

Added by Etienne Trimaille almost 6 years ago. Updated almost 6 years ago.

Status:Closed
Priority:Normal
Assignee:Even Rouault
Category:Data Provider/OGR
Affected QGIS version:3.3(master) Regression?:Yes
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:27920

Description

Since this commit https://github.com/qgis/QGIS/commit/f410b4a4da07463a25786045b107282dffabf1bd, the python iterator getFeatures() can't be run twice on an OSM file:

l = QgsVectorLayer('/tmp/request-jY9056.osm|layername=multipolygons', "test", "ogr")
print('first loop')
for f in l.getFeatures():
    print(f.id())

print('second loop')

for f in l.getFeatures():
    print(f.id())

print('end loops')

It gives:

exec(open('/home/etienne/quickosm.py'.encode('utf-8')).read())
first loop
65738329
65739173
65744728
65759782
second loop
end loops

It was working fine the commit before.

This breaks the QuickOSM plugin: https://github.com/3liz/QuickOSM/issues/125

Thanks

request-jY9056.osm (6.43 KB) Etienne Trimaille, 2018-10-13 02:29 AM

Associated revisions

Revision 906f8021
Added by Even Rouault almost 6 years ago

[OGR provider] Make again a feature iterator to be resetable on a OSM layer (fixes #20098)

Revision b777ab23
Added by Even Rouault almost 6 years ago

Merge pull request #8184 from rouault/fix_20098

[OGR provider] Make again a feature iterator to be resetable on a OSM layer (fixes #20098)

History

#1 Updated by Etienne Trimaille almost 6 years ago

Using GDAL/OGR 2.2.3 on Ubuntu 18.04

#2 Updated by Even Rouault almost 6 years ago

  • Assignee set to Even Rouault

#4 Updated by Even Rouault almost 6 years ago

  • % Done changed from 0 to 100
  • Status changed from Open to Closed

Also available in: Atom PDF