Skip to content

Instantly share code, notes, and snippets.

@JamesKingdom
Last active September 22, 2017 20:24
Show Gist options
  • Save JamesKingdom/c771f4a24f98d7dc7f95f07cbffc6394 to your computer and use it in GitHub Desktop.
Save JamesKingdom/c771f4a24f98d7dc7f95f07cbffc6394 to your computer and use it in GitHub Desktop.
Mass retagger funciton for ID OSM editor
// 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