1use geometry_coords::CoordinateScalar;
7use geometry_cs::CoordinateSystem;
8
9use crate::{
10 Box, Linestring, MultiLinestring, MultiPoint, MultiPolygon, Point, Polygon, Ring, Segment,
11};
12
13pub trait RebindGeometry<T: CoordinateScalar, Cs: CoordinateSystem> {
22 type Output;
24}
25
26pub type Rebound<G, T, Cs> = <G as RebindGeometry<T, Cs>>::Output;
32
33impl<A, const D: usize, OldCs, T, Cs> RebindGeometry<T, Cs> for Point<A, D, OldCs>
34where
35 A: CoordinateScalar,
36 OldCs: CoordinateSystem,
37 T: CoordinateScalar,
38 Cs: CoordinateSystem,
39{
40 type Output = Point<T, D, Cs>;
41}
42
43impl<A, const D: usize, OldCs, T, Cs> RebindGeometry<T, Cs> for Box<Point<A, D, OldCs>>
44where
45 A: CoordinateScalar,
46 OldCs: CoordinateSystem,
47 T: CoordinateScalar,
48 Cs: CoordinateSystem,
49{
50 type Output = Box<Point<T, D, Cs>>;
51}
52
53impl<A, const D: usize, OldCs, T, Cs> RebindGeometry<T, Cs> for Linestring<Point<A, D, OldCs>>
54where
55 A: CoordinateScalar,
56 OldCs: CoordinateSystem,
57 T: CoordinateScalar,
58 Cs: CoordinateSystem,
59{
60 type Output = Linestring<Point<T, D, Cs>>;
61}
62
63impl<A, const D: usize, OldCs, T, Cs, const CW: bool, const CL: bool> RebindGeometry<T, Cs>
64 for Ring<Point<A, D, OldCs>, CW, CL>
65where
66 A: CoordinateScalar,
67 OldCs: CoordinateSystem,
68 T: CoordinateScalar,
69 Cs: CoordinateSystem,
70{
71 type Output = Ring<Point<T, D, Cs>, CW, CL>;
72}
73
74impl<A, const D: usize, OldCs, T, Cs> RebindGeometry<T, Cs> for Segment<Point<A, D, OldCs>>
75where
76 A: CoordinateScalar,
77 OldCs: CoordinateSystem,
78 T: CoordinateScalar,
79 Cs: CoordinateSystem,
80{
81 type Output = Segment<Point<T, D, Cs>>;
82}
83
84impl<A, const D: usize, OldCs, T, Cs> RebindGeometry<T, Cs> for MultiPoint<Point<A, D, OldCs>>
85where
86 A: CoordinateScalar,
87 OldCs: CoordinateSystem,
88 T: CoordinateScalar,
89 Cs: CoordinateSystem,
90{
91 type Output = MultiPoint<Point<T, D, Cs>>;
92}
93
94impl<A, const D: usize, OldCs, T, Cs, const CW: bool, const CL: bool> RebindGeometry<T, Cs>
95 for Polygon<Point<A, D, OldCs>, CW, CL>
96where
97 A: CoordinateScalar,
98 OldCs: CoordinateSystem,
99 T: CoordinateScalar,
100 Cs: CoordinateSystem,
101{
102 type Output = Polygon<Point<T, D, Cs>, CW, CL>;
103}
104
105impl<A, const D: usize, OldCs, T, Cs> RebindGeometry<T, Cs>
106 for MultiLinestring<Linestring<Point<A, D, OldCs>>>
107where
108 A: CoordinateScalar,
109 OldCs: CoordinateSystem,
110 T: CoordinateScalar,
111 Cs: CoordinateSystem,
112{
113 type Output = MultiLinestring<Linestring<Point<T, D, Cs>>>;
114}
115
116impl<A, const D: usize, OldCs, T, Cs, const CW: bool, const CL: bool> RebindGeometry<T, Cs>
117 for MultiPolygon<Polygon<Point<A, D, OldCs>, CW, CL>>
118where
119 A: CoordinateScalar,
120 OldCs: CoordinateSystem,
121 T: CoordinateScalar,
122 Cs: CoordinateSystem,
123{
124 type Output = MultiPolygon<Polygon<Point<T, D, Cs>, CW, CL>>;
125}