Changeset 17275 in josm for trunk/test/unit/org/openstreetmap/josm/data/projection/SwissGridTest.java
- Timestamp:
- 2020-10-28T20:41:00+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/projection/SwissGridTest.java
r16913 r17275 2 2 package org.openstreetmap.josm.data.projection; 3 3 4 import static org.junit. Assert.assertSame;5 import static org.junit. Assert.assertTrue;6 7 import org.junit. BeforeClass;8 import org.junit. Rule;9 import org.junit. Test;4 import static org.junit.jupiter.api.Assertions.assertSame; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 7 import org.junit.jupiter.api.BeforeAll; 8 import org.junit.jupiter.api.Test; 9 import org.junit.jupiter.api.extension.RegisterExtension; 10 10 import org.openstreetmap.josm.data.coor.EastNorth; 11 11 import org.openstreetmap.josm.data.coor.LatLon; … … 17 17 * Unit tests for the Swiss projection grid. 18 18 */ 19 publicclass SwissGridTest {19 class SwissGridTest { 20 20 private static final String SWISS_EPSG_CODE = "EPSG:21781"; 21 21 private final boolean debug = false; … … 24 24 * Setup test. 25 25 */ 26 @R ule26 @RegisterExtension 27 27 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 28 28 public JOSMTestRules test = new JOSMTestRules().projectionNadGrids(); … … 31 31 * Setup test. 32 32 */ 33 @Before Class33 @BeforeAll 34 34 public static void setUp() { 35 35 ProjectionRegistry.setProjection(Projections.getProjectionByCode(SWISS_EPSG_CODE)); // Swiss grid … … 79 79 } 80 80 } 81 assertSame(errs. toString(), errs.length(), 0);81 assertSame(errs.length(), 0, errs::toString); 82 82 } 83 83 … … 86 86 */ 87 87 @Test 88 publicvoid testProjReferenceTestAccurate() {88 void testProjReferenceTestAccurate() { 89 89 projReferenceTest(EPSILON_ACCURATE); 90 90 } … … 94 94 */ 95 95 @Test 96 publicvoid testAlatlon2eastNorth() {96 void testAlatlon2eastNorth() { 97 97 LatLon ll = new LatLon(46.518, 6.567); 98 98 EastNorth en = ProjectionRegistry.getProjection().latlon2eastNorth(ll); … … 100 100 System.out.println(en); 101 101 } 102 assertTrue( "Lausanne",Math.abs(en.east() - 533112.13) < 0.1);103 assertTrue( "Lausanne",Math.abs(en.north() - 152227.35) < 0.1);102 assertTrue(Math.abs(en.east() - 533112.13) < 0.1, "Lausanne"); 103 assertTrue(Math.abs(en.north() - 152227.35) < 0.1, "Lausanne"); 104 104 105 105 ll = new LatLon(47.78, 8.58); … … 108 108 System.out.println(en); 109 109 } 110 assertTrue( "Schafouse",Math.abs(en.east() - 685542.97) < 0.1);111 assertTrue( "Schafouse",Math.abs(en.north() - 292783.21) < 0.1);110 assertTrue(Math.abs(en.east() - 685542.97) < 0.1, "Schafouse"); 111 assertTrue(Math.abs(en.north() - 292783.21) < 0.1, "Schafouse"); 112 112 113 113 ll = new LatLon(46.58, 10.48); … … 116 116 System.out.println(en); 117 117 } 118 assertTrue( "Grinson",Math.abs(en.east() - 833066.95) < 0.1);119 assertTrue( "Grinson",Math.abs(en.north() - 163265.32) < 0.1);118 assertTrue(Math.abs(en.east() - 833066.95) < 0.1, "Grinson"); 119 assertTrue(Math.abs(en.north() - 163265.32) < 0.1, "Grinson"); 120 120 121 121 ll = new LatLon(46.0 + 57.0 / 60 + 3.89813884505 / 3600, 7.0 + 26.0 / 60 + 19.076595154147 / 3600); … … 124 124 System.out.println(en); 125 125 } 126 assertTrue( "Berne",Math.abs(en.east() - 600000.0) < 0.1);127 assertTrue( "Berne",Math.abs(en.north() - 200000.0) < 0.1);126 assertTrue(Math.abs(en.east() - 600000.0) < 0.1, "Berne"); 127 assertTrue(Math.abs(en.north() - 200000.0) < 0.1, "Berne"); 128 128 129 129 // http://geodesy.geo.admin.ch/reframe/lv03towgs84?easting=700000&northing=100000 … … 133 133 System.out.println(en); 134 134 } 135 assertTrue( "Ref",Math.abs(en.east() - 700000.0) < 0.1);136 assertTrue( "Ref",Math.abs(en.north() - 100000.0) < 0.1);135 assertTrue(Math.abs(en.east() - 700000.0) < 0.1, "Ref"); 136 assertTrue(Math.abs(en.north() - 100000.0) < 0.1, "Ref"); 137 137 } 138 138 … … 141 141 */ 142 142 @Test 143 publicvoid testBeastNorth2latlon() {143 void testBeastNorth2latlon() { 144 144 EastNorth en = new EastNorth(533112.13, 152227.35); 145 145 LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(en); … … 147 147 System.out.println(ll); 148 148 } 149 assertTrue( "Lausanne",Math.abs(ll.lat() - 46.518) < 0.00001);150 assertTrue( "Lausanne",Math.abs(ll.lon() - 6.567) < 0.00001);149 assertTrue(Math.abs(ll.lat() - 46.518) < 0.00001, "Lausanne"); 150 assertTrue(Math.abs(ll.lon() - 6.567) < 0.00001, "Lausanne"); 151 151 152 152 en = new EastNorth(685542.97, 292783.21); … … 155 155 System.out.println(ll); 156 156 } 157 assertTrue( "Schafouse",Math.abs(ll.lat() - 47.78) < 0.00001);158 assertTrue( "Schafouse",Math.abs(ll.lon() - 8.58) < 0.00001);157 assertTrue(Math.abs(ll.lat() - 47.78) < 0.00001, "Schafouse"); 158 assertTrue(Math.abs(ll.lon() - 8.58) < 0.00001, "Schafouse"); 159 159 160 160 en = new EastNorth(833066.95, 163265.32); … … 163 163 System.out.println(ll); 164 164 } 165 assertTrue( "Grinson",Math.abs(ll.lat() - 46.58) < 0.00001);166 assertTrue( "Grinson",Math.abs(ll.lon() - 10.48) < 0.00001);165 assertTrue(Math.abs(ll.lat() - 46.58) < 0.00001, "Grinson"); 166 assertTrue(Math.abs(ll.lon() - 10.48) < 0.00001, "Grinson"); 167 167 168 168 en = new EastNorth(600000.0, 200000.0); … … 171 171 System.out.println(ll); 172 172 } 173 assertTrue( "Berne",Math.abs(ll.lat() - (46.0 + 57.0 / 60 + 3.89813884505 / 3600)) < 0.00001);174 assertTrue( "Berne",Math.abs(ll.lon() - (7.0 + 26.0 / 60 + 19.076595154147 / 3600)) < 0.00001);173 assertTrue(Math.abs(ll.lat() - (46.0 + 57.0 / 60 + 3.89813884505 / 3600)) < 0.00001, "Berne"); 174 assertTrue(Math.abs(ll.lon() - (7.0 + 26.0 / 60 + 19.076595154147 / 3600)) < 0.00001, "Berne"); 175 175 176 176 // http://geodesy.geo.admin.ch/reframe/lv03towgs84?easting=700000&northing=100000 … … 180 180 System.out.println(ll); 181 181 } 182 assertTrue( "Ref",Math.abs(ll.lat() - 46.04412093223244) < 0.00001);183 assertTrue( "Ref",Math.abs(ll.lon() - 8.730497366167727) < 0.00001);182 assertTrue(Math.abs(ll.lat() - 46.04412093223244) < 0.00001, "Ref"); 183 assertTrue(Math.abs(ll.lon() - 8.730497366167727) < 0.00001, "Ref"); 184 184 } 185 185 … … 188 188 */ 189 189 @Test 190 publicvoid testCsendandreturn() {190 void testCsendandreturn() { 191 191 EastNorth en = new EastNorth(533111.69, 152227.85); 192 192 LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(en); … … 198 198 System.out.println(en.north() - en2.north()); 199 199 } 200 assertTrue( "Lausanne",Math.abs(en.east() - en2.east()) < 0.002);201 assertTrue( "Lausanne",Math.abs(en.north() - en2.north()) < 0.002);200 assertTrue(Math.abs(en.east() - en2.east()) < 0.002, "Lausanne"); 201 assertTrue(Math.abs(en.north() - en2.north()) < 0.002, "Lausanne"); 202 202 203 203 en = new EastNorth(685544.16, 292782.91); … … 210 210 System.out.println(en.north() - en2.north()); 211 211 } 212 assertTrue( "Schafouse",Math.abs(en.east() - en2.east()) < 0.002);213 assertTrue( "Schafouse",Math.abs(en.north() - en2.north()) < 0.002);212 assertTrue(Math.abs(en.east() - en2.east()) < 0.002, "Schafouse"); 213 assertTrue(Math.abs(en.north() - en2.north()) < 0.002, "Schafouse"); 214 214 215 215 en = new EastNorth(833068.04, 163265.39); … … 222 222 System.out.println(en.north() - en2.north()); 223 223 } 224 assertTrue( "Grinson",Math.abs(en.east() - en2.east()) < 0.002);225 assertTrue( "Grinson",Math.abs(en.north() - en2.north()) < 0.002);224 assertTrue(Math.abs(en.east() - en2.east()) < 0.002, "Grinson"); 225 assertTrue(Math.abs(en.north() - en2.north()) < 0.002, "Grinson"); 226 226 227 227 en = new EastNorth(600000.0, 200000.0); … … 234 234 System.out.println(en.north() - en2.north()); 235 235 } 236 assertTrue( "Berne",Math.abs(en.east() - en2.east()) < 0.002);237 assertTrue( "Berne",Math.abs(en.north() - en2.north()) < 0.002);236 assertTrue(Math.abs(en.east() - en2.east()) < 0.002, "Berne"); 237 assertTrue(Math.abs(en.north() - en2.north()) < 0.002, "Berne"); 238 238 239 239 en = new EastNorth(700000.0, 100000.0); … … 246 246 System.out.println(en.north() - en2.north()); 247 247 } 248 assertTrue( "Ref",Math.abs(en.east() - en2.east()) < 0.002);249 assertTrue( "Ref",Math.abs(en.north() - en2.north()) < 0.002);248 assertTrue(Math.abs(en.east() - en2.east()) < 0.002, "Ref"); 249 assertTrue(Math.abs(en.north() - en2.north()) < 0.002, "Ref"); 250 250 } 251 251 }
Note:
See TracChangeset
for help on using the changeset viewer.
