Skip to content

Commit

Permalink
Add HaversineSpec (not very accurate); fixed ZoomedLayoutSchemeSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
pomadchin authored and echeipesh committed Oct 5, 2017
1 parent 2c0297d commit 3ae457e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
Expand Up @@ -113,7 +113,7 @@ class ZoomedLayoutSchemeSpec extends FunSpec with Matchers {
val (lat2, lon2) = (-81.572543, -148.009213)
val scheme = ZoomedLayoutScheme(LatLng, 256)
val z = scheme.zoom(lon1, lat1, CellSize(lon2 - lon1, lat2 - lat1))
z should be (6)
z should be (9)
}

it("should pyramid floating layout") {
Expand Down
32 changes: 32 additions & 0 deletions util/src/test/scala/geotrellis/util/HaversineSpec.scala
@@ -0,0 +1,32 @@
/*
* Copyright 2016 Azavea
*
* 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.util

import org.scalatest._

class HaversineSpec extends FunSpec with Matchers {
describe("HaversineSpec") {
// Rio de Janeiro
val rio = -22.906847 -> -43.172896
// São Paulo
val sp = -23.550520 -> -46.633309

it("should calculate distance between") {
(Haversine(rio, sp) / 1000).toInt shouldBe 388
}
}
}

0 comments on commit 3ae457e

Please sign in to comment.