Changeset 11792 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2017-03-29T22:50:22+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/imagery
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/GetCapabilitiesParseHelper.java
r11747 r11792 64 64 static final QName QN_OWS_OPERATIONS_METADATA = new QName(OWS_NS_URL, "OperationsMetadata"); 65 65 static final QName QN_OWS_SUPPORTED_CRS = new QName(OWS_NS_URL, "SupportedCRS"); 66 static final QName QN_OWS_TITLE = new QName(OWS_NS_URL, "Title"); 66 67 static final QName QN_OWS_VALUE = new QName(OWS_NS_URL, "Value"); 67 68 // CHECKSTYLE.ON: SingleSpaceSeparator -
trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java
r11791 r11792 144 144 private static class Layer { 145 145 private String format; 146 private String name; 146 private String identifier; 147 private String title; 147 148 private TileMatrixSet tileMatrixSet; 148 149 private String baseUrl; … … 153 154 Objects.requireNonNull(l); 154 155 format = l.format; 155 name = l.name; 156 identifier = l.identifier; 157 title = l.title; 156 158 baseUrl = l.baseUrl; 157 159 style = l.style; … … 160 162 161 163 Layer() { 164 } 165 166 /** 167 * Get title of the layer for user display. 168 * 169 * This is either the content of the Title element (if available) or 170 * the layer identifier (as fallback) 171 * @return title of the layer for user display 172 */ 173 public String getUserTitle() { 174 return title != null ? title : identifier; 162 175 } 163 176 } … … 179 192 return SelectLayerDialog.this.layers.get(rowIndex).getValue() 180 193 .stream() 181 .map(x -> x. name)194 .map(x -> x.getUserTitle()) 182 195 .collect(Collectors.joining(", ")); //this should be only one 183 196 case 1: … … 231 244 } 232 245 Layer selectedLayer = layers.get(index).getValue().get(0); 233 return new WMTSDefaultLayer(selectedLayer. name, selectedLayer.tileMatrixSet.identifier);246 return new WMTSDefaultLayer(selectedLayer.identifier, selectedLayer.tileMatrixSet.identifier); 234 247 } 235 248 } … … 269 282 */ 270 283 public DefaultLayer userSelectLayer() { 271 Map<String, List<Layer>> layerBy Name= layers.stream().collect(272 Collectors.groupingBy(x -> x. name));273 if (layerBy Name.size() == 1) { // only one layer274 List<Layer> ls = layerBy Name.entrySet().iterator().next().getValue()284 Map<String, List<Layer>> layerById = layers.stream().collect( 285 Collectors.groupingBy(x -> x.identifier)); 286 if (layerById.size() == 1) { // only one layer 287 List<Layer> ls = layerById.entrySet().iterator().next().getValue() 275 288 .stream().filter( 276 289 u -> u.tileMatrixSet.crs.equals(Main.getProjection().toCode())) … … 279 292 // only one tile matrix set with matching projection - no point in asking 280 293 Layer selectedLayer = ls.get(0); 281 return new WMTSDefaultLayer(selectedLayer. name, selectedLayer.tileMatrixSet.identifier);294 return new WMTSDefaultLayer(selectedLayer.identifier, selectedLayer.tileMatrixSet.identifier); 282 295 } 283 296 } … … 304 317 private static List<Entry<String, List<Layer>>> groupLayersByNameAndTileMatrixSet(Collection<Layer> layers) { 305 318 Map<String, List<Layer>> layerByName = layers.stream().collect( 306 Collectors.groupingBy(x -> x. name+ '\u001c' + x.tileMatrixSet.identifier));319 Collectors.groupingBy(x -> x.identifier + '\u001c' + x.tileMatrixSet.identifier)); 307 320 return layerByName.entrySet().stream().sorted(Map.Entry.comparingByKey()).collect(Collectors.toList()); 308 321 } … … 412 425 } 413 426 } else if (GetCapabilitiesParseHelper.QN_OWS_IDENTIFIER.equals(reader.getName())) { 414 layer.name = reader.getElementText(); 427 layer.identifier = reader.getElementText(); 428 } else if (GetCapabilitiesParseHelper.QN_OWS_TITLE.equals(reader.getName())) { 429 layer.title = reader.getElementText(); 415 430 } else if (QN_RESOURCE_URL.equals(reader.getName()) && 416 431 "tile".equals(reader.getAttributeValue("", "resourceType"))) { … … 444 459 // no format found - it's mandatory parameter - can't use this layer 445 460 Main.warn(tr("Can''t use layer {0} because no supported formats where found. Layer is available in formats: {1}", 446 layer. name,461 layer.getUserTitle(), 447 462 String.join(", ", unsupportedFormats))); 448 463 return null; … … 581 596 // so we will not ask the user again to chose the layer, if he just changes projection 582 597 Collection<Layer> candidates = getLayers( 583 currentLayer != null ? new WMTSDefaultLayer(currentLayer. name, currentLayer.tileMatrixSet.identifier) : defaultLayer,598 currentLayer != null ? new WMTSDefaultLayer(currentLayer.identifier, currentLayer.tileMatrixSet.identifier) : defaultLayer, 584 599 proj.toCode()); 585 600 … … 602 617 } else if (candidates.size() > 1) { 603 618 Main.warn("More than one layer WMTS available: {0} for projection {1} and name {2}. Do not know which to process", 604 candidates.stream().map(x -> x. name+ ": " + x.tileMatrixSet.identifier).collect(Collectors.joining(", ")),619 candidates.stream().map(x -> x.getUserTitle() + ": " + x.tileMatrixSet.identifier).collect(Collectors.joining(", ")), 605 620 proj.toCode(), 606 currentLayer != null ? currentLayer. name: defaultLayer621 currentLayer != null ? currentLayer.getUserTitle() : defaultLayer 607 622 ); 608 623 } … … 621 636 for (Layer layer: this.layers) { 622 637 if ((searchLayer == null || (// if it's null, then accept all layers 623 searchLayer.getLayerName().equals(layer. name)))638 searchLayer.getLayerName().equals(layer.identifier))) 624 639 && (projectionCode == null || // if it's null, then accept any projection 625 640 projectionCode.equals(layer.tileMatrixSet.crs))) { … … 673 688 } 674 689 675 return url.replaceAll("\\{layer\\}", this.currentLayer. name)690 return url.replaceAll("\\{layer\\}", this.currentLayer.identifier) 676 691 .replaceAll("\\{format\\}", this.currentLayer.format) 677 692 .replaceAll("\\{TileMatrixSet\\}", this.currentTileMatrixSet.identifier) … … 845 860 } else { 846 861 for (Layer layer: this.layers) { 847 if (currentLayer. name.equals(layer.name)) {862 if (currentLayer.identifier.equals(layer.identifier)) { 848 863 ret.add(layer.tileMatrixSet.crs); 849 864 }
Note:
See TracChangeset
for help on using the changeset viewer.