[Mercator]: Code review changes.

This commit is contained in:
Grigorios Dimopoulos 2018-10-29 12:45:14 +02:00
parent 0187c74f79
commit 3f187e0deb
5 changed files with 9 additions and 9 deletions

View File

@ -1,4 +1,4 @@
package com.baeldung.mercator;
package com.baeldung.algorithms.mercator;
class EllipticalMercator extends Mercator {
@Override

View File

@ -1,4 +1,4 @@
package com.baeldung.mercator;
package com.baeldung.algorithms.mercator;
abstract class Mercator {
final static double RADIUS_MAJOR = 6378137.0;

View File

@ -1,14 +1,14 @@
package com.baeldung.mercator;
package com.baeldung.algorithms.mercator;
public class SphericalMercator extends Mercator {
@Override
double yAxisProjection(double input) {
double xAxisProjection(double input) {
return Math.toRadians(input) * RADIUS_MAJOR;
}
@Override
double xAxisProjection(double input) {
double yAxisProjection(double input) {
return Math.log(Math.tan(Math.PI / 4 + Math.toRadians(input) / 2)) * RADIUS_MAJOR;
}
}

View File

@ -1,4 +1,4 @@
package com.baeldung.mercator;
package com.baeldung.algorithms.mercator;
import org.junit.Test;
import org.junit.runner.RunWith;

View File

@ -1,4 +1,4 @@
package com.baeldung.mercator;
package com.baeldung.algorithms.mercator;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -13,13 +13,13 @@ public class SphericalMercatorUnitTest {
public void giventThatTheInputIs22_whenXAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() {
Mercator mercator = new SphericalMercator();
double result = mercator.xAxisProjection(22);
assertEquals(result, 2511525.234845713);
assertEquals(result, 2449028.7974520186);
}
@Test
public void giventThatTheInputIs44_whenYAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() {
Mercator mercator = new SphericalMercator();
double result = mercator.yAxisProjection(44);
assertEquals(result, 4898057.594904037);
assertEquals(result, 5465442.183322753);
}
}