s2json_core/geometry/mod.rs
1/// BBox and BBox3D shapes and utilities
2pub mod bbox;
3/// Impls that we want to hide to make the code more readable
4pub mod impls;
5/// Primitive geometry types (used by GeoJSON spec)
6pub mod primitive;
7/// Vector geometry types (used by the s2json spec for both WGS84 and S2Geometry)
8pub mod vector;
9/// The VectorPoint struct is a powerful tool for 2D and 3D points
10pub mod vector_point;
11
12use crate::{Face, MValue};
13pub use bbox::*;
14pub use primitive::*;
15use serde::{Deserialize, Serialize};
16pub use vector::*;
17pub use vector_point::*;
18/// Trait to extract the x and y values
19pub trait GetXY {
20 /// Returns the x value
21 fn x(&self) -> f64;
22 /// Returns the y value
23 fn y(&self) -> f64;
24}
25/// Trait to extract the z value
26pub trait GetZ {
27 /// Returns the z value
28 fn z(&self) -> Option<f64>;
29}
30/// Trait to extract the m value
31pub trait GetM<M = MValue> {
32 /// Returns the m value
33 fn m(&self) -> Option<&M>;
34}
35
36/// Composite Trait: XY + Z
37pub trait GetXYZ: GetXY + GetZ {}
38/// Composite Trait: XY + M
39pub trait GetXYM<M = MValue>: GetXY + GetM<M> {}
40/// Composite Trait: XY + Z + M
41pub trait GetXYZM<M = MValue>: GetXY + GetZ + GetM<M> {}
42
43/// The axis to apply an operation to
44#[derive(Debug, PartialEq, Eq, Clone, Copy)]
45pub enum Axis {
46 /// X axis
47 X = 0,
48 /// Y axis
49 Y = 1,
50}
51
52/// A Point in S2 Space with a Face
53#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Default)]
54pub struct STPoint<M = MValue> {
55 /// The face of the point
56 pub face: Face,
57 /// The s coordinate
58 pub s: f64,
59 /// The t coordinate
60 pub t: f64,
61 /// The z coordinate
62 pub z: Option<f64>,
63 /// The m coordinate
64 pub m: Option<M>,
65}