Changeset 9167 in josm for trunk/test
- Timestamp:
- 2015-12-26T20:41:45+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/imagery/TemplatedWMSTileSourceTest.java
r8857 r9167 15 15 import org.openstreetmap.josm.data.coor.EastNorth; 16 16 import org.openstreetmap.josm.data.coor.LatLon; 17 import org.openstreetmap.josm.data.osm.BBox;18 17 import org.openstreetmap.josm.data.projection.CustomProjection; 19 18 import org.openstreetmap.josm.data.projection.Projection; … … 107 106 TemplatedWMSTileSource source = getSource(); 108 107 109 verifyLocation(source, new LatLon(60, 18), 3); 110 verifyLocation(source, new LatLon(60, 18)); 108 verifyTileSquarness(source, 0, 1, 4); 109 verifyLocation(source, new LatLon(60, 18.1), 3); 110 verifyLocation(source, new LatLon(60, 18.1)); 111 111 } 112 112 … … 158 158 tileIndex.getYIndex() <= source.getTileYMax(z)); 159 159 160 EastNorth locationEN = Main.getProjection().latlon2eastNorth(location); 161 EastNorth x1 = Main.getProjection().latlon2eastNorth(getTileLatLon(source, tileIndex, z)); 162 EastNorth x2 = Main.getProjection().latlon2eastNorth(getTileLatLon(source, tileIndex.getXIndex() + 1, tileIndex.getYIndex() + 1, z)); 160 163 // test that location is within tile bounds 161 BBox bbox = new BBox( 162 getTileLatLon(source, tileIndex, z), 163 getTileLatLon(source, tileIndex.getXIndex() + 1, tileIndex.getYIndex() + 1, z) 164 ); 165 assertTrue(location.toDisplayString() + " not within " + bbox.toString() + 164 assertTrue(locationEN.toString() + " not within " + bboxStr(x1, x2) + 166 165 " for tile " + z + "/" + tileIndex.getXIndex() + "/" + tileIndex.getYIndex(), 167 bbox.bounds(location));166 isWithin(locationEN, x1, x2)); 168 167 verifyTileSquarness(source, tileIndex.getXIndex(), tileIndex.getYIndex(), z); 168 } 169 170 private static boolean isWithin(EastNorth point, EastNorth topLeft, EastNorth bottomRight) { 171 return Math.min(topLeft.east(), bottomRight.east()) <= point.east() && 172 point.east() <= Math.max(topLeft.east(), bottomRight.east()) && 173 Math.min(topLeft.north(), bottomRight.north()) <= point.north() && 174 point.north() <= Math.max(topLeft.north(), bottomRight.north()); 175 } 176 177 private static String bboxStr(EastNorth x1, EastNorth x2) { 178 return "[" + x1.east() +", " + x1.north() + ", " + x2.east() + ", " + x2.north() +"]"; 169 179 } 170 180
Note:
See TracChangeset
for help on using the changeset viewer.