Changeset 17275 in josm for trunk/test/unit/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSourceTest.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/imagery/TemplatedWMSTileSourceTest.java
r17094 r17275 2 2 package org.openstreetmap.josm.data.imagery; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertTrue;6 7 import org.junit. Rule;8 import org.junit. Test;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 7 import org.junit.jupiter.api.Test; 8 import org.junit.jupiter.api.extension.RegisterExtension; 9 9 import org.openstreetmap.gui.jmapviewer.TileXY; 10 10 import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate; … … 24 24 * Unit tests for class {@link TemplatedWMSTileSource}. 25 25 */ 26 publicclass TemplatedWMSTileSourceTest {26 class TemplatedWMSTileSourceTest { 27 27 28 28 private final ImageryInfo testImageryWMS = new ImageryInfo("test imagery", "http://localhost", "wms", null, null); … … 32 32 * Setup test. 33 33 */ 34 @R ule34 @RegisterExtension 35 35 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 36 36 public JOSMTestRules test = new JOSMTestRules(); … … 40 40 */ 41 41 @Test 42 publicvoid testEPSG3857() {42 void testEPSG3857() { 43 43 Projection projection = Projections.getProjectionByCode("EPSG:3857"); 44 44 ProjectionRegistry.setProjection(projection); … … 65 65 */ 66 66 @Test 67 publicvoid testEPSG4326() {67 void testEPSG4326() { 68 68 Projection projection = Projections.getProjectionByCode("EPSG:4326"); 69 69 ProjectionRegistry.setProjection(projection); … … 81 81 */ 82 82 @Test 83 publicvoid testEPSG4326widebounds() {83 void testEPSG4326widebounds() { 84 84 Projection projection = new CustomProjection("+proj=lonlat +datum=WGS84 +axis=neu +bounds=-180,53,180,54"); 85 85 ProjectionRegistry.setProjection(projection); … … 94 94 */ 95 95 @Test 96 publicvoid testEPSG4326narrowbounds() {96 void testEPSG4326narrowbounds() { 97 97 Projection projection = new CustomProjection("+proj=lonlat +datum=WGS84 +axis=neu +bounds=18,-90,20,90"); 98 98 ProjectionRegistry.setProjection(projection); … … 107 107 */ 108 108 @Test 109 publicvoid testEPSG2180() {109 void testEPSG2180() { 110 110 Projection projection = Projections.getProjectionByCode("EPSG:2180"); 111 111 ProjectionRegistry.setProjection(projection); … … 124 124 */ 125 125 @Test 126 publicvoid testEPSG3006withbounds() {126 void testEPSG3006withbounds() { 127 127 Projection projection = 128 128 new CustomProjection("+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 " … … 140 140 */ 141 141 @Test 142 publicvoid testEPSG3006withoutbounds() {142 void testEPSG3006withoutbounds() { 143 143 Projection projection = 144 144 new CustomProjection("+proj=utm +zone=33 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 " … … 156 156 */ 157 157 @Test 158 publicvoid testGetTileUrl() {158 void testGetTileUrl() { 159 159 // "https://maps.six.nsw.gov.au/arcgis/services/public/NSW_Imagery_Dates/MapServer/WMSServer? 160 160 // SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&CRS={proj}&BBOX={bbox}&WIDTH={width}&HEIGHT={height} … … 206 206 ICoordinate expected = verifier.tileXYToLatLon(x, y, z - 1); 207 207 assertEquals(expected.getLat(), result.lat(), 1e-4); 208 assertEquals(LatLon.normalizeLon(expected.getLon() - result.lon()) , 0.0, 1e-4);208 assertEquals(0.0, LatLon.normalizeLon(expected.getLon() - result.lon()), 1e-4); 209 209 LatLon tileCenter = new Bounds(result, getTileLatLon(source, x+1, y+1, z)).getCenter(); 210 210 TileXY backwardsResult = source.latLonToTileXY(CoordinateConversion.llToCoor(tileCenter), z); … … 224 224 private void verifyLocation(TemplatedWMSTileSource source, LatLon location, int z) { 225 225 Projection projection = ProjectionRegistry.getProjection(); 226 assertTrue( 227 "Point outside world bounds", 228 projection.getWorldBoundsLatLon().contains(location) 229 ); 226 assertTrue(projection.getWorldBoundsLatLon().contains(location), "Point outside world bounds"); 230 227 231 228 TileXY tileIndex = source.latLonToTileXY(CoordinateConversion.llToCoor(location), z); 232 229 233 assertTrue( "X index: " +tileIndex.getXIndex()+ " greater than tileXmax: " +source.getTileXMax(z)+ " at zoom: " + z,234 tileIndex.getXIndex() <=source.getTileXMax(z));235 236 assertTrue( "Y index: " +tileIndex.getYIndex()+ " greater than tileYmax: " +source.getTileYMax(z)+ " at zoom: " + z,237 tileIndex.getYIndex() <=source.getTileYMax(z));230 assertTrue(tileIndex.getXIndex() <= source.getTileXMax(z), 231 "X index: " + tileIndex.getXIndex() + " greater than tileXmax: " + source.getTileXMax(z) + " at zoom: " + z); 232 233 assertTrue(tileIndex.getYIndex() <= source.getTileYMax(z), 234 "Y index: " + tileIndex.getYIndex() + " greater than tileYmax: " + source.getTileYMax(z) + " at zoom: " + z); 238 235 239 236 ICoordinate x1 = source.tileXYToLatLon(tileIndex.getXIndex(), tileIndex.getYIndex(), z); … … 245 242 bounds.extend(x2.getLat(), x2.getLon()); 246 243 // test that location is within tile bounds 247 assertTrue(location + " not within " + bounds + " for tile " + z + "/" + tileIndex.getXIndex() + "/" + tileIndex.getYIndex(),248 bounds.contains(location));244 assertTrue(bounds.contains(location), 245 location + " not within " + bounds + " for tile " + z + "/" + tileIndex.getXIndex() + "/" + tileIndex.getYIndex()); 249 246 verifyTileSquareness(source, tileIndex.getXIndex(), tileIndex.getYIndex(), z); 250 247 }
Note:
See TracChangeset
for help on using the changeset viewer.
