Skip to content

Commit b2f8d3c

Browse files
committed
Add failing unit test for mask by value on 0
Signed-off-by: Jason T. Brown <[email protected]>
1 parent b45543b commit b2f8d3c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -686,6 +686,25 @@ class RasterFunctionsSpec extends TestEnvironment with RasterMatchers {
686686
checkDocs("rf_mask_by_value")
687687
}
688688

689+
it("should mask by value for value 0.") {
690+
// maskingTile has -4, ND, and -15 values. Expect mask by value with 0 to not change the
691+
val df = Seq((byteArrayTile, maskingTile)).toDF("data", "mask")
692+
693+
// data tile is all data cells
694+
df.select(rf_no_data_cells($"data")).first() should be (byteArrayTile.size)
695+
696+
// mask by value against 15 should set 3 cell locations to Nodata
697+
df.withColumn("mbv", rf_mask_by_value($"data", $"mask", 15))
698+
.select(rf_data_cells($"mbv"))
699+
.first() should be (byteArrayTile.size - 3)
700+
701+
// breaks with issue https://github.com/locationtech/rasterframes/issues/416
702+
val result = df.withColumn("mbv", rf_mask_by_value($"data", $"mask", 0))
703+
.select(rf_data_cells($"mbv"))
704+
.first()
705+
result should be (byteArrayTile.size)
706+
}
707+
689708
it("should inverse mask tile by another identified by specified value") {
690709
val df = Seq[Tile](randPRT).toDF("tile")
691710
val mask_value = 4

0 commit comments

Comments
 (0)