diff pkg/imports/sr.go @ 4751:dbf07d0c364e

SR import: If the point density is greater than 0.2 values per meter² the interpolating step is omitted.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 18 Oct 2019 17:07:24 +0200
parents 56bd9ba0354c
children 64979fec89a7
line wrap: on
line diff
--- a/pkg/imports/sr.go	Fri Oct 18 16:04:22 2019 +0200
+++ b/pkg/imports/sr.go	Fri Oct 18 17:07:24 2019 +0200
@@ -71,6 +71,13 @@
 )
 
 const (
+	// multiBeamThreshold is the number of points m² which
+	// is assumed that greater values are indicators for
+	// an already interpolated point cloud.
+	multiBeamThreshold = 1.0 / 5.0
+)
+
+const (
 	// pointsPerSquareMeter is the average number of points
 	// when generating a artifical height model for single beam scans.
 	pointsPerSquareMeter = 2
@@ -488,6 +495,17 @@
 
 	if sr.singleBeam() {
 
+		origDensity := float64(len(xyz)) / polygonArea
+
+		feedback.Info("Boundary area: %.2fm²", polygonArea)
+		feedback.Info("Original point density: %.2f points/m²", origDensity)
+
+		if origDensity > multiBeamThreshold {
+			feedback.Warn("The density is greater than %.2f points/m².")
+			feedback.Warn("It is assumed that the data is already interpolated.")
+			goto multibeam
+		}
+
 		// Build the first mesh to generate random points on.
 
 		feedback.Info("Build virtual DEM based on original XYZ data.")
@@ -500,8 +518,6 @@
 
 		feedback.Info("Building took %v", time.Since(start))
 
-		feedback.Info("Boundary area: %.2fm²", polygonArea)
-
 		numPoints := int(math.Ceil(polygonArea * pointsPerSquareMeter))
 
 		feedback.Info("Generate %d random points for an average density of ~%d points/m².",
@@ -547,6 +563,8 @@
 		feedback.Info("Clipping triangles from new mesh.")
 	}
 
+multibeam:
+
 	start = time.Now()
 	tin = tri.Tin()
 	tin.EPSG = epsg