diff --git a/spark-etl/src/main/scala/geotrellis/spark/etl/config/Output.scala b/spark-etl/src/main/scala/geotrellis/spark/etl/config/Output.scala index 225fe21586..223cbd4a6c 100644 --- a/spark-etl/src/main/scala/geotrellis/spark/etl/config/Output.scala +++ b/spark-etl/src/main/scala/geotrellis/spark/etl/config/Output.scala @@ -23,9 +23,10 @@ import geotrellis.spark.io.index.{HilbertKeyIndexMethod, KeyIndexMethod, RowMajo import geotrellis.spark.pyramid.Pyramid import geotrellis.spark.tiling._ import geotrellis.vector.Extent - import org.apache.spark.HashPartitioner +import scala.util.Try + case class Output( backend: Backend, resampleMethod: PointResampleMethod, @@ -48,7 +49,7 @@ case class Output( require(maxZoom.isEmpty || layoutScheme == Some("zoomed"), "maxZoom can only be used with 'zoomed' layoutScheme") - def getCrs = crs.map(CRS.fromName) + def getCrs = crs.map(c => Try(CRS.fromName(c)) getOrElse CRS.fromString(c)) def getLayoutScheme: LayoutScheme = (layoutScheme, getCrs, resolutionThreshold) match { case (Some("floating"), _, _) => FloatingLayoutScheme(tileSize) diff --git a/spark-etl/src/test/scala/geotrellis/spark/etl/EtlSpec.scala b/spark-etl/src/test/scala/geotrellis/spark/etl/EtlSpec.scala index debfb43d6c..6a56feb50b 100644 --- a/spark-etl/src/test/scala/geotrellis/spark/etl/EtlSpec.scala +++ b/spark-etl/src/test/scala/geotrellis/spark/etl/EtlSpec.scala @@ -16,6 +16,7 @@ package geotrellis.spark.etl +import geotrellis.proj4.{LatLng, Sinusoidal} import geotrellis.raster.{CellSize, CellType} import geotrellis.raster.resample.NearestNeighbor import geotrellis.spark.etl.config._ @@ -23,7 +24,7 @@ import geotrellis.vector.Extent import org.apache.spark.storage.StorageLevel import org.scalatest._ -object EtlSpec { +class EtlSpec extends FunSuite { // Test that ETL module can be instantiated in convenient ways val profiles = List( AccumuloProfile("accumulo-name", "instance", "zookeepers", "user", "password"), @@ -74,4 +75,13 @@ object EtlSpec { Etl(etlConf) Etl(etlConf, List(s3.S3Module, hadoop.HadoopModule)) + + test("OutputPlugin.getCrs should handle proj4 strings") { + assert(output.copy(crs = Some("EPSG:4326")).getCrs === Some(LatLng)) + assert(output.copy(crs = Some(Sinusoidal.toProj4String)).getCrs === Some(Sinusoidal)) + assert(output.copy(crs = None).getCrs === None) + intercept[Exception] { + output.copy(crs = Some("BAD:CRS")).getCrs + } + } }