Mercurial > gemma
changeset 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 | 1d4801145a2d |
children | 7e6fce79ddc8 |
files | pkg/imports/sr.go pkg/octree/contours.go |
diffstat | 2 files changed, 12 insertions(+), 4 deletions(-) [+] |
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,
--- a/pkg/octree/contours.go Thu Nov 15 16:33:12 2018 +0100 +++ b/pkg/octree/contours.go Thu Nov 15 17:32:40 2018 +0100 @@ -55,11 +55,11 @@ cr.cond.Signal() } -func DoContours(tree *Tree, step float64, store func(*ContourResult)) { +func DoContours(tree *Tree, heights []float64, store func(*ContourResult)) { var contours []*ContourResult - for h := tree.Min.Z; h <= tree.Max.Z; h += step { - contours = append(contours, NewContorResult(h)) + for i := 0; i < len(heights); i++ { + contours = append(contours, NewContorResult(heights[i])) } jobs := make(chan *ContourResult)