Ticket #11910: imagery_used.diff

File imagery_used.diff, 2.1 KB (added by Rub21, 10 years ago)
  • src/org/openstreetmap/josm/gui/MapView.java

     
    11661166        }
    11671167        return Utils.join("; ", layerInfo);
    11681168    }
     1169   
     1170     /**
     1171     * Get a string representation of all visible TMS and WMS layers for the {@code imagery_used} changeset tag.
     1172     * @return A String of imagery_used separated by ';'
     1173     */
     1174    public String getLayerInformationForImageryUsedTag() {
     1175        final Collection<String> layerInfo = new ArrayList<>();
     1176        for (final ImageryLayer i : getLayersOfType(ImageryLayer.class)) {
     1177                if(i.isVisible()){
     1178                    if(i.getInfo().getId() !=null &&  !i.getInfo().getId().isEmpty()){
     1179                        layerInfo.add(i.getInfo().getId());
     1180                    }else{
     1181                        layerInfo.add(i.getName());
     1182                    }
     1183            }
     1184        }
     1185        //Return less or equal 255 characters, according https://github.com/openstreetmap/iD/issues/2181
     1186        String imagery_used = Utils.join("; ", layerInfo);
     1187        if(imagery_used.length() > 255){
     1188            imagery_used = Utils.join("; ", layerInfo).substring(0, 255);
     1189        }
     1190        return imagery_used;
     1191    }
     1192   
    11691193
    11701194    /**
    11711195     * This is a listener that gets informed whenever repaint is called for this MapView.
  • src/org/openstreetmap/josm/gui/io/TagSettingsPanel.java

     
    9797        } else if (!created_by.contains(agent)) {
    9898            tags.put("created_by", created_by + ";" + agent);
    9999        }
     100        //Add imagery_used tag accoding to http://wiki.openstreetmap.org/wiki/Key:imagery_used
     101        tags.put("imagery_used", Main.map.mapView.getLayerInformationForImageryUsedTag());
    100102        pnlTagEditor.getModel().initFromTags(tags);
    101103    }
    102104