A Elixir wrapper to access the Overpass API.
Have a look at the documentation to find additional information.
Based on https://github.com/DinoTools/python-overpy http://python-overpy.readthedocs.org/
- Query Overpass API
- Parse JSON and XML response data
- Additional helper functions
As available in Hex, the package can be installed as:
-
Add overpass to your list of dependencies in
mix.exs
:def deps do [{:overpass, "~> 0.1.0"}] end
-
Ensure overpass is started before your application:
def application do [applications: [:overpass]] end
-
Add the Overpass API URL to your config in
config/config.exs
:config :overpass, url: "http://overpass-api.de/api/interpreter"
Using QL:
{:ok, {:xml, response}} = Overpass.API.query("""
node["name"="Gielgen"];
out body;
""")
{:ok, {:json, response}} = Overpass.API.query("""
[out:json];
node["name"="Gielgen"];
out body;
""")
Using XML:
{:ok, {:xml, response}} = Overpass.API.query("""
<osm-script>
<query type="node">
<has-kv k="name" v="Gielgen"/>
</query>
<print/>
</osm-script>
""")
{:ok, {:json, response}} = Overpass.API.query("""
<osm-script output="json">
<query type="node">
<has-kv k="name" v="Gielgen"/>
</query>
<print/>
</osm-script>
""")
{:ok, %Overpass.Response{nodes: nodes, ways: ways, relations: relations}} = Overpass.API.query("""
(
node
["amenity"="fire_station"]
(50.6,7.0,50.8,7.3);
way
["amenity"="fire_station"]
(50.6,7.0,50.8,7.3);
rel
["amenity"="fire_station"]
(50.6,7.0,50.8,7.3);
);
(._;>;);
out;
""") |> Overpass.Parser.parse()
{:ok, %Overpass.Response{nodes: nodes, ways: ways, relations: _relations}} = Overpass.API.query("""
(
node
["amenity"="fire_station"]
(50.6,7.0,50.8,7.3);
way
["amenity"="fire_station"]
(50.6,7.0,50.8,7.3);
rel
["amenity"="fire_station"]
(50.6,7.0,50.8,7.3);
);
(._;>;);
out;
""") |> Overpass.Parser.parse()
# Get nodes for the way from the responded nodes
list_with_nodes = Overpass.Way.get_nodes(nodes, List.first(ways))
# Get all nodes for the way (new Overpass.Query)
list_with_nodes = Overpass.Way.get_nodes(nodes, List.first(ways), true)
TODO
The MIT License (MIT)