Ignore:
Timestamp:
2016-07-16T16:24:16+02:00 (8 years ago)
Author:
wiktorn
Message:

Do not use 180 meridian hack when drawing tiles from different zoom

  • 180 meridian hack works improperly, when tileset doesn't cover whole screen. In case when we are creating small tilesets, we do not execute the hack
  • always load placeholder tile if the tile is not loaded
  • use shifted LatLon when computing the tileset for tiles from different zoom level

See: #12681
Closes: #13147

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java

    r10488 r10534  
    904904            tile = new Tile(tileSource, x, y, zoom);
    905905            tileCache.addTile(tile);
     906        }
     907
     908        if (!tile.isLoaded()) {
    906909            tile.loadPlaceholderFromCache(tileCache);
    907910        }
     
    939942        EastNorth topLeft = mv.getEastNorth(0, 0);
    940943        EastNorth botRight = mv.getEastNorth(mv.getWidth(), mv.getHeight());
    941         return new TileSet(topLeft, botRight, currentZoomLevel);
     944        return new MapWrappingTileSet(topLeft, botRight, currentZoomLevel);
    942945    }
    943946
     
    11971200    }
    11981201
     1202    private LatLon getShiftedLatLon(ICoordinate latLon) {
     1203        return getShiftedLatLon(Main.getProjection().latlon2eastNorth(new LatLon(latLon)));
     1204    }
     1205
     1206
    11991207    private final TileSet nullTileSet = new TileSet((LatLon) null, (LatLon) null, 0);
    12001208
    1201     private final class TileSet {
     1209    private final class MapWrappingTileSet extends TileSet {
     1210            private MapWrappingTileSet(EastNorth topLeft, EastNorth botRight, int zoom) {
     1211                this(getShiftedLatLon(topLeft), getShiftedLatLon(botRight), zoom);
     1212            }
     1213
     1214            private MapWrappingTileSet(LatLon topLeft, LatLon botRight, int zoom) {
     1215                super(topLeft, botRight, zoom);
     1216                double centerLon = getShiftedLatLon(Main.map.mapView.getCenter()).lon();
     1217
     1218                if (topLeft.lon() > centerLon) {
     1219                    x0 = tileSource.getTileXMin(zoom);
     1220                }
     1221                if (botRight.lon() < centerLon) {
     1222                    x1 = tileSource.getTileXMax(zoom);
     1223                }
     1224                sanitize();
     1225            }
     1226    }
     1227
     1228    private class TileSet {
    12021229        int x0, x1, y0, y1;
    12031230        int zoom;
     
    12311258            x1 = t2.getXIndex();
    12321259            y1 = t2.getYIndex();
    1233             double centerLon = getShiftedLatLon(Main.map.mapView.getCenter()).lon();
    1234 
    1235             if (topLeft.lon() > centerLon) {
    1236                 x0 = tileSource.getTileXMin(zoom);
    1237             }
    1238             if (botRight.lon() < centerLon) {
    1239                 x1 = tileSource.getTileXMax(zoom);
    1240             }
    1241 
     1260            sanitize();
     1261        }
     1262
     1263        protected void sanitize() {
    12421264            if (x0 > x1) {
    12431265                int tmp = x0;
     
    14181440                TileSet ts = tileSets[zoom-minZoom];
    14191441                if (ts == null) {
    1420                     ts = new TileSet(topLeft, botRight, zoom);
     1442                    ts = new MapWrappingTileSet(topLeft, botRight, zoom);
    14211443                    tileSets[zoom-minZoom] = ts;
    14221444                }
     
    15361558                }
    15371559                Tile t2 = tempCornerTile(missed);
    1538                 LatLon topLeft2 = new LatLon(tileSource.tileXYToLatLon(missed));
    1539                 LatLon botRight2 = new LatLon(tileSource.tileXYToLatLon(t2));
     1560                LatLon topLeft2 = getShiftedLatLon(tileSource.tileXYToLatLon(missed));
     1561                LatLon botRight2 = getShiftedLatLon(tileSource.tileXYToLatLon(t2));
    15401562                TileSet ts2 = new TileSet(topLeft2, botRight2, newzoom);
    15411563                // Instantiating large TileSets is expensive.  If there
Note: See TracChangeset for help on using the changeset viewer.