Skip to content

Commit

Permalink
additional test for subdivide on subdatasets
Browse files Browse the repository at this point in the history
  • Loading branch information
sllynn committed Oct 11, 2024
1 parent 225f95d commit 412d44f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,35 @@ trait RST_GetSubdatasetBehaviors extends QueryTest {

}

def behaviorsSubdivide(indexSystem: IndexSystem, geometryAPI: GeometryAPI): Unit = {
spark.sparkContext.setLogLevel("ERROR")
val mc = MosaicContext.build(indexSystem, geometryAPI)
mc.register()
val sc = spark
import mc.functions._
import sc.implicits._

val rasters = spark.read
.format("gdal")
.option("driverName", "NetCDF")
.load("src/test/resources/binary/netcdf-coral")

val rasterCount = rasters.count.toInt
rasterCount shouldBe 10

val subdatasetDF = rasters
.select(rst_getsubdataset($"tile", lit("bleaching_alert_area")).alias("tile"))

val subdatasetCount = subdatasetDF.count.toInt
subdatasetCount shouldBe 10

val subdivideDF = subdatasetDF
.select(rst_subdivide($"tile", lit(8)).alias("tile"))

noException should be thrownBy subdivideDF.write.format("noop").mode("overwrite").save()
val paths = subdivideDF.select($"tile.raster").as[String].collect
paths.size shouldBe 40

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,11 @@ class RST_GetSubdatasetTest extends QueryTest with SharedSparkSessionGDAL with R
}
}

test("Testing RST_GetSubdataset -> RST_Subdivide with manual GDAL registration (H3, JTS).") {
noCodegen {
assume(System.getProperty("os.name") == "Linux")
behaviorsSubdivide(H3IndexSystem, JTS)
}
}

}

0 comments on commit 412d44f

Please sign in to comment.