Error when trying to skip an object in translation
iandees opened this issue · 3 comments
iandees commented
The convention is to return None
when you want your translation to skip an object. That seems to cause an error in 9c4b6ea:
Merging points
Making list
Checking list
Merging duplicate points in ways
Outputting XML
Traceback (most recent call last):
File "ogr2osm.py", line 616, in <module>
output()
File "ogr2osm.py", line 563, in output
for (key, value) in featuresmap[node].tags.items():
AttributeError: 'NoneType' object has no attribute 'items'
iandees commented
Using this translation to transform this data.
pnorman commented
The convention isn't for skipping objects, but skipping untagged objects, but thinking about it, that's not what's actually being done.
I suspect it's a carryover from svn ogr2osm and we can safely use return None to drop an object, finally giving us a way to drop objects from within filterTags
iandees commented
Adding this method:
def filterFeature(ogrfeature, fieldNames, reproject):
AddressLab = None
index = ogrfeature.GetFieldIndex('AddressLab')
if index >= 0:
AddressLab = ogrfeature.GetField(index)
if not AddressLab:
return None
return ogrfeature
...keeps it from crashing.