Changeset 7033 in josm for trunk/test/unit/org/openstreetmap/josm/data/projection
- Timestamp:
- 2014-05-01T02:34:43+02:00 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRefTest.java
r7005 r7033 49 49 @Test 50 50 public void test() throws IOException, FileNotFoundException { 51 BufferedReader in = new BufferedReader(new InputStreamReader( new FileInputStream("data_nodist/projection-reference-data.csv"), Utils.UTF_8));52 StringBuilder fail = new StringBuilder();53 String line;54 while ((line = in.readLine()) != null) {55 if (line.startsWith("#")) {56 continue;57 }58 String[] f = line.split(",");59 String code = f[0];60 double lat = Double.parseDouble(f[1]);61 double l on= Double.parseDouble(f[2]);62 double east= Double.parseDouble(f[3]);63 double north= Double.parseDouble(f[4]);64 Projection p = Projections.getProjectionByCode(code);65 {51 try (BufferedReader in = new BufferedReader(new InputStreamReader( 52 new FileInputStream("data_nodist/projection-reference-data.csv"), Utils.UTF_8))) { 53 StringBuilder fail = new StringBuilder(); 54 String line; 55 while ((line = in.readLine()) != null) { 56 if (line.startsWith("#")) { 57 continue; 58 } 59 String[] f = line.split(","); 60 String code = f[0]; 61 double lat = Double.parseDouble(f[1]); 62 double lon = Double.parseDouble(f[2]); 63 double east = Double.parseDouble(f[3]); 64 double north = Double.parseDouble(f[4]); 65 Projection p = Projections.getProjectionByCode(code); 66 66 EastNorth en = p.latlon2eastNorth(new LatLon(lat, lon)); 67 String error = String.format("%s (%s): Projecting latlon(%s,%s):%n" + 67 String errorEN = String.format("%s (%s): Projecting latlon(%s,%s):%n" + 68 68 " expected: eastnorth(%s,%s),%n" + 69 69 " but got: eastnorth(%s,%s)!%n", 70 70 p.toString(), code, lat, lon, east, north, en.east(), en.north()); 71 double EPSILON = 1e-3; // 1 mm accuracy 72 if (Math.abs(east - en.east()) > EPSILON || Math.abs(north - en.north()) > EPSILON) { 73 fail.append(error); 71 double EPSILON_EN = 1e-3; // 1 mm accuracy 72 if (Math.abs(east - en.east()) > EPSILON_EN || Math.abs(north - en.north()) > EPSILON_EN) { 73 fail.append(errorEN); 74 74 } 75 }76 {77 75 LatLon ll = p.eastNorth2latlon(new EastNorth(east, north)); 78 String error = String.format("%s (%s): Inverse projecting eastnorth(%s,%s):%n" + 76 String errorLL = String.format("%s (%s): Inverse projecting eastnorth(%s,%s):%n" + 79 77 " expected: latlon(%s,%s),%n" + 80 78 " but got: latlon(%s,%s)!%n", 81 79 p.toString(), code, east, north, lat, lon, ll.lat(), ll.lon()); 82 double EPSILON = Math.toDegrees(1e-3 / 6378137); // 1 mm accuracy (or better) 83 if (Math.abs(lat - ll.lat()) > EPSILON || Math.abs(lon - ll.lon()) > EPSILON) { 80 double EPSILON_LL = Math.toDegrees(1e-3 / 6378137); // 1 mm accuracy (or better) 81 if (Math.abs(lat - ll.lat()) > EPSILON_LL || Math.abs(lon - ll.lon()) > EPSILON_LL) { 84 82 if (!("yes".equals(System.getProperty("suppressPermanentFailure")) && code.equals("EPSG:21781"))) { 85 fail.append(error); 83 fail.append(errorLL); 86 84 } 87 85 } 88 86 } 89 } 90 Utils.close(in); 91 if (fail.length() > 0) { 92 System.err.println(fail.toString()); 93 throw new AssertionError(fail.toString()); 87 if (fail.length() > 0) { 88 System.err.println(fail.toString()); 89 throw new AssertionError(fail.toString()); 90 } 94 91 } 95 92 }
Note:
See TracChangeset
for help on using the changeset viewer.
