postgis_butmaintained/
types.rs1pub trait Point: Send + Sync {
2 fn x(&self) -> f64;
3 fn y(&self) -> f64;
4 fn opt_z(&self) -> Option<f64> {
5 None
6 }
7 fn opt_m(&self) -> Option<f64> {
8 None
9 }
10}
11
12pub trait LineString<'a>: Send + Sync {
13 type ItemType: 'a + Point;
14 type Iter: Iterator<Item = &'a Self::ItemType>;
15 fn points(&'a self) -> Self::Iter;
16}
17
18pub trait Polygon<'a>: Send + Sync {
19 type ItemType: 'a + LineString<'a>;
20 type Iter: Iterator<Item = &'a Self::ItemType>;
21 fn rings(&'a self) -> Self::Iter;
22}
23
24pub trait MultiPoint<'a>: Send + Sync {
25 type ItemType: 'a + Point;
26 type Iter: Iterator<Item = &'a Self::ItemType>;
27 fn points(&'a self) -> Self::Iter;
28}
29
30pub trait MultiLineString<'a>: Send + Sync {
31 type ItemType: 'a + LineString<'a>;
32 type Iter: Iterator<Item = &'a Self::ItemType>;
33 fn lines(&'a self) -> Self::Iter;
34}
35
36pub trait MultiPolygon<'a>: Send + Sync {
37 type ItemType: 'a + Polygon<'a>;
38 type Iter: Iterator<Item = &'a Self::ItemType>;
39 fn polygons(&'a self) -> Self::Iter;
40}
41
42pub trait Geometry<'a>: Send + Sync {
43 type Point: 'a + Point;
44 type LineString: 'a + LineString<'a>;
45 type Polygon: 'a + Polygon<'a>;
46 type MultiPoint: 'a + MultiPoint<'a>;
47 type MultiLineString: 'a + MultiLineString<'a>;
48 type MultiPolygon: 'a + MultiPolygon<'a>;
49 type GeometryCollection: 'a + GeometryCollection<'a>;
50 fn as_type(
51 &'a self,
52 ) -> GeometryType<
53 'a,
54 Self::Point,
55 Self::LineString,
56 Self::Polygon,
57 Self::MultiPoint,
58 Self::MultiLineString,
59 Self::MultiPolygon,
60 Self::GeometryCollection,
61 >;
62}
63
64pub enum GeometryType<'a, P, L, Y, MP, ML, MY, GC>
65where
66 P: 'a + Point,
67 L: 'a + LineString<'a>,
68 Y: 'a + Polygon<'a>,
69 MP: 'a + MultiPoint<'a>,
70 ML: 'a + MultiLineString<'a>,
71 MY: 'a + MultiPolygon<'a>,
72 GC: 'a + GeometryCollection<'a>,
73{
74 Point(&'a P),
75 LineString(&'a L),
76 Polygon(&'a Y),
77 MultiPoint(&'a MP),
78 MultiLineString(&'a ML),
79 MultiPolygon(&'a MY),
80 GeometryCollection(&'a GC),
81}
82
83pub trait GeometryCollection<'a> {
84 type ItemType: 'a;
85 type Iter: Iterator<Item = &'a Self::ItemType>;
86 fn geometries(&'a self) -> Self::Iter;
87}