changeset 5415:4ad68ab239b7 marking-single-beam

Factored creation of default class breaks in SR import to be reused with markings, too.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 07 Jul 2021 12:01:28 +0200
parents bb402cdfe545
children 31b0e865e7a0
files pkg/imports/sr.go
diffstat 1 files changed, 10 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/imports/sr.go	Wed Jul 07 11:45:55 2021 +0200
+++ b/pkg/imports/sr.go	Wed Jul 07 12:01:28 2021 +0200
@@ -899,6 +899,15 @@
 	return shapeToPolygon(s)
 }
 
+func defaultClassBreaks(min, max float64) mesh.ClassBreaks {
+	var heights mesh.ClassBreaks
+	h := contourStepWidth * math.Ceil(min/contourStepWidth)
+	for ; h <= max; h += contourStepWidth {
+		heights = append(heights, h)
+	}
+	return heights
+}
+
 func generateIsos(
 	ctx context.Context,
 	tx *sql.Tx,
@@ -917,11 +926,7 @@
 	if err != nil {
 		feedback.Warn("Loading class breaks failed: %v", err)
 		feedback.Info("Using default class breaks")
-		heights = nil
-		h := contourStepWidth * math.Ceil(minZ/contourStepWidth)
-		for ; h <= maxZ; h += contourStepWidth {
-			heights = append(heights, h)
-		}
+		heights = defaultClassBreaks(minZ, maxZ)
 	} else {
 		heights = heights.ExtrapolateClassBreaks(minZ, maxZ)
 	}