Skip to content

Commit b60b8ac

Browse files
authored
Merge pull request #31 from jisantuc/feature/js/upgrade-cats
Upgrade cats -> 1.3.1 and cats-effect -> 1.0 and fix fallout
2 parents 7e8b2f5 + 8f4ba43 commit b60b8ac

File tree

15 files changed

+40
-31
lines changed

15 files changed

+40
-31
lines changed

core/src/main/scala/geotrellis/server/core/maml/MamlExtent.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ object MamlExtent extends LazyLogging {
2929
)(
3030
implicit reify: MamlExtentReification[Param],
3131
enc: Encoder[Param],
32-
t: Timer[IO]
32+
contextShift: ContextShift[IO]
3333
): (Extent, CellSize) => IO[Interpreted[Tile]] = (extent: Extent, cs: CellSize) => {
3434
for {
3535
expr <- getExpression
@@ -38,7 +38,8 @@ object MamlExtent extends LazyLogging {
3838
_ <- IO.pure(logger.info(s"Retrieved parameters for extent ($extent) and cellsize ($cs): ${paramMap.asJson.noSpaces}"))
3939
vars <- IO.pure { Vars.varsWithBuffer(expr) }
4040
params <- vars.toList.parTraverse { case (varName, (_, buffer)) =>
41-
paramMap(varName).extentReification(t)(extent, cs).map(varName -> _)
41+
val thingify = paramMap(varName).extentReification
42+
thingify(extent, cs).map(varName -> _)
4243
} map { _.toMap }
4344
reified <- IO.pure { Expression.bindParams(expr, params) }
4445
} yield reified.andThen(interpreter(_)).andThen(_.as[Tile])

core/src/main/scala/geotrellis/server/core/maml/MamlHistogram.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ object MamlHistogram extends LazyLogging {
7373
implicit reify: MamlExtentReification[Param],
7474
extended: HasRasterExtents[Param],
7575
enc: Encoder[Param],
76-
t: Timer[IO]
76+
contextShift: ContextShift[IO]
7777
): IO[Interpreted[Histogram[Double]]] =
7878
for {
7979
params <- getParams
@@ -104,7 +104,7 @@ object MamlHistogram extends LazyLogging {
104104
implicit reify: MamlExtentReification[Param],
105105
extended: HasRasterExtents[Param],
106106
enc: Encoder[Param],
107-
t: Timer[IO]
107+
contextShift: ContextShift[IO]
108108
) = apply[Param](getParams.map(mkExpr(_)), getParams, interpreter, maxCells)
109109

110110

@@ -117,7 +117,7 @@ object MamlHistogram extends LazyLogging {
117117
implicit reify: MamlExtentReification[Param],
118118
extended: HasRasterExtents[Param],
119119
enc: Encoder[Param],
120-
t: Timer[IO]
120+
contextShift: ContextShift[IO]
121121
): (Map[String, Param]) => IO[Interpreted[Histogram[Double]]] =
122122
(paramMap: Map[String, Param]) => {
123123
apply[Param](IO.pure(expr), IO.pure(paramMap), interpreter, maxCells)
@@ -132,7 +132,7 @@ object MamlHistogram extends LazyLogging {
132132
implicit reify: MamlExtentReification[Param],
133133
extended: HasRasterExtents[Param],
134134
enc: Encoder[Param],
135-
t: Timer[IO]
135+
contextShift: ContextShift[IO]
136136
) = curried(RasterVar("identity"), interpreter, maxCells)
137137

138138
}

core/src/main/scala/geotrellis/server/core/maml/MamlTms.scala

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ object MamlTms extends LazyLogging {
2929
)(
3030
implicit reify: MamlTmsReification[Param],
3131
enc: Encoder[Param],
32-
t: Timer[IO]
32+
contextShift: ContextShift[IO]
3333
): (Int, Int, Int) => IO[Interpreted[Tile]] = (z: Int, x: Int, y: Int) => {
3434
for {
3535
expr <- getExpression
@@ -38,7 +38,8 @@ object MamlTms extends LazyLogging {
3838
_ <- IO.pure(logger.info(s"Retrieved parameters for TMS ($z, $x, $y): ${paramMap.asJson.noSpaces}"))
3939
vars <- IO.pure { Vars.varsWithBuffer(expr) }
4040
params <- vars.toList.parTraverse { case (varName, (_, buffer)) =>
41-
paramMap(varName).tmsReification(buffer)(t)(z, x, y).map(varName -> _)
41+
val thingify = paramMap(varName).tmsReification(buffer)
42+
thingify(z, x, y).map(varName -> _)
4243
} map { _.toMap }
4344
reified <- IO.pure { Expression.bindParams(expr, params) }
4445
} yield reified.andThen(interpreter(_)).andThen(_.as[Tile])
@@ -55,8 +56,8 @@ object MamlTms extends LazyLogging {
5556
)(
5657
implicit reify: MamlTmsReification[Param],
5758
enc: Encoder[Param],
58-
t: Timer[IO]
59-
) = apply[Param](getParams.map(mkExpr(_)), getParams, interpreter)(reify, enc, t)
59+
contextShift: ContextShift[IO]
60+
) = apply[Param](getParams.map(mkExpr(_)), getParams, interpreter)
6061

6162

6263
/** Provide an expression and expect arguments to fulfill its needs */
@@ -66,10 +67,11 @@ object MamlTms extends LazyLogging {
6667
)(
6768
implicit reify: MamlTmsReification[Param],
6869
enc: Encoder[Param],
69-
t: Timer[IO]
70+
contextShift: ContextShift[IO]
7071
): (Map[String, Param], Int, Int, Int) => IO[Interpreted[Tile]] =
7172
(paramMap: Map[String, Param], z: Int, x: Int, y: Int) => {
72-
apply[Param](IO.pure(expr), IO.pure(paramMap), interpreter)(reify, enc, t)(z, x, y)
73+
val thingify = apply[Param](IO.pure(expr), IO.pure(paramMap), interpreter)
74+
thingify(z, x, y)
7375
}
7476

7577

@@ -79,7 +81,7 @@ object MamlTms extends LazyLogging {
7981
)(
8082
implicit reify: MamlTmsReification[Param],
8183
enc: Encoder[Param],
82-
t: Timer[IO]
84+
contextShift: ContextShift[IO]
8385
) = curried(RasterVar("identity"), interpreter)
8486

8587
}

core/src/main/scala/geotrellis/server/core/maml/instances/CogNode.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,19 @@ object CogNode {
3333
implicit val cogNodeDecoder: Decoder[CogNode] = deriveDecoder[CogNode]
3434

3535
implicit val cogNodeRasterExtents: HasRasterExtents[CogNode] = new HasRasterExtents[CogNode] {
36-
def rasterExtents(self: CogNode)(implicit t: Timer[IO]): IO[NEL[RasterExtent]] =
36+
def rasterExtents(self: CogNode)(implicit contextShift: ContextShift[IO]): IO[NEL[RasterExtent]] =
3737
CogUtils.getTiff(self.uri.toString).map { tiff =>
3838
NEL(tiff.rasterExtent, tiff.overviews.map(_.rasterExtent))
3939
}
40-
def crs(self: CogNode)(implicit t: Timer[IO]): IO[CRS] =
40+
def crs(self: CogNode)(implicit contextShift: ContextShift[IO]): IO[CRS] =
4141
CogUtils.getTiff(self.uri.toString).map { tiff =>
4242
tiff.crs
4343
}
4444
}
4545

4646
implicit val cogNodeTmsReification: MamlTmsReification[CogNode] = new MamlTmsReification[CogNode] {
4747
def kind(self: CogNode): MamlKind = MamlKind.Tile
48-
def tmsReification(self: CogNode, buffer: Int)(implicit t: Timer[IO]): (Int, Int, Int) => IO[Literal] = (z: Int, x: Int, y: Int) => {
48+
def tmsReification(self: CogNode, buffer: Int)(implicit contextShift: ContextShift[IO]): (Int, Int, Int) => IO[Literal] = (z: Int, x: Int, y: Int) => {
4949
def fetch(xCoord: Int, yCoord: Int) =
5050
CogUtils.fetch(self.uri.toString, z, xCoord, yCoord)
5151
.map(_.tile)
@@ -62,7 +62,7 @@ object CogNode {
6262

6363
implicit val cogNodeExtentReification: MamlExtentReification[CogNode] = new MamlExtentReification[CogNode] {
6464
def kind(self: CogNode): MamlKind = MamlKind.Tile
65-
def extentReification(self: CogNode)(implicit t: Timer[IO]): (Extent, CellSize) => IO[Literal] = (extent: Extent, cs: CellSize) => {
65+
def extentReification(self: CogNode)(implicit contextShift: ContextShift[IO]): (Extent, CellSize) => IO[Literal] = (extent: Extent, cs: CellSize) => {
6666
CogUtils.getTiff(self.uri.toString)
6767
.map { CogUtils.cropGeoTiffToTile(_, extent, cs, self.band) }
6868
.map { RasterLit(_) }

core/src/main/scala/geotrellis/server/core/maml/metadata/HasRasterExtent.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import java.util.UUID
1313

1414

1515
@typeclass trait HasRasterExtents[A] {
16-
@op("rasterExtents") def rasterExtents(self: A)(implicit t: Timer[IO]): IO[NEL[RasterExtent]]
17-
@op("crs") def crs(self: A)(implicit t: Timer[IO]): IO[CRS]
16+
@op("rasterExtents") def rasterExtents(self: A)(implicit contextShift: ContextShift[IO]): IO[NEL[RasterExtent]]
17+
@op("crs") def crs(self: A)(implicit contextShift: ContextShift[IO]): IO[CRS]
1818
}
1919

core/src/main/scala/geotrellis/server/core/maml/reification/MamlExtentReification.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ import java.util.UUID
1313

1414
@typeclass trait MamlExtentReification[A] {
1515
@op("kind") def kind(self: A): MamlKind
16-
@op("extentReification") def extentReification(self: A)(implicit t: Timer[IO]): (Extent, CellSize) => IO[Literal]
16+
@op("extentReification") def extentReification(self: A)(implicit contextShift: ContextShift[IO]): (Extent, CellSize) => IO[Literal]
1717
}
1818

core/src/main/scala/geotrellis/server/core/maml/reification/MamlTmsReification.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ import java.util.UUID
1212

1313
@typeclass trait MamlTmsReification[A] {
1414
@op("kind") def kind(self: A): MamlKind
15-
@op("tmsReification") def tmsReification(self: A, buffer: Int)(implicit t: Timer[IO]): (Int, Int, Int) => IO[Literal]
15+
@op("tmsReification") def tmsReification(self: A, buffer: Int)(implicit contextShift: ContextShift[IO]): (Int, Int, Int) => IO[Literal]
1616
}
1717

example/src/main/scala/geotrellis/server/example/ndvi/NdviMamlServer.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ import java.util.UUID
3030

3131
object NdviMamlServer extends StreamApp[IO] with LazyLogging with Http4sDsl[IO] {
3232

33+
implicit val contextShift: ContextShift[IO] = IO.contextShift(global)
34+
3335
private val corsConfig = CORSConfig(
3436
anyOrigin = true,
3537
anyMethod = false,

example/src/main/scala/geotrellis/server/example/ndvi/NdviMamlService.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import scala.collection.mutable
3333

3434
class ExampleNdviMamlService[Param](
3535
interpreter: BufferingInterpreter = BufferingInterpreter.DEFAULT
36-
)(implicit t: Timer[IO],
36+
)(implicit contextShift: ContextShift[IO],
3737
enc: Encoder[Param],
3838
dec: Decoder[Param],
3939
mr: MamlTmsReification[Param]) extends Http4sDsl[IO] with LazyLogging {

example/src/main/scala/geotrellis/server/example/overlay/OverlayDefinition.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ object OverlayDefinition {
3030
new MamlTmsReification[OverlayDefinition] {
3131
def kind(self: OverlayDefinition): MamlKind = MamlKind.Tile
3232

33-
def tmsReification(self: OverlayDefinition, buffer: Int)(implicit t: Timer[IO]): (Int, Int, Int) => IO[Literal] =
33+
def tmsReification(self: OverlayDefinition, buffer: Int)(implicit contextShift: ContextShift[IO]): (Int, Int, Int) => IO[Literal] =
3434
(z: Int, x: Int, y: Int) => {
3535
CogUtils.fetch(self.uri.toString, z, x, y).map(_.tile.band(self.band - 1)).map { tile =>
3636
val extent = CogUtils.tmsLevels(z).mapTransform.keyToExtent(x, y)
@@ -43,7 +43,7 @@ object OverlayDefinition {
4343
new MamlExtentReification[OverlayDefinition] {
4444
def kind(self: OverlayDefinition): MamlKind = MamlKind.Tile
4545

46-
def extentReification(self: OverlayDefinition)(implicit t: Timer[IO]): (Extent, CellSize) => IO[Literal] =
46+
def extentReification(self: OverlayDefinition)(implicit contextShift: ContextShift[IO]): (Extent, CellSize) => IO[Literal] =
4747
(extent: Extent, cs: CellSize) => {
4848
CogUtils.getTiff(self.uri.toString)
4949
.map { CogUtils.cropGeoTiffToTile(_, extent, cs, self.band - 1) }
@@ -52,11 +52,11 @@ object OverlayDefinition {
5252
}
5353

5454
implicit val overlayDefinitionRasterExtents: HasRasterExtents[OverlayDefinition] = new HasRasterExtents[OverlayDefinition] {
55-
def rasterExtents(self: OverlayDefinition)(implicit t: Timer[IO]): IO[NEL[RasterExtent]] =
55+
def rasterExtents(self: OverlayDefinition)(implicit contextShift: ContextShift[IO]): IO[NEL[RasterExtent]] =
5656
CogUtils.getTiff(self.uri.toString).map { tiff =>
5757
NEL(tiff.rasterExtent, tiff.overviews.map(_.rasterExtent))
5858
}
59-
def crs(self: OverlayDefinition)(implicit t: Timer[IO]): IO[CRS] =
59+
def crs(self: OverlayDefinition)(implicit contextShift: ContextShift[IO]): IO[CRS] =
6060
CogUtils.getTiff(self.uri.toString).map { tiff =>
6161
tiff.crs
6262
}

0 commit comments

Comments
 (0)