pub struct QueryEngine { /* private fields */ }Expand description
QueryEngine is a structure that helps create queries to the Overpass API. It allows us to make lower level API calls (with the Overpass QL) as well as some higher level API calls such as just fetching a place of interest or a polygon of interest.
Implementations§
Source§impl QueryEngine
impl QueryEngine
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new instance of the query engine with the base url set to:
https://overpass-api.de/api/interpreter
QueryEngine also has a default set of filters for ways. The filter is currently set to only fetch roads that can be driven on with a car. However, you might be interested in footpaths, railroads, etc. If you would like to change the filter, take a look at https://wiki.openstreetmap.org/wiki/Key:highway for more information on the options available.
Note that these filters are only applied when using higher level api calls such as
Self::query_place. The lowest level api call, Self::query directly sends your query to the api
without any modification.
Sourcepub fn with_url(&self, new_url: String) -> Self
pub fn with_url(&self, new_url: String) -> Self
Set a new url to query. Meant to be used in a functional style
use osmgraph::api::QueryEngine;
let engine = QueryEngine::new()
.with_url("www.url_example.com".to_string());Sourcepub fn with_filters(&self, new_filters: Vec<String>) -> Self
pub fn with_filters(&self, new_filters: Vec<String>) -> Self
Set new way filters in queries. Meant to be used in a functional style
use osmgraph::api::QueryEngine;
let engine = QueryEngine::new()
.with_filters(vec![String::from("motorway")]);Sourcepub async fn query_place(
&self,
area_name: String,
admin_level: Option<usize>,
) -> Result<String, Error>
pub async fn query_place( &self, area_name: String, admin_level: Option<usize>, ) -> Result<String, Error>
Given an area name, like “Manhattan” or “Germany”, and an admin level, return the nodes and ways for that specific area.
Admin level is a number that represents the scope of area you are interested in. In general: admin_level=2: Usually represents countries admin_level=4: Often represents states, provinces, or regions admin_level=6: May represent counties or districts admin_level=8: Often represents municipalities, cities, or towns admin_level=10: May represent neighborhoods or suburbs
If you don’t want to worry about admin levels, it is not required but will generally improve the results of your query.
Sourcepub fn query_place_blocking(
&self,
area_name: String,
admin_level: Option<usize>,
) -> Result<String, Error>
pub fn query_place_blocking( &self, area_name: String, admin_level: Option<usize>, ) -> Result<String, Error>
This function does the same thing as Self::query_place but waits for the request to complete
Sourcepub async fn query_poly(
&self,
polygon: Vec<(f64, f64)>,
) -> Result<String, Error>
pub async fn query_poly( &self, polygon: Vec<(f64, f64)>, ) -> Result<String, Error>
Given a closed polygon, return all of the nodes and ways within that polygon.
Note: the first and last element of the vector must be the same!
Sourcepub fn query_poly_blocking(
&self,
polygon: Vec<(f64, f64)>,
) -> Result<String, Error>
pub fn query_poly_blocking( &self, polygon: Vec<(f64, f64)>, ) -> Result<String, Error>
This function does the same thing as Self::query_poly but waits for the request to complete
Sourcepub async fn query(&self, query: String) -> Result<String, Error>
pub async fn query(&self, query: String) -> Result<String, Error>
Requests data from the Overpass API given a particular query. The query must conform to the Overpass Query Language.
Sourcepub fn query_blocking(&self, query: String) -> Result<String, Error>
pub fn query_blocking(&self, query: String) -> Result<String, Error>
Behaves the same as Self::query, but will wait for the function to finish before continuing.
Trait Implementations§
Source§impl Clone for QueryEngine
impl Clone for QueryEngine
Source§fn clone(&self) -> QueryEngine
fn clone(&self) -> QueryEngine
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more