Changeset 4328 in josm for trunk/src/org/openstreetmap


Ignore:
Timestamp:
2011-08-21T17:41:08+02:00 (13 years ago)
Author:
hansendc
Message:

skew TMSLayer optimal zoom levels to be a bit lower

From the code comment:

In general, smaller zoom levels are more readable. We prefer big,
block, pixelated (but readable) map text to small, smeared,
unreadable underzoomed text. So, use .floor() instead of rounding
to skew things a bit toward the lower zooms.

File:
1 edited

Legend:

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

    r4306 r4328  
    106106    }
    107107
    108     /*boolean debug = false;*/
     108    /*boolean debug = true;*/
    109109
    110110    protected MemoryTileCache tileCache;
     
    311311        double factor = getScaleFactor(1);
    312312        double result = Math.log(factor)/Math.log(2)/2+1;
    313         int intResult = (int)Math.round(result);
     313        // In general, smaller zoom levels are more readable.  We prefer big,
     314        // block, pixelated (but readable) map text to small, smeared,
     315        // unreadable underzoomed text.  So, use .floor() instead of rounding
     316        // to skew things a bit toward the lower zooms.
     317        int intResult = (int)Math.floor(result);
    314318        if (intResult > getMaxZoomLvl())
    315319            return getMaxZoomLvl();
     
    822826        }
    823827        List<Tile> missedTiles = new LinkedList<Tile>();
    824         for (Tile tile : ts.allTiles()) {
     828        // The callers of this code *require* that we return any tiles
     829        // that we do not draw in missedTiles.  ts.allTiles() by default
     830        // will only return already-existing tiles.  However, we need
     831        // to return *all* tiles to the callers, so force creation here.
     832        boolean forceTileCreation = true;
     833        for (Tile tile : ts.allTiles(forceTileCreation)) {
    825834            Image img = getLoadedTileImage(tile);
    826835            if (img == null || tile.hasError()) {
     
    10281037            return ret;
    10291038        }
     1039        private List<Tile> allLoadedTiles()
     1040        {
     1041            List<Tile> ret = new ArrayList<Tile>();
     1042            for (Tile t : this.allTiles()) {
     1043                if (t.isLoaded())
     1044                    ret.add(t);
     1045            }
     1046            return ret;
     1047        }
    10301048
    10311049        void loadAllTiles(boolean force)
     
    11301148        if (autoZoom) {
    11311149            double pixelScaling = getScaleFactor(zoom);
    1132             if (pixelScaling > 3 || pixelScaling < 0.45) {
     1150            if (pixelScaling > 3 || pixelScaling < 0.7) {
    11331151                zoom = getBestZoom();
    11341152            }
     
    11921210        int otherZooms[] = { -1, 1, -2, 2, -3, -4, -5};
    11931211        for (int zoomOffset : otherZooms) {
    1194             if (!autoZoom) {
     1212            if (!autoZoom)
    11951213                break;
    1196             }
    1197             if (!autoLoad) {
    1198                 break;
    1199             }
    12001214            int newzoom = displayZoomLevel + zoomOffset;
     1215            if (newzoom < MIN_ZOOM)
     1216                continue;
    12011217            if (missedTiles.size() <= 0) {
    12021218                break;
     
    12131229                LatLon botRight2 = tileLatLon(t2);
    12141230                TileSet ts2 = new TileSet(topLeft2, botRight2, newzoom);
     1231                // Instantiating large TileSets is expensive.  If there
     1232                // are no loaded tiles, don't bother even trying.
     1233                if (ts2.allLoadedTiles().size() == 0) {
     1234                    newlyMissedTiles.add(missed);
     1235                    continue;
     1236                }
    12151237                if (ts2.tooLarge()) {
    12161238                    continue;
Note: See TracChangeset for help on using the changeset viewer.