Skip to content

Commit

Permalink
Add Temporal Periods support
Browse files Browse the repository at this point in the history
  • Loading branch information
pomadchin committed Apr 21, 2021
1 parent f243f16 commit 640d3e2
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import geotrellis.raster.{EmptyName, RasterSource, SourceName, StringName}
import geotrellis.raster.geotiff.GeoTiffPath
import com.azavea.stac4s.{StacAsset, StacExtent}
import com.azavea.stac4s.api.client.{SearchFilters, StacClient, Query => SQuery}
import com.azavea.stac4s.extensions.periodic.PeriodicExtent
import com.azavea.stac4s.syntax._
import io.circe.syntax._
import cats.{Applicative, Foldable, FunctorFilter}
import cats.data.NonEmptyList
Expand All @@ -34,15 +36,15 @@ import cats.syntax.functorFilter._
import cats.syntax.applicative._
import eu.timepit.refined.types.string.NonEmptyString

import java.time.{ZoneOffset, ZonedDateTime}
import java.time.ZoneOffset

package object stac {
implicit class StacExtentionOps(val self: StacExtent) extends AnyVal {

/** [[StacExtent]]s with no temporal component are valid. */
def ogcTime: Option[OgcTime] = self.temporal.interval.headOption.map(_.value.flatten.map(_.atZone(ZoneOffset.UTC))).map {
case fst :: Nil => OgcTimeInterval(fst)
case fst :: snd :: Nil => OgcTimeInterval(fst, snd)
case fst :: snd :: Nil => OgcTimeInterval(fst, snd, self.temporal.getExtensionFields[PeriodicExtent].map(_.period.toString).toOption)
case _ => OgcTimeEmpty
}
}
Expand Down

0 comments on commit 640d3e2

Please sign in to comment.