Changeset 12469 in josm
- Timestamp:
- 2017-07-12T21:41:19+02:00 (8 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AddImageryLayerAction.java
r12279 r12469 94 94 case WMS_ENDPOINT: 95 95 // convert to WMS type 96 return getWMSLayerInfo(); 96 return getWMSLayerInfo(info); 97 97 case WMTS: 98 98 // specify which layer to use … … 152 152 } 153 153 154 protected ImageryInfo getWMSLayerInfo() throws IOException, WMSGetCapabilitiesException { 154 /** 155 * Asks user to choose a WMS layer from a WMS endpoint. 156 * @param info the WMS endpoint. 157 * @return chosen WMS layer, or null 158 * @throws IOException if any I/O error occurs while contacting the WMS endpoint 159 * @throws WMSGetCapabilitiesException if the WMS getCapabilities request fails 160 */ 161 protected static ImageryInfo getWMSLayerInfo(ImageryInfo info) throws IOException, WMSGetCapabilitiesException { 155 162 CheckParameterUtil.ensureThat(ImageryType.WMS_ENDPOINT.equals(info.getImageryType()), "wms_endpoint imagery type expected"); 156 163 -
trunk/src/org/openstreetmap/josm/actions/MapRectifierWMSmenuAction.java
r12279 r12469 9 9 import java.awt.event.ActionEvent; 10 10 import java.awt.event.KeyEvent; 11 import java.io.IOException; 11 12 import java.util.ArrayList; 12 13 import java.util.List; … … 22 23 import org.openstreetmap.josm.Main; 23 24 import org.openstreetmap.josm.data.imagery.ImageryInfo; 25 import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType; 24 26 import org.openstreetmap.josm.gui.ExtendedDialog; 25 27 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils; … … 27 29 import org.openstreetmap.josm.gui.widgets.JosmTextField; 28 30 import org.openstreetmap.josm.gui.widgets.UrlLabel; 31 import org.openstreetmap.josm.io.imagery.WMSImagery.WMSGetCapabilitiesException; 29 32 import org.openstreetmap.josm.tools.GBC; 30 33 import org.openstreetmap.josm.tools.Shortcut; … … 232 235 */ 233 236 private static void addWMSLayer(String title, String url) { 234 WMSLayer layer = new WMSLayer(new ImageryInfo(title, url)); 235 Main.getLayerManager().addLayer(layer); 237 ImageryInfo info = new ImageryInfo(title, url); 238 if (info.getImageryType() == ImageryType.WMS_ENDPOINT) { 239 try { 240 info = AddImageryLayerAction.getWMSLayerInfo(info); 241 } catch (IOException | WMSGetCapabilitiesException e) { 242 Main.error(e); 243 JOptionPane.showMessageDialog(Main.parent, e.getMessage(), tr("No valid WMS URL or id"), JOptionPane.ERROR_MESSAGE); 244 return; 245 } 246 } 247 Main.getLayerManager().addLayer(new WMSLayer(info)); 236 248 } 237 249 -
trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java
r11747 r12469 345 345 bboxElem = getChild(element, "LatLonBoundingBox"); 346 346 if (bboxElem != null) { 347 double left = Double.parseDouble(bboxElem.getAttribute("minx"));348 double top = Double.parseDouble(bboxElem.getAttribute("maxy"));349 double right = Double.parseDouble(bboxElem.getAttribute("maxx"));350 double bot = Double.parseDouble(bboxElem.getAttribute("miny"));347 double left = getDecimalDegree(bboxElem ,"minx"); 348 double top = getDecimalDegree(bboxElem, "maxy"); 349 double right = getDecimalDegree(bboxElem, "maxx"); 350 double bot = getDecimalDegree(bboxElem, "miny"); 351 351 bounds = new Bounds(bot, left, top, right); 352 352 } … … 357 357 358 358 return new LayerDetails(name, ident, crsList, josmSupportsThisLayer, bounds, childLayers); 359 } 360 361 private static double getDecimalDegree(Element elem, String attr) { 362 // Some real-world WMS servers use a comma instead of a dot as decimal separator (seen in Polish WMS server) 363 return Double.parseDouble(elem.getAttribute(attr).replace(',', '.')); 359 364 } 360 365
Note:
See TracChangeset
for help on using the changeset viewer.