Changeset 9899 in josm


Ignore:
Timestamp:
2016-02-28T14:06:46+01:00 (4 years ago)
Author:
wiktorn
Message:

Use one static instance of NativeScaleLayer for all TMS layers.

See: #12568

File:
1 edited

Legend:

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

    r9897 r9899  
    4848            true);
    4949
    50     private ScaleList nativeScaleList;
     50    private static final ScaleList nativeScaleList = initNativeScaleList();
    5151
    5252    /**
     
    5656    public TMSLayer(ImageryInfo info) {
    5757        super(info);
    58         Collection<Double> scales = new ArrayList<>(info.getMaxZoom());
    59         for (int zoom = AbstractTileSourceLayer.MIN_ZOOM; zoom <= AbstractTileSourceLayer.MAX_ZOOM; zoom++) {
    60             double scale = OsmMercator.EARTH_RADIUS * Math.PI * 2 / Math.pow(2, zoom) / OsmMercator.DEFAUL_TILE_SIZE;
    61             scales.add(scale);
    62         }
    63         this.nativeScaleList = new ScaleList(scales);
    6458    }
    6559
     
    162156        return nativeScaleList;
    163157    }
     158
     159    private static ScaleList initNativeScaleList() {
     160        Collection<Double> scales = new ArrayList<>(AbstractTileSourceLayer.MAX_ZOOM);
     161        for (int zoom = AbstractTileSourceLayer.MIN_ZOOM; zoom <= AbstractTileSourceLayer.MAX_ZOOM; zoom++) {
     162            double scale = OsmMercator.EARTH_RADIUS * Math.PI * 2 / Math.pow(2, zoom) / OsmMercator.DEFAUL_TILE_SIZE;
     163            scales.add(scale);
     164        }
     165        return new ScaleList(scales);
     166    }
    164167 }
Note: See TracChangeset for help on using the changeset viewer.