#osm #query #server #json #query-response #node #overpass

osm_overpass

A library to run Overpass queries against OSM Overpass servers

3 releases

0.1.2 Jul 16, 2024
0.1.1 Jul 16, 2024
0.1.0 Jul 16, 2024

#102 in Geospatial

21 downloads per month

MIT license

17KB
230 lines

OSM Overpass

A library to query OSM Overpass servers

Example

Async example

let url = String::from("https://overpass-api.de/api/interpreter");
let query = "
[out:json][timeout:30];
node(3662847634);
// print results
out;
";
let api = api::OverpassAPI::new(url);
let res = api.query(String::from(query)).await;
...

Sync example

...
let res = api.query_sync(String::from(query));

Using query response

...
let unwrapped = res.unwrap();
//unwrapped is iterable, so
for nwr in unwrapped {
    match nwr {
        NWR::Node(n) => ...,
        NWR::Way(w) => ...,  
        NWR::Relation(r) => ...      
    }
}

Notes

Queries must return a JSON result. Put [out:json] in the first line of the query to do this.


lib.rs:

OSM Overpass

A library to query OSM Overpass servers

Example

Async example

let url = String::from("https://overpass-api.de/api/interpreter");
let query = "
[out:json][timeout:30];
node(3662847634);
// print results
out;
";
let api = api::OverpassAPI::new(url);
let res = api.query(String::from(query)).await;
...

Sync example

...
let res = api.query_sync(String::from(query));

Using query response

...
let unwrapped = res.unwrap();
//unwrapped is iterable, so
for nwr in unwrapped {
    match nwr {
        NWR::Node(n) => ...,
        NWR::Way(w) => ...,  
        NWR::Relation(r) => ...      
    }
}

Notes

Queries must return a JSON result. Put [out:json] in the first line of the query to do this.

Dependencies

~4–14MB
~193K SLoC