Skip to content

Commit

Permalink
Add GeoTiffSegmentLayout.intersectingSegments
Browse files Browse the repository at this point in the history
  • Loading branch information
echeipesh committed Dec 9, 2016
1 parent e0cac50 commit 1ca071e
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ case class GeoTiffSegmentLayout(totalCols: Int, totalRows: Int, tileLayout: Tile
* Generate layout for cropped a cropped region of this raster.
* Preserves the structure of parent layout as best possible,
* using same storageMethod and segment size.
*
* @param bounds Pixel bounds inside the current segment layout
*/
def crop(bounds: GridBounds): GeoTiffSegmentLayout = {
if(isTiled) {
Expand All @@ -212,6 +214,19 @@ case class GeoTiffSegmentLayout(totalCols: Int, totalRows: Int, tileLayout: Tile
GeoTiffSegmentLayout(bounds.width, bounds.height, newLayout, isTiled = false)
}
}

/** Returns all segment indices which intersect given pixel grid bounds */
def intersectingSegments(bounds: GridBounds): Array[Int] = {
val tc = tileLayout.tileCols
val tr = tileLayout.tileRows
val ab = ArrayBuffer[Int]()
for (layoutCol <- (bounds.colMin / tc) to (bounds.colMax / tc)) {
for (layoutRow <- (bounds.rowMin / tr) to (bounds.rowMax / tr)) {
ab += (layoutRow * tileLayout.layoutCols) + layoutCol
}
}
ab.toArray
}
}

/**
Expand Down

0 comments on commit 1ca071e

Please sign in to comment.