From 0187c74f792cf39feda799508e74ce1478c9b964 Mon Sep 17 00:00:00 2001 From: Grigorios Dimopoulos Date: Fri, 26 Oct 2018 11:22:09 +0300 Subject: [PATCH 1/8] Mercator: Article example implementation of mercator projections. --- .../baeldung/mercator/EllipticalMercator.java | 29 +++++++++++++++++++ .../java/com/baeldung/mercator/Mercator.java | 10 +++++++ .../baeldung/mercator/SphericalMercator.java | 14 +++++++++ .../mercator/EllipticalMercatorUnitTest.java | 25 ++++++++++++++++ .../mercator/SphericalMercatorUnitTest.java | 25 ++++++++++++++++ 5 files changed, 103 insertions(+) create mode 100644 core-java/src/main/java/com/baeldung/mercator/EllipticalMercator.java create mode 100644 core-java/src/main/java/com/baeldung/mercator/Mercator.java create mode 100644 core-java/src/main/java/com/baeldung/mercator/SphericalMercator.java create mode 100644 core-java/src/test/java/com/baeldung/mercator/EllipticalMercatorUnitTest.java create mode 100644 core-java/src/test/java/com/baeldung/mercator/SphericalMercatorUnitTest.java diff --git a/core-java/src/main/java/com/baeldung/mercator/EllipticalMercator.java b/core-java/src/main/java/com/baeldung/mercator/EllipticalMercator.java new file mode 100644 index 0000000000..bb9ebb0e58 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/mercator/EllipticalMercator.java @@ -0,0 +1,29 @@ +package com.baeldung.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; + } + + @Override + double xAxisProjection(double input) { + return RADIUS_MAJOR * Math.toRadians(input); + } +} diff --git a/core-java/src/main/java/com/baeldung/mercator/Mercator.java b/core-java/src/main/java/com/baeldung/mercator/Mercator.java new file mode 100644 index 0000000000..3f50884f6b --- /dev/null +++ b/core-java/src/main/java/com/baeldung/mercator/Mercator.java @@ -0,0 +1,10 @@ +package com.baeldung.mercator; + +abstract class Mercator { + final static double RADIUS_MAJOR = 6378137.0; + final static double RADIUS_MINOR = 6356752.3142; + + abstract double yAxisProjection(double input); + + abstract double xAxisProjection(double input); +} diff --git a/core-java/src/main/java/com/baeldung/mercator/SphericalMercator.java b/core-java/src/main/java/com/baeldung/mercator/SphericalMercator.java new file mode 100644 index 0000000000..6cc405b3b0 --- /dev/null +++ b/core-java/src/main/java/com/baeldung/mercator/SphericalMercator.java @@ -0,0 +1,14 @@ +package com.baeldung.mercator; + +public class SphericalMercator extends Mercator { + + @Override + double yAxisProjection(double input) { + return Math.toRadians(input) * RADIUS_MAJOR; + } + + @Override + double xAxisProjection(double input) { + return Math.log(Math.tan(Math.PI / 4 + Math.toRadians(input) / 2)) * RADIUS_MAJOR; + } +} diff --git a/core-java/src/test/java/com/baeldung/mercator/EllipticalMercatorUnitTest.java b/core-java/src/test/java/com/baeldung/mercator/EllipticalMercatorUnitTest.java new file mode 100644 index 0000000000..0088cc451c --- /dev/null +++ b/core-java/src/test/java/com/baeldung/mercator/EllipticalMercatorUnitTest.java @@ -0,0 +1,25 @@ +package com.baeldung.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 + public void giventThatTheInputIs22_whenXAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { + Mercator mercator = new EllipticalMercator(); + double result = mercator.xAxisProjection(22); + assertEquals(result, 2449028.7974520186); + } + + @Test + public void giventThatTheInputIs44_whenYAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { + Mercator mercator = new EllipticalMercator(); + double result = mercator.yAxisProjection(44); + assertEquals(result, 5435749.887511954); + } +} diff --git a/core-java/src/test/java/com/baeldung/mercator/SphericalMercatorUnitTest.java b/core-java/src/test/java/com/baeldung/mercator/SphericalMercatorUnitTest.java new file mode 100644 index 0000000000..2e5ebe53cb --- /dev/null +++ b/core-java/src/test/java/com/baeldung/mercator/SphericalMercatorUnitTest.java @@ -0,0 +1,25 @@ +package com.baeldung.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 + public void giventThatTheInputIs22_whenXAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { + Mercator mercator = new SphericalMercator(); + double result = mercator.xAxisProjection(22); + assertEquals(result, 2511525.234845713); + } + + @Test + public void giventThatTheInputIs44_whenYAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { + Mercator mercator = new SphericalMercator(); + double result = mercator.yAxisProjection(44); + assertEquals(result, 4898057.594904037); + } +} From 3f187e0deb2822104a56f8554f2f93b0fc0ac85b Mon Sep 17 00:00:00 2001 From: Grigorios Dimopoulos Date: Mon, 29 Oct 2018 12:45:14 +0200 Subject: [PATCH 2/8] [Mercator]: Code review changes. --- .../baeldung/algorithms}/mercator/EllipticalMercator.java | 2 +- .../java/com/baeldung/algorithms}/mercator/Mercator.java | 2 +- .../baeldung/algorithms}/mercator/SphericalMercator.java | 6 +++--- .../algorithms}/mercator/EllipticalMercatorUnitTest.java | 2 +- .../algorithms}/mercator/SphericalMercatorUnitTest.java | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) rename {core-java/src/main/java/com/baeldung => algorithms/src/main/java/com/baeldung/algorithms}/mercator/EllipticalMercator.java (95%) rename {core-java/src/main/java/com/baeldung => algorithms/src/main/java/com/baeldung/algorithms}/mercator/Mercator.java (84%) rename {core-java/src/main/java/com/baeldung => algorithms/src/main/java/com/baeldung/algorithms}/mercator/SphericalMercator.java (88%) rename {core-java/src/test/java/com/baeldung => algorithms/src/test/java/com/baeldung/algorithms}/mercator/EllipticalMercatorUnitTest.java (94%) rename {core-java/src/test/java/com/baeldung => algorithms/src/test/java/com/baeldung/algorithms}/mercator/SphericalMercatorUnitTest.java (82%) diff --git a/core-java/src/main/java/com/baeldung/mercator/EllipticalMercator.java b/algorithms/src/main/java/com/baeldung/algorithms/mercator/EllipticalMercator.java similarity index 95% rename from core-java/src/main/java/com/baeldung/mercator/EllipticalMercator.java rename to algorithms/src/main/java/com/baeldung/algorithms/mercator/EllipticalMercator.java index bb9ebb0e58..8c3e4c554f 100644 --- a/core-java/src/main/java/com/baeldung/mercator/EllipticalMercator.java +++ b/algorithms/src/main/java/com/baeldung/algorithms/mercator/EllipticalMercator.java @@ -1,4 +1,4 @@ -package com.baeldung.mercator; +package com.baeldung.algorithms.mercator; class EllipticalMercator extends Mercator { @Override diff --git a/core-java/src/main/java/com/baeldung/mercator/Mercator.java b/algorithms/src/main/java/com/baeldung/algorithms/mercator/Mercator.java similarity index 84% rename from core-java/src/main/java/com/baeldung/mercator/Mercator.java rename to algorithms/src/main/java/com/baeldung/algorithms/mercator/Mercator.java index 3f50884f6b..b289b1839d 100644 --- a/core-java/src/main/java/com/baeldung/mercator/Mercator.java +++ b/algorithms/src/main/java/com/baeldung/algorithms/mercator/Mercator.java @@ -1,4 +1,4 @@ -package com.baeldung.mercator; +package com.baeldung.algorithms.mercator; abstract class Mercator { final static double RADIUS_MAJOR = 6378137.0; diff --git a/core-java/src/main/java/com/baeldung/mercator/SphericalMercator.java b/algorithms/src/main/java/com/baeldung/algorithms/mercator/SphericalMercator.java similarity index 88% rename from core-java/src/main/java/com/baeldung/mercator/SphericalMercator.java rename to algorithms/src/main/java/com/baeldung/algorithms/mercator/SphericalMercator.java index 6cc405b3b0..1be976d82e 100644 --- a/core-java/src/main/java/com/baeldung/mercator/SphericalMercator.java +++ b/algorithms/src/main/java/com/baeldung/algorithms/mercator/SphericalMercator.java @@ -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; } } diff --git a/core-java/src/test/java/com/baeldung/mercator/EllipticalMercatorUnitTest.java b/algorithms/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java similarity index 94% rename from core-java/src/test/java/com/baeldung/mercator/EllipticalMercatorUnitTest.java rename to algorithms/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java index 0088cc451c..13618e80a7 100644 --- a/core-java/src/test/java/com/baeldung/mercator/EllipticalMercatorUnitTest.java +++ b/algorithms/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java @@ -1,4 +1,4 @@ -package com.baeldung.mercator; +package com.baeldung.algorithms.mercator; import org.junit.Test; import org.junit.runner.RunWith; diff --git a/core-java/src/test/java/com/baeldung/mercator/SphericalMercatorUnitTest.java b/algorithms/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java similarity index 82% rename from core-java/src/test/java/com/baeldung/mercator/SphericalMercatorUnitTest.java rename to algorithms/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java index 2e5ebe53cb..f1152441b8 100644 --- a/core-java/src/test/java/com/baeldung/mercator/SphericalMercatorUnitTest.java +++ b/algorithms/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java @@ -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); } } From 03fd0d8f5385b42cbb41114048f9cd56c7956d1b Mon Sep 17 00:00:00 2001 From: Grigorios Dimopoulos Date: Wed, 31 Oct 2018 12:53:14 +0200 Subject: [PATCH 3/8] [Mercator] Code review changes --- .../mercator/EllipticalMercator.java | 28 +++++++------------ .../mercator/EllipticalMercatorUnitTest.java | 5 +--- .../mercator/SphericalMercatorUnitTest.java | 6 +--- 3 files changed, 12 insertions(+), 27 deletions(-) diff --git a/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/mercator/EllipticalMercator.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/mercator/EllipticalMercator.java index 8c3e4c554f..8f007dc00e 100644 --- a/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/mercator/EllipticalMercator.java +++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/mercator/EllipticalMercator.java @@ -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 diff --git a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java index 13618e80a7..535a6c2c99 100644 --- a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java +++ b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java @@ -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 diff --git a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java index f1152441b8..3fe765f218 100644 --- a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java +++ b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java @@ -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 From a32911077f95f62a6b042d25201df1d7fe44f84c Mon Sep 17 00:00:00 2001 From: Grigorios Dimopoulos Date: Wed, 31 Oct 2018 13:07:14 +0200 Subject: [PATCH 4/8] [Mercator] Code review changes --- .../com/baeldung/algorithms/mercator/EllipticalMercator.java | 1 + 1 file changed, 1 insertion(+) diff --git a/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/mercator/EllipticalMercator.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/mercator/EllipticalMercator.java index 8f007dc00e..24b341aea1 100644 --- a/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/mercator/EllipticalMercator.java +++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/mercator/EllipticalMercator.java @@ -1,6 +1,7 @@ package com.mercator; class EllipticalMercator extends Mercator { + @Override double yAxisProjection(double input) { From eefac3911dc37a72304eb47798f122831fd7a66d Mon Sep 17 00:00:00 2001 From: Grigorios Dimopoulos Date: Wed, 31 Oct 2018 12:16:55 +0200 Subject: [PATCH 5/8] Minor fix --- .../com/baeldung/algorithms/mercator/EllipticalMercator.java | 4 ++-- .../algorithms/mercator/EllipticalMercatorUnitTest.java | 2 +- .../algorithms/mercator/SphericalMercatorUnitTest.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/mercator/EllipticalMercator.java b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/mercator/EllipticalMercator.java index 24b341aea1..e1c41f9518 100644 --- a/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/mercator/EllipticalMercator.java +++ b/algorithms-miscellaneous-2/src/main/java/com/baeldung/algorithms/mercator/EllipticalMercator.java @@ -1,7 +1,7 @@ -package com.mercator; +package com.baeldung.algorithms.mercator; class EllipticalMercator extends Mercator { - + @Override double yAxisProjection(double input) { diff --git a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java index 535a6c2c99..f24d1328f0 100644 --- a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java +++ b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java @@ -1,4 +1,4 @@ -package com.mercator; +package com.baeldung.algorithms.mercator; import org.junit.Test; diff --git a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java index 3fe765f218..196abe63cf 100644 --- a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java +++ b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java @@ -1,4 +1,4 @@ -package com.mercator; +package com.baeldung.algorithms.mercator; import org.junit.Test; import static junit.framework.TestCase.assertEquals; From e90545f3b74c433ef9bf2801d6c00d7bfafa1c89 Mon Sep 17 00:00:00 2001 From: Grigorios Dimopoulos Date: Thu, 1 Nov 2018 13:51:27 +0200 Subject: [PATCH 6/8] [Mercator]Unit test fox --- .../algorithms/mercator/EllipticalMercatorUnitTest.java | 5 ++--- .../algorithms/mercator/SphericalMercatorUnitTest.java | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java index f24d1328f0..4889c7640f 100644 --- a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java +++ b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java @@ -2,7 +2,6 @@ package com.baeldung.algorithms.mercator; import org.junit.Test; -import static junit.framework.TestCase.assertEquals; public class EllipticalMercatorUnitTest { @@ -10,13 +9,13 @@ public class EllipticalMercatorUnitTest { public void giventThatTheInputIs22_whenXAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { Mercator mercator = new EllipticalMercator(); double result = mercator.xAxisProjection(22); - assertEquals(result, 2449028.7974520186); + assert result == 2449028.7974520186; } @Test public void giventThatTheInputIs44_whenYAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { Mercator mercator = new EllipticalMercator(); double result = mercator.yAxisProjection(44); - assertEquals(result, 5435749.887511954); + assert result == 5435749.887511954; } } diff --git a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java index 196abe63cf..80e09b4c79 100644 --- a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java +++ b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java @@ -9,13 +9,13 @@ public class SphericalMercatorUnitTest { public void giventThatTheInputIs22_whenXAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { Mercator mercator = new SphericalMercator(); double result = mercator.xAxisProjection(22); - assertEquals(result, 2449028.7974520186); + assert result == 2449028.7974520186; } @Test public void giventThatTheInputIs44_whenYAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { Mercator mercator = new SphericalMercator(); double result = mercator.yAxisProjection(44); - assertEquals(result, 5465442.183322753); + assert result == 5465442.183322753; } } From d66c39b20744583039cc9104dd2dc5b2c7cc20e3 Mon Sep 17 00:00:00 2001 From: Grigorios Dimopoulos Date: Thu, 1 Nov 2018 14:00:37 +0200 Subject: [PATCH 7/8] [Mercator] Minor fix --- .../algorithms/mercator/EllipticalMercatorUnitTest.java | 4 ++-- .../algorithms/mercator/SphericalMercatorUnitTest.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java index 4889c7640f..ce2f171051 100644 --- a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java +++ b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java @@ -6,14 +6,14 @@ import org.junit.Test; public class EllipticalMercatorUnitTest { @Test - public void giventThatTheInputIs22_whenXAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { + public void givenThatTheInputIs22_whenXAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { Mercator mercator = new EllipticalMercator(); double result = mercator.xAxisProjection(22); assert result == 2449028.7974520186; } @Test - public void giventThatTheInputIs44_whenYAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { + public void givenThatTheInputIs44_whenYAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { Mercator mercator = new EllipticalMercator(); double result = mercator.yAxisProjection(44); assert result == 5435749.887511954; diff --git a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java index 80e09b4c79..bbb34302ed 100644 --- a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java +++ b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java @@ -6,14 +6,14 @@ import static junit.framework.TestCase.assertEquals; public class SphericalMercatorUnitTest { @Test - public void giventThatTheInputIs22_whenXAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { + public void givenThatTheInputIs22_whenXAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { Mercator mercator = new SphericalMercator(); double result = mercator.xAxisProjection(22); assert result == 2449028.7974520186; } @Test - public void giventThatTheInputIs44_whenYAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { + public void givenThatTheInputIs44_whenYAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { Mercator mercator = new SphericalMercator(); double result = mercator.yAxisProjection(44); assert result == 5465442.183322753; From 80357224acfd98d117054ddb70fd86d5e508bad8 Mon Sep 17 00:00:00 2001 From: Grigorios Dimopoulos Date: Mon, 5 Nov 2018 11:04:44 +0200 Subject: [PATCH 8/8] [Mercator]: Unit test fixes --- .../mercator/EllipticalMercatorUnitTest.java | 9 +++++---- .../algorithms/mercator/SphericalMercatorUnitTest.java | 10 +++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java index ce2f171051..96b644c46c 100644 --- a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java +++ b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/EllipticalMercatorUnitTest.java @@ -1,21 +1,22 @@ package com.baeldung.algorithms.mercator; +import org.junit.Assert; import org.junit.Test; public class EllipticalMercatorUnitTest { @Test - public void givenThatTheInputIs22_whenXAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { + public void giventThatTheInputIs22_whenXAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { Mercator mercator = new EllipticalMercator(); double result = mercator.xAxisProjection(22); - assert result == 2449028.7974520186; + Assert.assertEquals(result, 2449028.7974520186, 0.0); } @Test - public void givenThatTheInputIs44_whenYAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { + public void giventThatTheInputIs44_whenYAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { Mercator mercator = new EllipticalMercator(); double result = mercator.yAxisProjection(44); - assert result == 5435749.887511954; + Assert.assertEquals(result, 5435749.887511954, 0.0); } } diff --git a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java index bbb34302ed..348c6ad3e4 100644 --- a/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java +++ b/algorithms-miscellaneous-2/src/test/java/com/baeldung/algorithms/mercator/SphericalMercatorUnitTest.java @@ -1,21 +1,21 @@ package com.baeldung.algorithms.mercator; +import org.junit.Assert; import org.junit.Test; -import static junit.framework.TestCase.assertEquals; public class SphericalMercatorUnitTest { @Test - public void givenThatTheInputIs22_whenXAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { + public void giventThatTheInputIs22_whenXAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { Mercator mercator = new SphericalMercator(); double result = mercator.xAxisProjection(22); - assert result == 2449028.7974520186; + Assert.assertEquals(result, 2449028.7974520186, 0.0); } @Test - public void givenThatTheInputIs44_whenYAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { + public void giventThatTheInputIs44_whenYAxisProjectionIsCalled_thenTheResultIsTheCorrectOne() { Mercator mercator = new SphericalMercator(); double result = mercator.yAxisProjection(44); - assert result == 5465442.183322753; + Assert.assertEquals(result, 5465442.183322753, 0.0); } }