Changeset 8570 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2015-07-05T02:25:58+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/imagery/WMTSTileSource.java
r8569 r8570 110 110 } 111 111 112 private finalString getTypeString() {112 private String getTypeString() { 113 113 return typeString; 114 114 } … … 124 124 } 125 125 126 private class SelectLayerDialog extends ExtendedDialog {126 private final class SelectLayerDialog extends ExtendedDialog { 127 127 private Layer[] layers; 128 128 private JList<String> list; … … 133 133 this.list = new JList<>(getLayerNames(layers)); 134 134 this.list.setPreferredSize(new Dimension(400, 400)); 135 this.list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) 135 this.list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 136 136 JPanel panel = new JPanel(new GridBagLayout()); 137 137 panel.add(this.list, GBC.eol().fill()); … … 141 141 private String[] getLayerNames(Collection<Layer> layers) { 142 142 Collection<String> ret = new ArrayList<>(); 143 for (Layer layer: layers) {143 for (Layer layer: layers) { 144 144 ret.add(layer.name); 145 145 } … … 167 167 * Creates a tile source based on imagery info 168 168 * @param info imagery info 169 * @throws IOException 169 * @throws IOException if any I/O error occurs 170 170 */ 171 171 public WMTSTileSource(ImageryInfo info) throws IOException { … … 189 189 initProjection(); 190 190 } 191 192 193 191 194 192 private String handleTemplate(String url) { … … 222 220 } 223 221 Document document = builder.parse(new ByteArrayInputStream(data)); 224 Node getTileOperation = getByXpath(document, "/Capabilities/OperationsMetadata/Operation[@name=\"GetTile\"]/DCP/HTTP/Get").item(0); 222 Node getTileOperation = getByXpath(document, 223 "/Capabilities/OperationsMetadata/Operation[@name=\"GetTile\"]/DCP/HTTP/Get").item(0); 225 224 this.baseUrl = getStringByXpath(getTileOperation, "@href"); 226 this.transferMode = TransferMode.fromString(getStringByXpath(getTileOperation, "Constraint[@name=\"GetEncoding\"]/AllowedValues/Value")); 225 this.transferMode = TransferMode.fromString(getStringByXpath(getTileOperation, 226 "Constraint[@name=\"GetEncoding\"]/AllowedValues/Value")); 227 227 NodeList layersNodeList = getByXpath(document, "/Capabilities/Contents/Layer"); 228 228 Map<String, TileMatrixSet> matrixSetById = parseMatrices(getByXpath(document, "/Capabilities/Contents/TileMatrixSet")); … … 231 231 } catch (Exception e) { 232 232 Main.error(e); 233 //Main.error(new String(data, "UTF-8"));234 233 } 235 234 return null; … … 242 241 } 243 242 244 private finalCollection<Layer> parseLayer(NodeList nodeList, Map<String, TileMatrixSet> matrixSetById) throws XPathExpressionException {243 private Collection<Layer> parseLayer(NodeList nodeList, Map<String, TileMatrixSet> matrixSetById) throws XPathExpressionException { 245 244 Collection<Layer> ret = new ArrayList<>(); 246 245 for (int layerId = 0; layerId < nodeList.getLength(); layerId++) { … … 262 261 } 263 262 264 private finalMap<String, TileMatrixSet> parseMatrices(NodeList nodeList) throws DOMException, XPathExpressionException {263 private Map<String, TileMatrixSet> parseMatrices(NodeList nodeList) throws DOMException, XPathExpressionException { 265 264 Map<String, TileMatrixSet> ret = new ConcurrentHashMap<>(); 266 265 for (int matrixSetId = 0; matrixSetId < nodeList.getLength(); matrixSetId++) { … … 292 291 293 292 private static String crsToCode(String crsIdentifier) { 294 if (crsIdentifier.startsWith("urn:ogc:def:crs:")) {293 if (crsIdentifier.startsWith("urn:ogc:def:crs:")) { 295 294 return crsIdentifier.replaceFirst("urn:ogc:def:crs:([^:]*):[^:]*:(.*)$", "$1:$2"); 296 295 } 297 296 return crsIdentifier; 298 297 } 298 299 299 private static String getStringByXpath(Node document, String xpathQuery) throws XPathExpressionException { 300 300 return (String) getByXpath(document, xpathQuery, XPathConstants.STRING); … … 304 304 return (NodeList) getByXpath(document, xpathQuery, XPathConstants.NODESET); 305 305 } 306 307 306 308 307 private static Object getByXpath(Node document, String xpathQuery, QName returnType) throws XPathExpressionException { … … 325 324 public void initProjection(Projection proj) { 326 325 this.currentTileMatrixSet = currentLayer.tileMatrixSetByCRS.get(proj.toCode()); 327 if (this.currentTileMatrixSet == null) {326 if (this.currentTileMatrixSet == null) { 328 327 Main.warn("Unsupported CRS selected"); 329 328 // take first, maybe it will work (if user sets custom projections, codes will not match) 330 329 this.currentTileMatrixSet = currentLayer.tileMatrixSetByCRS.values().iterator().next(); 331 330 } 332 this.crsScale = getTileSize() * 0.28e-03 / proj.getMetersPerUnit() 331 this.crsScale = getTileSize() * 0.28e-03 / proj.getMetersPerUnit(); 333 332 } 334 333 … … 381 380 /** 382 381 * 383 * @param zoom 382 * @param zoom zoom level 384 383 * @return TileMatrix that's working on this zoom level 385 384 */ … … 423 422 throw new UnsupportedOperationException("Not implemented"); 424 423 } 425 426 424 427 425 @Override … … 513 511 public Coordinate XYToLatLon(int x, int y, int zoom) { 514 512 TileMatrix matrix = getTileMatrix(zoom); 515 if (matrix == null ){513 if (matrix == null) { 516 514 return new Coordinate(0, 0); 517 515 } -
trunk/src/org/openstreetmap/josm/data/projection/CustomProjection.java
r8568 r8570 36 36 public class CustomProjection extends AbstractProjection { 37 37 38 private final staticMap<String, Double> UNITS_TO_METERS = getUnitsToMeters();39 private final staticdouble METER_PER_UNIT_DEGREE = 2 * Math.PI * 6370997 / 360;38 private static final Map<String, Double> UNITS_TO_METERS = getUnitsToMeters(); 39 private static final double METER_PER_UNIT_DEGREE = 2 * Math.PI * 6370997 / 360; 40 40 41 41 /**
Note:
See TracChangeset
for help on using the changeset viewer.