Changeset 9619 in josm


Ignore:
Timestamp:
2016-01-24T22:53:29+01:00 (8 years ago)
Author:
wiktorn
Message:

Finish removal of tile-size workaround code started in [9617].

Now WMTS TileSources with other than 256px tile size should work properly.
See #12437, #12186

Fix name of "valid-georeference", so it will be properly loaded from preferences

Location:
trunk/src/org/openstreetmap/josm
Files:
3 edited

Legend:

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

    r9614 r9619  
    1919import javax.swing.ImageIcon;
    2020
    21 import org.openstreetmap.gui.jmapviewer.OsmMercator;
    2221import org.openstreetmap.gui.jmapviewer.interfaces.Attributed;
    2322import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate;
     
    221220        @pref Map<String, List<String>> noTileHeaders;
    222221        @pref Map<String, List<String>> noTileChecksums;
    223         @pref int tileSize = OsmMercator.DEFAUL_TILE_SIZE;
     222        @pref int tileSize = -1;
    224223        @pref Map<String, String> metadataHeaders;
    225224        @pref boolean valid_georeference;
  • trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java

    r9617 r9619  
    594594     */
    595595    public void initProjection(Projection proj) {
    596         String layerName = null;
    597         if (currentLayer != null) {
    598             layerName = currentLayer.name;
    599         }
    600         Collection<Layer> candidates = getLayers(layerName, proj.toCode());
     596        // getLayers will return only layers matching the name, if the user already choose the layer
     597        // so we will not ask the user again to chose the layer, if he just changes projection
     598        Collection<Layer> candidates = getLayers(currentLayer != null ? currentLayer.name : null, proj.toCode());
    601599        if (!candidates.isEmpty()) {
    602600            Layer newLayer = userSelectLayer(candidates);
     
    610608    }
    611609
     610    /**
     611     *
     612     * @param name of the layer to match
     613     * @param projectionCode projection code to match
     614     * @return Collection of layers matching the name of the layer and projection, or only projection if name is not provided
     615     */
    612616    private Collection<Layer> getLayers(String name, String projectionCode) {
    613617        Collection<Layer> ret = new ArrayList<>();
    614         for (Layer layer: this.layers) {
    615             if ((name == null || name.equals(layer.name)) && (projectionCode == null || projectionCode.equals(layer.tileMatrixSet.crs))) {
    616                 ret.add(layer);
     618        if (this.layers != null) {
     619            for (Layer layer: this.layers) {
     620                if ((name == null || name.equals(layer.name)) && (projectionCode == null || projectionCode.equals(layer.tileMatrixSet.crs))) {
     621                    ret.add(layer);
     622                }
    617623            }
    618624        }
     
    621627
    622628    @Override
    623     public int getDefaultTileSize() {
    624         return getTileSize();
     629    public int getTileSize() {
     630        // no support for non-square tiles (tileHeight != tileWidth)
     631        // and for different tile sizes at different zoom levels
     632        Collection<Layer> layers = getLayers(null, Main.getProjection().toCode());
     633        if (!layers.isEmpty()) {
     634            return layers.iterator().next().tileMatrixSet.tileMatrix.first().tileHeight;
     635        }
     636        // if no layers is found, fallback to default mercator tile size. Maybe it will work
     637        Main.warn("WMTS: Could not determine tile size. Using default tile size of: {0}", getDefaultTileSize());
     638        return getDefaultTileSize();
    625639    }
    626640
  • trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java

    r9615 r9619  
    152152                        "icon",
    153153                        "tile-size",
    154                         "validGeoreference",
     154                        "valid-georeference",
    155155                        "epsg4326to3857Supported",
    156156                }).contains(qName)) {
Note: See TracChangeset for help on using the changeset viewer.