Skip to content

Commit 5f214c7

Browse files
committed
Finish refactor to util.ResampleMethod unapply in reproject_and_merge function
Signed-off-by: Jason T. Brown <[email protected]>
1 parent 337b480 commit 5f214c7

File tree

1 file changed

+4
-15
lines changed
  • core/src/main/scala/org/locationtech/rasterframes/functions

1 file changed

+4
-15
lines changed

core/src/main/scala/org/locationtech/rasterframes/functions/package.scala

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
package org.locationtech.rasterframes
2222
import geotrellis.proj4.CRS
2323
import geotrellis.raster.reproject.Reproject
24-
import geotrellis.raster.resample._
2524
import geotrellis.raster.{Tile, _}
2625
import geotrellis.vector.Extent
2726
import org.apache.spark.sql.functions.udf
2827
import org.apache.spark.sql.{Row, SQLContext}
2928
import org.locationtech.jts.geom.Geometry
3029
import org.locationtech.rasterframes.encoders.CatalystSerializer._
30+
import org.locationtech.rasterframes.util.ResampleMethod
3131

3232
/**
3333
* Module utils.
@@ -108,20 +108,9 @@ package object functions {
108108
val leftCRS = leftCRSEnc.to[CRS]
109109
lazy val rightExtents = rightExtentEnc.map(_.to[Extent])
110110
lazy val rightCRSs = rightCRSEnc.map(_.to[CRS])
111-
lazy val resample = resampleMethod //.getString(0)
112-
.toLowerCase().trim().replaceAll("_", "") match {
113-
case "nearestneighbor" | "nearest" NearestNeighbor
114-
case "bilinear" Bilinear
115-
case "cubicconvolution" CubicConvolution
116-
case "cubicspline" CubicSpline
117-
case "lanczos" | "lanzos" Lanczos
118-
// aggregates
119-
case "average" Average
120-
case "mode" Mode
121-
case "median" Median
122-
case "max" Max
123-
case "min" Min
124-
case "sum" Sum
111+
lazy val resample = resampleMethod match {
112+
case ResampleMethod(mm) mm
113+
case _ throw new IllegalArgumentException(s"Unable to parse ResampleMethod for ${resampleMethod}.")
125114
}
126115

127116
if (leftExtent == null || leftDims == null || leftCRS == null) null

0 commit comments

Comments
 (0)