changeset 3883:0b382767b5ab

Use custom class breaks in morpho differences.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 10 Jul 2019 11:55:06 +0200
parents 37d5c4441c70
children db24b4347604
files pkg/controllers/diff.go
diffstat 1 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/controllers/diff.go	Wed Jul 10 11:45:55 2019 +0200
+++ b/pkg/controllers/diff.go	Wed Jul 10 11:55:06 2019 +0200
@@ -248,10 +248,6 @@
 
 	log.Printf("info: min/max: %f %f\n", tree.Min.Z, tree.Max.Z)
 
-	heights := octree.SampleDiffHeights(
-		tree.Min.Z, tree.Max.Z, contourStep)
-	log.Printf("info: num heights: %d\n", len(heights))
-
 	start = time.Now()
 
 	// XXX: Maybe we should start this transaction earlier!?
@@ -261,6 +257,22 @@
 	}
 	defer tx.Rollback()
 
+	var heights []float64
+
+	heights, err = octree.LoadClassBreaks(
+		ctx, tx,
+		"morphology_classbreaks_compare")
+	if err != nil {
+		log.Printf("warn: Loading class breaks failed: %v\n", err)
+		heights = octree.SampleDiffHeights(
+			tree.Min.Z, tree.Max.Z, contourStep)
+	} else {
+		heights = octree.ExtrapolateClassBreaks(heights, tree.Min.Z, tree.Max.Z)
+		heights = octree.InBetweenClassBreaks(heights, 0.05, 2)
+	}
+
+	log.Printf("info: num heights: %d\n", len(heights))
+
 	var stmt *sql.Stmt
 	if stmt, err = tx.PrepareContext(ctx, insertDiffContourSQL); err != nil {
 		return