- Timestamp:
- 2015-07-05T02:25:58+02:00 (9 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 7 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 /** -
trunk/src/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayer.java
r8568 r8570 276 276 277 277 private final class ShowTileInfoAction extends AbstractAction { 278 private transient finalTileHolder clickedTileHolder;278 private final transient TileHolder clickedTileHolder; 279 279 280 280 private ShowTileInfoAction(TileHolder clickedTileHolder) { -
trunk/src/org/openstreetmap/josm/gui/layer/WMTSLayer.java
r8568 r8570 88 88 LatLon botLeft = mv.getLatLon(0, tileSource.getTileSize()); 89 89 90 return Math.abs((north.getLat() - south.getLat()) / ( 90 return Math.abs((north.getLat() - south.getLat()) / (topLeft.lat() - botLeft.lat())); 91 91 } 92 92 … … 95 95 if (!Main.isDisplayingMapView()) return 1; 96 96 97 for (int i=getMinZoomLvl(); i <= getMaxZoomLvl(); i++) {97 for (int i = getMinZoomLvl(); i <= getMaxZoomLvl(); i++) { 98 98 double ret = getTileToScreenRatio(i); 99 99 if (ret < 1) { … … 106 106 @Override 107 107 public boolean isProjectionSupported(Projection proj) { 108 return ((WMTSTileSource) tileSource).getSupportedProjections().contains(proj.toCode());108 return ((WMTSTileSource) tileSource).getSupportedProjections().contains(proj.toCode()); 109 109 } 110 110 … … 112 112 public String nameSupportedProjections() { 113 113 StringBuilder ret = new StringBuilder(); 114 for (String e: ((WMTSTileSource) tileSource).getSupportedProjections()) {114 for (String e: ((WMTSTileSource) tileSource).getSupportedProjections()) { 115 115 ret.append(e).append(", "); 116 116 } … … 121 121 public void projectionChanged(Projection oldValue, Projection newValue) { 122 122 super.projectionChanged(oldValue, newValue); 123 ((WMTSTileSource) tileSource).initProjection(newValue);123 ((WMTSTileSource) tileSource).initProjection(newValue); 124 124 } 125 126 125 } -
trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddWMTSLayerPanel.java
r8568 r8570 29 29 registerValidableComponent(rawUrl); 30 30 } 31 31 32 @Override 32 33 protected ImageryInfo getImageryInfo() { -
trunk/src/org/openstreetmap/josm/io/CachedFile.java
r8568 r8570 500 500 * @since TODO 501 501 */ 502 public static HttpURLConnection connectFollowingRedirect(URL downloadUrl, String httpAccept, Long ifModifiedSince, Map<String, String> headers)503 throws MalformedURLException, IOException {502 public static HttpURLConnection connectFollowingRedirect(URL downloadUrl, String httpAccept, Long ifModifiedSince, 503 Map<String, String> headers) throws MalformedURLException, IOException { 504 504 CheckParameterUtil.ensureParameterNotNull(downloadUrl, "downloadUrl"); 505 505 String downloadString = downloadUrl.toExternalForm(); -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r8568 r8570 1342 1342 * Reads the input stream and closes the stream at the end of processing (regardless if an exception was thrown) 1343 1343 * 1344 * @param stream 1344 * @param stream input stream 1345 1345 * @return byte array of data in input stream 1346 * @throws IOException 1346 * @throws IOException if any I/O error occurs 1347 1347 */ 1348 1348 public static byte[] readBytesFromStream(InputStream stream) throws IOException {
Note:
See TracChangeset
for help on using the changeset viewer.