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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//! # Pluggable algorithm strategies, keyed by coordinate-system family.
//!
//! Mirrors `boost/geometry/strategies/` — every algorithm has a
//! strategy trait here; concrete strategies live in submodules keyed
//! by coordinate-system family (`cartesian`, `spherical`,
//! `geographic`).
//!
//! ## Writing a new strategy
//!
//! Take the worked example: a Cartesian point-to-point distance
//! strategy (`Pythagoras`). A strategy for any algorithm follows the
//! same three steps.
//!
//! ### Step 1 — Pick the coordinate-system family to bind on
//!
//! Strategies bind on the [`CoordinateSystem::Family`](geometry_cs::CoordinateSystem::Family)
//! — never on the concrete CS — so that one impl covers both
//! `Spherical<Degree>` and `Spherical<Radian>` (or
//! `Geographic<Degree>` / `Geographic<Radian>`). The bound is
//! expressed via the [`geometry_tag::SameAs`] trait, the Rust
//! analogue of C++'s `std::is_same`:
//!
//! ```ignore
//! impl<P1, P2> DistanceStrategy<P1, P2> for Pythagoras
//! where
//! P1: Point,
//! P2: Point<Scalar = P1::Scalar>,
//! <P1::Cs as CoordinateSystem>::Family: SameAs<CartesianFamily>,
//! <P2::Cs as CoordinateSystem>::Family: SameAs<CartesianFamily>,
//! { /* ... */ }
//! ```
//!
//! The two `SameAs<CartesianFamily>` bounds form the family fence:
//! they refuse to monomorphise for a `Spherical` or `Geographic` point.
//! The `#[diagnostic::on_unimplemented]` plate on
//! [`geometry_tag::SameAs`] then redirects the resulting
//! compile error to the correct mitigation (wrap in
//! `geometry_adapt::WithCs<_, Geographic<_>>`, or pick a
//! CS-appropriate strategy such as `Haversine` / `Andoyer` /
//! `Vincenty`).
//!
//! ### Step 2 — Decide whether to provide a `Comparable` form
//!
//! A "comparable" form is a sibling strategy that returns the *same
//! ordering* as the real strategy but skips work the ordering does
//! not need. For Pythagoras this means returning the *squared*
//! distance and skipping the final `sqrt`. The squared form sorts
//! identically and is roughly twice as fast on a hot inner loop:
//!
//! ```ignore
//! impl<P1, P2> DistanceStrategy<P1, P2> for Pythagoras /* ... */ {
//! type Out = P1::Scalar;
//! type Comparable = ComparablePythagoras; // <- skip-sqrt sibling
//! fn distance(&self, a: &P1, b: &P2) -> Self::Out {
//! self.comparable().distance(a, b).sqrt()
//! }
//! fn comparable(&self) -> Self::Comparable { ComparablePythagoras }
//! }
//! ```
//!
//! If the math has no equivalent shortcut (Andoyer, Vincenty,
//! Haversine after the half-angle formula), set
//! `type Comparable = Self;` — the optimiser collapses the
//! indirection. The doc on [`distance::DistanceStrategy::Comparable`]
//! warns implementers not to over-engineer this.
//!
//! ### Step 3 — Wire the default selection
//!
//! Each coordinate-system family picks one default strategy per
//! algorithm via [`distance::DefaultDistance`]:
//!
//! ```ignore
//! impl DefaultDistance<CartesianFamily> for CartesianFamily { type Strategy = Pythagoras; }
//! impl DefaultDistance<SphericalFamily> for SphericalFamily { type Strategy = Haversine; }
//! impl DefaultDistance<GeographicFamily> for GeographicFamily { type Strategy = Andoyer; }
//! ```
//!
//! That is what makes the no-strategy `distance(a, b)` overload
//! resolve to the right algorithm: the type-level walk
//! `A → A::Point → Cs → Family → DefaultDistance<…B's family…>::Strategy`
//! resolves to the correct concrete strategy at the call site.
//!
//! ## Reverse dispatch — argument symmetry
//!
//! For algorithms whose arguments are symmetric, write one impl per
//! tag pair `(A, B)` and the `Reversed<S>` blanket impl in
//! [`distance::Reversed`] picks up `(B, A)` automatically. The
//! analogue of Boost's `core/reverse_dispatch.hpp` partial
//! specialisation, done once at the strategy-trait layer instead of
//! per-algorithm.
//!
//! ## Module layout
//!
//! Each algorithm has its own strategy trait module — `distance`,
//! `area`, `length`, `envelope`, `within`, `intersects`, `disjoint`,
//! `equals`. Concrete strategies live under `cartesian`,
//! `spherical`, or `geographic` per coordinate-system family.
extern crate alloc;
pub
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;