diff pkg/imports/sr.go @ 1184:064d44ccc6f2

Adjust contour lines heights to multiples of step width As the step width is currently 0.1 m, this gives one contour line at each whole-number decimeter of depth.
author Tom Gottfried <tom@intevation.de>
date Thu, 15 Nov 2018 17:32:40 +0100
parents 930fdd8b474f
children 58acc343b1b6
line wrap: on
line diff
--- a/pkg/imports/sr.go	Thu Nov 15 16:33:12 2018 +0100
+++ b/pkg/imports/sr.go	Thu Nov 15 17:32:40 2018 +0100
@@ -24,6 +24,7 @@
 	"errors"
 	"fmt"
 	"io"
+	"math"
 	"os"
 	"path"
 	"path/filepath"
@@ -441,7 +442,14 @@
 	}
 	defer stmt.Close()
 
-	octree.DoContours(tree, contourStepWidth, func(res *octree.ContourResult) {
+	// Adjust contour lines heights to multiples of contourStepWidth
+	heights := make([]float64, 0)
+	h := contourStepWidth * math.Ceil(tree.Min.Z/contourStepWidth)
+	for ; h <= tree.Max.Z; h += contourStepWidth {
+		heights = append(heights, h)
+	}
+
+	octree.DoContours(tree, heights, func(res *octree.ContourResult) {
 		if err == nil {
 			_, err = stmt.Exec(
 				id, res.Height, tree.EPSG,