changeset 4553:4c476d65d1bb iso-areas

Avoid the extra closing raster by directly constructing a raster with a border.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 01 Oct 2019 13:40:01 +0200
parents 7ed5a4a94efc
children 23236657b032
files cmd/isoareas/main.go
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/cmd/isoareas/main.go	Tue Oct 01 13:18:16 2019 +0200
+++ b/cmd/isoareas/main.go	Tue Oct 01 13:40:01 2019 +0200
@@ -344,7 +344,8 @@
 
 	log.Printf("raster size: (%d, %d)\n", xcells, ycells)
 
-	raster := make([]float64, xcells*ycells)
+	// Add border for closing
+	raster := make([]float64, (xcells+2)*(ycells+2))
 
 	const closed = -math.MaxFloat64
 	for i := range raster {
@@ -360,7 +361,7 @@
 	rasterRow := func() {
 		defer wg.Done()
 		for i := range rows {
-			pos := i * xcells
+			pos := (i+1)*(xcells+2) + 1
 			row := raster[pos : pos+xcells]
 			//log.Printf("len: %d\n", len(row))
 			py := min.Y + float64(i)*cellSize + cellSize/2
@@ -392,7 +393,7 @@
 	log.Printf("Rasterizing took %v.\n", time.Since(start))
 
 	start = time.Now()
-	cm := contourmap.FromFloat64s(xcells, ycells, raster).Closed()
+	cm := contourmap.FromFloat64s(xcells+2, ycells+2, raster)
 
 	start = time.Now()