Skip to content

Commit b3ee32c

Browse files
committed
Upd up to the main branch
1 parent c6562af commit b3ee32c

File tree

6 files changed

+43
-35
lines changed

6 files changed

+43
-35
lines changed

build.sbt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ lazy val root = project
125125
.settings(commonSettings)
126126
.settings(publishSettings)
127127
.settings(noPublishSettings)
128-
.aggregate(coreJS, coreJVM, testingJS, testingJVM, coreTestJS, coreTestJVM)
128+
.aggregate(coreJS, coreJVM, testingJS, testingJVM, coreTestJS, coreTestJVM, clientJS, clientJVM)
129129

130130
lazy val core = crossProject(JSPlatform, JVMPlatform)
131131
.in(file("modules/core"))
@@ -157,7 +157,7 @@ lazy val core = crossProject(JSPlatform, JVMPlatform)
157157
lazy val coreJVM = core.jvm
158158
lazy val coreJS = core.js
159159

160-
lazy val testing = (crossProject(JSPlatform, JVMPlatform))
160+
lazy val testing = crossProject(JSPlatform, JVMPlatform)
161161
.in(file("modules/testing"))
162162
.dependsOn(core)
163163
.settings(commonSettings)
@@ -202,7 +202,8 @@ lazy val coreTestJVM = coreTest.jvm
202202
lazy val coreTestJS = coreTest.js
203203
lazy val coreTestRef = LocalProject("modules/core-test")
204204

205-
lazy val client = (project in file("modules/client"))
205+
lazy val client = crossProject(JSPlatform, JVMPlatform)
206+
.in(file("modules/client"))
206207
.dependsOn(core)
207208
.settings(commonSettings)
208209
.settings(publishSettings)
@@ -214,7 +215,7 @@ lazy val client = (project in file("modules/client"))
214215
"com.chuusai" %% "shapeless" % Versions.ShapelessVersion,
215216
"eu.timepit" %% "refined" % Versions.RefinedVersion,
216217
"org.locationtech.geotrellis" %% "geotrellis-vector" % Versions.GeoTrellisVersion,
217-
"org.locationtech.jts" % "jts-core" % Versions.jts,
218+
"org.locationtech.jts" % "jts-core" % Versions.Jts,
218219
"org.typelevel" %% "cats-core" % Versions.CatsVersion,
219220
"co.fs2" %% "fs2-core" % "2.4.2",
220221
"org.http4s" %% "http4s-blaze-client" % "0.21.7",
@@ -226,3 +227,6 @@ lazy val client = (project in file("modules/client"))
226227
"io.chrisdavenport" %% "log4cats-core" % "1.1.1"
227228
)
228229
)
230+
231+
lazy val clientJVM = client.jvm
232+
lazy val clientJS = client.js

modules/client/src/main/scala/com/azavea/stac4s/api/client/Http4sStacClient.scala renamed to modules/client/shared/src/main/scala/com/azavea/stac4s/api/client/Http4sStacClient.scala

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
package com.azavea.stac4s.api.client
22

33
import com.azavea.stac4s.{StacCollection, StacItem}
4-
import org.http4s.Method.{GET, POST}
5-
import org.http4s.{Request, Uri}
6-
import org.http4s.client.Client
7-
import io.circe.syntax._
8-
import org.http4s.circe._
9-
import cats.syntax.functor._
10-
import cats.syntax.either._
11-
import cats.syntax.apply._
4+
125
import cats.effect.{ConcurrentEffect, Resource, Sync}
6+
import cats.syntax.apply._
7+
import cats.syntax.either._
8+
import cats.syntax.functor._
139
import eu.timepit.refined.types.string.NonEmptyString
14-
import org.http4s.client.blaze.BlazeClientBuilder
1510
import io.chrisdavenport.log4cats.Logger
11+
import io.circe.syntax._
12+
import org.http4s.Method.{GET, POST}
13+
import org.http4s.circe._
14+
import org.http4s.client.Client
15+
import org.http4s.client.blaze.BlazeClientBuilder
16+
import org.http4s.{Request, Uri}
1617

1718
import scala.concurrent.ExecutionContext
1819

modules/client/src/main/scala/com/azavea/stac4s/api/client/Query.scala renamed to modules/client/shared/src/main/scala/com/azavea/stac4s/api/client/Query.scala

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import io.circe._
77
import io.circe.syntax._
88
import io.circe.refined._
99

10+
/** https://github.com/azavea/franklin/blob/286c5c755585cf743eae5bd176609d8c125ad2b9/application/src/main/scala/com/azavea/franklin/datamodel/Query.scala */
1011
sealed abstract class Query
1112

1213
case class Equals(value: Json) extends Query
@@ -83,24 +84,22 @@ object Query {
8384
case (k, _) => Left(s"$k is not a valid operator")
8485
})
8586

86-
implicit val encQuery: Encoder[List[Query]] = new Encoder[List[Query]] {
87-
88-
def apply(queries: List[Query]): Json =
89-
Map(
90-
(queries map {
91-
case Equals(value) => "eq" -> value.asJson
92-
case NotEqualTo(value) => "neq" -> value.asJson
93-
case GreaterThan(floor) => "gt" -> floor.asJson
94-
case GreaterThanEqual(floor) => "gte" -> floor.asJson
95-
case LessThan(ceiling) => "lt" -> ceiling.asJson
96-
case LessThanEqual(ceiling) => "lte" -> ceiling.asJson
97-
case StartsWith(prefix) => "startsWith" -> prefix.asJson
98-
case EndsWith(postfix) => "endsWith" -> postfix.asJson
99-
case Contains(substring) => "contains" -> substring.asJson
100-
case In(values) => "in" -> values.asJson
101-
case Superset(values) => "superset" -> values.asJson
102-
}): _*
103-
).asJson
87+
implicit val encQuery: Encoder[List[Query]] = { queries =>
88+
Map(
89+
queries map {
90+
case Equals(value) => "eq" -> value.asJson
91+
case NotEqualTo(value) => "neq" -> value.asJson
92+
case GreaterThan(floor) => "gt" -> floor.asJson
93+
case GreaterThanEqual(floor) => "gte" -> floor.asJson
94+
case LessThan(ceiling) => "lt" -> ceiling.asJson
95+
case LessThanEqual(ceiling) => "lte" -> ceiling.asJson
96+
case StartsWith(prefix) => "startsWith" -> prefix.asJson
97+
case EndsWith(postfix) => "endsWith" -> postfix.asJson
98+
case Contains(substring) => "contains" -> substring.asJson
99+
case In(values) => "in" -> values.asJson
100+
case Superset(values) => "superset" -> values.asJson
101+
}: _*
102+
).asJson
104103
}
105104

106105
implicit val decQueries: Decoder[List[Query]] = Decoder[JsonObject].emap { jsonObj => queriesFromMap(jsonObj.toMap) }

modules/client/src/main/scala/com/azavea/stac4s/api/client/SearchFilters.scala renamed to modules/client/shared/src/main/scala/com/azavea/stac4s/api/client/SearchFilters.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
package com.azavea.stac4s.api.client
22

3-
import com.azavea.stac4s.{Bbox, TemporalExtent}
3+
import com.azavea.stac4s.Bbox
4+
import com.azavea.stac4s.types.TemporalExtent
5+
46
import io.circe._
57
import io.circe.generic.semiauto._
68
import io.circe.refined._
7-
import geotrellis.vector._
8-
import cats.syntax.either._
9-
import cats.syntax.apply._
109
import cats.instances.either._
10+
import cats.syntax.apply._
11+
import cats.syntax.either._
1112
import eu.timepit.refined.types.numeric.NonNegInt
13+
import geotrellis.vector._
1214

1315
import java.time.Instant
1416

@@ -26,6 +28,7 @@ case class SearchFilters(
2628
object SearchFilters {
2729

2830
// TemporalExtent STAC API compatible serialization
31+
// Ported from https://github.com/azavea/franklin/
2932
private def stringToInstant(s: String): Either[Throwable, Instant] =
3033
Either.catchNonFatal(Instant.parse(s))
3134

modules/client/src/main/scala/com/azavea/stac4s/api/client/StacClient.scala renamed to modules/client/shared/src/main/scala/com/azavea/stac4s/api/client/StacClient.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
package com.azavea.stac4s.api.client
1818

1919
import com.azavea.stac4s._
20+
2021
import eu.timepit.refined.types.string.NonEmptyString
2122

2223
trait StacClient[F[_]] {

0 commit comments

Comments
 (0)