Skip to content

Commit

Permalink
Fix WCSRefication, wcs and wms default behavior when time is not spec…
Browse files Browse the repository at this point in the history
…ified for temporal layers
  • Loading branch information
pomadchin committed Jun 15, 2020
1 parent 4848522 commit fdaaf81
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
5 changes: 4 additions & 1 deletion ogc/src/main/scala/geotrellis/server/ogc/OgcLayer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
9 changes: 4 additions & 5 deletions ogc/src/main/scala/geotrellis/server/ogc/wcs/WcsModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =>
Expand Down
8 changes: 6 additions & 2 deletions ogc/src/main/scala/geotrellis/server/ogc/wms/WmsModel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down

0 comments on commit fdaaf81

Please sign in to comment.