Mechanical Edits/Mateusz Konieczny - bot account/remove boundary tagging on ways in Poland/

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 remove unneded boundary=administrative tags that are duplications causing warning in validators.

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

Removing boundary=administrative tags from ways in Poland, except cases where also admin_level=* is present. Only ways belonging to boundary=administrative relation will be edited.

Why

boundary=administrative + admin_level=* on ways, duplicating boundary=administrative + admin_level=* on relations is likely an outdated tagging that should be eliminated. (but see discussion).

boundary=administrative without admin_level=* on ways, duplicating boundary=administrative + admin_level=* on relations is tagging

  • without any known benefits
  • raising validator warnings in JOSM, Vespucci, Osmose and probably also other QA tools
  • that is pointless duplication


Note also that tagging boundary=administrative + admin_level=* on ways is not needed and useful anymore anyway

  • with exception of very rare data consumers like an abandoned ÖPNVKarte where such boundaries are of minor importance

Numbers

Unknown, let me know if it is important to someone.

How

An example (note that way belongs to relations such as [1] [2] [3] [4]):
state before a mechanical edit:

state after a mechanical edit:

Changeset would be described and tagged with tags that mark it as automatic, provide link to discussion approving edit etc

Discussion

Discussed by Polish OSM community at https://forum.openstreetmap.org/viewtopic.php?id=71873

Thread specifically about bot edit: https://forum.openstreetmap.org/viewtopic.php?pid=819797#p819797

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 osm_bot_abstraction_layer.overpass_downloader as overpass_downloader
from osm_iterator.osm_iterator import Data
import osm_bot_abstraction_layer.world_data as world_data
import time

def edit_element(tags):
    if tags.get('admin_level') != None:
        return tags
    if tags.get('boundary') != ("administrative"):
        return tags
    tags.pop('boundary', None)
    return tags

def query(area_name):
  return """
[out:xml][timeout:1000];
area['name'='""" + area_name + """']->.searchArea;
rel(area.searchArea)["boundary"="administrative"]["admin_level"];
>;
way["boundary"=administrative][!"admin_level"]._;
(._;>;);
out meta qt;"""

def storage_path(filename):
  return '/tmp/' + filename

def edit_part(area_name):
    run_simple_retagging_task(
        max_count_of_elements_in_one_changeset=5000,
        objects_to_consider_query= query(area_name),
        objects_to_consider_query_storage_file=storage_path('bare_boundary_tags'),
        is_in_manual_mode=False,
        changeset_comment='usunięcie zbędnego boundary=administrative z lini, dublującego tagi na relacjach granic',
        discussion_url='https://forum.openstreetmap.org/viewtopic.php?pid=819797#p819797',
        osm_wiki_documentation_page='https://wiki.openstreetmap.org/wiki/Mechanical_Edits/Mateusz_Konieczny_-_bot_account/remove_boundary_tagging_on_ways_in_Poland/',
        edit_element_function=edit_element,
    )

def main():
    #edit_part("Warszawa") #for test run
    edit_part("Polska")
    
    # following turned out to be not needed
    """
    code = "PL"
    admin_level_of_split = 4
    storage_file = storage_path(code+"_area_divisions.osm")
    for area_name in world_data.list_of_area_divisions(code, admin_level_of_split, storage_file):
      print(query(area_name))
      edit_part(area_name)
      minutes_sleeping = 3 # to avoid overloading overpass
      time.sleep(60 * minutes_sleeping)
    """

main()

Opt-out

Please write at bot approval thread . Note that in case of opt-out exactly the same edit will be made manually for objects where bot opt-out was used.

See also