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

If a way or relation has an id attribute, an "Attribute id already exists" exception will throws. #150

Open
jetelain opened this issue Aug 12, 2023 · 1 comment

Comments

@jetelain
Copy link

Steps to reproduce:

Extract OSM data that contains way 4745698 (many other ways have the same issue, it's just an example):

  <way id="4745698">
    ...
    <tag k="area_ha" v="35.7400213134766"/>
    <tag k="farm_name" v="NA"/>
    <tag k="id" v="652"/>
    <tag k="is_in" v="Falkland Islands"/>
    <tag k="latitude" v="-51.307763637"/>
    <tag k="loc_name" v="Rabbit Island (Pebble)"/>
    <tag k="longitude" v="-59.726512313"/>
    <tag k="name" v="Rabbit Island"/>
    <tag k="natural" v="coastline"/>
    <tag k="notes" v="None"/>
    <tag k="oid" v="165.0"/>
    <tag k="place" v="islet"/>
    <tag k="source" v="smallislandsownership"/>
    <tag k="wider_area" v="Pebble Island"/>
  </way>

Read the resulting data with OsmSharp, and use the DefaultFeatureInterpreter to interpret the way.

An exception "Attribute id already exists!" will throws.

System.ArgumentException: Attribute id already exists!
   at NetTopologySuite.Features.AttributesTable.Add(String attributeName, Object attributeValue)
   at OsmSharp.Geo.DefaultFeatureInterpreter.TagsAndIdToAttributes(ICompleteOsmGeo osmObject)
   at OsmSharp.Geo.DefaultFeatureInterpreter.Interpret(ICompleteOsmGeo osmObject)
   at OsmSharp.Geo.FeatureInterpreter.Interpret(OsmGeo osmGeo, ISnapshotDb data)

I dont known the best way to handle this case.

  • I think the best option it to ignore the id tag from the way, and only keep the way id to be backward compatible. The id tag might be shifted to an other name, to be still accessible.
  • An other option would be to change how the id is transformed to tag with a reserved name that would not collide such as $id but this will broke all existing users of DefaultFeatureInterpreter.
@jetelain
Copy link
Author

According to https://taginfo.openstreetmap.org/keys/id#overview 31403 elements have an id tag.

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

1 participant