Changeset 7871 in josm


Ignore:
Timestamp:
2014-12-22T01:01:08+01:00 (10 years ago)
Author:
Don-vip
Message:

fix #10878 - do not add new imagery layer through remote control if it already exists

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImageryHandler.java

    r7760 r7871  
    5757    }
    5858
    59     @Override
    60     protected void handleRequest() throws RequestHandlerErrorException {
     59    protected ImageryInfo buildImageryInfo() {
    6160        String url = args.get("url");
    6261        String title = args.get("title");
     
    7473            imgInfo.setIcon(bing.getIcon());
    7574        }
    76         String min_zoom = args.get("min_zoom");
    77         if (min_zoom != null && !min_zoom.isEmpty()) {
     75        String minZoom = args.get("min_zoom");
     76        if (minZoom != null && !minZoom.isEmpty()) {
    7877            try {
    79                 imgInfo.setDefaultMinZoom(Integer.parseInt(min_zoom));
     78                imgInfo.setDefaultMinZoom(Integer.parseInt(minZoom));
    8079            } catch (NumberFormatException e) {
    8180                Main.error(e);
    8281            }
    8382        }
    84         String max_zoom = args.get("max_zoom");
    85         if (max_zoom != null && !max_zoom.isEmpty()) {
     83        String maxZoom = args.get("max_zoom");
     84        if (maxZoom != null && !maxZoom.isEmpty()) {
    8685            try {
    87                 imgInfo.setDefaultMaxZoom(Integer.parseInt(max_zoom));
     86                imgInfo.setDefaultMaxZoom(Integer.parseInt(maxZoom));
    8887            } catch (NumberFormatException e) {
    8988                Main.error(e);
     89            }
     90        }
     91        return imgInfo;
     92    }
     93
     94    @Override
     95    protected void handleRequest() throws RequestHandlerErrorException {
     96        final ImageryInfo imgInfo = buildImageryInfo();
     97        if (Main.isDisplayingMapView()) {
     98            for (ImageryLayer layer : Main.map.mapView.getLayersOfType(ImageryLayer.class)) {
     99                if (layer.getInfo().equals(imgInfo)) {
     100                    Main.info("Imagery layer already exists: "+imgInfo);
     101                    return;
     102                }
    90103            }
    91104        }
     
    114127                    args.put("url", decodeParam(query.substring(urlIdx + 5)));
    115128                    query = query.substring(0, urlIdx);
    116                 } else {
    117                     if (query.indexOf('#') != -1) {
    118                         query = query.substring(0, query.indexOf('#'));
    119                     }
     129                } else if (query.indexOf('#') != -1) {
     130                    query = query.substring(0, query.indexOf('#'));
    120131                }
    121132                String[] params = query.split("&", -1);
Note: See TracChangeset for help on using the changeset viewer.