-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathspatial.go
75 lines (59 loc) · 1.73 KB
/
spatial.go
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package geojson
import "github.com/tidwall/geojson/geometry"
type Spatial interface {
WithinRect(rect geometry.Rect) bool
WithinPoint(point geometry.Point) bool
WithinLine(line *geometry.Line) bool
WithinPoly(poly *geometry.Poly) bool
IntersectsRect(rect geometry.Rect) bool
IntersectsPoint(point geometry.Point) bool
IntersectsLine(line *geometry.Line) bool
IntersectsPoly(poly *geometry.Poly) bool
DistanceRect(rect geometry.Rect) float64
DistancePoint(point geometry.Point) float64
DistanceLine(line *geometry.Line) float64
DistancePoly(poly *geometry.Poly) float64
}
var _ = []Spatial{
&Point{}, &LineString{}, &Polygon{}, &Feature{},
&MultiPoint{}, &MultiLineString{}, &MultiPolygon{},
&GeometryCollection{}, &FeatureCollection{}, &Rect{},
EmptySpatial{},
}
type EmptySpatial struct{}
func (s EmptySpatial) WithinRect(rect geometry.Rect) bool {
return false
}
func (s EmptySpatial) WithinPoint(point geometry.Point) bool {
return false
}
func (s EmptySpatial) WithinLine(line *geometry.Line) bool {
return false
}
func (s EmptySpatial) WithinPoly(poly *geometry.Poly) bool {
return false
}
func (s EmptySpatial) IntersectsRect(rect geometry.Rect) bool {
return false
}
func (s EmptySpatial) IntersectsPoint(point geometry.Point) bool {
return false
}
func (s EmptySpatial) IntersectsLine(line *geometry.Line) bool {
return false
}
func (s EmptySpatial) IntersectsPoly(poly *geometry.Poly) bool {
return false
}
func (s EmptySpatial) DistanceRect(rect geometry.Rect) float64 {
return 0
}
func (s EmptySpatial) DistancePoint(point geometry.Point) float64 {
return 0
}
func (s EmptySpatial) DistanceLine(line *geometry.Line) float64 {
return 0
}
func (s EmptySpatial) DistancePoly(poly *geometry.Poly) float64 {
return 0
}