diff pkg/octree/areas.go @ 4640:fb09a43b062e

Decouple the tracing of the iso areas from the octree data structure.
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 11 Oct 2019 20:09:37 +0200
parents 82029885c11b
children 3eda5a7215ab
line wrap: on
line diff
--- a/pkg/octree/areas.go	Fri Oct 11 20:00:06 2019 +0200
+++ b/pkg/octree/areas.go	Fri Oct 11 20:09:37 2019 +0200
@@ -26,11 +26,12 @@
 	"gemma.intevation.de/gemma/pkg/wkb"
 )
 
-func (tree *Tree) TraceAreas(
+func TraceAreas(
 	heights []float64,
 	cellSize float64,
+	min, max Vertex,
+	eval func(float64, float64) (float64, bool),
 ) []wkb.MultiPolygonGeom {
-	min, max := tree.Min, tree.Max
 
 	width := max.X - min.X
 	height := max.Y - min.Y
@@ -73,19 +74,19 @@
 				var n int
 				var sum float64
 
-				if v, ok := tree.Value(px-quat, y1); ok {
+				if v, ok := eval(px-quat, y1); ok {
 					sum = v
 					n = 1
 				}
-				if v, ok := tree.Value(px-quat, y2); ok {
+				if v, ok := eval(px-quat, y2); ok {
 					sum += v
 					n++
 				}
-				if v, ok := tree.Value(px+quat, y1); ok {
+				if v, ok := eval(px+quat, y1); ok {
 					sum += v
 					n++
 				}
-				if v, ok := tree.Value(px+quat, y2); ok {
+				if v, ok := eval(px+quat, y2); ok {
 					sum += v
 					n++
 				}