Skip to content

Commit

Permalink
rework OSM map parser to use streaming XML reader
Browse files Browse the repository at this point in the history
  • Loading branch information
breunigs committed Aug 17, 2024
1 parent 8e08ad3 commit 5c275ec
Show file tree
Hide file tree
Showing 5 changed files with 242 additions and 118 deletions.
2 changes: 2 additions & 0 deletions lib/map/node.ex
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ defmodule Map.Node do

@enforce_keys [:lon, :lat]
defstruct [:id, :lon, :lat, :tags]

def get_and_update(node, :tags, fun), do: Map.get_and_update(node, :tags, fun)
end

defimpl Geo.Interpolate, for: Map.Node do
Expand Down
10 changes: 7 additions & 3 deletions lib/map/parsed.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ defmodule Map.Parsed do
@enforce_keys @known_params
defstruct @known_params

@type indexed_nodes :: %{optional(binary()) => Map.Node.t()}
@type indexed_ways :: %{optional(binary()) => [Map.Way.t()]}
@type indexed_relations :: %{optional(binary()) => Map.Relation.t()}

@type t :: %__MODULE__{
ways: %{optional(binary()) => Map.Way.t()},
relations: %{optional(binary()) => Map.Relation.t()},
nodes: %{optional(binary()) => Map.Node.t()}
ways: indexed_ways(),
relations: indexed_relations(),
nodes: indexed_nodes()
}
end
Loading

0 comments on commit 5c275ec

Please sign in to comment.