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
//! [`Ring`] adapter for `geo_types::LineString<T>`.
//!
//! Mirrors `boost/geometry/geometries/adapted/` (the *pattern*; Boost
//! has no `geo-types` analogue). `geo-types` has no separate `Ring`
//! type — a ring is spelled as a `LineString` that the caller keeps
//! closed and correctly oriented (the OGC `LinearRing` convention, see
//! `geo_types::LineString`'s own docs). This wrapper therefore adapts a
//! `geo_types::LineString<T>` to the [`Ring`] concept, and inherits the
//! concept's Boost-matching defaults `closure() = Closed`,
//! `point_order() = Clockwise`. **The caller asserts closure and
//! orientation** — this wrapper does not validate or re-wind the ring.
//!
//! As with [`GeoLineString`](crate::GeoLineString), the vertices are
//! stored as [`GeoCoord`] wrappers so `points()` can yield
//! `&GeoCoord<T>` under `#![forbid(unsafe_code)]`.
use Vec;
use ;
use CoordinateScalar;
use RingTag;
use ;
use crateGeoCoord;
/// Shape-only adapter presenting a `geo_types::LineString<T>` as a
/// [`Ring`].
///
/// `geo-types` does not distinguish rings from line strings; the
/// caller is responsible for supplying a closed, correctly-oriented
/// ring. Inherits the concept defaults `closure() = Closed`,
/// `point_order() = Clockwise`.
///
/// **Winding caveat.** This default is `Clockwise` (Boost's convention),
/// but `geo-types`' own convention winds an exterior ring
/// *counter-clockwise*. The wrapper does not re-wind, so a `geo-types`-
/// native ring reaches signed-area functions (`ring_area`, `area`) with
/// the opposite sign — a CCW exterior yields a *negative* area here.
/// Orientation-independent queries (`within`, `centroid`, `envelope`,
/// `perimeter`) are unaffected. Re-wind with `geometry_algorithm::correct`
/// (or geo-types' own `orient`) first if you need Boost's sign.
///
/// # Examples
///
/// ```
/// use geo_types::LineString;
/// use geometry_adapt_geo_types::GeoRing;
/// use geometry_algorithm::ring_area;
///
/// // Vertices matching the ring's declared clockwise order give a
/// // positive signed area of 1 for a unit square.
/// let ring = GeoRing::new(LineString::from(vec![
/// (0.0_f64, 0.0), (0.0, 1.0), (1.0, 1.0), (1.0, 0.0), (0.0, 0.0),
/// ]));
/// assert_eq!(ring_area(&ring), 1.0);
/// ```
;