Mechanical Edits/Mateusz Konieczny - bot account/remove not needed address import tags

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.

Who

I, Mateusz Konieczny using my bot account

contact

message via OSM I will respond also to PMs to the bot account. In both cases I will be notified about incoming PMs via email and notifications in OSM editors.

What

Remove:

Why

This keys were imported and are not actually needed or useful. They just confuse people editing OSM data, writing software to process it. Especially people writing software used by mappers to edit OSM - that is how I found them, and also go confused by them.

Removing them will require making some edits but will make OSM data slightly easier to edit and reduce future confusion.

And will make less likely that future import would add not necessary tags.

Numbers

Depends on how many new matches appear - depends on editing activity in OSM.

How

Each changeset contains a single element or group of close elements to avoid edits spanning across large areas (it is impossible in cases where edited object itself spans very large area)

Changeset would be described and tagged with tags that mark it as automatic, provide link to documentation page etc

Editing is limited to objects in Faroe Islands.

state before a mechanical edit:

state after a mechanical edit:

Bot source code

Bot is using https://github.com/matkoniecz/osm_bot_abstraction_layer library, this code is GNU GPLv3 licensed

from osm_bot_abstraction_layer.generic_bot_retagging import run_simple_retagging_task
import osm_bot_abstraction_layer.overpass_downloader as overpass_downloader
import osm_bot_abstraction_layer.world_data as world_data
import osm_bot_abstraction_layer.language_tag_knowledge as language_tag_knowledge
import time
import shared_generate_import_tag_cleanup_wiki_page

# https://community.openstreetmap.org/t/faroe-islands-address-metadata-cleanup-proposed-mass-edit/109790

def tags_for_removal():
    return [
        "us.fo:Galdandi_frá",
        "us.fo:kommununr",
        "us.fo:Postnr",
        "us.fo:Veganr",
        "us.fo:Eindir",
        "us.fo:Býlingsnr",
        "us.fo:Eindir",
        "us.fo:Býlingsnr",
    ]


def edit_element(tags):
    for key in tags_for_removal():
        if key in tags:
            tags.pop(key, None)
    return tags


def query():
    returned = """
[out:xml][timeout:500];
(
"""
    for key in tags_for_removal():
        returned += 'nwr["' + key + '"];\n'
    returned += """);
out meta;
>;
out meta qt;"""
    return returned


def query_by_area(iso3166_1):
    returned = """
[out:xml][timeout:500];
area['ISO3166-1'='""" + iso3166_1 + """']->.searchArea;
(
"""
    for key in tags_for_removal():
        returned += 'nwr(area.searchArea)["' + key + '"];\n'
    returned += """);
out meta;
>;
out meta qt;"""
    return returned


def main():
    print(shared_generate_import_tag_cleanup_wiki_page.page_content(tags_for_removal(), "https://community.openstreetmap.org/t/faroe-islands-address-metadata-cleanup-proposed-mass-edit/109790", "Faroe Islands"))
    run_simple_retagging_task(
        max_count_of_elements_in_one_changeset=5000,
        objects_to_consider_query=query_by_area("FO"),
        cache_folder_filepath='/media/mateusz/OSM_cache/osm_bot_cache',
        is_in_manual_mode=False,
        changeset_comment='remove unnecessary gnis tags that got imported',
        discussion_url="https://community.openstreetmap.org/t/faroe-islands-address-metadata-cleanup-proposed-mass-edit/109790",
        osm_wiki_documentation_page="https://wiki.openstreetmap.org/wiki/Mechanical_Edits/Mateusz_Konieczny_-_bot_account/remove_not_needed_address_import_tags",
        edit_element_function=edit_element,
    )

main()

Discussion

https://community.openstreetmap.org/t/faroe-islands-address-metadata-cleanup-proposed-mass-edit/109790

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

Opt-out

Please write at forum topic where it was discussed .

Note that in case of opt-out exactly the same edit will be made manually.