Changeset 30344 in osm for applications/editors/josm/plugins/ElevationProfile/test/org
- Timestamp:
- 2014-03-24T18:28:13+01:00 (11 years ago)
- Location:
- applications/editors/josm/plugins/ElevationProfile/test/org/openstreetmap/josm/plugins/elevation/tests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/ElevationProfile/test/org/openstreetmap/josm/plugins/elevation/tests/EleVertexTest.java
r29964 r30344 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.elevation.tests; 2 3 … … 18 19 * Setup test. 19 20 */ 21 @Override 20 22 public void setUp() { 21 23 Main.pref = new Preferences(); 22 24 } 23 25 24 26 public void testDivide() { 25 26 27 28 29 30 31 32 33 34 // 1st vertex (p1, p2, pN 105m) 35 36 37 38 39 40 41 // 2nd vertex (p3, p2, pN = 105m) 42 43 44 45 46 47 27 EleCoordinate p1 = new EleCoordinate(30.0, 30.0, 100.0); 28 EleCoordinate p2 = new EleCoordinate(35.0, 30.0, 120.0); 29 EleCoordinate p3 = new EleCoordinate(35.0, 40.0, 110.0); 30 EleVertex ev = new EleVertex(p1, p2, p3); 31 32 List<EleVertex> list = ev.divide(); 33 34 assertEquals(2, list.size()); 35 36 // 1st vertex (p1, p2, pN 105m) 37 EleVertex v1 = list.get(0); 38 assertEquals(325 / 3D, v1.getEle()); 39 assertCoorEq(v1, 30D, 30D, 0); 40 assertCoorEq(v1, 30D, 35D, 1); 41 assertCoorEq(v1, 35D, 32.5D, 2); 42 43 // 2nd vertex (p3, p2, pN = 105m) 44 EleVertex v2 = list.get(1); 45 46 assertEquals(335/3D, v2.getEle()); 47 assertCoorEq(v2, 40D, 35D, 0); 48 assertCoorEq(v2, 30D, 35D, 1); 49 assertCoorEq(v2, 35D, 32.5D, 2); 48 50 } 49 51 50 52 public void testSimpleRecurse() { 51 52 53 54 55 56 57 58 53 EleCoordinate c1 = new EleCoordinate(new LatLon(50.8328, 8.1337), 300); 54 EleCoordinate c2 = new EleCoordinate(new LatLon(50.8328, 7.9217), 200); 55 EleCoordinate c3 = new EleCoordinate(new LatLon(50.9558, 7.9217), 400); 56 EleCoordinate c4 = new EleCoordinate(new LatLon(50.5767627, 9.1938483), 100); 57 58 EleVertex v1 = new EleVertex(c1, c2, c3); 59 System.out.println("Start recurse"); 60 recurse(v1, 0); 59 61 } 60 62 61 63 private void recurse(EleVertex v, int depth) { 62 63 64 65 66 67 assertTrue(depth < 50); //, "Too many recursions?"); 68 69 70 71 72 73 74 75 64 if (!v.isFinished() && depth <100) { 65 System.out.println("\tDivide: " + v); 66 List<EleVertex> list = v.divide(); 67 assertNotNull(list); 68 assertEquals(2, list.size()); 69 assertTrue(depth < 50); //, "Too many recursions?"); 70 for (EleVertex eleVertex : list) { 71 //System.out.println("\t\tRecurse: " + eleVertex); 72 assertTrue("Area is larger " + v.getArea() + " > " + eleVertex.getArea(), eleVertex.getArea() < v.getArea()); 73 recurse(eleVertex, depth + 1); 74 } 75 } else { 76 System.out.println("Finished: " + depth); 77 } 76 78 } 77 79 /* 78 80 public void testRenderer() { 79 80 81 82 83 new LatLon(50.6607106, 8.7337029), 84 85 86 81 82 // Staufenberg, Hessen 83 // Ulrichstein, Hessen 84 GridRenderer er = new GridRenderer("Ele", new Bounds( 85 new LatLon(50.6607106, 8.7337029), 86 new LatLon(50.5767627, 9.1938483)), null); 87 88 er.run(); 87 89 }*/ 88 90 89 91 public void testColorMap() { 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 assertEquals(Color.darkGray, c5); 92 ColorMap testMap = ColorMap.create("Test", new Color[]{Color.white, Color.black}, new int[]{0, 1000}); 93 94 // range test 95 Color c1 = testMap.getColor(-100); 96 assertEquals(Color.white, c1); 97 // range test 98 Color c2 = testMap.getColor(1100); 99 assertEquals(Color.black, c2); 100 // test mid (RGB 128, 128, 128) 101 Color c3 = testMap.getColor(500); 102 assertEquals(Color.gray, c3); 103 104 // test 0.75 (RGB 192 x 3) 105 Color c4 = testMap.getColor(751); 106 assertEquals(Color.lightGray, c4); 107 // test 0.25 (RGB 64 x 3) 108 Color c5 = testMap.getColor(251); 109 assertEquals(Color.darkGray, c5); 108 110 } 109 111 110 112 private void assertCoorEq(EleVertex v1, double x, double y, int n) { 111 112 113 assertEquals(x, v1.get(n).getX()); 114 assertEquals(y, v1.get(n).getY()); 113 115 } 114 116 } -
applications/editors/josm/plugins/ElevationProfile/test/org/openstreetmap/josm/plugins/elevation/tests/HgtReaderTest.java
r29907 r30344 1 // License: GPL. For details, see LICENSE file. 1 2 package org.openstreetmap.josm.plugins.elevation.tests; 2 3 4 3 5 4 import junit.framework.TestCase; … … 15 14 * Setup test. 16 15 */ 16 @Override 17 17 public void setUp() { 18 18 Main.pref = new Preferences(); … … 20 20 21 21 public void testGetElevationFromHgt() { 22 23 24 25 26 27 22 // Staufenberg, Hessen 23 testHgtData(50.6607106, 8.7337029, "N50E008.hgt", 199); 24 // Ulrichstein, Hessen 25 testHgtData(50.5767627, 9.1938483, "N50E009.hgt", 560); 26 // Fujijama 27 //testHgtData(35.360555, 138.727777, "N35E138.hgt", 3741); 28 28 } 29 29 30 30 private void testHgtData(final double lat, final double lon, 31 32 33 34 35 36 37 38 39 40 41 42 31 final String expTag, final int expHeight) { 32 LatLon l = new LatLon(lat, lon); 33 HgtReader hr = new HgtReader(); 34 String text = hr.getHgtFileName(l); 35 36 assertEquals(expTag, text); 37 38 double d = hr.getElevationFromHgt(l); 39 System.out.println(d); 40 assertFalse("Data missing or void for coor " + l, Double.isNaN(d)); 41 42 assertEquals((int)d, expHeight); 43 43 } 44 44 }
Note:
See TracChangeset
for help on using the changeset viewer.