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::*;
18pub trait GetXY {
20 fn x(&self) -> f64;
22 fn y(&self) -> f64;
24}
25pub trait GetZ {
27 fn z(&self) -> Option<f64>;
29}
30pub trait GetM<M> {
32 fn m(&self) -> Option<&M>;
34}
35
36pub trait GetXYZ: GetXY + GetZ {}
38pub trait GetXYM<M>: GetXY + GetM<M> {}
40pub trait GetXYZM<M>: GetXY + GetZ + GetM<M> {}
42
43pub trait SetXY {
45 fn set_x(&mut self, x: f64);
47 fn set_y(&mut self, y: f64);
49 fn set_xy(&mut self, x: f64, y: f64) {
51 self.set_x(x);
52 self.set_y(y);
53 }
54}
55pub trait SetZ {
57 fn set_z(&mut self, z: f64);
59}
60pub trait SetM<M> {
62 fn set_m(&mut self, m: M);
64}
65
66pub trait SetXYZ: SetXY + SetZ {
68 fn set_xyz(&mut self, x: f64, y: f64, z: f64) {
70 self.set_xy(x, y);
71 self.set_z(z);
72 }
73}
74pub trait SetXYM<M>: SetXY + SetM<M> {
76 fn set_xym(&mut self, x: f64, y: f64, m: M) {
78 self.set_xy(x, y);
79 self.set_m(m);
80 }
81}
82pub trait SetXYZM<M>: SetXY + SetZ + SetM<M> {
84 fn set_xyzm(&mut self, x: f64, y: f64, z: f64, m: M) {
86 self.set_xy(x, y);
87 self.set_z(z);
88 self.set_m(m);
89 }
90}
91
92pub trait NewXY {
94 fn new_xy(x: f64, y: f64) -> Self;
96}
97pub trait NewXYZ {
99 fn new_xyz(x: f64, y: f64, z: f64) -> Self;
101}
102pub trait NewXYZM<M> {
104 fn new_xyzm(x: f64, y: f64, z: f64, m: M) -> Self;
106}
107
108#[derive(Debug, PartialEq, Eq, Clone, Copy)]
110pub enum Axis {
111 X = 0,
113 Y = 1,
115}
116
117#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Default)]
119pub struct STPoint<M> {
120 pub face: Face,
122 pub s: f64,
124 pub t: f64,
126 pub z: Option<f64>,
128 pub m: Option<M>,
130}