From 3910b2250478231f28645b318209651cb146ea57 Mon Sep 17 00:00:00 2001 From: Alexander Nozik Date: Fri, 17 Jun 2022 17:55:01 +0300 Subject: [PATCH] Add webMercator absolute coordinates test --- .../kscience/kmath/geometry/MercatorTest.kt | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/kmath-geometry/src/commonTest/kotlin/space/kscience/kmath/geometry/MercatorTest.kt b/kmath-geometry/src/commonTest/kotlin/space/kscience/kmath/geometry/MercatorTest.kt index 4f6060de2..bd85df64e 100644 --- a/kmath-geometry/src/commonTest/kotlin/space/kscience/kmath/geometry/MercatorTest.kt +++ b/kmath-geometry/src/commonTest/kotlin/space/kscience/kmath/geometry/MercatorTest.kt @@ -22,8 +22,8 @@ class MercatorTest { val m = mskCoordinates.toMercator() val r = m.toGeodetic() - assertEquals(mskCoordinates.longitude, r.longitude,1e-4) - assertEquals(mskCoordinates.latitude, r.latitude,1e-4) + assertEquals(mskCoordinates.longitude, r.longitude, 1e-4) + assertEquals(mskCoordinates.latitude, r.latitude, 1e-4) } @Test @@ -32,8 +32,8 @@ class MercatorTest { val m = mskCoordinates.toMercator(2.0) val r = m.toGeodetic() - assertEquals(mskCoordinates.longitude, r.longitude,1e-4) - assertEquals(mskCoordinates.latitude, r.latitude,1e-4) + assertEquals(mskCoordinates.longitude, r.longitude, 1e-4) + assertEquals(mskCoordinates.latitude, r.latitude, 1e-4) } @Test @@ -47,4 +47,12 @@ class MercatorTest { assertTrue { offset.y in -127.0..128.0 } assertTrue { offset.zoom > 0.0 } } + + @Test + fun webMercatorAbsolute() { + val mskCoordinates = GeodeticCoordinates.ofDegrees(55.7558, 37.6173) + val wmc = with(WebMercatorAlgebra) { mskCoordinates.toMercator(13.0) } + assertEquals(wmc.x, 1267712.0, 50.0) + assertEquals(wmc.y, 655616.0, 50.0) + } } \ No newline at end of file