Mercurial > gemma
annotate pkg/octree/vertex.go @ 959:6ab012d0f0c2
Started with writing an importer job for sounding results.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 16 Oct 2018 18:20:50 +0200 |
parents | be7b83638ec8 |
children | a4fe07a21ba7 |
rev | line source |
---|---|
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
1 package octree |
674
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
2 |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
3 import ( |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
4 "bytes" |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
5 "encoding/binary" |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
6 "io" |
795
bd5f38eb6153
Vertical Triangle intersection: Fixed function to determine where intersection point
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
792
diff
changeset
|
7 "log" |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
8 "math" |
768
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
9 "sort" |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
10 ) |
674
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
11 |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
12 type ( |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
13 Vertex struct { |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
14 X float64 |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
15 Y float64 |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
16 Z float64 |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
17 } |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
18 |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
19 Triangle [3]Vertex |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
20 |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
21 Line [2]Vertex |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
22 |
959
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
23 MultiPointZ []Vertex |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
24 LineStringZ []Vertex |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
25 MultiLineStringZ []LineStringZ |
774
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
26 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
27 Box2D struct { |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
28 X1 float64 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
29 Y1 float64 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
30 X2 float64 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
31 Y2 float64 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
32 } |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
33 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
34 Plane2D struct { |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
35 A float64 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
36 B float64 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
37 C float64 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
38 } |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
39 ) |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
40 |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
41 const ( |
959
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
42 wkbNDR byte = 1 |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
43 |
925
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
44 wkbLineString uint32 = 2 |
959
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
45 wkbMultiLineString uint32 = 5 |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
46 wkbPointZ uint32 = 1000 + 1 |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
47 wkbLineStringZ uint32 = 1000 + 2 |
959
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
48 wkbMultiPointZ uint32 = 1000 + 4 |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
49 wkbMultiLineStringZ uint32 = 1000 + 5 |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
50 ) |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
51 |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
52 func (v *Vertex) Minimize(w Vertex) { |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
53 if w.X < v.X { |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
54 v.X = w.X |
674
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
55 } |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
56 if w.Y < v.Y { |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
57 v.Y = w.Y |
674
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
58 } |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
59 if w.Z < v.Z { |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
60 v.Z = w.Z |
674
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
61 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
62 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
63 |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
64 func (v *Vertex) Maximize(w Vertex) { |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
65 if w.X > v.X { |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
66 v.X = w.X |
674
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
67 } |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
68 if w.Y > v.Y { |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
69 v.Y = w.Y |
674
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
70 } |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
71 if w.Z > v.Z { |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
72 v.Z = w.Z |
674
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
73 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
74 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
75 |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
76 func (v Vertex) Sub(w Vertex) Vertex { |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
77 return Vertex{ |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
78 v.X - w.X, |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
79 v.Y - w.Y, |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
80 v.Z - w.Z, |
674
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
81 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
82 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
83 |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
84 func (v Vertex) Add(w Vertex) Vertex { |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
85 return Vertex{ |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
86 v.X + w.X, |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
87 v.Y + w.Y, |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
88 v.Z + w.Z, |
687
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
89 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
90 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
91 |
730
4c05bdbf8e4b
Renamed scale in Vertex to uppercase to make it public.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
729
diff
changeset
|
92 func (v Vertex) Scale(s float64) Vertex { |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
93 return Vertex{ |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
94 s * v.X, |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
95 s * v.Y, |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
96 s * v.Z, |
687
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
97 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
98 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
99 |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
100 func Interpolate(v1, v2 Vertex) func(Vertex) Vertex { |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
101 v2 = v2.Sub(v1) |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
102 return func(s Vertex) Vertex { |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
103 return Vertex{ |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
104 v2.X*s.X + v1.X, |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
105 v2.Y*s.Y + v1.Y, |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
106 v2.Z*s.Z + v1.Z, |
674
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
107 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
108 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
109 } |
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
110 |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
111 func (a Vertex) Less(b Vertex) bool { |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
112 return a.X < b.X || a.Y < b.Y || a.Z < b.Z |
674
120a82bd9953
octree: Added loading frame for contour generation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
113 } |
687
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
114 |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
115 func NewLine(p1, p2 Vertex) Line { |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
116 return Line{ |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
117 p2.Sub(p1), |
687
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
118 p1, |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
119 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
120 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
121 |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
122 func (l Line) Eval(t float64) Vertex { |
730
4c05bdbf8e4b
Renamed scale in Vertex to uppercase to make it public.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
729
diff
changeset
|
123 return l[0].Scale(t).Add(l[1]) |
687
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
124 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
125 |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
126 func (l Line) IntersectHorizontal(h float64) Vertex { |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
127 t := (h - l[1].Z) / l[0].Z |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
128 return l.Eval(t) |
687
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
129 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
130 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
131 func side(z, h float64) int { |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
132 switch { |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
133 case z < h: |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
134 return -1 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
135 case z > h: |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
136 return +1 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
137 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
138 return 0 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
139 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
140 |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
141 func (t *Triangle) IntersectHorizontal(h float64) LineStringZ { |
687
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
142 sides := [3]int{ |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
143 side(t[0].Z, h), |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
144 side(t[1].Z, h), |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
145 side(t[2].Z, h), |
687
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
146 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
147 |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
148 var points LineStringZ |
689
614135d69823
octree: prepare storing the lines to file in contouring tool.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
687
diff
changeset
|
149 |
687
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
150 for i := 0; i < 3; i++ { |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
151 j := (i + 1) % 3 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
152 si := sides[i] |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
153 sj := sides[j] |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
154 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
155 switch { |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
156 case si == 0 && sj == 0: |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
157 // both on plane |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
158 points = append(points, t[i], t[j]) |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
159 case si == 0 && sj != 0: |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
160 // first on plane |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
161 points = append(points, t[i]) |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
162 case si != 0 && sj == 0: |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
163 // second on plane |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
164 points = append(points, t[j]) |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
165 case si == sj: |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
166 // both on same side |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
167 default: |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
168 // real intersection |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
169 v := NewLine(t[i], t[j]).IntersectHorizontal(h) |
687
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
170 points = append(points, v) |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
171 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
172 } |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
173 |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
174 return points |
be90ab542aa7
octree: contouring: Do the math to calculate the intersection points of the triangles and the planes.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
674
diff
changeset
|
175 } |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
176 |
768
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
177 func linearScale(x1, y1, x2, y2 float64) func(Vertex) float64 { |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
178 dx := x2 - x1 |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
179 dy := y2 - y1 |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
180 |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
181 switch { |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
182 case dx != 0: |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
183 return func(v Vertex) float64 { |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
184 return (v.X - x1) / dx |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
185 } |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
186 case dy != 0: |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
187 return func(v Vertex) float64 { |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
188 return (v.Y - y1) / dy |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
189 } |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
190 default: |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
191 return func(Vertex) float64 { |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
192 return 0 |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
193 } |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
194 } |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
195 } |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
196 |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
197 func (ls LineStringZ) order(position func(Vertex) float64) { |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
198 type posVertex struct { |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
199 pos float64 |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
200 v Vertex |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
201 } |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
202 positions := make([]posVertex, len(ls)) |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
203 for i, v := range ls { |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
204 positions[i] = posVertex{position(v), v} |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
205 } |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
206 sort.Slice(positions, func(i, j int) bool { |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
207 return positions[i].pos < positions[j].pos |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
208 }) |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
209 for i := range positions { |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
210 ls[i] = positions[i].v |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
211 } |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
212 } |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
213 |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
214 func (v Vertex) EpsEquals(w Vertex) bool { |
769
ba2007b746ef
Fixed nasty typo.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
768
diff
changeset
|
215 const eps = 1e-5 |
768
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
216 return math.Abs(v.X-w.X) < eps && |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
217 math.Abs(v.Y-w.Y) < eps && math.Abs(v.Z-w.Z) < eps |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
218 } |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
219 |
763
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
730
diff
changeset
|
220 func (mls MultiLineStringZ) JoinOnLine(x1, y1, x2, y2 float64) MultiLineStringZ { |
768
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
221 |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
222 position := linearScale(x1, y1, x2, y2) |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
223 |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
224 type posLineString struct { |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
225 pos float64 |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
226 line LineStringZ |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
227 } |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
228 |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
229 positions := make([]posLineString, 0, len(mls)) |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
230 |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
231 for _, ls := range mls { |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
232 if len(ls) == 0 { |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
233 continue |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
234 } |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
235 // order the atoms first |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
236 ls.order(position) |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
237 positions = append(positions, posLineString{position(ls[0]), ls}) |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
238 } |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
239 |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
240 sort.Slice(positions, func(i, j int) bool { |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
241 return positions[i].pos < positions[j].pos |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
242 }) |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
243 |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
244 out := make(MultiLineStringZ, 0, len(positions)) |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
245 |
796
0cc97135717c
More fixes to vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
795
diff
changeset
|
246 var ignored int |
0cc97135717c
More fixes to vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
795
diff
changeset
|
247 |
768
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
248 for i := range positions { |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
249 curr := positions[i].line |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
250 if l := len(out); l > 0 { |
796
0cc97135717c
More fixes to vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
795
diff
changeset
|
251 last := out[l-1] |
0cc97135717c
More fixes to vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
795
diff
changeset
|
252 |
0cc97135717c
More fixes to vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
795
diff
changeset
|
253 if last[len(last)-1].EpsEquals(curr[0]) { |
768
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
254 out[l-1] = append(last[:len(last)-1], curr...) |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
255 continue |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
256 } |
796
0cc97135717c
More fixes to vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
795
diff
changeset
|
257 if position(last[len(last)-1]) > position(curr[0]) { |
0cc97135717c
More fixes to vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
795
diff
changeset
|
258 ignored++ |
0cc97135717c
More fixes to vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
795
diff
changeset
|
259 continue |
0cc97135717c
More fixes to vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
795
diff
changeset
|
260 } |
768
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
261 } |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
262 out = append(out, curr) |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
263 } |
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
264 |
796
0cc97135717c
More fixes to vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
795
diff
changeset
|
265 log.Printf("ignored parts: %d\n", ignored) |
0cc97135717c
More fixes to vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
795
diff
changeset
|
266 |
768
3219e7e34953
Join neighbored linestring segments in octree cross sections and sort them along the input line.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
763
diff
changeset
|
267 return out |
763
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
730
diff
changeset
|
268 } |
d05bc3e34338
More infrastructure for the octree driven cross section endpoint.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
730
diff
changeset
|
269 |
729
b0bd242ff821
Removed vertex duplicate.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
727
diff
changeset
|
270 func (v *Vertex) Write(w io.Writer) error { |
b0bd242ff821
Removed vertex duplicate.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
727
diff
changeset
|
271 if err := binary.Write( |
b0bd242ff821
Removed vertex duplicate.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
727
diff
changeset
|
272 w, binary.LittleEndian, math.Float64bits(v.X)); err != nil { |
b0bd242ff821
Removed vertex duplicate.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
727
diff
changeset
|
273 return err |
b0bd242ff821
Removed vertex duplicate.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
727
diff
changeset
|
274 } |
b0bd242ff821
Removed vertex duplicate.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
727
diff
changeset
|
275 if err := binary.Write( |
b0bd242ff821
Removed vertex duplicate.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
727
diff
changeset
|
276 w, binary.LittleEndian, math.Float64bits(v.Y)); err != nil { |
b0bd242ff821
Removed vertex duplicate.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
727
diff
changeset
|
277 return err |
b0bd242ff821
Removed vertex duplicate.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
727
diff
changeset
|
278 } |
b0bd242ff821
Removed vertex duplicate.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
727
diff
changeset
|
279 return binary.Write( |
b0bd242ff821
Removed vertex duplicate.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
727
diff
changeset
|
280 w, binary.LittleEndian, math.Float64bits(v.Z)) |
b0bd242ff821
Removed vertex duplicate.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
727
diff
changeset
|
281 } |
b0bd242ff821
Removed vertex duplicate.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
727
diff
changeset
|
282 |
b0bd242ff821
Removed vertex duplicate.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
727
diff
changeset
|
283 func (v *Vertex) Read(r io.Reader) error { |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
284 var buf [8]byte |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
285 b := buf[:] |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
286 if _, err := io.ReadFull(r, b); err != nil { |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
287 return nil |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
288 } |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
289 v.X = math.Float64frombits(binary.LittleEndian.Uint64(b)) |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
290 if _, err := io.ReadFull(r, b); err != nil { |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
291 return nil |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
292 } |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
293 v.Y = math.Float64frombits(binary.LittleEndian.Uint64(b)) |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
294 if _, err := io.ReadFull(r, b); err != nil { |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
295 return nil |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
296 } |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
297 v.Z = math.Float64frombits(binary.LittleEndian.Uint64(b)) |
726
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
298 return nil |
5af9ab39e715
Renamed a few types to uppercase names to prepare the move to the octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
718
diff
changeset
|
299 } |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
300 |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
301 func (mls MultiLineStringZ) AsWKB() []byte { |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
302 |
924
c8146132059e
Precalculate WKB size for MultiLineStringZ to avoid reallocations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
824
diff
changeset
|
303 // pre-calculate size to avoid reallocations. |
c8146132059e
Precalculate WKB size for MultiLineStringZ to avoid reallocations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
824
diff
changeset
|
304 size := 1 + 4 + 4 |
c8146132059e
Precalculate WKB size for MultiLineStringZ to avoid reallocations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
824
diff
changeset
|
305 for _, ml := range mls { |
c8146132059e
Precalculate WKB size for MultiLineStringZ to avoid reallocations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
824
diff
changeset
|
306 size += 1 + 4 + 4 + len(ml)*3*8 |
c8146132059e
Precalculate WKB size for MultiLineStringZ to avoid reallocations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
824
diff
changeset
|
307 } |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
308 |
924
c8146132059e
Precalculate WKB size for MultiLineStringZ to avoid reallocations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
824
diff
changeset
|
309 buf := bytes.NewBuffer(make([]byte, 0, size)) |
c8146132059e
Precalculate WKB size for MultiLineStringZ to avoid reallocations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
824
diff
changeset
|
310 |
c8146132059e
Precalculate WKB size for MultiLineStringZ to avoid reallocations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
824
diff
changeset
|
311 binary.Write(buf, binary.LittleEndian, wkbNDR) |
c8146132059e
Precalculate WKB size for MultiLineStringZ to avoid reallocations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
824
diff
changeset
|
312 binary.Write(buf, binary.LittleEndian, wkbMultiLineStringZ) |
c8146132059e
Precalculate WKB size for MultiLineStringZ to avoid reallocations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
824
diff
changeset
|
313 binary.Write(buf, binary.LittleEndian, uint32(len(mls))) |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
314 |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
315 for _, ml := range mls { |
924
c8146132059e
Precalculate WKB size for MultiLineStringZ to avoid reallocations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
824
diff
changeset
|
316 binary.Write(buf, binary.LittleEndian, wkbNDR) |
c8146132059e
Precalculate WKB size for MultiLineStringZ to avoid reallocations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
824
diff
changeset
|
317 binary.Write(buf, binary.LittleEndian, wkbLineStringZ) |
c8146132059e
Precalculate WKB size for MultiLineStringZ to avoid reallocations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
824
diff
changeset
|
318 binary.Write(buf, binary.LittleEndian, uint32(len(ml))) |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
319 for _, p := range ml { |
924
c8146132059e
Precalculate WKB size for MultiLineStringZ to avoid reallocations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
824
diff
changeset
|
320 binary.Write(buf, binary.LittleEndian, math.Float64bits(p.X)) |
c8146132059e
Precalculate WKB size for MultiLineStringZ to avoid reallocations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
824
diff
changeset
|
321 binary.Write(buf, binary.LittleEndian, math.Float64bits(p.Y)) |
c8146132059e
Precalculate WKB size for MultiLineStringZ to avoid reallocations.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
824
diff
changeset
|
322 binary.Write(buf, binary.LittleEndian, math.Float64bits(p.Z)) |
727
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
323 } |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
324 } |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
325 |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
326 return buf.Bytes() |
41c8dc61f38f
Moved octree loading stuff to octree package.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
726
diff
changeset
|
327 } |
774
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
328 |
925
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
329 func (mls MultiLineStringZ) AsWKB2D() []byte { |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
330 |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
331 // pre-calculate size to avoid reallocations. |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
332 size := 1 + 4 + 4 |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
333 for _, ml := range mls { |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
334 size += 1 + 4 + 4 + len(ml)*2*8 |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
335 } |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
336 |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
337 buf := bytes.NewBuffer(make([]byte, 0, size)) |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
338 |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
339 binary.Write(buf, binary.LittleEndian, wkbNDR) |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
340 binary.Write(buf, binary.LittleEndian, wkbMultiLineString) |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
341 binary.Write(buf, binary.LittleEndian, uint32(len(mls))) |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
342 |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
343 for _, ml := range mls { |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
344 binary.Write(buf, binary.LittleEndian, wkbNDR) |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
345 binary.Write(buf, binary.LittleEndian, wkbLineString) |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
346 binary.Write(buf, binary.LittleEndian, uint32(len(ml))) |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
347 for _, p := range ml { |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
348 binary.Write(buf, binary.LittleEndian, math.Float64bits(p.X)) |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
349 binary.Write(buf, binary.LittleEndian, math.Float64bits(p.Y)) |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
350 } |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
351 } |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
352 |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
353 return buf.Bytes() |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
354 } |
15bf101e1522
Send 2D X/Y vertices to the database directly instead of sending 3D data and dropping the Z value afterwards.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
924
diff
changeset
|
355 |
928
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
356 // Join joins two lines leaving the first of the secoung out. |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
357 func (ls LineStringZ) Join(other LineStringZ) LineStringZ { |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
358 nline := make(LineStringZ, len(ls)+len(other)-1) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
359 copy(nline, ls) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
360 copy(nline[len(ls):], other[1:]) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
361 return nline |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
362 } |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
363 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
364 func (mls MultiLineStringZ) Merge() MultiLineStringZ { |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
365 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
366 var out MultiLineStringZ |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
367 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
368 min := Vertex{math.MaxFloat64, math.MaxFloat64, math.MaxFloat64} |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
369 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
370 for _, line := range mls { |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
371 for _, v := range line { |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
372 min.Minimize(v) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
373 } |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
374 } |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
375 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
376 type point struct { |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
377 x int64 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
378 y int64 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
379 } |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
380 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
381 const precision = 1e7 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
382 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
383 quant := func(v Vertex) point { |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
384 return point{ |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
385 x: int64(math.Round((v.X - min.X) * precision)), |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
386 y: int64(math.Round((v.Y - min.Y) * precision)), |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
387 } |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
388 } |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
389 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
390 heads := make(map[point]*[]LineStringZ) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
391 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
392 for _, line := range mls { |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
393 if len(line) < 2 { |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
394 out = append(out, line) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
395 continue |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
396 } |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
397 head := quant(line[0]) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
398 tail := quant(line[len(line)-1]) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
399 if head == tail { // its already a ring |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
400 out = append(out, line) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
401 continue |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
402 } |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
403 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
404 if hs := heads[tail]; hs != nil { |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
405 l := len(*hs) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
406 last := (*hs)[l-1] |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
407 if l == 1 { |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
408 delete(heads, tail) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
409 } else { |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
410 (*hs)[l-1] = nil |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
411 *hs = (*hs)[:l-1] |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
412 } |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
413 line = line.Join(last) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
414 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
415 if head == quant(line[len(line)-1]) { // its a ring |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
416 out = append(out, line) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
417 continue |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
418 } |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
419 } |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
420 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
421 if hs := heads[head]; hs != nil { |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
422 *hs = append(*hs, line) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
423 } else { |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
424 heads[head] = &[]LineStringZ{line} |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
425 } |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
426 } |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
427 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
428 again: |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
429 for head, lines := range heads { |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
430 for i, line := range *lines { |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
431 tail := quant(line[len(line)-1]) |
940
be7b83638ec8
Simplified line merging in generating contour lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
928
diff
changeset
|
432 for hs := heads[tail]; hs != nil && len(*hs) > 0; hs = heads[tail] { |
928
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
433 l := len(*hs) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
434 last := (*hs)[l-1] |
940
be7b83638ec8
Simplified line merging in generating contour lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
928
diff
changeset
|
435 (*hs)[l-1] = nil |
be7b83638ec8
Simplified line merging in generating contour lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
928
diff
changeset
|
436 *hs = (*hs)[:l-1] |
928
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
437 line = line.Join(last) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
438 |
940
be7b83638ec8
Simplified line merging in generating contour lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
928
diff
changeset
|
439 if tail = quant(line[len(line)-1]); head == tail { // its a ring |
928
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
440 out = append(out, line) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
441 // remove from current lines |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
442 copy((*lines)[i:], (*lines)[i+1:]) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
443 (*lines)[len(*lines)-1] = nil |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
444 *lines = (*lines)[:len(*lines)-1] |
940
be7b83638ec8
Simplified line merging in generating contour lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
928
diff
changeset
|
445 goto again |
928
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
446 } |
940
be7b83638ec8
Simplified line merging in generating contour lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
928
diff
changeset
|
447 // overwrite in current lines |
be7b83638ec8
Simplified line merging in generating contour lines.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
928
diff
changeset
|
448 (*lines)[i] = line |
928
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
449 } |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
450 } |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
451 } |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
452 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
453 rings := len(out) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
454 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
455 // The rest are open line strings. |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
456 for _, lines := range heads { |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
457 for _, line := range *lines { |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
458 out = append(out, line) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
459 } |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
460 } |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
461 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
462 log.Printf("segments before/after merge: %d/%d (%d rings)\n", |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
463 len(mls), len(out), rings) |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
464 |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
465 return out |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
466 } |
0a0013fbda4a
octree2contour: Merge multi linestrings in user land before sending them to database.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
925
diff
changeset
|
467 |
774
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
468 func (a Box2D) Intersects(b Box2D) bool { |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
469 return !(a.X2 < a.X1 || a.X2 < b.X1 || |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
470 a.Y2 < a.Y1 || a.Y2 < b.Y1) |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
471 } |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
472 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
473 func (a Box2D) Mid() (float64, float64) { |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
474 return (a.X2-a.X1)*0.5 + a.X1, (a.Y2-a.Y1)*0.5 + a.Y1 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
475 } |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
476 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
477 func (a Box2D) Xi(i int) float64 { |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
478 if i == 0 { |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
479 return a.X1 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
480 } |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
481 return a.X2 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
482 } |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
483 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
484 func (a Box2D) Yi(i int) float64 { |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
485 if i == 0 { |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
486 return a.Y1 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
487 } |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
488 return a.Y2 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
489 } |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
490 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
491 func NewPlane2D(x1, y1, x2, y2 float64) Plane2D { |
778
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
492 b := x2 - x1 |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
493 a := -(y2 - y1) |
774
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
494 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
495 l := math.Sqrt(a*a + b*b) |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
496 a /= l |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
497 b /= l |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
498 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
499 // a*x1 + b*y1 + c = 0 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
500 c := -(a*x1 + b*y1) |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
501 return Plane2D{a, b, c} |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
502 } |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
503 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
504 func (p Plane2D) Eval(x, y float64) float64 { |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
505 return p.A*x + p.B*y + p.C |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
506 } |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
507 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
508 const epsPlane = 1e-5 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
509 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
510 func sides(s int, x float64) int { |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
511 if math.Signbit(x) { |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
512 return s | 2 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
513 } |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
514 return s | 1 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
515 } |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
516 |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
517 func (a Box2D) IntersectsPlane(p Plane2D) bool { |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
518 var s int |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
519 for i := 0; i < 2; i++ { |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
520 x := a.Xi(i) |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
521 for j := 0; j < 2; j++ { |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
522 y := a.Yi(j) |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
523 v := p.Eval(x, y) |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
524 if math.Abs(v) < epsPlane { |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
525 //log.Printf("on line") |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
526 return true |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
527 } |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
528 if s = sides(s, v); s == 3 { |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
529 //log.Printf("... on both sides (djt)") |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
530 return true |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
531 } |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
532 } |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
533 } |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
534 //log.Printf("side: %d\n", s) |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
535 return false |
c55771b7c502
Moved Box2D and Plane2D into vertex.go and made to API public.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
769
diff
changeset
|
536 } |
778
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
537 |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
538 func (a Vertex) Cross(b Vertex) Vertex { |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
539 return Vertex{ |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
540 a.Y*b.Z - a.Z*b.Y, |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
541 a.Z*b.X - a.X*b.Z, |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
542 a.X*b.Y - a.Y*b.X, |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
543 } |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
544 } |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
545 |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
546 func (p1 Plane2D) Intersection(p2 Plane2D) (float64, float64, bool) { |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
547 |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
548 u1 := Vertex{p1.A, p1.B, p1.C} |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
549 u2 := Vertex{p2.A, p2.B, p2.C} |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
550 |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
551 p := u1.Cross(u2) |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
552 |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
553 if p.Z == 0 { |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
554 return 0, 0, false |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
555 } |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
556 |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
557 return p.X / p.Z, p.Y / p.Z, true |
9be20bd0f131
Fixed a bug with 2d planes (lines) found while working on line intersections.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
774
diff
changeset
|
558 } |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
559 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
560 type VerticalLine struct { |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
561 x1 float64 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
562 y1 float64 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
563 x2 float64 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
564 y2 float64 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
565 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
566 line Plane2D |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
567 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
568 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
569 func NewVerticalLine(x1, y1, x2, y2 float64) *VerticalLine { |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
570 return &VerticalLine{ |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
571 x1: x1, |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
572 y1: y1, |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
573 x2: x2, |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
574 y2: y2, |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
575 line: NewPlane2D(x1, y1, x2, y2), |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
576 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
577 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
578 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
579 func onPlane(x float64) bool { return math.Abs(x) < epsPlane } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
580 |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
581 func relative(v1, v2 Vertex) func(x, y float64) float64 { |
795
bd5f38eb6153
Vertical Triangle intersection: Fixed function to determine where intersection point
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
792
diff
changeset
|
582 ls := linearScale(v1.X, v1.Y, v2.X, v2.Y) |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
583 return func(x, y float64) float64 { |
795
bd5f38eb6153
Vertical Triangle intersection: Fixed function to determine where intersection point
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
792
diff
changeset
|
584 return ls(Vertex{x, y, 0}) |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
585 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
586 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
587 |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
588 func interpolate(a, b float64) func(float64) float64 { |
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
589 return func(x float64) float64 { |
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
590 return (b-a)*x + a |
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
591 } |
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
592 } |
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
593 |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
594 func linear(v1, v2 Vertex) func(t float64) Vertex { |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
595 return func(t float64) Vertex { |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
596 return Vertex{ |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
597 (v2.X-v1.X)*t + v1.X, |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
598 (v2.Y-v1.Y)*t + v1.Y, |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
599 (v2.Z-v1.Z)*t + v1.Z, |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
600 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
601 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
602 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
603 |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
604 func inRange(a float64) bool { return 0 <= a && a <= 1 } |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
605 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
606 func (vl *VerticalLine) Intersection(t *Triangle) LineStringZ { |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
607 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
608 var out LineStringZ |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
609 |
815
01019d4c8359
Cross section: Made triangle intersection less spammy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
813
diff
changeset
|
610 //defer func() { log.Printf("length out: %d\n", len(out)) }() |
796
0cc97135717c
More fixes to vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
795
diff
changeset
|
611 |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
612 edges: |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
613 for i := 0; i < 3 && len(out) < 2; i++ { |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
614 j := (i + 1) % 3 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
615 edge := NewPlane2D(t[i].X, t[i].Y, t[j].X, t[j].Y) |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
616 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
617 s1 := edge.Eval(vl.x1, vl.y1) |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
618 s2 := edge.Eval(vl.x2, vl.y2) |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
619 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
620 o1 := onPlane(s1) |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
621 o2 := onPlane(s2) |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
622 |
815
01019d4c8359
Cross section: Made triangle intersection less spammy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
813
diff
changeset
|
623 // log.Printf("s1, s2: %t %t (%f %f)\n", o1, o2, s1, s2) |
795
bd5f38eb6153
Vertical Triangle intersection: Fixed function to determine where intersection point
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
792
diff
changeset
|
624 |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
625 switch { |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
626 case o1 && o2: |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
627 pos := relative(t[i], t[j]) |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
628 t1 := pos(vl.x1, vl.y1) |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
629 t2 := pos(vl.x2, vl.y2) |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
630 |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
631 r1 := inRange(t1) |
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
632 r2 := inRange(t2) |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
633 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
634 switch { |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
635 case r1 && r2: |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
636 lin := linear(t[i], t[j]) |
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
637 out = append(out, lin(t1), lin(t2)) |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
638 return out |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
639 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
640 case !r1 && !r2: // the hole edge |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
641 out = append(out, t[i], t[j]) |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
642 return out |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
643 case !r1: |
789
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
644 if t1 < 0 { |
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
645 // below first -> clip by first |
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
646 lin := linear(t[i], t[j]) |
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
647 out = append(out, t[i], lin(t2)) |
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
648 } else { |
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
649 // above second -> clip by second |
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
650 lin := linear(t[i], t[j]) |
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
651 out = append(out, lin(t2), t[j]) |
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
652 } |
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
653 return out |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
654 case !r2: |
789
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
655 if t2 < 0 { |
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
656 // below first -> clip by first |
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
657 lin := linear(t[i], t[j]) |
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
658 out = append(out, t[i], lin(t1)) |
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
659 } else { |
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
660 // above second -> clip by second |
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
661 lin := linear(t[i], t[j]) |
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
662 out = append(out, lin(t1), t[j]) |
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
663 } |
d43e61044ad8
Fill in last remaining corner cases in vertical triangle interpolation.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
788
diff
changeset
|
664 return out |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
665 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
666 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
667 case o1: |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
668 t1 := relative(t[i], t[j])(vl.x1, vl.y1) |
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
669 if !inRange(t1) { |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
670 continue edges |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
671 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
672 out = append(out, linear(t[i], t[j])(t1)) |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
673 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
674 case o2: |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
675 t2 := relative(t[i], t[j])(vl.x2, vl.y2) |
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
676 if !inRange(t2) { |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
677 continue edges |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
678 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
679 out = append(out, linear(t[i], t[j])(t2)) |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
680 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
681 default: |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
682 x, y, intersects := vl.line.Intersection(edge) |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
683 if !intersects { |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
684 continue edges |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
685 } |
795
bd5f38eb6153
Vertical Triangle intersection: Fixed function to determine where intersection point
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
792
diff
changeset
|
686 |
815
01019d4c8359
Cross section: Made triangle intersection less spammy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
813
diff
changeset
|
687 // log.Println("Intersection -----------------------------") |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
688 t1 := relative(t[i], t[j])(x, y) |
815
01019d4c8359
Cross section: Made triangle intersection less spammy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
813
diff
changeset
|
689 // log.Printf("relative pos: %f\n", t1) |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
690 if !inRange(t1) { |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
691 continue edges |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
692 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
693 |
815
01019d4c8359
Cross section: Made triangle intersection less spammy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
813
diff
changeset
|
694 // log.Println("valid ***************") |
795
bd5f38eb6153
Vertical Triangle intersection: Fixed function to determine where intersection point
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
792
diff
changeset
|
695 |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
696 z := interpolate(t[j].Z, t[i].Z)(t1) |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
697 n := Vertex{x, y, z} |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
698 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
699 if math.Signbit(s1) != math.Signbit(s2) { |
815
01019d4c8359
Cross section: Made triangle intersection less spammy.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
813
diff
changeset
|
700 // log.Println("\ton different sides") |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
701 // different sides -> vertex on edge. |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
702 out = append(out, n) |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
703 } else { // same side -> inside. Find peer |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
704 if len(out) > 0 { // we already have our peer |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
705 out = append(out, n) |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
706 return out |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
707 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
708 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
709 for k := 0; k < 3; k++ { |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
710 if k == i { |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
711 continue |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
712 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
713 l := (k + 1) % 3 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
714 other := NewPlane2D(t[k].X, t[k].Y, t[l].X, t[l].Y) |
813
1a808929c2c5
Cross sections: Fixed problem that certain inputs don't deliver data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
796
diff
changeset
|
715 xo, yo, intersects := vl.line.Intersection(other) |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
716 if !intersects { |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
717 continue |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
718 } |
813
1a808929c2c5
Cross sections: Fixed problem that certain inputs don't deliver data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
796
diff
changeset
|
719 t2 := relative(t[k], t[l])(xo, yo) |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
720 if !inRange(t2) { |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
721 continue |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
722 } |
813
1a808929c2c5
Cross sections: Fixed problem that certain inputs don't deliver data.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
796
diff
changeset
|
723 zo := interpolate(t[k].Z, t[l].Z)(t2) |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
724 |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
725 m := Vertex{xo, yo, zo} |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
726 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
727 var xn, yn, xf, yf float64 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
728 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
729 // Which is nearer to current edge? |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
730 if math.Abs(s1) < math.Abs(s2) { |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
731 xn, yn = vl.x1, vl.y1 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
732 xf, yf = vl.x2, vl.y2 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
733 } else { |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
734 xn, yn = vl.x2, vl.y2 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
735 xf, yf = vl.x1, vl.y1 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
736 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
737 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
738 if onPlane(other.Eval(xn, yn)) { |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
739 // triangle intersect in only point |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
740 // treat as no intersection |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
741 break edges |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
742 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
743 |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
744 pos := relative(n, m) |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
745 |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
746 tzn := pos(xn, yn) |
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
747 tzf := pos(xf, yf) |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
748 |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
749 if !inRange(tzn) { |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
750 // if near is out of range far is, too. |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
751 return out |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
752 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
753 |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
754 lin := interpolate(n.Z, m.Z) |
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
755 |
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
756 if inRange(tzf) { |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
757 m.X = xf |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
758 m.Y = yf |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
759 m.Z = lin(tzf) |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
760 } // else m is clipping |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
761 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
762 n.X = xn |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
763 n.Y = yn |
788
9f3a4a60dc04
Cleaned up interpolation mess in vertical triangle intersection.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
787
diff
changeset
|
764 n.Z = lin(tzn) |
787
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
765 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
766 out = append(out, n, m) |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
767 return out |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
768 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
769 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
770 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
771 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
772 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
773 // supress single point touches. |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
774 if len(out) == 1 { |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
775 out = out[:0] |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
776 } |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
777 |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
778 return out |
3d927e06b92c
Triangle intersection. WIP. Currently interpolation is messed up.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
778
diff
changeset
|
779 } |
959
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
780 |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
781 func (mpz MultiPointZ) AsWKB() []byte { |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
782 size := 1 + 4 + 4 + len(mpz)*(1+4+3*8) |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
783 |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
784 buf := bytes.NewBuffer(make([]byte, 0, size)) |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
785 |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
786 binary.Write(buf, binary.LittleEndian, wkbNDR) |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
787 binary.Write(buf, binary.LittleEndian, wkbMultiPointZ) |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
788 binary.Write(buf, binary.LittleEndian, uint32(len(mpz))) |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
789 |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
790 for _, p := range mpz { |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
791 binary.Write(buf, binary.LittleEndian, wkbNDR) |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
792 binary.Write(buf, binary.LittleEndian, wkbPointZ) |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
793 binary.Write(buf, binary.LittleEndian, math.Float64bits(p.X)) |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
794 binary.Write(buf, binary.LittleEndian, math.Float64bits(p.Y)) |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
795 binary.Write(buf, binary.LittleEndian, math.Float64bits(p.Z)) |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
796 } |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
797 |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
798 return buf.Bytes() |
6ab012d0f0c2
Started with writing an importer job for sounding results.
Sascha L. Teichmann <sascha.teichmann@intevation.de>
parents:
940
diff
changeset
|
799 } |