Ignore:
Timestamp:
2009-11-14T19:09:20+01:00 (15 years ago)
Author:
dhansen
Message:

Put some better limits on slippymap tiles.

Even though we did not draw or attempt to create them,
we could try to iterate past some pretty large numbers
of tiles. That made things slow.

There was also a bug when calculating very large tileset
sizes where the integer would overflow. Make it a double
so that the calculation at least goes through

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/slippymap/src/org/openstreetmap/josm/plugins/slippymap/SlippyMapLayer.java

    r18367 r18590  
    732732            return this.tilesSpanned() > 10;
    733733        }
     734        boolean insane() {
     735            return this.tilesSpanned() > 100;
     736        }
    734737        double tilesSpanned() {
    735738            return Math.sqrt(1.0 * this.size());
    736739        }
    737740
    738         int size() {
    739             int x_span = z12x1 - z12x0 + 1;
    740             int y_span = z12y1 - z12y0 + 1;
     741        double size() {
     742            double x_span = z12x1 - z12x0 + 1.0;
     743            double y_span = z12y1 - z12y0 + 1.0;
    741744            return x_span * y_span;
    742745        }
     
    753756        {
    754757            List<Tile> ret = new ArrayList<Tile>();
     758            // Don't even try to iterate over the set.
     759            // Someone created a crazy number of them
     760            if (this.insane())
     761                return ret;
    755762            for (int x = z12x0; x <= z12x1; x++) {
    756763                for (int y = z12y0; y <= z12y1; y++) {
     
    852859        // Too many tiles... refuse to draw
    853860        if (!ts.tooLarge()) {
     861            //out("size: " + ts.size() + " spanned: " + ts.tilesSpanned());
    854862            ts.loadAllTiles(false);
    855863        }
     
    875883                LatLon botRight2 = tileLatLon(t2);
    876884                TileSet ts2 = new TileSet(topLeft2, botRight2, newzoom);
     885                if (ts2.tooLarge())
     886                    continue;
    877887                newlyMissedTiles.addAll(this.paintTileImages(g, ts2, newzoom, missed));
    878888            }
     
    911921        //g.drawString("currentZoomLevel=" + currentZoomLevel, 120, 120);
    912922        oldg.setColor(Color.black);
    913         if (ts.tooLarge()) {
     923        if (ts.insane()) {
     924            oldg.drawString("zoom in to load any tiles", 120, 120);
     925        } else if (ts.tooLarge()) {
    914926            oldg.drawString("zoom in to load more tiles", 120, 120);
    915927        } else if (ts.tooSmall()) {
Note: See TracChangeset for help on using the changeset viewer.