Changeset 14572 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2018-12-17T16:15:05+01:00 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java
r14507 r14572 2 2 package org.openstreetmap.josm.data.imagery; 3 3 4 import static org.openstreetmap.josm.data.imagery.GetCapabilitiesParseHelper.QN_OWS_DCP; 5 import static org.openstreetmap.josm.data.imagery.GetCapabilitiesParseHelper.QN_OWS_GET; 6 import static org.openstreetmap.josm.data.imagery.GetCapabilitiesParseHelper.QN_OWS_HTTP; 7 import static org.openstreetmap.josm.data.imagery.GetCapabilitiesParseHelper.QN_OWS_IDENTIFIER; 8 import static org.openstreetmap.josm.data.imagery.GetCapabilitiesParseHelper.QN_OWS_OPERATION; 9 import static org.openstreetmap.josm.data.imagery.GetCapabilitiesParseHelper.QN_OWS_OPERATIONS_METADATA; 10 import static org.openstreetmap.josm.data.imagery.GetCapabilitiesParseHelper.QN_OWS_SUPPORTED_CRS; 11 import static org.openstreetmap.josm.data.imagery.GetCapabilitiesParseHelper.QN_OWS_TITLE; 4 12 import static org.openstreetmap.josm.tools.I18n.tr; 5 13 … … 74 82 75 83 // CHECKSTYLE.OFF: SingleSpaceSeparator 76 private static final QName QN_CONTENTS = new QName(WMTS TileSource.WMTS_NS_URL, "Contents");77 private static final QName QN_DEFAULT = new QName(WMTS TileSource.WMTS_NS_URL, "Default");78 private static final QName QN_DIMENSION = new QName(WMTS TileSource.WMTS_NS_URL, "Dimension");79 private static final QName QN_FORMAT = new QName(WMTS TileSource.WMTS_NS_URL, "Format");80 private static final QName QN_LAYER = new QName(WMTS TileSource.WMTS_NS_URL, "Layer");81 private static final QName QN_MATRIX_WIDTH = new QName(WMTS TileSource.WMTS_NS_URL, "MatrixWidth");82 private static final QName QN_MATRIX_HEIGHT = new QName(WMTS TileSource.WMTS_NS_URL, "MatrixHeight");83 private static final QName QN_RESOURCE_URL = new QName(WMTS TileSource.WMTS_NS_URL, "ResourceURL");84 private static final QName QN_SCALE_DENOMINATOR = new QName(WMTS TileSource.WMTS_NS_URL, "ScaleDenominator");85 private static final QName QN_STYLE = new QName(WMTS TileSource.WMTS_NS_URL, "Style");86 private static final QName QN_TILEMATRIX = new QName(WMTS TileSource.WMTS_NS_URL, "TileMatrix");87 private static final QName QN_TILEMATRIXSET = new QName(WMTS TileSource.WMTS_NS_URL, "TileMatrixSet");88 private static final QName QN_TILEMATRIX_SET_LINK = new QName(WMTS TileSource.WMTS_NS_URL, "TileMatrixSetLink");89 private static final QName QN_TILE_WIDTH = new QName(WMTS TileSource.WMTS_NS_URL, "TileWidth");90 private static final QName QN_TILE_HEIGHT = new QName(WMTS TileSource.WMTS_NS_URL, "TileHeight");91 private static final QName QN_TOPLEFT_CORNER = new QName(WMTS TileSource.WMTS_NS_URL, "TopLeftCorner");92 private static final QName QN_VALUE = new QName(WMTS TileSource.WMTS_NS_URL, "Value");84 private static final QName QN_CONTENTS = new QName(WMTS_NS_URL, "Contents"); 85 private static final QName QN_DEFAULT = new QName(WMTS_NS_URL, "Default"); 86 private static final QName QN_DIMENSION = new QName(WMTS_NS_URL, "Dimension"); 87 private static final QName QN_FORMAT = new QName(WMTS_NS_URL, "Format"); 88 private static final QName QN_LAYER = new QName(WMTS_NS_URL, "Layer"); 89 private static final QName QN_MATRIX_WIDTH = new QName(WMTS_NS_URL, "MatrixWidth"); 90 private static final QName QN_MATRIX_HEIGHT = new QName(WMTS_NS_URL, "MatrixHeight"); 91 private static final QName QN_RESOURCE_URL = new QName(WMTS_NS_URL, "ResourceURL"); 92 private static final QName QN_SCALE_DENOMINATOR = new QName(WMTS_NS_URL, "ScaleDenominator"); 93 private static final QName QN_STYLE = new QName(WMTS_NS_URL, "Style"); 94 private static final QName QN_TILEMATRIX = new QName(WMTS_NS_URL, "TileMatrix"); 95 private static final QName QN_TILEMATRIXSET = new QName(WMTS_NS_URL, "TileMatrixSet"); 96 private static final QName QN_TILEMATRIX_SET_LINK = new QName(WMTS_NS_URL, "TileMatrixSetLink"); 97 private static final QName QN_TILE_WIDTH = new QName(WMTS_NS_URL, "TileWidth"); 98 private static final QName QN_TILE_HEIGHT = new QName(WMTS_NS_URL, "TileHeight"); 99 private static final QName QN_TOPLEFT_CORNER = new QName(WMTS_NS_URL, "TopLeftCorner"); 100 private static final QName QN_VALUE = new QName(WMTS_NS_URL, "Value"); 93 101 // CHECKSTYLE.ON: SingleSpaceSeparator 94 102 … … 298 306 private TileMatrixSet currentTileMatrixSet; 299 307 private double crsScale; 300 private final GetCapabilitiesParseHelper.TransferMode transferMode;308 private final TransferMode transferMode; 301 309 302 310 private ScaleList nativeScaleList; … … 417 425 for (int event = reader.getEventType(); reader.hasNext(); event = reader.next()) { 418 426 if (event == XMLStreamReader.START_ELEMENT) { 419 if (GetCapabilitiesParseHelper.QN_OWS_OPERATIONS_METADATA.equals(reader.getName())) { 427 QName qName = reader.getName(); 428 if (QN_OWS_OPERATIONS_METADATA.equals(qName)) { 420 429 ret = parseOperationMetadata(reader); 421 } 422 423 if (QN_CONTENTS.equals(reader.getName())) { 430 } else if (QN_CONTENTS.equals(qName)) { 424 431 layers = parseContents(reader); 425 432 } … … 466 473 event = reader.next()) { 467 474 if (event == XMLStreamReader.START_ELEMENT) { 468 if (QN_LAYER.equals(reader.getName())) { 475 QName qName = reader.getName(); 476 if (QN_LAYER.equals(qName)) { 469 477 Layer l = parseLayer(reader); 470 478 if (l != null) { 471 479 layers.add(l); 472 480 } 473 } 474 if (QN_TILEMATRIXSET.equals(reader.getName())) { 481 } else if (QN_TILEMATRIXSET.equals(qName)) { 475 482 TileMatrixSet entry = parseTileMatrixSet(reader); 476 483 matrixSetById.put(entry.identifier, entry); … … 512 519 event = reader.next()) { 513 520 if (event == XMLStreamReader.START_ELEMENT) { 514 tagStack.push(reader.getName()); 521 QName qName = reader.getName(); 522 tagStack.push(qName); 515 523 if (tagStack.size() == 2) { 516 if (QN_FORMAT.equals( reader.getName())) {524 if (QN_FORMAT.equals(qName)) { 517 525 String format = reader.getElementText(); 518 526 if (supportedMimeTypes.contains(format)) { … … 521 529 unsupportedFormats.add(format); 522 530 } 523 } else if ( GetCapabilitiesParseHelper.QN_OWS_IDENTIFIER.equals(reader.getName())) {531 } else if (QN_OWS_IDENTIFIER.equals(qName)) { 524 532 layer.identifier = reader.getElementText(); 525 } else if ( GetCapabilitiesParseHelper.QN_OWS_TITLE.equals(reader.getName())) {533 } else if (QN_OWS_TITLE.equals(qName)) { 526 534 layer.title = reader.getElementText(); 527 } else if (QN_RESOURCE_URL.equals( reader.getName()) &&535 } else if (QN_RESOURCE_URL.equals(qName) && 528 536 "tile".equals(reader.getAttributeValue("", "resourceType"))) { 529 537 layer.baseUrl = reader.getAttributeValue("", "template"); 530 } else if (QN_STYLE.equals( reader.getName()) &&538 } else if (QN_STYLE.equals(qName) && 531 539 "true".equals(reader.getAttributeValue("", "isDefault"))) { 532 if (GetCapabilitiesParseHelper.moveReaderToTag(reader, GetCapabilitiesParseHelper.QN_OWS_IDENTIFIER)) {540 if (GetCapabilitiesParseHelper.moveReaderToTag(reader, QN_OWS_IDENTIFIER)) { 533 541 layer.style = reader.getElementText(); 534 542 tagStack.push(reader.getName()); // keep tagStack in sync 535 543 } 536 } else if (QN_DIMENSION.equals( reader.getName())) {544 } else if (QN_DIMENSION.equals(qName)) { 537 545 layer.dimensions.add(parseDimension(reader)); 538 } else if (QN_TILEMATRIX_SET_LINK.equals( reader.getName())) {546 } else if (QN_TILEMATRIX_SET_LINK.equals(qName)) { 539 547 layer.tileMatrixSetLinks.add(parseTileMatrixSetLink(reader)); 540 548 } else { … … 579 587 event = reader.next()) { 580 588 if (event == XMLStreamReader.START_ELEMENT) { 581 if (GetCapabilitiesParseHelper.QN_OWS_IDENTIFIER.equals(reader.getName())) { 589 QName qName = reader.getName(); 590 if (QN_OWS_IDENTIFIER.equals(qName)) { 582 591 ret.identifier = reader.getElementText(); 583 } else if (QN_DEFAULT.equals( reader.getName())) {592 } else if (QN_DEFAULT.equals(qName)) { 584 593 ret.defaultValue = reader.getElementText(); 585 } else if (QN_VALUE.equals( reader.getName())) {594 } else if (QN_VALUE.equals(qName)) { 586 595 ret.values.add(reader.getElementText()); 587 596 } … … 623 632 event = reader.next()) { 624 633 if (event == XMLStreamReader.START_ELEMENT) { 625 if (GetCapabilitiesParseHelper.QN_OWS_IDENTIFIER.equals(reader.getName())) { 634 QName qName = reader.getName(); 635 if (QN_OWS_IDENTIFIER.equals(qName)) { 626 636 matrixSet.identifier = reader.getElementText(); 627 } 628 if (GetCapabilitiesParseHelper.QN_OWS_SUPPORTED_CRS.equals(reader.getName())) { 637 } else if (QN_OWS_SUPPORTED_CRS.equals(qName)) { 629 638 matrixSet.crs = GetCapabilitiesParseHelper.crsToCode(reader.getElementText()); 630 } 631 if (QN_TILEMATRIX.equals(reader.getName())) { 639 } else if (QN_TILEMATRIX.equals(qName)) { 632 640 matrixSet.tileMatrix.add(parseTileMatrix(reader, matrixSet.crs)); 633 641 } … … 652 660 event = reader.next()) { 653 661 if (event == XMLStreamReader.START_ELEMENT) { 654 if (GetCapabilitiesParseHelper.QN_OWS_IDENTIFIER.equals(reader.getName())) { 662 QName qName = reader.getName(); 663 if (QN_OWS_IDENTIFIER.equals(qName)) { 655 664 ret.identifier = reader.getElementText(); 656 } 657 if (QN_SCALE_DENOMINATOR.equals(reader.getName())) { 665 } else if (QN_SCALE_DENOMINATOR.equals(qName)) { 658 666 ret.scaleDenominator = Double.parseDouble(reader.getElementText()); 659 } 660 if (QN_TOPLEFT_CORNER.equals(reader.getName())) { 667 } else if (QN_TOPLEFT_CORNER.equals(qName)) { 661 668 String[] topLeftCorner = reader.getElementText().split(" "); 662 669 if (matrixProj.switchXY()) { … … 665 672 ret.topLeftCorner = new EastNorth(Double.parseDouble(topLeftCorner[0]), Double.parseDouble(topLeftCorner[1])); 666 673 } 667 } 668 if (QN_TILE_HEIGHT.equals(reader.getName())) { 674 } else if (QN_TILE_HEIGHT.equals(qName)) { 669 675 ret.tileHeight = Integer.parseInt(reader.getElementText()); 670 } 671 if (QN_TILE_WIDTH.equals(reader.getName())) { 676 } else if (QN_TILE_WIDTH.equals(qName)) { 672 677 ret.tileWidth = Integer.parseInt(reader.getElementText()); 673 } 674 if (QN_MATRIX_HEIGHT.equals(reader.getName())) { 678 } else if (QN_MATRIX_HEIGHT.equals(qName)) { 675 679 ret.matrixHeight = Integer.parseInt(reader.getElementText()); 676 } 677 if (QN_MATRIX_WIDTH.equals(reader.getName())) { 680 } else if (QN_MATRIX_WIDTH.equals(qName)) { 678 681 ret.matrixWidth = Integer.parseInt(reader.getElementText()); 679 682 } … … 698 701 for (int event = reader.getEventType(); 699 702 reader.hasNext() && !(event == XMLStreamReader.END_ELEMENT && 700 GetCapabilitiesParseHelper.QN_OWS_OPERATIONS_METADATA.equals(reader.getName()));703 QN_OWS_OPERATIONS_METADATA.equals(reader.getName())); 701 704 event = reader.next()) { 702 705 if (event == XMLStreamReader.START_ELEMENT && 703 GetCapabilitiesParseHelper.QN_OWS_OPERATION.equals(reader.getName()) &&706 QN_OWS_OPERATION.equals(reader.getName()) && 704 707 "GetTile".equals(reader.getAttributeValue("", "name")) && 705 GetCapabilitiesParseHelper.moveReaderToTag(reader, 706 GetCapabilitiesParseHelper.QN_OWS_DCP, 707 GetCapabilitiesParseHelper.QN_OWS_HTTP, 708 GetCapabilitiesParseHelper.QN_OWS_GET 709 )) { 708 GetCapabilitiesParseHelper.moveReaderToTag(reader, QN_OWS_DCP, QN_OWS_HTTP, QN_OWS_GET)) { 710 709 return new WMTSCapabilities( 711 710 reader.getAttributeValue(GetCapabilitiesParseHelper.XLINK_NS_URL, "href"),
Note:
See TracChangeset
for help on using the changeset viewer.