Skip to content

Commit

Permalink
Merge pull request #2169 from mteldridge/etl-proj4-crc
Browse files Browse the repository at this point in the history
Support for the ability to specify output CRS via proj4 string.
  • Loading branch information
lossyrob authored May 9, 2017
2 parents ad4bd78 + e50d43d commit 518f3a4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)
Expand Down
12 changes: 11 additions & 1 deletion spark-etl/src/test/scala/geotrellis/spark/etl/EtlSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@

package geotrellis.spark.etl

import geotrellis.proj4.{LatLng, Sinusoidal}
import geotrellis.raster.{CellSize, CellType}
import geotrellis.raster.resample.NearestNeighbor
import geotrellis.spark.etl.config._
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"),
Expand Down Expand Up @@ -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
}
}
}

0 comments on commit 518f3a4

Please sign in to comment.