-
Notifications
You must be signed in to change notification settings - Fork 106
/
multi_point.go
56 lines (44 loc) · 1.11 KB
/
multi_point.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
package orb
// A MultiPoint represents a set of points in the 2D Eucledian or Cartesian plane.
type MultiPoint []Point
// GeoJSONType returns the GeoJSON type for the object.
func (mp MultiPoint) GeoJSONType() string {
return "MultiPoint"
}
// Dimensions returns 0 because a MultiPoint is a 0d object.
func (mp MultiPoint) Dimensions() int {
return 0
}
// Clone returns a new copy of the points.
func (mp MultiPoint) Clone() MultiPoint {
if mp == nil {
return nil
}
points := make([]Point, len(mp))
copy(points, mp)
return MultiPoint(points)
}
// Bound returns a bound around the points. Uses rectangular coordinates.
func (mp MultiPoint) Bound() Bound {
if len(mp) == 0 {
return emptyBound
}
b := Bound{mp[0], mp[0]}
for _, p := range mp {
b = b.Extend(p)
}
return b
}
// Equal compares two MultiPoint objects. Returns true if lengths are the same
// and all points are Equal, and in the same order.
func (mp MultiPoint) Equal(multiPoint MultiPoint) bool {
if len(mp) != len(multiPoint) {
return false
}
for i := range mp {
if !mp[i].Equal(multiPoint[i]) {
return false
}
}
return true
}