Mercurial > gemma
annotate cmd/soundingresults/points.go @ 685:a8672ba9ebad octree
octree: Tighten code and dedup triangles earlier in horizontal traversal.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Wed, 19 Sep 2018 23:17:03 +0200 |
parents | bc2b7da07d60 |
children |
rev | line source |
---|---|
606
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
1 package main |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
3 import ( |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
4 "bufio" |
607
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
5 "bytes" |
606
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
6 "compress/bzip2" |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
7 "compress/gzip" |
607
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
8 "encoding/binary" |
606
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
9 "io" |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 "log" |
607
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
11 "math" |
606
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 "os" |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 "path/filepath" |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 "strconv" |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 "strings" |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 ) |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 type point3d struct { |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 x float64 |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 y float64 |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 z float64 |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 } |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 type points3d []*point3d |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 func parseXYZ(fname string) (points3d, error) { |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 f, err := os.Open(fname) |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 if err != nil { |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 return nil, err |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 } |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 defer f.Close() |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 r, err := wrap(fname, f) |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
34 if err != nil { |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
35 return nil, err |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
36 } |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
37 return readXYZ(r) |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
38 } |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
39 |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
40 func wrap(fname string, f io.Reader) (io.Reader, error) { |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
41 |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
42 switch strings.ToLower(filepath.Ext(fname)) { |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
43 case ".gz": |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
44 return gzip.NewReader(f) |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
45 case ".bz2": |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
46 return bzip2.NewReader(f), nil |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
47 } |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
48 |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
49 return bufio.NewReader(f), nil |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
50 } |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
51 |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 func readXYZ(r io.Reader) (points3d, error) { |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
54 // Alloc in larger chunks to reduce pressure on memory management. |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 var chunk []point3d |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
56 alloc := func() *point3d { |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
57 if len(chunk) == 0 { |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 chunk = make([]point3d, 8*1024) |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
59 } |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
60 p := &chunk[0] |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 chunk = chunk[1:] |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 return p |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 } |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
64 |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
65 var points points3d |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
66 |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 s := bufio.NewScanner(r) |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
68 if s.Scan() { // Skip header line. |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
69 for line := 2; s.Scan(); line++ { |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 p := alloc() |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
71 text := s.Text() |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
72 // fmt.Sscanf(text, "%f,%f,%f") is 4 times slower. |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 idx := strings.IndexByte(text, ',') |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 if idx == -1 { |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 log.Printf("format error in line %d\n", line) |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
76 continue |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
77 } |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
78 var err error |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
79 if p.x, err = strconv.ParseFloat(text[:idx], 64); err != nil { |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
80 log.Printf("format error in line %d: %v\n", line, err) |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 continue |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 } |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 text = text[idx+1:] |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
84 if idx = strings.IndexByte(text, ','); idx == -1 { |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
85 log.Printf("format error in line %d\n", line) |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
86 continue |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
87 } |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
88 if p.y, err = strconv.ParseFloat(text[:idx], 64); err != nil { |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
89 log.Printf("format error in line %d: %v\n", line, err) |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
90 continue |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
91 } |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
92 text = text[idx+1:] |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
93 if p.z, err = strconv.ParseFloat(text, 64); err != nil { |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
94 log.Printf("format error in line %d: %v\n", line, err) |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
95 continue |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
96 } |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
97 points = append(points, p) |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
98 } |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
99 } |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
100 |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
101 return points, s.Err() |
e6d95e6d232b
Sounding results: Moved point handling stuff to separate file.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
102 } |
607
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
103 |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
104 const ( |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
105 wkbNDR byte = 1 |
608
bc2b7da07d60
Sounding results: Use correct codes for multipointZ in WKB encoding.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
607
diff
changeset
|
106 wkbPointZ uint32 = 1 + 1000 |
bc2b7da07d60
Sounding results: Use correct codes for multipointZ in WKB encoding.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
607
diff
changeset
|
107 wkbMultiPointZ uint32 = 4 + 1000 |
607
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
108 ) |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
109 |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
110 func (ps points3d) asWKB() string { |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
111 |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
112 size := 1 + 4 + 4 + len(ps)*(1+4+3*8) |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
113 |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
114 buf := bytes.NewBuffer(make([]byte, 0, size)) |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
115 |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
116 binary.Write(buf, binary.LittleEndian, wkbNDR) |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
117 binary.Write(buf, binary.LittleEndian, wkbMultiPointZ) |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
118 binary.Write(buf, binary.LittleEndian, uint32(len(ps))) |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
119 |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
120 for _, p := range ps { |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
121 binary.Write(buf, binary.LittleEndian, wkbNDR) |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
122 binary.Write(buf, binary.LittleEndian, wkbPointZ) |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
123 binary.Write(buf, binary.LittleEndian, math.Float64bits(p.x)) |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
124 binary.Write(buf, binary.LittleEndian, math.Float64bits(p.y)) |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
125 binary.Write(buf, binary.LittleEndian, math.Float64bits(p.z)) |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
126 } |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
127 |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
128 return buf.String() |
21f1f03a8a39
Sounding results: Added simple WKB encoder for points3d.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
606
diff
changeset
|
129 } |