Skip to content

Instantly share code, notes, and snippets.

@Rub21
Last active September 30, 2015 01:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rub21/86981b40dc11eadd4d85 to your computer and use it in GitHub Desktop.
Save Rub21/86981b40dc11eadd4d85 to your computer and use it in GitHub Desktop.
Index: src/org/openstreetmap/josm/gui/MapView.java
===================================================================
--- src/org/openstreetmap/josm/gui/MapView.java (revision 8790)
+++ src/org/openstreetmap/josm/gui/MapView.java (working copy)
@@ -1166,6 +1166,30 @@
}
return Utils.join("; ", layerInfo);
}
+
+ /**
+ * Get a string representation of all visible TMS and WMS layers for the {@code imagery_used} changeset tag.
+ * @return A String of imagery_used separated by ';'
+ */
+ public String getLayerInformationForImageryUsedTag() {
+ final Collection<String> layerInfo = new ArrayList<>();
+ for (final ImageryLayer i : getLayersOfType(ImageryLayer.class)) {
+ if(i.isVisible()){
+ if(i.getInfo().getId() !=null && !i.getInfo().getId().isEmpty()){
+ layerInfo.add(i.getInfo().getId());
+ }else{
+ layerInfo.add(i.getName());
+ }
+ }
+ }
+ //Return less or equal 255 characters, according https://github.com/openstreetmap/iD/issues/2181
+ String imagery_used = Utils.join("; ", layerInfo);
+ if(imagery_used.length() > 255){
+ imagery_used = Utils.join("; ", layerInfo).substring(0, 255);
+ }
+ return imagery_used;
+ }
+
/**
* This is a listener that gets informed whenever repaint is called for this MapView.
Index: src/org/openstreetmap/josm/gui/io/TagSettingsPanel.java
===================================================================
--- src/org/openstreetmap/josm/gui/io/TagSettingsPanel.java (revision 8790)
+++ src/org/openstreetmap/josm/gui/io/TagSettingsPanel.java (working copy)
@@ -97,6 +97,10 @@
} else if (!created_by.contains(agent)) {
tags.put("created_by", created_by + ";" + agent);
}
+ //Add imagery_used tag accoding to http://wiki.openstreetmap.org/wiki/Key:imagery_used
+ if(Main.map.mapView.getLayerInformationForImageryUsedTag()!=null && !Main.map.mapView.getLayerInformationForImageryUsedTag().isEmpty()){
+ tags.put("imagery_used", Main.map.mapView.getLayerInformationForImageryUsedTag());
+ }
pnlTagEditor.getModel().initFromTags(tags);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment