Changeset 5556 in josm for trunk/test/unit/org/openstreetmap/josm/data/projection
- Timestamp:
- 2012-11-03T18:32:39+01:00 (12 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/data/projection
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionTest.java
r5236 r5556 23 23 text = ""; 24 24 25 testProj( new Epsg4326());26 testProj( new Mercator());25 testProj(Projections.getProjectionByCode("EPSG:4326")); // WGS 84 26 testProj(Projections.getProjectionByCode("EPSG:3857")); // Mercator 27 27 if (!"yes".equals(System.getProperty("suppressPermanentFailure"))) { 28 testProj( new LambertEST());28 testProj(Projections.getProjectionByCode("EPSG:3301")); // Lambert EST 29 29 } 30 30 31 31 for (int i=0; i<=3; ++i) { 32 testProj( new Lambert(i));32 testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(27561+i))); // Lambert 4 Zones France 33 33 } 34 34 35 35 for (int i=0; i<=4; ++i) { 36 testProj( new Puwg(i));36 testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(2176+i))); // PUWG Poland 37 37 } 38 38 39 testProj( new SwissGrid());39 testProj(Projections.getProjectionByCode("EPSG:21781")); // Swiss grid 40 40 41 for (int i=0; i<=6; ++i) { 42 int zone; 43 if (i==0) { 44 zone = 1; 45 } else if (i==6) { 46 zone = 60; 47 } else { 48 zone = rand.nextInt(60) + 1; 49 } 50 UTM.Hemisphere hem = rand.nextBoolean() ? UTM.Hemisphere.North : UTM.Hemisphere.South; 51 testProj(new UTM(zone, hem)); 41 for (int i=0; i<=60; ++i) { 42 testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(32601+i))); // UTM North 43 testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(32701+i))); // UTM South 52 44 } 53 45 54 46 if (!"yes".equals(System.getProperty("suppressPermanentFailure"))) { 55 47 for (int i=0; i<=4; ++i) { 56 testProj( new UTM_France_DOM(i));48 testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(2969+i))); // UTM France DOM 57 49 } 58 50 } 59 51 60 52 for (int i=0; i<=8; ++i) { 61 testProj( new LambertCC9Zones(i));53 testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(3942+i))); // Lambert CC9 Zones France 62 54 } 63 55 … … 69 61 70 62 private void testProj(Projection p) { 71 double maxErrLat = 0, maxErrLon = 0; 72 73 Bounds b = p.getWorldBoundsLatLon(); 74 75 text += String.format("*** %s %s\n", p.toString(), p.toCode()); 76 for (int num=0; num < 1000; ++num) { 77 78 double lat = rand.nextDouble() * (b.getMax().lat() - b.getMin().lat()) + b.getMin().lat(); 79 double lon = rand.nextDouble() * (b.getMax().lon() - b.getMin().lon()) + b.getMin().lon(); 80 81 LatLon ll = new LatLon(lat, lon); 82 83 for (int i=0; i<10; ++i) { 84 EastNorth en = p.latlon2eastNorth(ll); 85 ll = p.eastNorth2latlon(en); 63 if (p != null) { 64 double maxErrLat = 0, maxErrLon = 0; 65 Bounds b = p.getWorldBoundsLatLon(); 66 67 text += String.format("*** %s %s\n", p.toString(), p.toCode()); 68 for (int num=0; num < 1000; ++num) { 69 70 double lat = rand.nextDouble() * (b.getMax().lat() - b.getMin().lat()) + b.getMin().lat(); 71 double lon = rand.nextDouble() * (b.getMax().lon() - b.getMin().lon()) + b.getMin().lon(); 72 73 LatLon ll = new LatLon(lat, lon); 74 75 for (int i=0; i<10; ++i) { 76 EastNorth en = p.latlon2eastNorth(ll); 77 ll = p.eastNorth2latlon(en); 78 } 79 maxErrLat = Math.max(maxErrLat, Math.abs(lat - ll.lat())); 80 maxErrLon = Math.max(maxErrLon, Math.abs(lon - ll.lon())); 86 81 } 87 maxErrLat = Math.max(maxErrLat, Math.abs(lat - ll.lat())); 88 maxErrLon = Math.max(maxErrLon, Math.abs(lon - ll.lon())); 82 83 String mark = ""; 84 if (maxErrLat + maxErrLon > 1e-5) { 85 mark = "--FAILED-- "; 86 error = true; 87 } 88 text += String.format("%s errorLat: %s errorLon: %s\n", mark, maxErrLat, maxErrLon); 89 89 } 90 91 String mark = "";92 if (maxErrLat + maxErrLon > 1e-5) {93 mark = "--FAILED-- ";94 error = true;95 }96 text += String.format("%s errorLat: %s errorLon: %s\n", mark, maxErrLat, maxErrLon);97 90 } 98 91 } -
trunk/test/unit/org/openstreetmap/josm/data/projection/SwissGridTest.java
r4126 r5556 15 15 @BeforeClass 16 16 public static void setUp() { 17 Main.setProjection( new SwissGrid());17 Main.setProjection(Projections.getProjectionByCode("EPSG:21781")); // Swiss grid 18 18 } 19 19 … … 47 47 @Test 48 48 public void projReferenceTest() { 49 Projection swiss = new SwissGrid();49 Projection swiss = Projections.getProjectionByCode("EPSG:21781"); // Swiss grid 50 50 String errs = ""; 51 51 for (ProjData pd : data) {
Note:
See TracChangeset
for help on using the changeset viewer.