|
| 1 | +package geotrellis.server |
| 2 | + |
| 3 | +import geotrellis.server.vlm._ |
| 4 | +import geotrellis.contrib.vlm.gdal._ |
| 5 | +import geotrellis.raster._ |
| 6 | +import geotrellis.raster.io.geotiff.AutoHigherResolution |
| 7 | +import geotrellis.proj4._ |
| 8 | +import geotrellis.spark.tiling._ |
| 9 | +import geotrellis.contrib.vlm.TargetRegion |
| 10 | +import geotrellis.raster.resample.NearestNeighbor |
| 11 | +import geotrellis.vector.Extent |
| 12 | + |
| 13 | +import com.azavea.maml.ast._ |
| 14 | +import com.azavea.maml.ast.codec.tree._ |
| 15 | +import com.azavea.maml.eval._ |
| 16 | +import cats.effect._ |
| 17 | +import cats.data.{NonEmptyList => NEL} |
| 18 | +import org.scalatest._ |
| 19 | + |
| 20 | +import scala.concurrent.ExecutionContext |
| 21 | + |
| 22 | + |
| 23 | +class NoDataHandlingTest extends FunSuite with Matchers with TileAsSourceImplicits { |
| 24 | + implicit val cs = cats.effect.IO.contextShift(ExecutionContext.global) |
| 25 | + |
| 26 | + val expr = Addition(List(RasterVar("t1"), RasterVar("t2"))) |
| 27 | + val eval = LayerTms.curried(expr, BufferingInterpreter.DEFAULT) |
| 28 | + |
| 29 | + test("NODATA should be respected - user-defined, integer-based source celltype") { |
| 30 | + val t1 = IntUserDefinedNoDataArrayTile((1 to 100).toArray, 10, 10, IntUserDefinedNoDataCellType(1)) |
| 31 | + val t2 = IntUserDefinedNoDataArrayTile((1 to 100).toArray, 10, 10, IntUserDefinedNoDataCellType(1)) |
| 32 | + val paramMap = Map("t1" -> t1, "t2" -> t2) |
| 33 | + // We'll sample such that the bottom row (from 56 to 64) are excised from the result |
| 34 | + val res = eval(paramMap, 0, 0, 0).unsafeRunSync |
| 35 | + val tileRes = res.toOption.get.band(0) |
| 36 | + assert(tileRes.toArrayDouble.head.isNaN, s"Expected Double.NaN, got ${tileRes.toArrayDouble.head}") |
| 37 | + } |
| 38 | + |
| 39 | + test("NODATA should be respected - different source celltypes") { |
| 40 | + val t1 = IntUserDefinedNoDataArrayTile((1 to 100).toArray, 10, 10, IntUserDefinedNoDataCellType(1)) |
| 41 | + val t2 = DoubleUserDefinedNoDataArrayTile((1 to 100).map(_.toDouble).toArray, 10, 10, DoubleUserDefinedNoDataCellType(2.0)) |
| 42 | + val paramMap = Map("t1" -> t1, "t2" -> t2) |
| 43 | + // We'll sample such that the bottom row (from 56 to 64) are excised from the result |
| 44 | + val res = eval(paramMap, 0, 0, 0).unsafeRunSync |
| 45 | + val tileRes = res.toOption.get.band(0) |
| 46 | + assert(tileRes.toArrayDouble.apply(0).isNaN, s"Expected Double.NaN, got ${tileRes.toArrayDouble.head}") |
| 47 | + } |
| 48 | +} |
0 commit comments