d3_geo_rs/projection/builder/
reflect_set.rs

1use geo::CoordFloat;
2use num_traits::FloatConst;
3
4use crate::clip::rectangle::Rectangle;
5use crate::identity::Identity;
6use crate::projection::builder::ResampleNoPCNU;
7use crate::projection::builder::ResamplePCNU;
8use crate::projection::Recenter;
9use crate::projection::Reflect;
10use crate::projection::ReflectSet;
11use crate::stream::Unconnected;
12use crate::Transform;
13
14use super::template::ResampleNoneNoPCNU;
15use super::template::ResampleNonePCNU;
16use super::Builder;
17
18impl<CLIPU, DRAIN, PR, T> ReflectSet
19    for Builder<
20        CLIPU,
21        DRAIN,
22        Identity<Unconnected>,
23        PR,
24        ResampleNoPCNU<PR, T>,
25        T,
26    >
27where
28    PR: Clone + Transform<T = T>,
29    T: CoordFloat + FloatConst,
30{
31    type T = T;
32
33    /// Set the projection builder to invert the x-coordinate.
34    fn reflect_x_set(&mut self, reflect: Reflect) -> &mut Self {
35        self.sx = match reflect {
36            Reflect::Flipped => T::from(-1.0_f64).unwrap(),
37            Reflect::Unflipped => T::one(),
38        };
39        self.recenter()
40    }
41
42    /// Set the projection builder to invert the y-coordinate.
43    #[inline]
44    fn reflect_y_set(&mut self, reflect: Reflect) -> &mut Self {
45        self.sy = match reflect {
46            Reflect::Flipped => T::from(-1.0_f64).unwrap(),
47            Reflect::Unflipped => T::one(),
48        };
49        self.recenter()
50    }
51}
52
53impl<CLIPU, DRAIN, PR, T> ReflectSet
54    for Builder<
55        CLIPU,
56        DRAIN,
57        Rectangle<Unconnected, T>,
58        PR,
59        ResamplePCNU<PR, T>,
60        T,
61    >
62where
63    PR: Clone + Transform<T = T>,
64    T: CoordFloat + FloatConst,
65{
66    type T = T;
67
68    /// Set the projection builder to invert the x-coordinate.
69    fn reflect_x_set(&mut self, reflect: Reflect) -> &mut Self {
70        self.sx = match reflect {
71            Reflect::Flipped => T::from(-1.0_f64).unwrap(),
72            Reflect::Unflipped => T::one(),
73        };
74        self.recenter()
75    }
76
77    /// Set the projection builder to invert the y-coordinate.
78    #[inline]
79    fn reflect_y_set(&mut self, reflect: Reflect) -> &mut Self {
80        self.sy = match reflect {
81            Reflect::Flipped => T::from(-1.0_f64).unwrap(),
82            Reflect::Unflipped => T::one(),
83        };
84        self.recenter()
85    }
86}
87
88impl<CLIPU, DRAIN, PR, T> ReflectSet
89    for Builder<
90        CLIPU,
91        DRAIN,
92        Identity<Unconnected>,
93        PR,
94        ResampleNoneNoPCNU<PR, T>,
95        T,
96    >
97where
98    PR: Clone + Transform<T = T>,
99    T: CoordFloat + FloatConst,
100{
101    type T = T;
102
103    /// Set the projection builder to invert the x-coordinate.
104    fn reflect_x_set(&mut self, reflect: Reflect) -> &mut Self {
105        self.sx = match reflect {
106            Reflect::Flipped => T::from(-1.0_f64).unwrap(),
107            Reflect::Unflipped => T::one(),
108        };
109        self.recenter()
110    }
111
112    /// Set the projection builder to invert the y-coordinate.
113    #[inline]
114    fn reflect_y_set(&mut self, reflect: Reflect) -> &mut Self {
115        self.sy = match reflect {
116            Reflect::Flipped => T::from(-1.0_f64).unwrap(),
117            Reflect::Unflipped => T::one(),
118        };
119        self.recenter()
120    }
121}
122
123impl<CLIPU, DRAIN, PR, T> ReflectSet
124    for Builder<
125        CLIPU,
126        DRAIN,
127        Rectangle<Unconnected, T>,
128        PR,
129        ResampleNonePCNU<PR, T>,
130        T,
131    >
132where
133    PR: Clone + Transform<T = T>,
134    T: CoordFloat + FloatConst,
135{
136    type T = T;
137
138    /// Set the projection builder to invert the x-coordinate.
139    fn reflect_x_set(&mut self, reflect: Reflect) -> &mut Self {
140        self.sx = match reflect {
141            Reflect::Flipped => T::from(-1.0_f64).unwrap(),
142            Reflect::Unflipped => T::one(),
143        };
144        self.recenter()
145    }
146
147    /// Set the projection builder to invert the y-coordinate.
148    #[inline]
149    fn reflect_y_set(&mut self, reflect: Reflect) -> &mut Self {
150        self.sy = match reflect {
151            Reflect::Flipped => T::from(-1.0_f64).unwrap(),
152            Reflect::Unflipped => T::one(),
153        };
154        self.recenter()
155    }
156}