Skip to content

Commit 90dea60

Browse files
committed
Reenabled test (mostly) covered by 242.
1 parent 68a8e86 commit 90dea60

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

core/src/main/scala/org/locationtech/rasterframes/expressions/generators/RasterSourceToRasterRefs.scala

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,10 @@ case class RasterSourceToRasterRefs(children: Seq[Expression], bandIndexes: Seq[
6262
try {
6363
val refs = children.map { child
6464
val src = RasterSourceType.deserialize(child.eval(input))
65-
subtileDims.map(dims =>
66-
src
67-
.layoutExtents(dims)
68-
.map(e bandIndexes.map(band2ref(src, Some(e))))
69-
)
65+
subtileDims.map(dims => {
66+
val extents = src.layoutExtents(dims)
67+
extents.map(e bandIndexes.map(band2ref(src, Some(e))))
68+
})
7069
.getOrElse(Seq(bandIndexes.map(band2ref(src, None))))
7170
}
7271
refs.transpose.map(ts InternalRow(ts.flatMap(_.map(_.toInternalRow)): _*))

core/src/test/scala/org/locationtech/rasterframes/ref/RasterSourceSpec.scala

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import java.net.URI
2626
import org.locationtech.rasterframes._
2727
import geotrellis.vector.Extent
2828
import org.apache.spark.sql.rf.RasterSourceUDT
29-
import org.locationtech.rasterframes.model.TileDimensions
29+
import org.locationtech.rasterframes.model.{FixedRasterExtent, TileDimensions}
3030

3131

3232
class RasterSourceSpec extends TestEnvironment with TestData {
@@ -70,6 +70,21 @@ class RasterSourceSpec extends TestEnvironment with TestData {
7070
d._1 should be <= NOMINAL_TILE_SIZE
7171
d._2 should be <= NOMINAL_TILE_SIZE
7272
}
73+
74+
val re = FixedRasterExtent(
75+
Extent(1.4455356755667E7, -3335851.5589995002, 1.55673072753335E7, -2223901.039333),
76+
2400, 2400
77+
)
78+
79+
val divisions = re.gridBounds
80+
.split(256, 256)
81+
.map { gb => gb -> re.rasterExtentFor(gb) }
82+
.map { case (originalGB, t) => (originalGB, t.extent) }
83+
.map { case (originalGB, e) => (originalGB, re.gridBoundsFor(e, clamp = false)) }
84+
.map { case (ogb, gb) => ((ogb.width, ogb.height), (gb.width, gb.height)) }
85+
.toSeq
86+
.distinct
87+
divisions.length should be(4)
7388
}
7489
}
7590

datasource/src/test/scala/org/locationtech/rasterframes/datasource/raster/RasterSourceDataSourceSpec.scala

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ class RasterSourceDataSourceSpec extends TestEnvironment with TestData {
248248

249249
describe("RasterSource breaks up scenes into tiles") {
250250
val modis_df = spark.read.raster
251-
.withTileDimensions(128, 128)
251+
.withTileDimensions(256, 256)
252252
.withLazyTiles(true)
253253
.load(remoteMODIS.toASCIIString)
254254

@@ -257,16 +257,16 @@ class RasterSourceDataSourceSpec extends TestEnvironment with TestData {
257257
.withLazyTiles(true)
258258
.load(remoteL8.toASCIIString)
259259

260-
ignore("should have at most four tile dimensions reading MODIS; ignore until fix #242") {
260+
it("should have at most four tile dimensions reading MODIS") {
261261
val dims = modis_df.select(rf_dimensions($"proj_raster")).distinct().collect()
262-
dims.length should be > (0)
263-
dims.length should be <= (4)
262+
dims.length should be > 0
263+
dims.length should be <= 4
264264
}
265265

266266
it("should have at most four tile dimensions reading landsat") {
267267
val dims = l8_df.select(rf_dimensions($"proj_raster")).distinct().collect()
268-
dims.length should be > (0)
269-
dims.length should be <= (4)
268+
dims.length should be > 0
269+
dims.length should be <= 4
270270
}
271271

272272
it("should provide MODIS tiles with requested size") {
@@ -275,8 +275,8 @@ class RasterSourceDataSourceSpec extends TestEnvironment with TestData {
275275
.select($"dims".as[TileDimensions]).distinct().collect()
276276

277277
forEvery(res) { r =>
278-
r.cols should be <=128
279-
r.rows should be <=128
278+
r.cols should be <= 256
279+
r.rows should be <= 256
280280
}
281281
}
282282

@@ -286,8 +286,8 @@ class RasterSourceDataSourceSpec extends TestEnvironment with TestData {
286286
.select($"dims".as[TileDimensions]).distinct().collect()
287287

288288
forEvery(dims) { d =>
289-
d.cols should be <=32
290-
d.rows should be <=33
289+
d.cols should be <= 32
290+
d.rows should be <= 33
291291
}
292292
}
293293

0 commit comments

Comments
 (0)