forked from tidwall/geojson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
spatial.go
89 lines (73 loc) · 2 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package geojson
import "github.com/tidwall/geojson/geometry"
// Spatial ...
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{},
}
// EmptySpatial ...
type EmptySpatial struct{}
// WithinRect ...
func (s EmptySpatial) WithinRect(rect geometry.Rect) bool {
return false
}
// WithinPoint ...
func (s EmptySpatial) WithinPoint(point geometry.Point) bool {
return false
}
// WithinLine ...
func (s EmptySpatial) WithinLine(line *geometry.Line) bool {
return false
}
// WithinPoly ...
func (s EmptySpatial) WithinPoly(poly *geometry.Poly) bool {
return false
}
// IntersectsRect ...
func (s EmptySpatial) IntersectsRect(rect geometry.Rect) bool {
return false
}
// IntersectsPoint ...
func (s EmptySpatial) IntersectsPoint(point geometry.Point) bool {
return false
}
// IntersectsLine ...
func (s EmptySpatial) IntersectsLine(line *geometry.Line) bool {
return false
}
// IntersectsPoly ...
func (s EmptySpatial) IntersectsPoly(poly *geometry.Poly) bool {
return false
}
// DistanceRect ...
func (s EmptySpatial) DistanceRect(rect geometry.Rect) float64 {
return 0
}
// DistancePoint ...
func (s EmptySpatial) DistancePoint(point geometry.Point) float64 {
return 0
}
// DistanceLine ...
func (s EmptySpatial) DistanceLine(line *geometry.Line) float64 {
return 0
}
// DistancePoly ...
func (s EmptySpatial) DistancePoly(poly *geometry.Poly) float64 {
return 0
}