Skip to content

Commit 725c9d5

Browse files
committed
TileRasterizerAggregate expects column in rf_raster_proj order
This is a change but it's towards less surprising
1 parent 285e03d commit 725c9d5

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

core/src/main/scala/org/locationtech/rasterframes/expressions/aggregates/TileRasterizerAggregate.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
*/
2121

2222
package org.locationtech.rasterframes.expressions.aggregates
23-
2423
import geotrellis.layer._
2524
import geotrellis.proj4.CRS
2625
import geotrellis.raster.reproject.Reproject
@@ -48,6 +47,7 @@ class TileRasterizerAggregate(prd: ProjectedRasterDefinition) extends Aggregator
4847
override def zero: MutableArrayTile = ArrayTile.empty(prd.destinationCellType, prd.totalCols, prd.totalRows)
4948

5049
override def reduce(b: Tile, a: ProjectedRasterTile): Tile = {
50+
// TODO: this is not right, got to use dynamic reprojection for this extent
5151
val localExtent = a.extent.reproject(a.crs, prd.destinationCRS)
5252
if (prd.destinationExtent.intersects(localExtent)) {
5353
val localTile = a.tile.reproject(a.extent, a.crs, prd.destinationCRS, projOpts)
@@ -81,13 +81,13 @@ object TileRasterizerAggregate {
8181
}
8282
}
8383

84-
def apply(prd: ProjectedRasterDefinition, crsCol: Column, extentCol: Column, tileCol: Column): TypedColumn[Any, Tile] = {
84+
def apply(prd: ProjectedRasterDefinition, tileCol: Column, extentCol: Column, crsCol: Column): TypedColumn[Any, Tile] = {
8585
if (prd.totalCols.toDouble * prd.totalRows * 64.0 > Runtime.getRuntime.totalMemory() * 0.5)
8686
logger.warn(
8787
s"You've asked for the construction of a very large image (${prd.totalCols} x ${prd.totalRows}). Out of memory error likely.")
8888

8989
udaf(new TileRasterizerAggregate(prd))
90-
.apply(crsCol, extentCol, tileCol)
90+
.apply(tileCol, extentCol, crsCol)
9191
.as("rf_agg_overview_raster")
9292
.as[Tile]
9393
}

core/src/main/scala/org/locationtech/rasterframes/functions/AggregateFunctions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ trait AggregateFunctions {
108108
*/
109109
def rf_agg_overview_raster(tile: Column, tileExtent: Column, tileCRS: Column, cols: Int, rows: Int, areaOfInterest: Extent, sampler: ResampleMethod): TypedColumn[Any, Tile] = {
110110
val params = ProjectedRasterDefinition(cols, rows, IntConstantNoDataCellType, WebMercator, areaOfInterest, sampler)
111-
TileRasterizerAggregate(params, tileCRS, tileExtent, tile)
111+
TileRasterizerAggregate(params, tile, tileExtent, tileCRS)
112112
}
113113

114114
import org.apache.spark.sql.functions._

core/src/test/scala/org/locationtech/rasterframes/RasterJoinSpec.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class RasterJoinSpec extends TestEnvironment with TestData with RasterMatchers {
8181
// create a Raster from tile2 which should be almost equal to b4nativeTif
8282
val agg = joined.agg(TileRasterizerAggregate(
8383
ProjectedRasterDefinition(b4nativeTif.cols, b4nativeTif.rows, b4nativeTif.cellType, b4nativeTif.crs, b4nativeTif.extent, Bilinear),
84-
$"crs", $"extent", $"tile2") as "raster"
84+
$"tile2", $"extent", $"crs") as "raster"
8585
).select(col("raster").as[Tile])
8686

8787
val raster = Raster(agg.first(), srcExtent)

0 commit comments

Comments
 (0)