Skip to content

Commit

Permalink
Optimise fromSegments funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
pomadchin committed Jul 26, 2017
1 parent d952665 commit a1ee681
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,11 @@ abstract class GeoTiffMultibandTile(
def toArrayTile(): ArrayMultibandTile =
ArrayMultibandTile(bands.map(_.toArrayTile): _*)

/*def fromSegments(ids: Traversable[Int]): ArrayMultibandTile =
ArrayMultibandTile((0 until bandCount).map(i => band(i).fromSegments(ids)))*/

def fromSegments(ids: Traversable[Int]): ArrayMultibandTile =
ArrayMultibandTile(bandsFromSegments(ids): _*)
ArrayMultibandTile(bandsFromSegments(ids).map(_.toArrayTile): _*)

/**
* Performs a crop on itself. The returned MultibandGeoTiffTile will
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,8 @@ abstract class GeoTiffTile(
}

def fromSegments(ids: Traversable[Int]): ArrayTile = {
val gb = ids.map(segmentLayout.getGridBounds(_)).reduce(_ combine _)
val (cols, rows) = gb.width -> gb.height
val tile = ArrayTile.empty(cellType, cols, rows)

getSegments(ids).foreach { case (segmentId, segment) =>
Expand Down

0 comments on commit a1ee681

Please sign in to comment.