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
use crate::elevation::request::{
    locations::Locations,
    Request,
};

impl<'a> Request<'a> {

    /// Adds the _sampled path request_ parameters to the Elevation API query.
    ///
    /// ## Arguments:
    ///
    /// * `path` ‧ Defines a path on the earth for which to return elevation
    /// data. This parameter defines a set of two or more ordered
    /// latitude/longitude pairs defining a path along the surface of the earth.
    /// For more information, see [Specifying
    /// Paths](https://developers.google.com/maps/documentation/elevation/intro#Paths).
    ///
    /// * `samples` ‧ Specifies the number of sample points along a path for
    /// which to return elevation data. The samples parameter divides the given
    /// path into an ordered set of equidistant points along the path.
    ///
    /// ## Examples:
    ///
    /// * 2 elevation samples between two points:
    /// ```rust
    /// .for_sampled_path_request(
    ///     ElevationLocations::LatLngs(vec![
    ///         // Denver, Colorado
    ///         LatLng::try_from(dec!(40.714728), dec!(-73.998672))?,
    ///         // Death Valley, California
    ///         LatLng::try_from(dec!(-34.397), dec!(-116.866667))?,
    ///     ]),
    ///     // Number of samples
    ///     2
    /// )
    /// ```
    ///
    /// * 4 elevation samples along a polyline:
    /// ```rust
    /// .for_sampled_path_request(
    ///     ElevationLocations::Polyline(String::from("gfo}EtohhUxD@bAxJmGF")),
    ///     // Number of samples
    ///     4
    /// )
    /// ```

    pub fn for_sampled_path_request(
        &'a mut self,
        path: Locations,
        samples: u8
    ) -> &'a mut Request {
        // Set the path in Request struct.
        self.path = Some(path);
        // Set the sample number in Request struct.
        self.samples = Some(samples);
        // Return modified Request struct to caller.
        self
    } // fn

} // impl