QueryEngine

Struct QueryEngine 

Source
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

Source

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.

Source

pub fn url(&self) -> &str

Getter for the base URL that the QueryEngine uses.

Source

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());
Source

pub fn filters(&self) -> &Vec<String>

Getter for the default way filters used in queries.

Source

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")]);
Source

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.

Source

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

Source

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!

Source

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

Source

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.

Source

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

Source§

fn clone(&self) -> QueryEngine

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for QueryEngine

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for QueryEngine

Source§

fn default() -> QueryEngine

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more