- Timestamp:
- 2017-03-29T22:07:06+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java
r11790 r11791 25 25 import java.util.TreeSet; 26 26 import java.util.concurrent.ConcurrentHashMap; 27 import java.util.function.Predicate;28 27 import java.util.regex.Matcher; 29 28 import java.util.regex.Pattern; … … 170 169 SelectLayerDialog(Collection<Layer> layers) { 171 170 super(Main.parent, tr("Select WMTS layer"), new String[]{tr("Add layers"), tr("Cancel")}); 172 this.layers = groupLayersByName (layers);171 this.layers = groupLayersByNameAndTileMatrixSet(layers); 173 172 //getLayersTable(layers, Main.getProjection()) 174 173 this.list = new JTable( … … 270 269 */ 271 270 public DefaultLayer userSelectLayer() { 272 Collection<Entry<String, List<Layer>>> grouppedLayers = groupLayersByName(layers); 273 274 // if there is only one layer name no point in asking 275 if (grouppedLayers.size() == 1) { 276 Layer selectedLayer = grouppedLayers.iterator().next().getValue().get(0); 277 return new WMTSDefaultLayer(selectedLayer.name, selectedLayer.tileMatrixSet.identifier); 271 Map<String, List<Layer>> layerByName = layers.stream().collect( 272 Collectors.groupingBy(x -> x.name)); 273 if (layerByName.size() == 1) { // only one layer 274 List<Layer> ls = layerByName.entrySet().iterator().next().getValue() 275 .stream().filter( 276 u -> u.tileMatrixSet.crs.equals(Main.getProjection().toCode())) 277 .collect(Collectors.toList()); 278 if (ls.size() == 1) { 279 // only one tile matrix set with matching projection - no point in asking 280 Layer selectedLayer = ls.get(0); 281 return new WMTSDefaultLayer(selectedLayer.name, selectedLayer.tileMatrixSet.identifier); 282 } 278 283 } 279 284 … … 297 302 } 298 303 299 private static List<Entry<String, List<Layer>>> groupLayersByName (Collection<Layer> layers) {304 private static List<Entry<String, List<Layer>>> groupLayersByNameAndTileMatrixSet(Collection<Layer> layers) { 300 305 Map<String, List<Layer>> layerByName = layers.stream().collect( 301 306 Collectors.groupingBy(x -> x.name + '\u001c' + x.tileMatrixSet.identifier));
Note:
See TracChangeset
for help on using the changeset viewer.