Changeset 11199 in josm for trunk/src/org
- Timestamp:
- 2016-10-30T22:59:14+01:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui/layer
- Files:
-
- 2 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r11197 r11199 42 42 import java.util.function.Function; 43 43 import java.util.stream.Collectors; 44 import java.util.stream.IntStream;45 44 import java.util.stream.Stream; 46 45 … … 93 92 import org.openstreetmap.josm.gui.layer.imagery.ImageryFilterSettings.FilterChangeListener; 94 93 import org.openstreetmap.josm.gui.layer.imagery.TileCoordinateConverter; 94 import org.openstreetmap.josm.gui.layer.imagery.TilePosition; 95 import org.openstreetmap.josm.gui.layer.imagery.TileRange; 95 96 import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings; 96 97 import org.openstreetmap.josm.gui.layer.imagery.TileSourceDisplaySettings.DisplaySettingsChangeEvent; … … 1269 1270 private final TileSet nullTileSet = new TileSet(); 1270 1271 1271 /**1272 * This is a rectangular range of tiles.1273 */1274 private static class TileRange {1275 int minX;1276 int maxX;1277 int minY;1278 int maxY;1279 int zoom;1280 1281 private TileRange() {1282 }1283 1284 protected TileRange(TileXY t1, TileXY t2, int zoom) {1285 minX = (int) Math.floor(Math.min(t1.getX(), t2.getX()));1286 minY = (int) Math.floor(Math.min(t1.getY(), t2.getY()));1287 maxX = (int) Math.ceil(Math.max(t1.getX(), t2.getX()));1288 maxY = (int) Math.ceil(Math.max(t1.getY(), t2.getY()));1289 this.zoom = zoom;1290 }1291 1292 protected double tilesSpanned() {1293 return Math.sqrt(1.0 * this.size());1294 }1295 1296 protected int size() {1297 int xSpan = maxX - minX + 1;1298 int ySpan = maxY - minY + 1;1299 return xSpan * ySpan;1300 }1301 1302 /**1303 * Gets a stream of all tile positions in this set1304 * @return A stream of all positions1305 */1306 public Stream<TilePosition> tilePositions() {1307 if (zoom == 0) {1308 return Stream.empty();1309 } else {1310 return IntStream.rangeClosed(minX, maxX).mapToObj(1311 x -> IntStream.rangeClosed(minY, maxY).mapToObj(y -> new TilePosition(x, y, zoom))1312 ).flatMap(Function.identity());1313 }1314 }1315 }1316 1317 /**1318 * The position of a single tile.1319 * @author Michael Zangl1320 */1321 private static class TilePosition {1322 private final int x;1323 private final int y;1324 private final int zoom;1325 TilePosition(int x, int y, int zoom) {1326 this.x = x;1327 this.y = y;1328 this.zoom = zoom;1329 }1330 1331 TilePosition(Tile tile) {1332 this(tile.getXtile(), tile.getYtile(), tile.getZoom());1333 }1334 1335 /**1336 * @return the x position1337 */1338 public int getX() {1339 return x;1340 }1341 1342 /**1343 * @return the y position1344 */1345 public int getY() {1346 return y;1347 }1348 1349 /**1350 * @return the zoom1351 */1352 public int getZoom() {1353 return zoom;1354 }1355 1356 @Override1357 public String toString() {1358 return "TilePosition [x=" + x + ", y=" + y + ", zoom=" + zoom + ']';1359 }1360 }1361 1362 1272 private class TileSet extends TileRange { 1363 1273
Note:
See TracChangeset
for help on using the changeset viewer.