Changeset 8068 in josm for trunk


Ignore:
Timestamp:
2015-02-15T19:55:12+01:00 (10 years ago)
Author:
Don-vip
Message:

fix #11076 - robustness to unsupported WMS rectifier imagery types

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

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/MapRectifierWMSmenuAction.java

    r8061 r8068  
    187187                // Just set the URL and hope everything works out
    188188                if(s.wmsUrl.isEmpty()) {
    189                     addWMSLayer(s.name + " (" + text + ")", text);
    190                     break outer;
     189                    try {
     190                        addWMSLayer(s.name + " (" + text + ")", text);
     191                        break outer;
     192                    } catch (IllegalStateException ex) {
     193                        Main.error(ex.getMessage());
     194                    }
    191195                }
    192196
     
    226230     * @param title Name of the layer as it will shop up in the layer manager
    227231     * @param url URL to the WMS server
     232     * @throws IllegalStateException if imagery time is neither HTML nor WMS
     233     * @see WMSLayer#checkGrabberType
    228234     */
    229235    private void addWMSLayer(String title, String url) {
    230         Main.main.addLayer(new WMSLayer(new ImageryInfo(title, url)));
     236        WMSLayer layer = new WMSLayer(new ImageryInfo(title, url));
     237        layer.checkGrabberType();
     238        Main.main.addLayer(layer);
    231239    }
    232240
  • trunk/src/org/openstreetmap/josm/gui/layer/WMSLayer.java

    r7596 r8068  
    10211021    }
    10221022
     1023    /**
     1024     * Checks that WMS layer is a grabber-compatible one (HTML or WMS).
     1025     * @throws IllegalStateException if imagery time is neither HTML nor WMS
     1026     * @since 8068
     1027     */
     1028    public void checkGrabberType() {
     1029        ImageryType it = getInfo().getImageryType();
     1030        if (!ImageryType.HTML.equals(it) && !ImageryType.WMS.equals(it))
     1031            throw new IllegalStateException("getGrabber() called for non-WMS layer type");
     1032    }
     1033
    10231034    protected WMSGrabber getGrabber(boolean localOnly) {
     1035        checkGrabberType();
    10241036        if (getInfo().getImageryType() == ImageryType.HTML)
    10251037            return new HTMLGrabber(Main.map.mapView, this, localOnly);
    1026         else if (getInfo().getImageryType() == ImageryType.WMS)
     1038        else
    10271039            return new WMSGrabber(Main.map.mapView, this, localOnly);
    1028         else throw new IllegalStateException("getGrabber() called for non-WMS layer type");
    10291040    }
    10301041
Note: See TracChangeset for help on using the changeset viewer.