[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 {
|
||||
@Override
|
||||
double yAxisProjection(double input) {
|
||||
if (input > 89.5) {
|
||||
input = 89.5;
|
||||
}
|
||||
if (input < -89.5) {
|
||||
input = -89.5;
|
||||
}
|
||||
double temp = RADIUS_MINOR / RADIUS_MAJOR;
|
||||
double es = 1.0 - (temp * temp);
|
||||
double eccent = Math.sqrt(es);
|
||||
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;
|
||||
|
||||
input = Math.min(Math.max(input, -89.5), 89.5);
|
||||
double earthDimensionalRateNormalized = 1.0 - Math.pow(RADIUS_MINOR / RADIUS_MAJOR, 2);
|
||||
|
||||
double inputOnEarthProj = Math.sqrt(earthDimensionalRateNormalized) * Math.sin( Math.toRadians(input));
|
||||
|
||||
inputOnEarthProj = Math.pow(((1.0 - inputOnEarthProj)/(1.0+inputOnEarthProj)), 0.5 * Math.sqrt(earthDimensionalRateNormalized));
|
||||
double inputOnEarthProjNormalized = Math.tan(0.5 * ((Math.PI*0.5) - Math.toRadians(input)))/inputOnEarthProj;
|
||||
return (-1) * RADIUS_MAJOR * Math.log(inputOnEarthProjNormalized);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
package com.baeldung.algorithms.mercator;
|
||||
package com.mercator;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class EllipticalMercatorUnitTest {
|
||||
|
||||
@Test
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
package com.baeldung.algorithms.mercator;
|
||||
package com.mercator;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.junit.MockitoJUnitRunner;
|
||||
|
||||
import static junit.framework.TestCase.assertEquals;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class SphericalMercatorUnitTest {
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue