diff cmd/octreediff/main.go @ 2576:647a58ee9ae9

Morphological differences: Centralized generation of height values for differences in octree package.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Mon, 11 Mar 2019 15:04:23 +0100
parents 59e7a011d347
children 5c6a7e69b02d
line wrap: on
line diff
--- a/cmd/octreediff/main.go	Mon Mar 11 14:50:04 2019 +0100
+++ b/cmd/octreediff/main.go	Mon Mar 11 15:04:23 2019 +0100
@@ -254,33 +254,7 @@
 
 		log.Printf("min/max: %f %f\n", tree.Min.Z, tree.Max.Z)
 
-		var heights []float64
-
-		switch {
-		case tree.Min.Z >= 0: // All values positive.
-			for v := 0.0; v <= tree.Max.Z; v += 0.1 {
-				if v >= tree.Min.Z {
-					heights = append(heights, v)
-				}
-			}
-		case tree.Max.Z <= 0: // All values negative.
-			for v := 0.0; v >= tree.Min.Z; v -= 0.1 {
-				if v <= tree.Max.Z {
-					heights = append(heights, v)
-				}
-			}
-		default: // Positive and negative.
-			for v := 0.1; v <= tree.Max.Z; v += 0.1 {
-				heights = append(heights, v)
-			}
-			for i, j := 0, len(heights)-1; i < j; i, j = i+1, j-1 {
-				heights[i], heights[j] = heights[j], heights[i]
-			}
-			for v := 0.0; v >= tree.Min.Z; v -= 0.1 {
-				heights = append(heights, v)
-			}
-		}
-
+		heights := octree.SampleDiffHeights(tree.Min.Z, tree.Max.Z, 0.1)
 		log.Printf("num heights: %d\n", len(heights))
 
 		var dataSize int