forked from go-spatial/tegola
-
Notifications
You must be signed in to change notification settings - Fork 0
/
point.go
58 lines (49 loc) · 884 Bytes
/
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
57
58
package list
import (
"fmt"
"github.com/go-spatial/tegola/container/singlelist"
"github.com/go-spatial/tegola/maths"
)
type Elementer interface {
list.Elementer
}
type ElementerPointer interface {
list.Elementer
maths.Pointer
}
// Pt is a point node.
type Pt struct {
maths.Pt
// This fulfills the Elementer interface.
list.Sentinel
}
func (p *Pt) Point() (pt maths.Pt) { return p.Pt }
func (p *Pt) String() string {
if p == nil {
return "(nil)"
}
return p.Pt.String()
}
func (p *Pt) GoString() string {
if p == nil {
return "(nil)"
}
return fmt.Sprintf("[%v,%v]", p.Pt.X, p.Pt.Y)
}
func NewPt(pt maths.Pt) *Pt {
return &Pt{Pt: pt}
}
func NewPoint(x, y float64) *Pt {
return &Pt{
Pt: maths.Pt{
X: x,
Y: y,
},
}
}
func NewPointSlice(pts ...maths.Pt) (rpts []*Pt) {
for _, pt := range pts {
rpts = append(rpts, &Pt{Pt: pt})
}
return rpts
}