@@ -5,6 +5,23 @@ pub trait InterpolatePoint<F: CoordFloat> {
5
5
/// Returns a new Point along a line between two existing points.
6
6
///
7
7
/// See [specific implementations](#implementors) for details.
8
+ ///
9
+ /// # Examples
10
+ ///
11
+ /// ```
12
+ /// # use approx::assert_relative_eq;
13
+ /// use geo::{Haversine, Euclidean, InterpolatePoint, Point};
14
+ ///
15
+ /// let p1: Point = Point::new(0.0, 0.0);
16
+ /// let p2: Point = Point::new(0.0, 2.0);
17
+ ///
18
+ /// assert_relative_eq!(Euclidean::point_at_distance_between(p1, p2, 0.5), Point::new(0.0, 0.5));
19
+ ///
20
+ /// // The units of the argument depend on the metric space.
21
+ /// // In the case of [`Haversine`], it's meters.
22
+ /// // See the documentation for each metric space for details.
23
+ /// assert_relative_eq!(Haversine::point_at_distance_between(p1, p2, 111_111.0), Point::new(0.0, 0.9992438493379715));
24
+ /// ```
8
25
fn point_at_distance_between (
9
26
start : Point < F > ,
10
27
end : Point < F > ,
@@ -14,6 +31,18 @@ pub trait InterpolatePoint<F: CoordFloat> {
14
31
/// Returns a new Point along a line between two existing points.
15
32
///
16
33
/// See [specific implementations](#implementors) for details.
34
+ ///
35
+ /// # Examples
36
+ ///
37
+ /// ```
38
+ /// # use approx::assert_relative_eq;
39
+ /// use geo::{Haversine, Euclidean, InterpolatePoint, Point};
40
+ /// let p1: Point = Point::new(0.0, 0.0);
41
+ /// let p2: Point = Point::new(20.0, 20.0);
42
+ ///
43
+ /// assert_relative_eq!(Euclidean::point_at_ratio_between(p1, p2, 0.5), Point::new(10.0, 10.0));
44
+ /// assert_relative_eq!(Haversine::point_at_ratio_between(p1, p2, 0.5), Point::new(9.685895184381804, 10.150932342575631));
45
+ /// ```
17
46
fn point_at_ratio_between ( start : Point < F > , end : Point < F > , ratio_from_start : F ) -> Point < F > ;
18
47
19
48
/// Interpolates `Point`s along a line between `start` and `end`.
@@ -25,6 +54,26 @@ pub trait InterpolatePoint<F: CoordFloat> {
25
54
/// `max_distance`, no additional points will be included in the output.
26
55
///
27
56
/// `include_ends`: Should the start and end points be included in the output?
57
+ ///
58
+ /// # Examples
59
+ ///
60
+ /// ```
61
+ /// # use approx::assert_relative_eq;
62
+ /// use geo::{Haversine, Euclidean, InterpolatePoint, Point, MultiPoint, LineString, wkt};
63
+ /// let p1: Point = Point::new(0.0, 0.0);
64
+ /// let p2: Point = Point::new(0.0, 2.0);
65
+ ///
66
+ /// let intermediate_points: Vec<Point> = Euclidean::points_along_line(p1, p2, 0.5, false).collect();
67
+ /// let multi_point = MultiPoint(intermediate_points);
68
+ /// assert_relative_eq!(multi_point, wkt!(MULTIPOINT(0. 0.5,0. 1.,0. 1.5)));
69
+ ///
70
+ /// // The units of the argument depend on the metric space.
71
+ /// // In the case of [`Haversine`], it's meters.
72
+ /// // See the documentation for each metric space for details.
73
+ /// let intermediate_points: Vec<Point> = Haversine::points_along_line(p1, p2, 55_555.0, false).collect();
74
+ /// let multi_point = MultiPoint(intermediate_points);
75
+ /// assert_relative_eq!(multi_point, wkt!(MULTIPOINT(0. 0.4,0. 0.8,0. 1.2,0. 1.6)));
76
+ /// ```
28
77
fn points_along_line (
29
78
start : Point < F > ,
30
79
end : Point < F > ,
0 commit comments