From 3f378cadcf93bab40460ebe546d20986969229fb Mon Sep 17 00:00:00 2001 From: Shannon Noe Date: Tue, 28 Feb 2017 10:20:51 -0600 Subject: [PATCH 1/2] Tile columns cannot be zero when rounding --- raster/src/main/scala/geotrellis/raster/GridExtent.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/raster/src/main/scala/geotrellis/raster/GridExtent.scala b/raster/src/main/scala/geotrellis/raster/GridExtent.scala index 99098a8df9..43f60fb2e5 100644 --- a/raster/src/main/scala/geotrellis/raster/GridExtent.scala +++ b/raster/src/main/scala/geotrellis/raster/GridExtent.scala @@ -41,8 +41,8 @@ class GridExtent(val extent: Extent, val cellwidth: Double, val cellheight: Doub * types. */ def toRasterExtent(): RasterExtent = { - val targetCols = math.round(extent.width / cellwidth).toLong - val targetRows = math.round(extent.height / cellheight).toLong + val targetCols = 1L.max(math.round(extent.width / cellwidth).toLong) + val targetRows = 1L.max(math.round(extent.height / cellheight).toLong) if(targetCols > Int.MaxValue) { throw new GeoAttrsError(s"Cannot convert GridExtent into a RasterExtent: number of columns exceeds maximum integer value ($targetCols > ${Int.MaxValue})") } From 72010456a70422e4a2b3717be812d3ef5ce10a49 Mon Sep 17 00:00:00 2001 From: Shannon Noe Date: Tue, 28 Feb 2017 11:20:36 -0600 Subject: [PATCH 2/2] Tile columns cannot be zero when rounding --- raster/src/main/scala/geotrellis/raster/GridExtent.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/raster/src/main/scala/geotrellis/raster/GridExtent.scala b/raster/src/main/scala/geotrellis/raster/GridExtent.scala index 43f60fb2e5..2e02920c13 100644 --- a/raster/src/main/scala/geotrellis/raster/GridExtent.scala +++ b/raster/src/main/scala/geotrellis/raster/GridExtent.scala @@ -41,8 +41,8 @@ class GridExtent(val extent: Extent, val cellwidth: Double, val cellheight: Doub * types. */ def toRasterExtent(): RasterExtent = { - val targetCols = 1L.max(math.round(extent.width / cellwidth).toLong) - val targetRows = 1L.max(math.round(extent.height / cellheight).toLong) + val targetCols = math.max(1L, math.round(extent.width / cellwidth).toLong) + val targetRows = math.max(1L, math.round(extent.height / cellheight).toLong) if(targetCols > Int.MaxValue) { throw new GeoAttrsError(s"Cannot convert GridExtent into a RasterExtent: number of columns exceeds maximum integer value ($targetCols > ${Int.MaxValue})") }