Skip to content

Commit 44229d2

Browse files
committed
Fix for 409: assert on mask target must have NoData defined
Signed-off-by: Jason T. Brown <[email protected]>
1 parent d8ea781 commit 44229d2

File tree

5 files changed

+473
-381
lines changed

5 files changed

+473
-381
lines changed

core/src/main/scala/org/locationtech/rasterframes/expressions/transformers/Mask.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ package org.locationtech.rasterframes.expressions.transformers
2323

2424
import com.typesafe.scalalogging.Logger
2525
import geotrellis.raster
26-
import geotrellis.raster.Tile
26+
import geotrellis.raster.{CellType, NoNoData, Tile}
2727
import geotrellis.raster.mapalgebra.local.{Undefined, InverseMask gtInverseMask, Mask gtMask}
2828
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult
2929
import org.apache.spark.sql.catalyst.analysis.TypeCheckResult.{TypeCheckFailure, TypeCheckSuccess}
@@ -73,6 +73,15 @@ abstract class Mask(val left: Expression, val middle: Expression, val right: Exp
7373
override protected def nullSafeEval(targetInput: Any, maskInput: Any, maskValueInput: Any): Any = {
7474
implicit val tileSer = TileUDT.tileSerializer
7575
val (targetTile, targetCtx) = tileExtractor(targetExp.dataType)(row(targetInput))
76+
77+
// Which of these is preferable? companion object Seq contains or pattern match on trait?
78+
// assert(!CellType.noNoDataCellTypes.contains(targetTile.cellType), maskErrorStr)
79+
targetTile.cellType match {
80+
case _: NoNoData assert(false,
81+
s"Input data expression ${left.prettyName} must have a CellType with NoData defined in order to perform a masking operation. Found CellType ${targetTile.cellType.toString()}.")
82+
case _
83+
}
84+
7685
val (maskTile, maskCtx) = tileExtractor(maskExp.dataType)(row(maskInput))
7786

7887
if (targetCtx.isEmpty && maskCtx.isDefined)

0 commit comments

Comments
 (0)