Skip to content

Commit

Permalink
CRS.fromWKT now returns Option[CRS]
Browse files Browse the repository at this point in the history
So that we don't swallow errors internally when
we attempt to get an EPSG code from the passed
WKT string.
  • Loading branch information
CloudNiner committed Sep 16, 2019
1 parent 33422da commit 2181e0c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions proj4/src/main/scala/geotrellis/proj4/CRS.scala
Expand Up @@ -66,10 +66,8 @@ object CRS {
* Creates a CoordinateReferenceSystem (CRS) from a
* well-known-text String.
*/
def fromWKT(wktString: String): CRS = {
// TODO: Make this method Option[CRS] too?
val epsgCode: String = WKT.getEpsgStringCode(wktString).get
fromName(epsgCode)
def fromWKT(wktString: String): Option[CRS] = {
WKT.getEpsgStringCode(wktString).map(fromName(_))
}

/**
Expand Down
2 changes: 1 addition & 1 deletion proj4/src/test/scala/geotrellis/proj4/CRSTest.scala
Expand Up @@ -68,7 +68,7 @@ class CRSTest extends FunSpec with Inspectors {
it("should have human friendly toString") {
val samples = Seq(
CRS.fromEpsgCode(3857),
CRS.fromWKT(WebMercator.toWKT().get),
CRS.fromWKT(WebMercator.toWKT().get).get,
CRS.fromName("EPSG:4326"),
CRS.fromString(Sinusoidal.toProj4String),
LatLng, Sinusoidal, WebMercator, ConusAlbers
Expand Down

0 comments on commit 2181e0c

Please sign in to comment.