[Mercator] Code review changes
This commit is contained in:
parent
381dc12579
commit
03fd0d8f53
|
@ -1,25 +1,17 @@
|
||||||
package com.baeldung.algorithms.mercator;
|
package com.mercator;
|
||||||
|
|
||||||
class EllipticalMercator extends Mercator {
|
class EllipticalMercator extends Mercator {
|
||||||
@Override
|
@Override
|
||||||
double yAxisProjection(double input) {
|
double yAxisProjection(double input) {
|
||||||
if (input > 89.5) {
|
|
||||||
input = 89.5;
|
input = Math.min(Math.max(input, -89.5), 89.5);
|
||||||
}
|
double earthDimensionalRateNormalized = 1.0 - Math.pow(RADIUS_MINOR / RADIUS_MAJOR, 2);
|
||||||
if (input < -89.5) {
|
|
||||||
input = -89.5;
|
double inputOnEarthProj = Math.sqrt(earthDimensionalRateNormalized) * Math.sin( Math.toRadians(input));
|
||||||
}
|
|
||||||
double temp = RADIUS_MINOR / RADIUS_MAJOR;
|
inputOnEarthProj = Math.pow(((1.0 - inputOnEarthProj)/(1.0+inputOnEarthProj)), 0.5 * Math.sqrt(earthDimensionalRateNormalized));
|
||||||
double es = 1.0 - (temp * temp);
|
double inputOnEarthProjNormalized = Math.tan(0.5 * ((Math.PI*0.5) - Math.toRadians(input)))/inputOnEarthProj;
|
||||||
double eccent = Math.sqrt(es);
|
return (-1) * RADIUS_MAJOR * Math.log(inputOnEarthProjNormalized);
|
||||||
double phi = Math.toRadians(input);
|
|
||||||
double sinphi = Math.sin(phi);
|
|
||||||
double con = eccent * sinphi;
|
|
||||||
double com = 0.5 * eccent;
|
|
||||||
con = Math.pow(((1.0 - con)/(1.0+con)), com);
|
|
||||||
double ts = Math.tan(0.5 * ((Math.PI*0.5) - phi))/con;
|
|
||||||
double y = 0 - RADIUS_MAJOR * Math.log(ts);
|
|
||||||
return y;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
package com.baeldung.algorithms.mercator;
|
package com.mercator;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.assertEquals;
|
||||||
|
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
|
||||||
public class EllipticalMercatorUnitTest {
|
public class EllipticalMercatorUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
package com.baeldung.algorithms.mercator;
|
package com.mercator;
|
||||||
|
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.assertEquals;
|
||||||
|
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
|
||||||
public class SphericalMercatorUnitTest {
|
public class SphericalMercatorUnitTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
Loading…
Reference in New Issue