-
-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathmulti_line_stringz.go
39 lines (32 loc) · 1.02 KB
/
multi_line_stringz.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
package geom
import "errors"
// ErrNilMultiLineStringZ is thrown when MultiLineStringZ is nil but shouldn't be
var ErrNilMultiLineStringZ = errors.New("geom: nil MultiLineStringZ")
// MultiLineStringZ is a geometry with multiple LineStringZs.
type MultiLineStringZ [][][3]float64
// LineStringZs returns the coordinates for the linestrings
func (mlsz MultiLineStringZ) LineStringZs() [][][3]float64 {
return mlsz
}
// SetLineStringZs modifies the array of 3D coordinates
func (mlsz *MultiLineStringZ) SetLineStringZs(input [][][3]float64) (err error) {
if mlsz == nil {
return ErrNilMultiLineStringZ
}
*mlsz = append((*mlsz)[:0], input...)
return
}
// AsSegments returns the multi lines string as a set of lineZs.
func (mlsz MultiLineStringZ) AsLineStringZs() (segs []LineStringZ, err error) {
if len(mlsz) == 0 {
return nil, nil
}
for i := range mlsz {
lsz := LineStringZ(mlsz[i])
if lsz == nil {
return nil, errors.New("geom: error in splitting MultiLineStringZ")
}
segs = append(segs, lsz)
}
return segs, nil
}