Changeset 13879 in josm for trunk/src


Ignore:
Timestamp:
2018-05-31T10:02:31+02:00 (6 years ago)
Author:
wiktorn
Message:

Add layer name/title to WMTS layers when user selects layer

see: #15988

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java

    r13872 r13879  
    1111import java.io.IOException;
    1212import java.net.MalformedURLException;
    13 import java.util.ArrayList;
    1413import java.util.Collection;
     14import java.util.Collections;
    1515import java.util.List;
    1616import java.util.stream.Collectors;
     
    104104                // specify which layer to use
    105105                if (info.getDefaultLayers() == null || info.getDefaultLayers().isEmpty()) {
    106                     DefaultLayer layerId = new WMTSTileSource(info).userSelectLayer();
     106                    WMTSTileSource tileSource = new WMTSTileSource(info);
     107                    DefaultLayer layerId = tileSource.userSelectLayer();
    107108                    if (layerId != null) {
    108109                        ImageryInfo copy = new ImageryInfo(info);
    109                         List<DefaultLayer> defaultLayers = new ArrayList<>(1);
    110                         defaultLayers.add(layerId);
    111                         copy.setDefaultLayers(defaultLayers);
     110                        copy.setDefaultLayers(Collections.singletonList(layerId));
     111                        String layerName = tileSource.getLayers().stream()
     112                                .filter(x -> x.getIdentifier().equals(layerId.getLayerName()))
     113                                .map(x -> x.getUserTitle())
     114                                .findFirst()
     115                                .orElse("");
     116                        copy.setName(copy.getName() + ": " + layerName);
    112117                        return copy;
    113118                    }
  • trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java

    r13828 r13879  
    11081108        return tileProjection != null ? tileProjection.toCode() : null;
    11091109    }
     1110
     1111    /**
     1112     * Layers that can be used with this tile source
     1113     * @return unmodifiable collection of layers available in this tile source
     1114     * @since 13879
     1115     */
     1116    public Collection<Layer> getLayers() {
     1117        return Collections.unmodifiableCollection(layers);
     1118    }
    11101119}
Note: See TracChangeset for help on using the changeset viewer.