Changeset 11877 in josm


Ignore:
Timestamp:
2017-04-09T23:45:09+02:00 (8 months ago)
Author:
bastiK
Message:

see #7427 - WMTS: if no default layer specified, choose first available (fixes tests)

File:
1 edited

Legend:

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

    r11858 r11877  
    282282        this.baseUrl = GetCapabilitiesParseHelper.normalizeCapabilitiesUrl(handleTemplate(info.getUrl()));
    283283        this.layers = getCapabilities();
    284         this.defaultLayer = info.getDefaultLayers().isEmpty() ? null : (WMTSDefaultLayer) info.getDefaultLayers().iterator().next();
     284        if (info.getDefaultLayers().isEmpty()) {
     285            Main.warn(tr("No default layer selected, choosing first layer."));
     286            if (!layers.isEmpty()) {
     287                Layer first = layers.iterator().next();
     288                this.defaultLayer = new WMTSDefaultLayer(first.identifier, first.tileMatrixSet.identifier);
     289            } else {
     290                this.defaultLayer = null;
     291            }
     292        } else {
     293            this.defaultLayer = (WMTSDefaultLayer) info.getDefaultLayers().iterator().next();
     294        }
    285295        if (this.layers.isEmpty())
    286296            throw new IllegalArgumentException(tr("No layers defined by getCapabilities document: {0}", info.getUrl()));
Note: See TracChangeset for help on using the changeset viewer.