Skip to content

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

@jetelain

Description

@jetelain

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions