Ignore:
Timestamp:
2019-10-03T22:02:47+02:00 (5 years ago)
Author:
Don-vip
Message:

find a more suitable WMTS layer when no default is provided. Helps to get more reliable imagery integration test

File:
1 edited

Legend:

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

    r14572 r15409  
    183183            return crs;
    184184        }
     185
     186        /**
     187         * Returns tile matrix max zoom. Assumes first zoom starts at 0, with continuous zoom levels.
     188         * @return tile matrix max zoom
     189         * @since 15409
     190         */
     191        public int getMaxZoom() {
     192            return tileMatrix.size() - 1;
     193        }
    185194    }
    186195
     
    258267        public TileMatrixSet getTileMatrixSet() {
    259268            return tileMatrixSet;
     269        }
     270
     271        /**
     272         * Returns layer max zoom.
     273         * @return layer max zoom
     274         * @since 15409
     275         */
     276        public int getMaxZoom() {
     277            return tileMatrixSet != null ? tileMatrixSet.getMaxZoom() : 0;
    260278        }
    261279    }
     
    334352            if (!layers.isEmpty()) {
    335353                Layer first = layers.iterator().next();
     354                // If max zoom lower than expected, try to find a better layer
     355                if (first.getMaxZoom() < info.getMaxZoom()) {
     356                    first = layers.stream().filter(l -> l.getMaxZoom() >= info.getMaxZoom()).findFirst().orElse(first);
     357                }
    336358                this.defaultLayer = new DefaultLayer(info.getImageryType(), first.identifier, first.style, first.tileMatrixSet.identifier);
    337359            } else {
     
    943965    public int getMaxZoom() {
    944966        if (this.currentTileMatrixSet != null) {
    945             return this.currentTileMatrixSet.tileMatrix.size()-1;
     967            return this.currentTileMatrixSet.getMaxZoom();
    946968        }
    947969        return 0;
Note: See TracChangeset for help on using the changeset viewer.