Skip to content
Permalink
Browse files
Added example that updates existing check_date tags.
  • Loading branch information
simonpoole committed Mar 29, 2017
1 parent 24a82de commit 223b3a0
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
@@ -60,4 +60,23 @@ for (var key in Iterator(new java.util.HashSet(tags.keySet()))) {
}
}
}
tags.remove('automatic_check_date');"
// example
// update existing check_date tags
//
// NOTE: actually doing this is likely a bad idea
//
function addCheckDate(key) {
df = new java.text.SimpleDateFormat('yyyy-MM-dd');
v = new java.util.ArrayList();
v.add(df.format(new java.util.Date()));
tags.put('check_date:'+key,v);
}
for (var key in Iterator(new java.util.HashSet(tags.keySet()))) {
if (key.startsWith('check_date')) {
addCheckDate(key);
}
}
tags.remove('automatic_check_date');"
@@ -75,5 +75,26 @@ for (var key in Iterator(new java.util.HashSet(tags.keySet()))) {
tags.remove('automatic_check_date');"
text="Automatic check_date generation"/>
</item> <!-- check_date example all changed -->
<item name="check_date example update existing" icon="" type="node,way,closedway,relation" preset_name_label="true">
<link href="http://wiki.openstreetmap.org/wiki/Key:check_date" />
<!-- originalTags and tags are java.util.Map<String,ArrayList<String>>, originalTags are the tags
before the PropertyEditor was started, tags are the current values, by removing the key at the
end of the script it can be re-run without manually reseting the value, &, <, > need to be escaped -->
<text key="automatic_check_date" javascript="
function addCheckDate(key) {
df = new java.text.SimpleDateFormat('yyyy-MM-dd');
v = new java.util.ArrayList();
v.add(df.format(new java.util.Date()));
tags.put(key,v);
}
for (var key in Iterator(new java.util.HashSet(tags.keySet()))) {
if (key.startsWith('check_date')) {
addCheckDate(key);
}
}
tags.remove('automatic_check_date');"
text="Automatic check_date generation"/>
</item> <!-- check_date example update existing -->
</group> <!-- check_date examples -->
</presets>

0 comments on commit 223b3a0

Please sign in to comment.