Changeset 15209 in josm for trunk


Ignore:
Timestamp:
2019-07-06T20:10:03+02:00 (5 years ago)
Author:
Don-vip
Message:

fix #17801 - create WMS URL correctly

Location:
trunk/src/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/preferences/imagery/AddWMSLayerPanel.java

    r14367 r15209  
    123123            wmsUrl.setEnabled(enabled);
    124124            if (endpoint.isSelected() && !setDefaultLayers.isSelected() && wms != null) {
    125                 name.setText(wms.buildRootUrl());
     125                name.setText(wms.buildRootUrlWithoutCapabilities());
    126126            }
    127127            onLayerSelectionChanged();
     
    161161                )
    162162            );
    163             name.setText(wms.buildRootUrl() + ": " + Utils.join(", ", tree.getSelectedLayers()));
     163            name.setText(wms.buildRootUrlWithoutCapabilities() + ": " + Utils.join(", ", tree.getSelectedLayers()));
    164164        }
    165165        showBounds.setEnabled(tree.getSelectedLayers().size() == 1);
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java

    r14411 r15209  
    4545public class WMSImagery {
    4646
    47     private static final String CAPABILITIES_QUERY_STRING = "SERVICE=WMS&REQUEST=GetCapabilities";
     47    private static final String SERVICE_WMS = "SERVICE=WMS";
     48    private static final String REQUEST_GET_CAPABILITIES = "REQUEST=GetCapabilities";
     49    private static final String CAPABILITIES_QUERY_STRING = SERVICE_WMS + "&" + REQUEST_GET_CAPABILITIES;
    4850
    4951    /**
     
    270272
    271273    /**
     274     * @return root URL of services without the GetCapabilities call
     275     * @since 15209
     276     */
     277    public String buildRootUrlWithoutCapabilities() {
     278        return buildRootUrl()
     279                .replace(CAPABILITIES_QUERY_STRING, "")
     280                .replace(SERVICE_WMS, "")
     281                .replace(REQUEST_GET_CAPABILITIES, "")
     282                .replace("?&", "?");
     283    }
     284
     285    /**
    272286     * Returns URL for accessing GetMap service. String will contain following parameters:
    273287     * * {proj} - that needs to be replaced with projection (one of {@link #getServerProjections(List)})
     
    322336                        selectedLayers.size());
    323337
    324         return buildRootUrl() + "FORMAT=" + format + ((imageFormatHasTransparency(format) && transparent) ? "&TRANSPARENT=TRUE" : "")
    325                 + "&VERSION=" + this.version + "&SERVICE=WMS&REQUEST=GetMap&LAYERS="
     338        return buildRootUrlWithoutCapabilities()
     339                + "FORMAT=" + format + ((imageFormatHasTransparency(format) && transparent) ? "&TRANSPARENT=TRUE" : "")
     340                + "&VERSION=" + this.version + "&" + SERVICE_WMS + "&REQUEST=GetMap&LAYERS="
    326341                + selectedLayers.stream().collect(Collectors.joining(","))
    327342                + "&STYLES="
Note: See TracChangeset for help on using the changeset viewer.