Last active
September 22, 2017 20:24
-
-
Save JamesKingdom/c771f4a24f98d7dc7f95f07cbffc6394 to your computer and use it in GitHub Desktop.
Mass retagger funciton for ID OSM editor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// select one or multiple things and ctrl+E to retag them | |
var context = id; | |
var addTags = { highway: 'residential'}; // change this as needed | |
//var removeTags = ['area','natural','landuse']; | |
function changeTags() { | |
if (iD.d3.event) { iD.d3.event.preventDefault(); } | |
var actions = [], | |
entities = context.selectedIDs().map(context.entity); | |
entities.forEach(function(entity) { | |
var newTags = Object.assign({}, entity.tags, addTags); // probably won't work in IE11 | |
//removeTags.forEach(function(t) { delete newTags[t]; }); | |
actions.push(iD.actionChangeTags(entity.id, newTags)); | |
}); | |
if (actions.length) { | |
actions.push('Changed a lot of tags'); | |
context.perform.apply(context, actions); | |
} | |
} | |
var myKeybinding = iD.d3keybinding('changeTags').on(iD.uiCmd('⌘E'), changeTags); | |
iD.d3.select(document).call(myKeybinding); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment