From 3424c16afa31cc9a6bf769b8f8d8e001f336b8b0 Mon Sep 17 00:00:00 2001 From: Grigory Pomadchin Date: Mon, 15 Jun 2020 16:17:27 -0400 Subject: [PATCH] Fix WCSRefication, wcs and wms default behavior when time is not specified for temporal layers --- CHANGELOG.md | 1 + ogc/src/main/scala/geotrellis/server/ogc/OgcLayer.scala | 5 ++++- .../scala/geotrellis/server/ogc/wcs/GetCoverage.scala | 2 +- .../main/scala/geotrellis/server/ogc/wcs/WcsModel.scala | 9 ++++----- .../main/scala/geotrellis/server/ogc/wms/WmsModel.scala | 8 ++++++-- 5 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 559e827d..8ef663df 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Expose overview strategy into the layers configuration [#252](/~https://github.com/geotrellis/geotrellis-server/pull/252) - RGB styling configuration [#249](/~https://github.com/geotrellis/geotrellis-server/issues/249) - Add STAC Support [#263](/~https://github.com/geotrellis/geotrellis-server/pull/263) +- Fix ExtentRefication, wcs and wms default behavior when time is not specified for temporal layers [#278](/~https://github.com/geotrellis/geotrellis-server/pull/278) ### Changed diff --git a/ogc/src/main/scala/geotrellis/server/ogc/OgcLayer.scala b/ogc/src/main/scala/geotrellis/server/ogc/OgcLayer.scala index 94846cb9..b2a26b40 100644 --- a/ogc/src/main/scala/geotrellis/server/ogc/OgcLayer.scala +++ b/ogc/src/main/scala/geotrellis/server/ogc/OgcLayer.scala @@ -80,7 +80,10 @@ object SimpleOgcLayer { val raster: Raster[MultibandTile] = self.source .reprojectToRegion(self.crs, targetGrid.toRasterExtent, self.resampleMethod, self.overviewStrategy) .read(extent) - .getOrElse(throw new Exception(s"Unable to retrieve layer $self at extent $extent $cs")) + .getOrElse { + logger.trace(s"Unable to retrieve layer $self at extent $extent $cs") + Raster(MultibandTile(ArrayTile.empty(self.source.cellType, 10, 10)), extent) + } logger.trace(s"Successfully retrieved layer $self at extent $extent with f $cs ${targetGrid.cols}x${targetGrid.rows}") ProjectedRaster(raster, self.crs) diff --git a/ogc/src/main/scala/geotrellis/server/ogc/wcs/GetCoverage.scala b/ogc/src/main/scala/geotrellis/server/ogc/wcs/GetCoverage.scala index 4836b8ca..fc8ffe43 100644 --- a/ogc/src/main/scala/geotrellis/server/ogc/wcs/GetCoverage.scala +++ b/ogc/src/main/scala/geotrellis/server/ogc/wcs/GetCoverage.scala @@ -84,7 +84,7 @@ class GetCoverage(wcsModel: WcsModel) { // STAC search will return an empty list, however QGIS may expect a test pixel to // return the actual tile // TODO: handle it in a proper way, how to get information about the bands amount? - val tile = ArrayTile(Array(0, 0), 1, 1) + val tile = ArrayTile.empty(IntCellType, 1, 1) GeoTiff( Raster( MultibandTile(tile, tile, tile), diff --git a/ogc/src/main/scala/geotrellis/server/ogc/wcs/WcsModel.scala b/ogc/src/main/scala/geotrellis/server/ogc/wcs/WcsModel.scala index bf29ce10..a3b42a78 100644 --- a/ogc/src/main/scala/geotrellis/server/ogc/wcs/WcsModel.scala +++ b/ogc/src/main/scala/geotrellis/server/ogc/wcs/WcsModel.scala @@ -37,11 +37,10 @@ case class WcsModel( case SimpleSource(name, title, source, _, _, resampleMethod, overviewStrategy) => SimpleOgcLayer(name, title, p.crs, source, None, resampleMethod, overviewStrategy) case gts @ GeoTrellisOgcSource(name, title, _, _, _, resampleMethod, overviewStrategy, _) => - val source = if (p.temporalSequence.nonEmpty) { - gts.sourceForTime(p.temporalSequence.head) - } else { - gts.source - } + val source = + if (p.temporalSequence.nonEmpty) gts.sourceForTime(p.temporalSequence.head) + else if (p.temporalSequence.isEmpty && gts.source.isTemporal) gts.sourceForTime(gts.source.times.head) + else gts.source SimpleOgcLayer(name, title, p.crs, source, None, resampleMethod, overviewStrategy) case MapAlgebraSource(name, title, sources, algebra, _, _, resampleMethod, overviewStrategy) => val simpleLayers = sources.mapValues { rs => diff --git a/ogc/src/main/scala/geotrellis/server/ogc/wms/WmsModel.scala b/ogc/src/main/scala/geotrellis/server/ogc/wms/WmsModel.scala index 02b7f44e..21c787d8 100644 --- a/ogc/src/main/scala/geotrellis/server/ogc/wms/WmsModel.scala +++ b/ogc/src/main/scala/geotrellis/server/ogc/wms/WmsModel.scala @@ -58,8 +58,12 @@ case class WmsModel( case SimpleSource(name, title, rasterSource, _, _, resampleMethod, overviewStrategy) => SimpleOgcLayer(name, title, supportedCrs, rasterSource, style, resampleMethod, overviewStrategy) case gts @ GeoTrellisOgcSource(name, title, _, _, _, resampleMethod, overviewStrategy, _) => - val rasterSource = p.time.fold(gts.source)(gts.sourceForTime) - SimpleOgcLayer(name, title, supportedCrs, rasterSource, style, resampleMethod, overviewStrategy) + val source = p.time match { + case Some(t) => gts.sourceForTime(t) + case _ if gts.source.isTemporal => gts.sourceForTime(gts.source.times.head) + case _ => gts.source + } + SimpleOgcLayer(name, title, supportedCrs, source, style, resampleMethod, overviewStrategy) } } }