Skip to content

Commit

Permalink
Assert sensible extends in UTM zones. #279
Browse files Browse the repository at this point in the history
  • Loading branch information
EmileSonneveld committed Jul 23, 2024
1 parent 14cfc60 commit 223b579
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,12 @@ class FileLayerProvider private(openSearch: OpenSearchClient, openSearchCollecti
val reprojectedBoundingBox: ProjectedExtent = DatacubeSupport.targetBoundingBox(fullBBox, layoutScheme)
val alignedExtent = worldLayout.createAlignedRasterExtent(reprojectedBoundingBox.extent)

val polygonIsUTM = polygons_crs.proj4jCrs.getProjection.getName == "utm"
if (polygonIsUTM) {
// This is an extend that has the highest sensible values for northern and/or southern hemisphere UTM zones
val utmProjectedBounds = Extent(166021.44, 0000000.00, 833978.56, 10000000)
assert(alignedExtent.extent.intersects(utmProjectedBounds), "Extend should be in valid values of UTM zone to avoid distortion when reprojecting.")
}

logger.info(s"Loading ${openSearchCollectionId} with params ${datacubeParams.getOrElse(new DataCubeParameters)} and bands ${openSearchLinkTitles.toList.mkString(";")} initial layout: ${worldLayout}")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,11 @@ class FileLayerProviderTest extends RasterMatchers{
cubeSpatial.writeGeoTiff(outDir + "/testMissingS2DateLine_" + crsName.replace(":", "_") + ".tiff")
}

@Test
def testMissingS2DateLineOutside(): Unit = {
assertThrows[AssertionError](testMissingS2DateLine("EPSG:32631"))
}

private def keysForLargeArea(useBBox:Boolean=false) = {
val date = LocalDate.of(2022, 2, 11).atStartOfDay(UTC)
val crs = CRS.fromEpsgCode(32630)
Expand Down

0 comments on commit 223b579

Please sign in to comment.