pub struct Openstreetmap { /* private fields */ }Expand description
An instance of the Openstreetmap geocoding service
Implementations§
Source§impl Openstreetmap
impl Openstreetmap
Sourcepub fn new_with_endpoint(endpoint: String) -> Self
pub fn new_with_endpoint(endpoint: String) -> Self
Create a new Openstreetmap geocoding instance with a custom endpoint.
Endpoint should include a trailing slash (i.e. “https://nominatim.openstreetmap.org/”)
Sourcepub async fn forward_full<T>(
&self,
params: &OpenstreetmapParams<'_, T>,
) -> Result<OpenstreetmapResponse<T>, GeocodingError>
pub async fn forward_full<T>( &self, params: &OpenstreetmapParams<'_, T>, ) -> Result<OpenstreetmapResponse<T>, GeocodingError>
A forward-geocoding lookup of an address, returning a full detailed response
Accepts an OpenstreetmapParams struct for specifying
options, including whether to include address details in the response and whether to filter
by a bounding box.
Please see the documentation for details.
This method passes the format parameter to the API.
§Examples
use geocoding::{Openstreetmap, InputBounds, Point};
use geocoding::openstreetmap::{OpenstreetmapParams, OpenstreetmapResponse};
#[tokio::main]
async fn main() {
let osm = Openstreetmap::new();
let viewbox = InputBounds::new(
(-0.13806939125061035, 51.51989264641164),
(-0.13427138328552246, 51.52319711775629),
);
let params = OpenstreetmapParams::new(&"UCL Centre for Advanced Spatial Analysis")
.with_addressdetails(true)
.with_viewbox(&viewbox)
.build();
let res: OpenstreetmapResponse<f64> = osm.forward_full(¶ms).await.unwrap();
let result = res.features[0].properties.clone();
assert!(result.display_name.contains("Tottenham Court Road"));
}Trait Implementations§
Source§impl Default for Openstreetmap
impl Default for Openstreetmap
Source§impl<T> Forward<T> for Openstreetmap
impl<T> Forward<T> for Openstreetmap
Source§fn forward<'life0, 'life1, 'async_trait>(
&'life0 self,
place: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Point<T>>, GeocodingError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn forward<'life0, 'life1, 'async_trait>(
&'life0 self,
place: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Vec<Point<T>>, GeocodingError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
A forward-geocoding lookup of an address. Please see the documentation for details.
This method passes the format parameter to the API.
Source§impl<T> Reverse<T> for Openstreetmap
impl<T> Reverse<T> for Openstreetmap
Source§fn reverse<'life0, 'life1, 'async_trait>(
&'life0 self,
point: &'life1 Point<T>,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, GeocodingError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn reverse<'life0, 'life1, 'async_trait>(
&'life0 self,
point: &'life1 Point<T>,
) -> Pin<Box<dyn Future<Output = Result<Option<String>, GeocodingError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
A reverse lookup of a point. More detail on the format of the
returned String can be found here
This method passes the format parameter to the API.