Skip to content

Commit

Permalink
Merge pull request #2145 from metasim/sinusoidal
Browse files Browse the repository at this point in the history
Added top-level "Sinusoidal" CRS, commonly used with MODIS
  • Loading branch information
lossyrob authored Apr 20, 2017
2 parents 974ad05 + 94034d8 commit 54f7cde
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
28 changes: 28 additions & 0 deletions proj4/src/main/scala/geotrellis/proj4/Sinusoidal.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 2017 Astraea, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package geotrellis.proj4

import org.osgeo.proj4j.CoordinateReferenceSystem

/**
* Sinusoidal projection, commonly used with MODIS-based data products.
*/
object Sinusoidal extends CRS {
lazy val proj4jCrs: CoordinateReferenceSystem = factory.createFromParameters(null,
"+proj=sinu +lon_0=0 +x_0=0 +y_0=0 +a=6371007.181 +b=6371007.181 +units=m +no_defs")
val epsgCode: Option[Int] = None
}
6 changes: 4 additions & 2 deletions spark/src/main/scala/geotrellis/spark/tiling/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ package object tiling {
implicit class CRSWorldExtent(crs: CRS) {
def worldExtent: Extent =
crs match {
case x if x == LatLng =>
case LatLng =>
WORLD_WSG84
case x if x == WebMercator =>
case WebMercator =>
Extent(-20037508.342789244, -20037508.342789244, 20037508.342789244, 20037508.342789244)
case Sinusoidal =>
Extent(-2.0015109355797417E7, -1.0007554677898709E7, 2.0015109355797417E7, 1.0007554677898709E7)
case _ =>
WORLD_WSG84.reproject(LatLng, crs)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class ReprojectSpec extends FunSpec with Matchers {

ll.reproject(LatLng, WebMercator) should matchGeom(wm, 0.00001)
wm.reproject(WebMercator, LatLng) should matchGeom(ll, 0.00001)
ll.reproject(LatLng, Sinusoidal).reproject(Sinusoidal, WebMercator) should matchGeom(wm, 0.00001)
}
}
}

0 comments on commit 54f7cde

Please sign in to comment.