Ignore:
Timestamp:
2016-02-17T23:27:47+01:00 (8 years ago)
Author:
wiktorn
Message:

Snap scale to mercator zoom levels.

See #12350

Patch submitted by: kolesar

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java

    r9799 r9818  
    4747import org.openstreetmap.josm.data.projection.Projections;
    4848import org.openstreetmap.josm.gui.ExtendedDialog;
     49import org.openstreetmap.josm.gui.layer.NativeScaleLayer.Scale;
     50import org.openstreetmap.josm.gui.layer.NativeScaleLayer.ScaleList;
    4951import org.openstreetmap.josm.io.CachedFile;
    5052import org.openstreetmap.josm.tools.CheckParameterUtil;
     
    286288    }
    287289
    288     private Collection<Layer> getCapabilities() throws IOException {
     290    private Collection<Layer> getCapabilities() {
    289291        XMLInputFactory factory = XMLInputFactory.newFactory();
    290292        // do not try to load external entities, nor validate the XML
     
    709711            return null;
    710712        }
    711         if (zoom < 1) {
     713        if (zoom < 0) {
    712714            return null;
    713715        }
    714         return this.currentTileMatrixSet.tileMatrix.get(zoom - 1);
     716        return this.currentTileMatrixSet.tileMatrix.get(zoom);
    715717    }
    716718
     
    830832    public int getMaxZoom() {
    831833        if (this.currentTileMatrixSet != null) {
    832             return this.currentTileMatrixSet.tileMatrix.size();
     834            return this.currentTileMatrixSet.tileMatrix.size()-1;
    833835        }
    834836        return 0;
     
    911913        return (int) Math.ceil(Math.abs(max.east() - min.east()) / scale);
    912914    }
     915
     916    /**
     917     * Get native scales of tile source.
     918     * @return {@link ScaleList} of native scales
     919     */
     920    public ScaleList getNativeScales() {
     921        ScaleList scales = new ScaleList();
     922        if (currentTileMatrixSet != null) {
     923            for (TileMatrix tileMatrix : currentTileMatrixSet.tileMatrix) {
     924                scales.add(new Scale(tileMatrix.scaleDenominator * 0.28e-03));
     925            }
     926        }
     927        return scales;
     928    }
     929
    913930}
Note: See TracChangeset for help on using the changeset viewer.