Skip to content

Commit

Permalink
include supported projections in describe coverage response
Browse files Browse the repository at this point in the history
  • Loading branch information
jisantuc committed Feb 17, 2021
1 parent be91f3b commit b5d1bac
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions ogc/src/main/scala/geotrellis/server/ogc/wcs/CoverageView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ import cats.syntax.option._
import scala.xml.Elem
import scalaxb._
import java.net.{URI, URL}
import geotrellis.proj4.CRS

class CoverageView[F[_]: Functor](wcsModel: WcsModel[F], serviceUrl: URL, identifiers: Seq[String]) {
def toXML: F[Elem] = {
val sources = if (identifiers == Nil) wcsModel.sources.store else wcsModel.sources.find(withNames(identifiers.toSet))
val sourcesMap: F[Map[String, List[OgcSource]]] = sources.map(_.groupBy(_.name))
val coverageTypeMap = sourcesMap.map(_.mapValues(CoverageView.sourceDescription))
val coverageTypeMap = sourcesMap.map(_.mapValues(CoverageView.sourceDescription(wcsModel.supportedProjections, _)))
coverageTypeMap map { coverageType =>
scalaxb
.toXML[CoverageDescriptions](
Expand All @@ -58,7 +59,7 @@ class CoverageView[F[_]: Functor](wcsModel: WcsModel[F], serviceUrl: URL, identi

object CoverageView {

def sourceDescription(sources: List[OgcSource]): CoverageDescriptionType = {
def sourceDescription(supportedProjections: List[CRS], sources: List[OgcSource]): CoverageDescriptionType = {
val source = sources.head
val nativeCrs = source.nativeCrs.head
val re = source.nativeRE
Expand Down Expand Up @@ -128,6 +129,10 @@ object CoverageView {
else None
}

val uniqueCrs: List[CRS] = (
nativeCrs :: LatLng :: supportedProjections
).distinct

CoverageDescriptionType(
Title = LanguageStringType(source.title) :: Nil,
Abstract = Nil,
Expand Down Expand Up @@ -200,9 +205,8 @@ object CoverageView {
) :: Nil
),
SupportedCRS =
new URI(URN.unsafeFromCrs(nativeCrs)) ::
new URI(URN.unsafeFromCrs(LatLng)) ::
new URI("urn:ogc:def:crs:OGC::imageCRS") :: Nil,
new URI("urn:ogc:def:crs:OGC::imageCRS") ::
(uniqueCrs flatMap { proj => URN.fromCrs(proj) map { new URI(_) } }),
SupportedFormat = "image/geotiff" :: "image/jpeg" :: "image/png" :: Nil
)
}
Expand Down

0 comments on commit b5d1bac

Please sign in to comment.