forked from stac-utils/stac4s
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade to STAC 0.9.0 (stac-utils#48)
* wip -- upgrade to stac 0.9.0 * scalafmt * wip -- fail for NotSerializable reasons * wip -- use unserializableCodec, which was like 10 lines away 🤦♂️ * sort serdespec * restore removed test * Add version link types * include versions in deserialization, test * Add label extension types and codecs * Add all implicits for testing * Add extensions to catalogs and collections
- Loading branch information
Showing
33 changed files
with
936 additions
and
288 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 20 additions & 9 deletions
29
modules/core/src/main/scala/com/azavea/stac4s/core/ItemCollection.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
modules/core/src/main/scala/com/azavea/stac4s/core/StacAsset.scala
This file was deleted.
Oops, something went wrong.
34 changes: 34 additions & 0 deletions
34
modules/core/src/main/scala/com/azavea/stac4s/core/StacAssetRole.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.azavea.stac4s | ||
|
||
import cats.Eq | ||
import cats.implicits._ | ||
import io.circe.{Decoder, Encoder} | ||
|
||
sealed abstract class StacAssetRole(val repr: String) { | ||
override def toString = repr | ||
} | ||
|
||
object StacAssetRole { | ||
|
||
implicit def eqStacAssetRole: Eq[StacAssetRole] = Eq[String].imap(fromString _)(_.repr) | ||
|
||
case object Thumbnail extends StacAssetRole("thumbnail") | ||
case object Overview extends StacAssetRole("overview") | ||
case object Data extends StacAssetRole("data") | ||
case object Metadata extends StacAssetRole("metadata") | ||
final case class VendorAsset(s: String) extends StacAssetRole(s) | ||
|
||
private def fromString(s: String): StacAssetRole = s.toLowerCase match { | ||
case "thumbnail" => Thumbnail | ||
case "overview" => Overview | ||
case "data" => Data | ||
case "metadata" => Metadata | ||
case s => VendorAsset(s) | ||
} | ||
|
||
implicit val encStacAssetRole: Encoder[StacAssetRole] = | ||
Encoder.encodeString.contramap[StacAssetRole](_.toString) | ||
|
||
implicit val decStacAssetRole: Decoder[StacAssetRole] = | ||
Decoder.decodeString.emap { str => Either.catchNonFatal(fromString(str)).leftMap(_ => "StacAssetRole") } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
modules/core/src/main/scala/com/azavea/stac4s/core/StacCollectionAsset.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.azavea.stac4s | ||
|
||
import cats.Eq | ||
import io.circe._ | ||
|
||
final case class StacCollectionAsset( | ||
title: String, | ||
description: Option[String], | ||
roles: List[StacAssetRole], | ||
_type: StacMediaType | ||
) | ||
|
||
object StacCollectionAsset { | ||
|
||
implicit val eqStacCollectionAsset: Eq[StacCollectionAsset] = Eq.fromUniversalEquals | ||
|
||
implicit val encStacCollectionAsset: Encoder[StacCollectionAsset] = | ||
Encoder.forProduct4("title", "description", "roles", "type")(asset => | ||
(asset.title, asset.description, asset.roles, asset._type) | ||
) | ||
|
||
implicit val decStacCollectionAsset: Decoder[StacCollectionAsset] = | ||
Decoder.forProduct4("title", "description", "roles", "type")( | ||
StacCollectionAsset.apply _ | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.