-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpoint_str.go
34 lines (28 loc) · 890 Bytes
/
point_str.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
package geom
import (
"bytes"
"github.com/intdxdt/math"
"strconv"
)
//String creates a wkt string format of point
func (self Point) WKT() string {
return WriteWKT(NewWKTParserObj(GeoTypePoint, Coordinates([]Point{self})))
}
//String creates a wkt string format of point
func (self *Point) String() string {
var buf bytes.Buffer
buf.WriteString("[")
buf.WriteString(strconv.FormatFloat(self[X], 'f', -1, 64) + ", ")
buf.WriteString(strconv.FormatFloat(self[Y], 'f', -1, 64) + ", ")
buf.WriteString(strconv.FormatFloat(self[Z], 'f', -1, 64))
buf.WriteString("]")
return buf.String()
}
//coordinate string
func coordStr(pt []float64) string {
return math.FloatToString(pt[X]) + " " + math.FloatToString(pt[Y])
}
//coordinate string
func coordStr3D(pt []float64) string {
return math.FloatToString(pt[X]) + " " + math.FloatToString(pt[Y]) + " " + math.FloatToString(pt[Z])
}