Mechanical Edits/Mateusz Konieczny - bot account/migrate surface=cement to surface=concrete on USA roads and paths

From OpenStreetMap Wiki
Jump to navigation Jump to search

Page content created as advised on Automated_Edits_code_of_conduct#Document_and_discuss_your_plans.

This edit will replace surface=cement by surface=concrete on roads and paths in USA

Who

I, Mateusz Konieczny using my bot account

contact

message via OSM I will respond also to PMs to the bot account, though messaging my main account is preferable as I will get notifications in OSM editors.

English and Polish languages are preferable, for other I need to use an automatic translator.

What

This edit will replace surface=cement by surface=concrete on roads and paths in USA

Why

Why it is useful? It helps newbies to avoid becoming confused. It protects against such values becoming established. Without drudgery that would be required from the manual cleanup.

Why automatic edit? I have a massive queue (in thousands and tens of thousands) of automatically detectable issues which are not reported by mainstream validators, require fixes and fix requires review or complete manual cleanup.

There is no point in manual drudgery here.

This value here do NOT require manual overview. If this cases would turn out to be an useful signal of invalid editing than I will remain reviewing nearby areas where bot edited.

Yes, bot edit WILL cause objects to be edited. Nevertheless, as result map data quality will improve.

Numbers

Large enough to make it useful to automate it.

objects affected by the next run: https://overpass-turbo.eu/s/1nAr

see Mechanical Edits/Mateusz Konieczny - bot account/migrate surface=cement to surface=concrete on USA roads and paths/stats for statistics of affected objects as of 2022-11-17

How

state after a mechanical edit:

Changeset would be described and tagged with tags that mark it as automatic, provide link to discussion approving edit, include link promoting https://matkoniecz.github.io/OSM-wikipedia-tag-validator-reports/ etc

Discussion

Repetition

This is reoccurring edit and may be made as soon as new matching elements appear. At this moment triggering new edit requires human intervention so exact schedule is not predictable and bot may stop running at any moment.

This can change in a future. If bot is abandoned and does not run, feel free to ping me. If I am unable to run it any more feel free to use my code. Note that it may require going through bot approval process again and that code is on specific license.

https://codeberg.org/matkoniecz/OpenStreetMap_cleanup_scripts/src/branch/master/recurrent_bot_edits may have more up to date code version that what is listed on this page

Source code

GPL 3.0 licensed

from osm_bot_abstraction_layer.generic_bot_retagging import run_simple_retagging_task
import hashlib

def edit_element(tags):
    if tags.get('surface') != ("cement"):
        return tags
    tags["surface"] = "concrete"
    return tags

def main():
    query="""
[out:xml][timeout:600];
area[name="United States"]->.a;
(
  way["surface"="cement"]["highway"~"^(motorway|motorway_link|trunk|trunk_link|primary|primary_link|secondary|secondary_link|tertiary|tertiary_link|unclassified|residential|living_street|pedestrian|service|track|road|footway|cycleway|path|bridleway|steps)$"](area.a);
  relation["surface"="cement"]["highway"~"^(pedestrian|service|track|road|footway|cycleway|path|bridleway|steps)$"](area.a);
);
out body;
>;
out skel qt;
"""
    hashed = hashlib.sha256(query.encode('utf-8')).hexdigest()
    run_simple_retagging_task(
        max_count_of_elements_in_one_changeset=500,
        objects_to_consider_query=query,
        objects_to_consider_query_storage_file='/media/mateusz/OSM_cache/osm_bot_cache/osm_bot_edit_' + hashed + '.osm',
        is_in_manual_mode=False,
        changeset_comment='migrate surface=cement to surface=concrete on USA roads and paths',
        discussion_url="https://osmus.slack.com/archives/C029HV951/p1667991028781419 https://lists.openstreetmap.org/pipermail/talk-us/2022-November/021864.html",
        osm_wiki_documentation_page='https://wiki.openstreetmap.org/wiki/Mechanical_Edits/Mateusz_Konieczny_-_bot_account/migrate_surface%3Dcement_to_surface%3Dconcrete_on_USA_roads_and_paths',
        edit_element_function=edit_element,
    )

main()

Opt-out

Please write at bot approval thread, in case of posting on mailing list - send me also a PM. Note that in case of opt-out exactly the same edit will be made manually for objects where bot opt-out was used.