Skip to content

Commit

Permalink
Revert "Use StringName instead of SentinelXMLMetadataRasterSource #177"
Browse files Browse the repository at this point in the history
This reverts commit 6321e03.
  • Loading branch information
EmileSonneveld committed Aug 7, 2023
1 parent 6321e03 commit a023a64
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import geotrellis.raster.gdal.{GDALPath, GDALRasterSource, GDALWarpOptions}
import geotrellis.raster.geotiff.{GeoTiffPath, GeoTiffReprojectRasterSource, GeoTiffResampleRasterSource}
import geotrellis.raster.io.geotiff.OverviewStrategy
import geotrellis.raster.rasterize.Rasterizer
import geotrellis.raster.{CellSize, CellType, ConvertTargetCellType, CroppedTile, FloatConstantNoDataCellType, FloatConstantTile, GridBounds, GridExtent, MosaicRasterSource, MultibandTile, NoNoData, PaddedTile, Raster, RasterExtent, RasterMetadata, RasterRegion, RasterSource, ResampleMethod, ResampleTarget, ShortConstantNoDataCellType, SourceName, SourcePath, StringName, TargetAlignment, TargetCellType, TargetRegion, Tile, UByteUserDefinedNoDataCellType, UShortConstantNoDataCellType}
import geotrellis.raster.{CellSize, CellType, ConvertTargetCellType, CroppedTile, FloatConstantNoDataCellType, FloatConstantTile, GridBounds, GridExtent, MosaicRasterSource, MultibandTile, NoNoData, PaddedTile, Raster, RasterExtent, RasterMetadata, RasterRegion, RasterSource, ResampleMethod, ResampleTarget, ShortConstantNoDataCellType, SourceName, SourcePath, TargetAlignment, TargetCellType, TargetRegion, Tile, UByteUserDefinedNoDataCellType, UShortConstantNoDataCellType}
import geotrellis.spark._
import geotrellis.spark.partition.PartitionerIndex.SpatialPartitioner
import geotrellis.spark.partition.SpacePartitioner
Expand Down Expand Up @@ -448,8 +448,8 @@ object FileLayerProvider {
val allRegions = tuple._2.toSeq

val tilesForRegion = allRegions
.flatMap { case (rasterRegion, sourcePath: StringName) =>
val result: Option[(MultibandTile, StringName)] = cloudFilterStrategy match {
.flatMap { case (rasterRegion, sourcePath: SourcePath) =>
val result: Option[(MultibandTile, SourcePath)] = cloudFilterStrategy match {
case l1cFilterStrategy: L1CCloudFilterStrategy =>
if (GDALCloudRasterSource.isRegionFullyClouded(rasterRegion, crs, layout, l1cFilterStrategy.bufferInMeters)) {
// Do not read the tile data at all.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.openeo.geotrellis.layers

import geotrellis.raster.SourcePath

/**
* SourcePath is a trait, so we need to subclass it to instantiate.
*/
case class OpenEoSourcePath(value: String) extends SourcePath
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package org.openeo.geotrellis.layers

import geotrellis.proj4.CRS
import geotrellis.raster.io.geotiff.OverviewStrategy
import geotrellis.raster.{CellSize, CellType, FloatConstantNoDataCellType, FloatConstantTile, GridBounds, GridExtent, MultibandTile, Raster, RasterMetadata, RasterSource, ResampleMethod, ResampleTarget, SourceName, StringName, TargetCellType}
import geotrellis.raster.{CellSize, CellType, FloatConstantNoDataCellType, FloatConstantTile, GridBounds, GridExtent, MultibandTile, Raster, RasterMetadata, RasterSource, ResampleMethod, ResampleTarget, SourceName, TargetCellType}
import geotrellis.vector.Extent
import org.openeo.opensearch.OpenSearchResponses.CreoFeatureCollection

Expand Down Expand Up @@ -32,15 +32,15 @@ object SentinelXMLMetadataRasterSource {
val extent = Extent(ulx, uly - (10 * 10980), ulx + (10 * 10980), uly)
val gridExtent = GridExtent[Long](extent,CellSize(10,10))
val allBands = Seq(mSAA,mSZA,mVAA,mVZA)
bands.map(b => allBands(b)).map(new SentinelXMLMetadataRasterSource(_, crs, gridExtent, StringName(path)))
bands.map(b => allBands(b)).map(new SentinelXMLMetadataRasterSource(_, crs, gridExtent, OpenEoSourcePath(path)))

}
}

class SentinelXMLMetadataRasterSource(value: Float,
theCrs: CRS,
theGridExtent: GridExtent[Long],
sourcePathName: StringName,
sourcePathName: OpenEoSourcePath,
) extends RasterSource {

val targetCellType = None
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.openeo.geotrellis.layers

import org.junit.Assert.{assertEquals, assertTrue}
import org.junit.Assert.assertEquals
import org.junit.Test


Expand All @@ -13,6 +13,6 @@ class SentinelXMLMetadataRasterSourceTest {
assertEquals( 171.800, source(0).read().get.tile.band(0).getDouble(0,0),0.001)
assertEquals( 65.707, source(1).read().get.tile.band(0).getDouble(0,0),0.001)
assertEquals( 251.333, source(2).read().get.tile.band(0).getDouble(0,0),0.001)
assertTrue(source.head.name.toString.contains("MTD_TL.xml"))
assertEquals(source.head.name.toString, path)
}
}

0 comments on commit a023a64

Please sign in to comment.