From 05b0b6d3628f8f6a8a1f14b9258262a43c8e7191 Mon Sep 17 00:00:00 2001 From: ntruchsess Date: Sun, 4 Feb 2018 18:58:16 +0100 Subject: [PATCH] more elaborated NogoPolygon unit-test --- .../btools/router/OsmNogoPolygonTest.java | 60 +++++++++++-------- 1 file changed, 35 insertions(+), 25 deletions(-) diff --git a/brouter-core/src/test/java/btools/router/OsmNogoPolygonTest.java b/brouter-core/src/test/java/btools/router/OsmNogoPolygonTest.java index bda1d7c..7aa95dc 100644 --- a/brouter-core/src/test/java/btools/router/OsmNogoPolygonTest.java +++ b/brouter-core/src/test/java/btools/router/OsmNogoPolygonTest.java @@ -17,27 +17,32 @@ **********************************************************************************************/ package btools.router; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; -import org.junit.Before; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; public class OsmNogoPolygonTest { - OsmNogoPolygon p; + static final int offset_x = 11000000; + static final int offset_y = 50000000; + + static OsmNogoPolygon polygon; - final double[] lons = { 1.0, 1.0, 0.5, 0.5, 1.0, 1.0, -1.0, -1.0 }; - final double[] lats = { -1.0, -0.1, -0.1, 0.1, 0.1, 1.0, 1.0, -1.0 }; + static final double[] lons = { 1.0, 1.0, 0.5, 0.5, 1.0, 1.0, -1.1, -1.0 }; + static final double[] lats = { -1.0, -0.1, -0.1, 0.1, 0.1, 1.0, 1.1, -1.0 }; - int toOsmLon(double lon) { - return (int)( ( lon + 180. ) *1000000. + 0.5); // see ServerHandler.readPosition() + static int toOsmLon(double lon) { + return (int)( ( lon + 180. ) *1000000. + 0.5)+offset_x; // see ServerHandler.readPosition() } - int toOsmLat(double lat) { - return (int)( ( lat + 90. ) *1000000. + 0.5); + static int toOsmLat(double lat) { + return (int)( ( lat + 90. ) *1000000. + 0.5)+offset_y; } - double coslat(int lat) // see RoutingContext.calcDistance() + static double coslat(int lat) // see RoutingContext.calcDistance() { final double l = (lat - 90000000) * 0.00000001234134; // 0.01234134 = Pi/(sqrt(2)*180) final double l2 = l*l; @@ -46,22 +51,27 @@ public class OsmNogoPolygonTest { return 1.- l2 + l4 / 6.; // - l6 / 90; } - @Before - public void setUp() throws Exception { - p = new OsmNogoPolygon(); + @BeforeClass + public static void setUp() throws Exception { + polygon = new OsmNogoPolygon(); for (int i = 0; i= r1("+r1+")", diff >= 0); @@ -77,20 +87,20 @@ public class OsmNogoPolygonTest { boolean[] within = { true, false, false, false, false, }; // false, false, false, false, false, for (int i=0; i