blob: 7cc87dd5ebb3c76a009546269b1abe778ef2bdec (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
package orb
import (
"fmt"
)
// Equal returns if the two geometrires are equal.
func Equal(g1, g2 Geometry) bool {
if g1 == nil || g2 == nil {
return g1 == g2
}
if g1.GeoJSONType() != g2.GeoJSONType() {
return false
}
switch g1 := g1.(type) {
case Point:
return g1.Equal(g2.(Point))
case MultiPoint:
return g1.Equal(g2.(MultiPoint))
case LineString:
return g1.Equal(g2.(LineString))
case MultiLineString:
return g1.Equal(g2.(MultiLineString))
case Ring:
g2, ok := g2.(Ring)
if !ok {
return false
}
return g1.Equal(g2)
case Polygon:
g2, ok := g2.(Polygon)
if !ok {
return false
}
return g1.Equal(g2)
case MultiPolygon:
return g1.Equal(g2.(MultiPolygon))
case Collection:
return g1.Equal(g2.(Collection))
case Bound:
g2, ok := g2.(Bound)
if !ok {
return false
}
return g1.Equal(g2)
}
panic(fmt.Sprintf("geometry type not supported: %T", g1))
}
|