Skip to content

LightOSM Graph fails to construct if Restrictions have empty role field for way or node members #114

@ThatDezKnightGuy

Description

@ThatDezKnightGuy

I was attempting to load an OSM graph using the graph_from_file method for a JSON graph that I had downloaded using the download_osm_network method for a point in Shibuya (https://www.openstreetmap.org/node/291758776).

json_graph = LightOSM.download_osm_network(
    :point,
    metadata=true,
    network_type=:drive,
    download_format=:json,
    point=GeoLocation(35.659482, 139.700572),
    radius=5,
)

When I try to construct the LightOSM graph using this JSON, I get the following:

ERROR:
  exception =
   MethodError: no method matching LightOSM.Restriction{Int64}(; id::Int64, tags::Dict{String, Any}, type::String, is_exclusion::Bool, is_exclusive::Bool, via_node::Int64,
to_way::Int64, from_way::Int64, _way::Int64)

   Closest candidates are:
     LightOSM.Restriction{T}(; id, type, tags, from_way, to_way, via_node, via_way, is_exclusion, is_exclusive) where T got unsupported keyword argument "_way"
      @ LightOSM .../Parameters.jl:491
     LightOSM.Restriction{T}(!Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any, !Matched::Any) where T
got unsupported keyword arguments "id", "tags", "type", "is_exclusion", "is_exclusive", "via_node", "to_way", "from_way", "_way"
      @ LightOSM .../Parameters.jl:503

From my investigation, there are relations (such as https://www.openstreetmap.org/relation/169794) with members that have roles that are blank strings, which are not handled by the constructor as it adds a _way kwarg:

{
  "tags": {
    "restriction": "only_left_turn",
    "type": "restriction"
  },
  "uid": 12272282,
  "id": 169794,
  "changeset": 174629211,
  "members": [
    {
      "role": "via",
      "type": "node",
      "ref": 255367561
    },
    {
      "role": "",
      "type": "way",
      "ref": 23581721
    },
    {
      "role": "",
      "type": "way",
      "ref": 253812428
    },
    {
      "role": "",
      "type": "way",
      "ref": 172358489
    },
    {
      "role": "",
      "type": "way",
      "ref": 172358491
    },
    {
      "role": "from",
      "type": "way",
      "ref": 24487315
    },
    {
      "role": "to",
      "type": "way",
      "ref": 59340772
    }
  ],
  "timestamp": "2025-11-14T01:52:20Z",
  "type": "relation",
  "version": 9,
  "user": "近場行き"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions