Skip to content

Commit 7345251

Browse files
committed
Evaluated removal of FixedDelegationTile, created (ignored) test
to verify behavior, and filed locationtech/geotrellis#3153.
1 parent 9a4f156 commit 7345251

File tree

3 files changed

+55
-9
lines changed

3 files changed

+55
-9
lines changed

build.sbt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,9 @@ lazy val pyrasterframes = project
9090
spark("core").value % Provided,
9191
spark("mllib").value % Provided,
9292
spark("sql").value % Provided
93-
),
94-
Test / test := (Test / test).dependsOn(experimental / Test / test).value
93+
)
9594
)
9695

97-
9896
lazy val datasource = project
9997
.configs(IntegrationTest)
10098
.settings(Defaults.itSettings)
@@ -107,7 +105,6 @@ lazy val datasource = project
107105
spark("mllib").value % Provided,
108106
spark("sql").value % Provided
109107
),
110-
Test / test := (Test / test).dependsOn(core / Test / test).value,
111108
initialCommands in console := (initialCommands in console).value +
112109
"""
113110
|import org.locationtech.rasterframes.datasource.geotrellis._
@@ -129,8 +126,7 @@ lazy val experimental = project
129126
spark("sql").value % Provided
130127
),
131128
fork in IntegrationTest := true,
132-
javaOptions in IntegrationTest := Seq("-Xmx2G"),
133-
Test / test := (Test / test).dependsOn(datasource / Test / test).value
129+
javaOptions in IntegrationTest := Seq("-Xmx2G")
134130
)
135131

136132
lazy val docs = project
@@ -171,8 +167,6 @@ lazy val docs = project
171167
addMappingsToSiteDir(Compile / paradox / mappings, paradox / siteSubdirName)
172168
)
173169

174-
//ParadoxMaterialThemePlugin.paradoxMaterialThemeSettings(Paradox)
175-
176170
lazy val bench = project
177171
.dependsOn(core % "compile->test")
178172
.settings(publish / skip := true)

core/src/main/scala/org/locationtech/rasterframes/tiles/FixedDelegatingTile.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import geotrellis.raster.{ArrayTile, DelegatingTile, Tile}
2424

2525
/**
2626
* Workaround for case where `combine` is invoked on two delegating tiles.
27+
* Remove after https://github.com/locationtech/geotrellis/issues/3153 is fixed and integrated
2728
* @since 8/22/18
2829
*/
2930
abstract class FixedDelegatingTile extends DelegatingTile {

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

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,13 @@
2222
package org.locationtech.rasterframes
2323

2424
import geotrellis.raster._
25-
import geotrellis.raster.mapalgebra.local.{Max, Min}
25+
import geotrellis.raster.mapalgebra.local.{Add, Max, Min}
2626
import geotrellis.spark._
2727
import org.apache.spark.sql.Column
2828
import org.apache.spark.sql.functions._
2929
import org.locationtech.rasterframes.TestData.randomTile
3030
import org.locationtech.rasterframes.stats.CellHistogram
31+
import org.locationtech.rasterframes.util.DataBiasedOp.BiasedAdd
3132

3233
/**
3334
* Test rig associated with computing statistics and other descriptive
@@ -318,6 +319,56 @@ class TileStatsSpec extends TestEnvironment with TestData {
318319
val ndCount2 = ndTiles.select("*").where(rf_is_no_data_tile($"tiles")).count()
319320
ndCount2 should be(count + 1)
320321
}
322+
323+
// Awaiting https://github.com/locationtech/geotrellis/issues/3153 to be fixed and integrated
324+
ignore("should allow NoData algebra to be changed via delegating tile") {
325+
val t1 = ArrayTile(Array.fill(4)(1), 2, 2)
326+
val t2 = {
327+
val d = Array.fill(4)(2)
328+
d(1) = geotrellis.raster.NODATA
329+
ArrayTile(d, 2, 2)
330+
}
331+
332+
val d1 = new DelegatingTile {
333+
override def delegate: Tile = t1
334+
}
335+
val d2 = new DelegatingTile {
336+
override def delegate: Tile = t2
337+
}
338+
339+
/** Counts the number of non-NoData cells in a tile */
340+
case object CountData {
341+
def apply(t: Tile) = {
342+
var count: Long = 0
343+
t.dualForeach(
344+
z if(isData(z)) count = count + 1
345+
) (
346+
z if(isData(z)) count = count + 1
347+
)
348+
count
349+
}
350+
}
351+
352+
// Confirm counts
353+
CountData(t1) should be (4L)
354+
CountData(t2) should be (3L)
355+
CountData(d1) should be (4L)
356+
CountData(d2) should be (3L)
357+
358+
// Standard Add evaluates `x + NoData` as `NoData`
359+
CountData(Add(t1, t2)) should be (3L)
360+
CountData(Add(d1, d2)) should be (3L)
361+
// Is commutative
362+
CountData(Add(t2, t1)) should be (3L)
363+
CountData(Add(d2, d1)) should be (3L)
364+
365+
// With BiasedAdd, all cells should be data cells
366+
CountData(BiasedAdd(t1, t2)) should be (4L) // <-- passes
367+
CountData(BiasedAdd(d1, d2)) should be (4L) // <-- fails
368+
// Should be commutative.
369+
CountData(BiasedAdd(t2, t1)) should be (4L) // <-- passes
370+
CountData(BiasedAdd(d2, d1)) should be (4L) // <-- fails
371+
}
321372
}
322373

323374
describe("proj_raster handling") {

0 commit comments

Comments
 (0)