Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when trying to skip an object in translation #24

Open
Tracked by #3
iandees opened this issue Oct 24, 2013 · 3 comments
Open
Tracked by #3

Error when trying to skip an object in translation #24

iandees opened this issue Oct 24, 2013 · 3 comments

Comments

@iandees
Copy link

iandees commented Oct 24, 2013

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
Copy link
Author

iandees commented Oct 24, 2013

Using this translation to transform this data.

@pnorman
Copy link
Owner

pnorman commented Oct 24, 2013

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
Copy link
Author

iandees commented Oct 24, 2013

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants