s2json_core/geometry/
mod.rs1pub mod bbox;
3pub mod impls;
5pub mod primitive;
7pub mod vector;
9pub mod vector_point;
11
12use crate::Face;
13pub use bbox::*;
14pub use primitive::*;
15use serde::{Deserialize, Serialize};
16pub use vector::*;
17pub use vector_point::*;
18
19pub trait GetXY {
21 fn x(&self) -> f64;
23 fn y(&self) -> f64;
25}
26pub trait GetZ {
28 fn z(&self) -> Option<f64>;
30}
31pub trait GetM<M> {
33 fn m(&self) -> Option<&M>;
35}
36
37pub trait GetXYZ: GetXY + GetZ {}
39pub trait GetXYM<M>: GetXY + GetM<M> {}
41pub trait GetXYZM<M>: GetXY + GetZ + GetM<M> {}
43
44pub trait SetXY {
46 fn set_x(&mut self, x: f64);
48 fn set_y(&mut self, y: f64);
50 fn set_xy(&mut self, x: f64, y: f64) {
52 self.set_x(x);
53 self.set_y(y);
54 }
55}
56pub trait SetZ {
58 fn set_z(&mut self, z: f64);
60}
61pub trait SetM<M> {
63 fn set_m(&mut self, m: M);
65}
66
67pub trait SetXYZ: SetXY + SetZ {
69 fn set_xyz(&mut self, x: f64, y: f64, z: f64) {
71 self.set_xy(x, y);
72 self.set_z(z);
73 }
74}
75pub trait SetXYM<M>: SetXY + SetM<M> {
77 fn set_xym(&mut self, x: f64, y: f64, m: M) {
79 self.set_xy(x, y);
80 self.set_m(m);
81 }
82}
83pub trait SetXYZM<M>: SetXY + SetZ + SetM<M> {
85 fn set_xyzm(&mut self, x: f64, y: f64, z: f64, m: M) {
87 self.set_xy(x, y);
88 self.set_z(z);
89 self.set_m(m);
90 }
91}
92
93pub trait NewXY {
95 fn new_xy(x: f64, y: f64) -> Self;
97}
98pub trait NewXYZ {
100 fn new_xyz(x: f64, y: f64, z: f64) -> Self;
102}
103pub trait NewXYZM<M> {
105 fn new_xyzm(x: f64, y: f64, z: f64, m: M) -> Self;
107}
108
109#[derive(Debug, PartialEq, Eq, Clone, Copy)]
111pub enum Axis {
112 X = 0,
114 Y = 1,
116}
117
118#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Default)]
120pub struct STPoint<M> {
121 pub face: Face,
123 pub s: f64,
125 pub t: f64,
127 pub z: Option<f64>,
129 pub m: Option<M>,
131}