forked from go-spatial/geom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
multi_pointz.go
38 lines (29 loc) · 858 Bytes
/
multi_pointz.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
package geom
import "errors"
// ErrNilMultiPointZ is thrown when a MultiPointZ is nil but shouldn't be
var ErrNilMultiPointZ = errors.New("geom: nil MultiPointZ")
// MultiPointZ is a geometry with multiple 3D points.
type MultiPointZ [][3]float64
// Points returns the coordinates for the 3D points
func (mpz MultiPointZ) Points() [][3]float64 {
return mpz
}
// SetPoints modifies the array of 3D coordinates
func (mpz *MultiPointZ) SetPoints(input [][3]float64) (err error) {
if mpz == nil {
return ErrNilMultiPointZ
}
*mpz = append((*mpz)[:0], input...)
return
}
// Get the simple 2D multipoint
func (mpz MultiPointZ) MultiPoint() MultiPoint {
var mpv [][2]float64
var mp MultiPoint
points := mpz.Points()
for i := 0; i < len(points); i++ {
mpv = append(mpv, [2]float64{points[i][0], points[i][1]})
}
mp.SetPoints(mpv)
return mp
}