changeset 4746:5e0041fd3cba

Round height values of extrapolated classbreaks to four place behind the dot.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 18 Oct 2019 13:48:20 +0200
parents aecba7e66301
children b1428b44e43f
files pkg/octree/classbreaks.go
diffstat 1 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/octree/classbreaks.go	Fri Oct 18 13:13:24 2019 +0200
+++ b/pkg/octree/classbreaks.go	Fri Oct 18 13:48:20 2019 +0200
@@ -98,6 +98,10 @@
 	return ParseClassBreaks(config.String)
 }
 
+func round(v float64) float64 {
+	return math.Round(v*10000) / 10000
+}
+
 func ExtrapolateClassBreaks(cbs []float64, min, max float64) []float64 {
 	if min > max {
 		min, max = max, min
@@ -129,7 +133,7 @@
 			break
 		}
 		m := make([]float64, len(n)+1)
-		m[0] = n[0] - diff
+		m[0] = round(n[0] - diff)
 		copy(m[1:], n)
 		n = m
 	}
@@ -139,7 +143,7 @@
 		if diff == 0 {
 			break
 		}
-		n = append(n, n[len(n)-1]+diff)
+		n = append(n, round(n[len(n)-1]+diff))
 	}
 
 	return n