1
+ // src/types/geometry.rs
2
+
3
+ // Geometry types
4
+ #[ derive( Debug , PartialEq ) ]
5
+ pub enum Geometry {
6
+ Point ,
7
+ LineString ,
8
+ Polygon ,
9
+ MultiPoint ,
10
+ MultiLineString ,
11
+ MultiPolygon ,
12
+ GeometryCollection ,
13
+ }
14
+
15
+ // impl PartialEq for Geometry
16
+ impl PartialEq for Geometry {
17
+ fn eq ( & self , other : & Self ) -> bool {
18
+ match self {
19
+ Geometry :: Point => {
20
+ if let Geometry :: Point = other {
21
+ true
22
+ } else {
23
+ false
24
+ }
25
+ } ,
26
+ Geometry :: LineString => {
27
+ if let Geometry :: LineString = other {
28
+ true
29
+ } else {
30
+ false
31
+ }
32
+ } ,
33
+ Geometry :: Polygon => {
34
+ if let Geometry :: Polygon = other {
35
+ true
36
+ } else {
37
+ false
38
+ }
39
+ } ,
40
+ Geometry :: MultiPoint => {
41
+ if let Geometry :: MultiPoint = other {
42
+ true
43
+ } else {
44
+ false
45
+ }
46
+ } ,
47
+ Geometry :: MultiLineString => {
48
+ if let Geometry :: MultiLineString = other {
49
+ true
50
+ } else {
51
+ false
52
+ }
53
+ } ,
54
+ Geometry :: MultiPolygon => {
55
+ if let Geometry :: MultiPolygon = other {
56
+ true
57
+ } else {
58
+ false
59
+ }
60
+ } ,
61
+ Geometry :: GeometryCollection => {
62
+ if let Geometry :: GeometryCollection = other {
63
+ true
64
+ } else {
65
+ false
66
+ }
67
+ } ,
68
+ }
69
+ }
70
+ }
71
+
72
+ // impl Geometry
73
+ impl Geometry {
74
+ pub fn to_string ( & self ) -> String {
75
+ self . to_string ( )
76
+ }
77
+ }
78
+
79
+ // impl Display for Geometry
80
+ impl std:: fmt:: Display for Geometry {
81
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
82
+ match * self {
83
+ Geometry :: Point => write ! ( f, "POINT" ) ,
84
+ Geometry :: LineString => write ! ( f, "LINESTRING" ) ,
85
+ Geometry :: Polygon => write ! ( f, "POLYGON" ) ,
86
+ Geometry :: MultiPoint => write ! ( f, "MULTIPOINT" ) ,
87
+ Geometry :: MultiLineString => write ! ( f, "MULTILINESTRING" ) ,
88
+ Geometry :: MultiPolygon => write ! ( f, "MULTIPOLYGON" ) ,
89
+ Geometry :: GeometryCollection => write ! ( f, "GEOMETRYCOLLECTION" ) ,
90
+ }
91
+ }
92
+ }
93
+
94
+ // impl Geometry
95
+ impl Geometry {
96
+ pub fn to_string ( & self ) -> String {
97
+ self . to_string ( )
98
+ }
99
+ }
100
+
101
+ // impl Display for Geometry
102
+ impl std:: fmt:: Display for Geometry {
103
+ fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> std:: fmt:: Result {
104
+ match * self {
105
+ Geometry :: Point => write ! ( f, "POINT" ) ,
106
+ Geometry :: LineString => write ! ( f, "LINESTRING" ) ,
107
+ Geometry :: Polygon => write ! ( f, "POLYGON" ) ,
108
+ Geometry :: MultiPoint => write ! ( f, "MULTIPOINT" ) ,
109
+ Geometry :: MultiLineString => write ! ( f, "MULTILINESTRING" ) ,
110
+ Geometry :: MultiPolygon => write ! ( f, "MULTIPOLYGON" ) ,
111
+ Geometry :: GeometryCollection => write ! ( f, "GEOMETRYCOLLECTION" ) ,
112
+ }
113
+ }
114
+ }
0 commit comments