Skip to content

Commit

Permalink
Use GridBounds.sizeLong
Browse files Browse the repository at this point in the history
  • Loading branch information
James McClain authored and echeipesh committed Oct 11, 2017
1 parent 4796038 commit a4d4a70
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
Expand Up @@ -213,7 +213,6 @@ object S3GeoTiffRDD extends LazyLogging {

RasterReader
.listWindows(cols, rows, options.maxTileSize.getOrElse(1<<10), layout.tileCols, layout.tileRows)
._3
.map((objectRequest, _))
}

Expand Down
Expand Up @@ -80,15 +80,16 @@ private [geotrellis] trait GeoTiffInfoReader extends LazyLogging {
case DoubleCellType | DoubleConstantNoDataCellType | DoubleUserDefinedNoDataCellType(_) => 8
}
}
val (tileCols, tileRows, fileWindows) =
val fileWindows =
RasterReader.listWindows(cols, rows, maxSize, segCols, segRows)
val windowBytes = tileCols * tileRows * depth

var currentBytes = 0
var currentBytes: Long = 0
val currentPartition = mutable.ArrayBuffer.empty[GridBounds]
val allPartitions = mutable.ArrayBuffer.empty[Array[GridBounds]]

fileWindows.foreach({ gb =>
val windowBytes = gb.sizeLong * depth

// Add the window to the present partition
if (currentBytes + windowBytes <= partitionBytes) {
currentPartition.append(gb)
Expand Down
4 changes: 2 additions & 2 deletions spark/src/main/scala/geotrellis/spark/io/RasterReader.scala
Expand Up @@ -74,12 +74,12 @@ object RasterReader {
def listWindows(
cols: Int, rows: Int, maxSize: Int,
segCols: Int, segRows: Int
): (Int, Int, Array[GridBounds]) = {
): Array[GridBounds] = {
val colSize: Int = if (maxSize >= segCols) segCols; else best(maxSize, segCols)
val rowSize: Int = if (maxSize >= segRows) segRows; else best(maxSize, segRows)
val windows = listWindows(cols, rows, colSize, rowSize)

(colSize, rowSize, windows)
windows
}

/** List all pixel windows that cover a grid of given size */
Expand Down
Expand Up @@ -184,7 +184,6 @@ object HadoopGeoTiffRDD extends LazyLogging {

RasterReader
.listWindows(cols, rows, options.maxTileSize.getOrElse(1<<10), layout.tileCols, layout.tileRows)
._3
.map((objectRequest, _))
}

Expand Down

0 comments on commit a4d4a70

Please sign in to comment.