1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
use crate::elevation::Locations;
use crate::types::LatLng;
// -----------------------------------------------------------------------------
impl crate::elevation::Request<'_> {
/// Adds the _positional request_ parameter to the Elevation API query.
///
/// ## Arguments
///
/// * `location` ‧ Defines the location on the earth from which to
/// return elevation data. This parameter takes a single `LatLng`
/// coordinate.
///
/// ## Example
///
/// ```rust
/// // Denver, Colorado, the "Mile High City"
/// .for_positional_request(LatLng::try_from_dec(dec!(39.7391536), dec!(-104.9847034))?)
/// ```
#[must_use] pub fn for_positional_request(
mut self,
location: impl Into<LatLng>
) -> Self {
let location: LatLng = location.into();
// Set the path in Request struct.
self.locations = Some(Locations::LatLngs(vec![location]));
// Return modified Request struct to caller.
self
} // fn
/// Adds a single _positional request_ parameter to the Elevation API query.
///
/// ## Arguments
///
/// * `locations` ‧ Defines the location(s) on the earth from which to
/// return elevation data. This parameter takes either a single location,
/// as a latitude/longitude pair, multiple latitude/longitude pairs, or an
/// encoded polyline. For more information, see [Specifying
/// Locations](https://developers.google.com/maps/documentation/elevation/intro#Locations).
///
/// ## Example
///
/// ```rust
/// .for_positional_requests(ElevationLocations::LatLngs(vec![
/// // Denver, Colorado, the "Mile High City"
/// LatLng::try_from_dec(dec!(39.7391536), dec!(-104.9847034))?,
/// // Death Valley
/// LatLng::try_from_dec(dec!(36.23998), dec!(-116.83171))?,
/// ]))
/// ```
///
/// See also: the Google Encoded Polyline encoding & decoding crate called
/// [polyline](https://crates.io/crates/polyline).
#[must_use] pub fn for_positional_requests(
mut self,
locations: impl Into<Locations>
) -> Self {
let locations: Locations = locations.into();
// Set the path in Request struct.
self.locations = Some(locations);
// Return modified Request struct to caller.
self
} // fn
/// Adds the _positional request_ parameter to the Elevation API query.
///
/// This function is the same as `for_positional_request` but it supports
/// the [geo](https://crates.io/crates/geo) crate's
/// [Coord](https://docs.rs/geo/latest/geo/geometry/struct.Coord.html) type.
///
/// ## Arguments
///
/// * `coordinate` ‧ Defines the location on the earth from which to
/// return elevation data. This parameter takes a single `Coord`.
#[cfg(feature = "geo")]
#[deprecated(since = "3.5.1", note =
"you may now use geo types directly with the google_maps crate. \
the geo-specific methods are no longer necessary. \
it's suggested to use the `for_positional_request` method instead"
)]
pub fn for_coordinate_request(
mut self,
coordinate: &geo_types::Coord
) -> Result<Self, crate::error::Error> {
// Set the path in Request struct.
self.locations = Some(Locations::LatLngs(vec![LatLng::try_from(coordinate)?]));
// Return modified Request struct to caller.
Ok(self)
} // fn
/// Adds the _positional request_ parameter to the Elevation API query.
///
/// This function is the same as `for_positional_request` but it supports
/// the [geo](https://crates.io/crates/geo) crate's
/// [Point](https://docs.rs/geo/latest/geo/geometry/struct.Point.html) type.
///
/// ## Arguments
///
/// * `point` ‧ Defines the location on the earth from which to return
/// elevation data. This parameter takes a single `Point`.
#[cfg(feature = "geo")]
#[deprecated(since = "3.5.1", note =
"you may now use geo types directly with the google_maps crate. \
the geo-specific methods are no longer necessary. \
it's suggested to use the `for_positional_request` method instead"
)]
pub fn try_point_request(
mut self,
point: &geo_types::Point
) -> Result<Self, crate::error::Error> {
// Set the path in Request struct.
self.locations = Some(Locations::LatLngs(vec![LatLng::try_from(point)?]));
// Return modified Request struct to caller.
Ok(self)
} // fn
} // impl