Changeset 8586 in josm for trunk/test/unit/org
- Timestamp:
- 2015-07-08T23:06:52+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/imagery/WMTSTileSourceTest.java
r8585 r8586 11 11 import org.junit.BeforeClass; 12 12 import org.junit.Test; 13 import org.openstreetmap.gui.jmapviewer.TileXY;14 13 import org.openstreetmap.gui.jmapviewer.tilesources.TemplatedTMSTileSource; 15 14 import org.openstreetmap.josm.JOSMFixture; … … 70 69 assertEquals("TileXMax", 2, testSource.getTileXMax(2)); 71 70 assertEquals("TileYMax", 2, testSource.getTileYMax(2)); 72 assertEquals("TileXMax", 5, testSource.getTileXMax(3));71 assertEquals("TileXMax", 4, testSource.getTileXMax(3)); 73 72 assertEquals("TileYMax", 4, testSource.getTileYMax(3)); 74 73 … … 79 78 Main.setProjection(Projections.getProjectionByCode("EPSG:31370")); 80 79 WMTSTileSource testSource = new WMTSTileSource(testImageryWALLONIE); 80 assertEquals("http://geoservices.wallonie.be/arcgis/rest/services/DONNEES_BASE/FOND_PLAN_ANNOTATIONS_2012_RW_NB/" 81 + "MapServer/WMTS/tile/1.0.0/DONNEES_BASE_FOND_PLAN_ANNOTATIONS_2012_RW_NB/default/default028mm/5/1219/1063.png", 82 testSource.getTileUrl(6, 1063, 1219)); 83 84 // +bounds=2.54,49.51,6.4,51.5 81 85 Bounds wallonieBounds = new Bounds( 82 86 new LatLon(49.485372459967245, 2.840548314430268), 83 87 new LatLon(50.820959517561256, 6.427849693016202) 84 88 ); 85 verifyBounds(wallonieBounds, testSource, 10, 20324, 17724); 89 verifyBounds(wallonieBounds, testSource, 6, 1063, 1219); 90 verifyBounds(wallonieBounds, testSource, 11, 17724, 20324); 91 LatLon ll = new LatLon(testSource.tileXYToLatLon(1063, 1219, 6)); 86 92 87 93 } 88 94 89 95 private void verifyBounds(Bounds bounds, WMTSTileSource testSource, int z, int x, int y) { 90 LatLon ret = new LatLon(testSource.tileXYToLatLon( y, y, z));96 LatLon ret = new LatLon(testSource.tileXYToLatLon(x, y, z)); 91 97 assertTrue(ret.toDisplayString() + " doesn't lie within: " + bounds.toString(), bounds.contains(ret)); 98 int tileXmax = testSource.getTileXMax(z); 99 int tileYmax = testSource.getTileYMax(z); 100 assertTrue("tile x: " + x + " is greater than allowed max: " + tileXmax, tileXmax >= x); 101 assertTrue("tile y: " + y + " is greater than allowed max: " + tileYmax, tileYmax >= y); 92 102 } 93 103 … … 96 106 Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); 97 107 WMTSTileSource testSource = new WMTSTileSource(testImageryWIEN); 98 int zoomOffset = 10; 99 100 // Linz - 11/1105/709.png 108 int zoomOffset = 9; 109 101 110 verifyMercatorTile(testSource, 0, 0, 1, zoomOffset); 102 111 verifyMercatorTile(testSource, 1105, 709, 2, zoomOffset); … … 106 115 verifyMercatorTile(testSource, 1, 1, 2, zoomOffset); 107 116 108 109 LatLon ll = new LatLon(testSource.tileXYToLatLon(500, 500, 1));110 111 TileXY xy = testSource.latLonToTileXY(new LatLon(48.21, 14.24).toCoordinate(), 1);112 assertTrue("X index is negative: " + xy.getXIndex(), xy.getXIndex() > 0);113 assertTrue(xy.getYIndex() > 0);114 117 for (int x = 0; x < 4; x++) { 115 118 for (int y = 0; y < 4; y++) { … … 119 122 for (int x = 0; x < 8; x++) { 120 123 for (int y = 0; y < 4; y++) { 121 verifyMercatorTile(testSource, x, y, zoomOffset); 122 } 123 } 124 125 verifyMercatorTile(testSource, 2 << 9 - 1, 2 << 8 - 1, zoomOffset); 126 127 assertEquals("TileXMax", 1, testSource.getTileXMax(1)); 128 assertEquals("TileYMax", 1, testSource.getTileYMax(1)); 129 assertEquals("TileXMax", 2, testSource.getTileXMax(2)); 130 assertEquals("TileYMax", 2, testSource.getTileYMax(2)); 131 assertEquals("TileXMax", 4, testSource.getTileXMax(3)); 132 assertEquals("TileYMax", 4, testSource.getTileYMax(3)); 124 verifyMercatorTile(testSource, x, y, 4, zoomOffset); 125 } 126 } 127 128 verifyMercatorTile(testSource, 2 << 9 - 1, 2 << 8 - 1, 2, zoomOffset); 129 130 verifyMercatorMax(testSource, 1, zoomOffset); 131 verifyMercatorMax(testSource, 2, zoomOffset); 132 verifyMercatorMax(testSource, 3, zoomOffset); 133 } 134 135 private void verifyMercatorMax(WMTSTileSource testSource, int zoom, int zoomOffset) { 136 TemplatedTMSTileSource verifier = new TemplatedTMSTileSource(testImageryTMS); 137 int result = testSource.getTileXMax(zoom); 138 int expected = verifier.getTileXMax(zoom + zoomOffset); 139 assertTrue("TileXMax expected: " + expected + " got: " + result, Math.abs(result - expected) < 5); 140 result = testSource.getTileYMax(zoom); 141 expected = verifier.getTileYMax(zoom + zoomOffset); 142 assertTrue("TileYMax expected: " + expected + " got: " + result, Math.abs(result - expected) < 5); 133 143 } 134 144 … … 141 151 verifyTile(new LatLon(51.1268639, 16.8731360), testSource, 1, 1, 2); 142 152 143 assertEquals("TileXMax", 37, testSource.getTileXMax(1));144 assertEquals("TileYMax", 1 9, testSource.getTileYMax(1));145 assertEquals("TileXMax", 74, testSource.getTileXMax(2));146 assertEquals("TileYMax", 37, testSource.getTileYMax(2));147 assertEquals("TileXMax", 148, testSource.getTileXMax(3));148 assertEquals("TileYMax", 74, testSource.getTileYMax(3));153 assertEquals("TileXMax", 2, testSource.getTileXMax(1)); 154 assertEquals("TileYMax", 1, testSource.getTileYMax(1)); 155 assertEquals("TileXMax", 3, testSource.getTileXMax(2)); 156 assertEquals("TileYMax", 2, testSource.getTileYMax(2)); 157 assertEquals("TileXMax", 6, testSource.getTileXMax(3)); 158 assertEquals("TileYMax", 4, testSource.getTileYMax(3)); 149 159 assertEquals( 150 160 "http://mapy.geoportal.gov.pl/wss/service/WMTS/guest/wmts/TOPO?SERVICE=WMTS&REQUEST=GetTile&" 151 + "VERSION=1.0.0&LAYER=MAPA TOPOGRAFICZNA&STYLE= &FORMAT=image/jpeg&tileMatrixSet=EPSG:4326&"161 + "VERSION=1.0.0&LAYER=MAPA TOPOGRAFICZNA&STYLE=default&FORMAT=image/jpeg&tileMatrixSet=EPSG:4326&" 152 162 + "tileMatrix=EPSG:4326:0&tileRow=1&tileCol=1", 153 163 testSource.getTileUrl(1, 1, 1)); … … 159 169 WMTSTileSource testSource = new WMTSTileSource(testImageryORTO_PL); 160 170 verifyTile(new LatLon(53.5993712684958, 19.560669777688176), testSource, 12412, 3941, 14); 161 162 171 verifyTile(new LatLon(49.783096954497786, 22.79034127751704), testSource, 17714, 10206, 14); 163 172 } … … 187 196 LatLon result = new LatLon(testSource.tileXYToLatLon(x, y, z)); 188 197 LatLon expected = new LatLon(verifier.tileXYToLatLon(x, y, z + zoomOffset)); 189 System.out.println(z + "/" + x + "/" + y + " - result: " + result.toDisplayString() + " osmMercator: " + expected.toDisplayString());198 //System.out.println(z + "/" + x + "/" + y + " - result: " + result.toDisplayString() + " osmMercator: " + expected.toDisplayString()); 190 199 assertEquals("Longitude" , expected.lon(), result.lon(), 1e-04); 191 200 assertEquals("Latitude", expected.lat(), result.lat(), 1e-04); 192 //assertTrue("result: " + result.toDisplayString() + " osmMercator: " + expected.toDisplayString(), result.equalsEpsilon(expected));193 // LatLon tileCenter = new Bounds(result, new LatLon(testSource.tileXYToLatLon(x+1, y+1, z))).getCenter();194 // TileXY backwardsResult = testSource.latLonToTileXY(tileCenter.toCoordinate(), z);195 //assertEquals(x, backwardsResult.getXIndex());196 //assertEquals(y, backwardsResult.getYIndex());197 201 } 198 202 }
Note:
See TracChangeset
for help on using the changeset viewer.