Skip to content

Commit

Permalink
Add WCS Intervals support
Browse files Browse the repository at this point in the history
  • Loading branch information
pomadchin committed Mar 31, 2021
1 parent c757d11 commit efc0f41
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import geotrellis.raster.resample._
import geotrellis.server.ogc._
import geotrellis.store.GeoTrellisPath
import com.azavea.maml.ast._
import cats.syntax.option._

// This sumtype corresponds to the in-config representation of a source
sealed trait OgcSourceConf {
Expand All @@ -38,12 +39,36 @@ case class RasterSourceConf(
defaultStyle: Option[String],
styles: List[StyleConf],
resampleMethod: ResampleMethod = ResampleMethod.DEFAULT,
overviewStrategy: OverviewStrategy = OverviewStrategy.DEFAULT
overviewStrategy: OverviewStrategy = OverviewStrategy.DEFAULT,
datetimeField: String = SimpleSource.TimeFieldDefault,
timeFormat: OgcTimeFormat = OgcTimeFormat.Self
) extends OgcSourceConf {
def toLayer: RasterOgcSource = {
GeoTrellisPath.parseOption(source) match {
case Some(_) => GeoTrellisOgcSource(name, title, source, defaultStyle, styles.map(_.toStyle), resampleMethod, overviewStrategy)
case None => SimpleSource(name, title, RasterSource(source), defaultStyle, styles.map(_.toStyle), resampleMethod, overviewStrategy, None)
case Some(_) =>
GeoTrellisOgcSource(
name,
title,
source,
defaultStyle,
styles.map(_.toStyle),
resampleMethod,
overviewStrategy,
datetimeField.some,
timeFormat
)
case None =>
SimpleSource(
name,
title,
RasterSource(source),
defaultStyle,
styles.map(_.toStyle),
resampleMethod,
overviewStrategy,
datetimeField.some,
timeFormat
)
}
}
}
Expand All @@ -55,7 +80,8 @@ case class MapAlgebraSourceConf(
defaultStyle: Option[String],
styles: List[StyleConf],
resampleMethod: ResampleMethod = ResampleMethod.DEFAULT,
overviewStrategy: OverviewStrategy = OverviewStrategy.DEFAULT
overviewStrategy: OverviewStrategy = OverviewStrategy.DEFAULT,
timeFormat: OgcTimeFormat = OgcTimeFormat.Self
) extends OgcSourceConf {
private def listParams(expr: Expression): List[String] = {
def eval(subExpr: Expression): List[String] =
Expand Down Expand Up @@ -90,7 +116,8 @@ case class MapAlgebraSourceConf(
defaultStyle,
styles.map(_.toStyle),
resampleMethod,
overviewStrategy
overviewStrategy,
timeFormat
)
}
}
4 changes: 3 additions & 1 deletion ogc/src/main/scala/geotrellis/server/ogc/OgcTime.scala
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ final case class OgcTimePositions(list: NonEmptyList[ZonedDateTime]) extends Ogc
val times = list.sorted
OgcTimeInterval(times.head, times.last, computeIntervalPeriod.map(_.toString))
}
override def toString: String = list.toList.map(_.toInstant.toString).mkString(", ")

def toList: List[String] = list.toList.map(_.toInstant.toString)
override def toString: String = toList.mkString(", ")
}

object OgcTimePositions {
Expand Down
18 changes: 10 additions & 8 deletions ogc/src/main/scala/geotrellis/server/ogc/wcs/CoverageView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,16 @@ object CoverageView {
*/
val temporalDomain: Option[TimeSequenceType] = {
val records = source.time match {
case OgcTimePositions(nel) =>
nel.toList.map { t => GmlDataRecord(TimePositionType(t.toInstant.toString)) }
case OgcTimeInterval(start, end, _) if start == end =>
GmlDataRecord(TimePositionType(start.toInstant.toString)) :: Nil
case OgcTimeInterval(start, end, _) =>
GmlDataRecord(TimePositionType(start.toInstant.toString)) ::
GmlDataRecord(TimePositionType(end.toInstant.toString)) :: Nil
case OgcTimeEmpty => Nil
case otp: OgcTimePositions => otp.toList.map(p => GmlDataRecord(TimePositionType(p)))
case OgcTimeInterval(start, end, period) =>
GmlDataRecord(
wcs.TimePeriodType(
BeginPosition = TimePositionType(start.toInstant.toString),
EndPosition = TimePositionType(end.toInstant.toString),
TimeResolution = period
)
) :: Nil
case OgcTimeEmpty => Nil
}
if (records.nonEmpty) TimeSequenceType(records).some
else None
Expand Down
3 changes: 3 additions & 0 deletions stac-example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ stac-lc8-red-us = {
default-style = "red-to-blue"
// force time positions computation even if the range is given through the collection / layer summary
compute-time-positions = true
// optional field (can be added to all layers definitions)
// the default value is "self", meaning that it would use the OGC Time in a format recieved from the source
time-format = "{interval | positions | self}"
styles = [
{
name = "red-to-blue"
Expand Down

0 comments on commit efc0f41

Please sign in to comment.