# HG changeset patch # User Sascha L. Teichmann # Date 1569930001 -7200 # Node ID 4c476d65d1bb40799e8ca8a76fabcf28c3dc3252 # Parent 7ed5a4a94efc64e9f09453c2b5a36b541b967fc2 Avoid the extra closing raster by directly constructing a raster with a border. diff -r 7ed5a4a94efc -r 4c476d65d1bb cmd/isoareas/main.go --- 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()