comparison 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
comparison
equal deleted inserted replaced
4639:4380f5483c03 4640:fb09a43b062e
24 24
25 "gemma.intevation.de/gemma/pkg/common" 25 "gemma.intevation.de/gemma/pkg/common"
26 "gemma.intevation.de/gemma/pkg/wkb" 26 "gemma.intevation.de/gemma/pkg/wkb"
27 ) 27 )
28 28
29 func (tree *Tree) TraceAreas( 29 func TraceAreas(
30 heights []float64, 30 heights []float64,
31 cellSize float64, 31 cellSize float64,
32 min, max Vertex,
33 eval func(float64, float64) (float64, bool),
32 ) []wkb.MultiPolygonGeom { 34 ) []wkb.MultiPolygonGeom {
33 min, max := tree.Min, tree.Max
34 35
35 width := max.X - min.X 36 width := max.X - min.X
36 height := max.Y - min.Y 37 height := max.Y - min.Y
37 38
38 log.Printf("info: Width/Height: %.2f / %.2f\n", width, height) 39 log.Printf("info: Width/Height: %.2f / %.2f\n", width, height)
71 y2 := py + quat 72 y2 := py + quat
72 for j := range row { 73 for j := range row {
73 var n int 74 var n int
74 var sum float64 75 var sum float64
75 76
76 if v, ok := tree.Value(px-quat, y1); ok { 77 if v, ok := eval(px-quat, y1); ok {
77 sum = v 78 sum = v
78 n = 1 79 n = 1
79 } 80 }
80 if v, ok := tree.Value(px-quat, y2); ok { 81 if v, ok := eval(px-quat, y2); ok {
81 sum += v 82 sum += v
82 n++ 83 n++
83 } 84 }
84 if v, ok := tree.Value(px+quat, y1); ok { 85 if v, ok := eval(px+quat, y1); ok {
85 sum += v 86 sum += v
86 n++ 87 n++
87 } 88 }
88 if v, ok := tree.Value(px+quat, y2); ok { 89 if v, ok := eval(px+quat, y2); ok {
89 sum += v 90 sum += v
90 n++ 91 n++
91 } 92 }
92 93
93 if n > 0 { 94 if n > 0 {