Struct geocoding::opencage::Opencage [] [src]

pub struct Opencage { /* fields omitted */ }

An instance of the Opencage Geocoding service

Methods

impl Opencage
[src]

[src]

Create a new OpenCage geocoding instance

[src]

Retrieve the remaining API calls in your daily quota

Initially, this value is None. Any OpenCage API call using a "Free Tier" key will update this value to reflect the remaining quota for the API key. See the API docs for details.

[src]

A reverse lookup of a point, returning an annotated response.

This method passes the no_record parameter to the API.

 use geocoding::{Opencage, Point};

 let oc = Opencage::new("dcdbf0d783374909b3debee728c7cc10".to_string());
 let p = Point::new(2.12870, 41.40139);
 // a full `OpencageResponse` struct
 let res = oc.reverse_full(&p).unwrap();
 // responses may include multiple results
 let first_result = &res.results[0];
 assert_eq!(
     first_result.components["road"],
     "Carrer de Calatrava"
 );

[src]

A forward-geocoding lookup of an address, returning an annotated response.

You may restrict the search space by passing an optional bounding box to search within. Please see the documentation for details of best practices in order to obtain good-quality results.

This method passes the no_record parameter to the API.

 use geocoding::{Opencage, Point};
 use geocoding::opencage::InputBounds;

 let oc = Opencage::new("dcdbf0d783374909b3debee728c7cc10".to_string());
 let address = "UCL CASA";
 // restrict the search space. An `into()` conversion exists for `Point` tuples
 let bbox = (
     Point::new(-0.13806939125061035, 51.51989264641164),
     Point::new(-0.13427138328552246, 51.52319711775629),
 );
 let res = oc.forward_full(&address, &Some(bbox.into())).unwrap();
 let first_result = &res.results[0];
 // the first result is correct
 assert_eq!(first_result.formatted, "UCL, 188 Tottenham Court Road, London WC1E 6BT, United Kingdom");

Trait Implementations

impl<T> Reverse<T> for Opencage where
    T: Float,
    T: Deserialize<'de>, 
[src]

[src]

A reverse lookup of a point. More detail on the format of the returned String can be found here

This method passes the no_annotations and no_record parameters to the API.

impl<T> Forward<T> for Opencage where
    T: Float,
    T: Deserialize<'de>, 
[src]

[src]

A forward-geocoding lookup of an address. Please see the documentation for details of best practices in order to obtain good-quality results.

This method passes the no_annotations and no_record parameters to the API.

Auto Trait Implementations

impl Send for Opencage

impl Sync for Opencage