-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
300300b
commit 81d32b5
Showing
2 changed files
with
79 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 23 additions & 34 deletions
57
src/commonTest/kotlin/com/jillesvangurp/geogeometry/MGRSTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,42 @@ | ||
package com.jillesvangurp.geogeometry | ||
|
||
import com.jillesvangurp.geo.convertUTMToMGRS | ||
import com.jillesvangurp.geo.toPointCoordinates | ||
import com.jillesvangurp.geo.toUtm | ||
import com.jillesvangurp.geo.toUtmCoordinate | ||
import com.jillesvangurp.geo.* | ||
import com.jillesvangurp.geojson.distanceTo | ||
import io.kotest.assertions.assertSoftly | ||
import io.kotest.assertions.withClue | ||
import io.kotest.matchers.doubles.shouldBeLessThan | ||
import io.kotest.matchers.shouldBe | ||
import kotlin.math.abs | ||
import kotlin.test.Test | ||
|
||
class MGRSTest { | ||
@Test | ||
fun shouldCalculateMgrsForBrandenburgerTor() { | ||
assertSoftly { | ||
var utm = brandenBurgerGate.toUtmCoordinate() | ||
utm.convertUTMToMGRS().let { | ||
withClue(it) { | ||
it.longitudeZone shouldBe 33 | ||
it.latitudeZoneLetter shouldBe 'U' | ||
it.colLetter shouldBe 'U' | ||
it.rowLetter shouldBe 'U' | ||
it.easting shouldBe 89880 | ||
it.northing shouldBe 19700 | ||
println(utm) | ||
val toUtm = it.toUtm() | ||
println(toUtm) | ||
toUtm.toPointCoordinates().distanceTo(brandenBurgerGate) shouldBeLessThan 2.0 | ||
} | ||
|
||
} | ||
testMgrsConversion(brandenBurgerGate) | ||
val skagen = doubleArrayOf(10.591979, 57.724205) | ||
utm = skagen.toUtmCoordinate() | ||
utm.convertUTMToMGRS().let { | ||
withClue(it) { | ||
it.longitudeZone shouldBe 32 | ||
it.latitudeZoneLetter shouldBe 'V' | ||
it.colLetter shouldBe 'N' | ||
it.rowLetter shouldBe 'J' | ||
it.easting shouldBe 94817 | ||
it.northing shouldBe 99119 | ||
testMgrsConversion(skagen) | ||
testMgrsConversion(rioFootballStadium) | ||
testMgrsConversion(sydneyOpera) | ||
} | ||
} | ||
|
||
println(utm) | ||
val toUtm = it.toUtm() | ||
println(toUtm) | ||
toUtm.toPointCoordinates().distanceTo(skagen) shouldBeLessThan 2.0 | ||
} | ||
private fun testMgrsConversion(p: DoubleArray) { | ||
val utm = p.toUtmCoordinate() | ||
utm.toPointCoordinates().distanceTo(p) shouldBeLessThan 2.0 | ||
|
||
utm.convertUTMToMGRS().let { | ||
val toUtm = it.toUtm() | ||
withClue("$utm -> $it -> $toUtm") { | ||
it.longitudeZone shouldBe utm.longitudeZone | ||
it.latitudeZoneLetter shouldBe utm.latitudeZoneLetter | ||
|
||
abs(utm.easting-toUtm.easting) shouldBeLessThan 2.0 | ||
abs(utm.northing-toUtm.northing) shouldBeLessThan 2.0 | ||
// toUtm.toPointCoordinates().distanceTo(p) shouldBeLessThan 2.0 | ||
} | ||
|
||
} | ||
|
||
} | ||
} |