forked from paulmach/orb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multi_line_string.go
58 lines (46 loc) · 1.19 KB
/
multi_line_string.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
package orb
// MultiLineString is a set of polylines.
type MultiLineString []LineString
// GeoJSONType returns the GeoJSON type for the object.
func (mls MultiLineString) GeoJSONType() string {
return "MultiLineString"
}
// Dimensions returns 1 because a MultiLineString is a 2d object.
func (mls MultiLineString) Dimensions() int {
return 1
}
// Bound returns a bound around all the line strings.
func (mls MultiLineString) Bound() Bound {
if len(mls) == 0 {
return emptyBound
}
bound := mls[0].Bound()
for i := 1; i < len(mls); i++ {
bound = bound.Union(mls[i].Bound())
}
return bound
}
// Equal compares two multi line strings. Returns true if lengths are the same
// and all points are Equal.
func (mls MultiLineString) Equal(multiLineString MultiLineString) bool {
if len(mls) != len(multiLineString) {
return false
}
for i, ls := range mls {
if !ls.Equal(multiLineString[i]) {
return false
}
}
return true
}
// Clone returns a new deep copy of the multi line string.
func (mls MultiLineString) Clone() MultiLineString {
if mls == nil {
return nil
}
nmls := make(MultiLineString, 0, len(mls))
for _, ls := range mls {
nmls = append(nmls, ls.Clone())
}
return nmls
}