- Timestamp:
- 2017-04-25T03:18:09+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java
r11324 r11999 180 180 } 181 181 182 final boolean java9 = TestUtils.getJavaVersion() >= 9; 182 183 for (TestData data : allData) { 183 184 Projection proj = Projections.getProjectionByCode(data.code); … … 188 189 EastNorth en = proj.latlon2eastNorth(data.ll); 189 190 LatLon ll2 = proj.eastNorth2latlon(data.en); 190 if (TestUtils.getJavaVersion() >= 9) { 191 en = getRoundedToOsmPrecision(en.east(), en.north()); 192 ll2 = ll2.getRoundedToOsmPrecision(); 193 data.en = getRoundedToOsmPrecision(data.en.east(), data.en.north()); 194 data.ll2 = data.ll2.getRoundedToOsmPrecision(); 195 } 196 if (!en.equals(data.en)) { 191 boolean eqJava8 = !java9 && en.equals(data.en); 192 boolean eqJava9 = java9 && equalsJava9(en, data.en); 193 if (!eqJava8 && !eqJava9) { 197 194 String error = String.format("%s (%s): Projecting latlon(%s,%s):%n" + 198 195 " expected: eastnorth(%s,%s),%n" + … … 201 198 fail.append(error); 202 199 } 203 if (!ll2.equals(data.ll2)) { 200 eqJava8 = !java9 && ll2.equals(data.ll2); 201 eqJava9 = java9 && equalsJava9(ll2, data.ll2); 202 if (!eqJava8 && !eqJava9) { 204 203 String error = String.format("%s (%s): Inverse projecting eastnorth(%s,%s):%n" + 205 204 " expected: latlon(%s,%s),%n" + … … 215 214 } 216 215 } 216 217 private static boolean equalsDoubleMaxUlp(double d1, double d2) { 218 // Due to error accumulation in projection computation, the difference can reach thousands of ULPs 219 return Math.abs(d1 - d2) <= 3500 * Math.ulp(d1); 220 } 221 222 private static boolean equalsJava9(EastNorth en1, EastNorth en2) { 223 return equalsDoubleMaxUlp(en1.east(), en2.east()) && 224 equalsDoubleMaxUlp(en1.north(), en2.north()); 225 } 226 227 private static boolean equalsJava9(LatLon ll1, LatLon ll2) { 228 return equalsDoubleMaxUlp(ll1.lat(), ll2.lat()) && 229 equalsDoubleMaxUlp(ll1.lon(), ll2.lon()); 230 } 217 231 }
Note:
See TracChangeset
for help on using the changeset viewer.