Mechanical Edits/Mateusz Konieczny - bot account/add highway=bus stop tag where only public transport=platform bus=yes is present 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.

There are at multiple ways to record that bus stop exists at a given location. Two of them are:

  1. node with public_transport=platform bus=yes
  2. node with highway=bus_stop (standard and simplest possible method)

Some bus stops in Poland are mapped solely with method (1) and not mapped with method (2). Method (2) is preferred by a Polish community, though currently double mapping using both is considered acceptable.

This automated edit adds highway=bus_stop to such elements to make using OSM data easier and makes data less confusing.

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

Adding highway=bus_stop where there are bus stops not mapped using this standard method for marking bus stop.

Editing is restricted to Poland.

Why

highway=bus_stop is standard and simple method for marking bus stop, and may be used on the same objects that already have public_transport=platform bus=yes. There is no good reason to not add it and doing this manually would be extremely boring and waste of human mapping time.

How

  • Editing is limited to nodes with public_transport=platform bus=yes
  • Nodes with nearby highway=bus_stop are ignored
  • To remaining highway=bus_stop is added
  • Elements with highway tag are skipped
  • Each changeset contains a single region to avoid edits spanning across large areas (it is impossible in cases where edited object itself spans very large area, what is not expected in case of editing bus stops)

A theoretical example:
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

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

I started editing and during monitoring but edit I noticed "and if your edit affects a specialist subject, such as oil rigs or public transport which has its own list then you should also discuss your plans on that mailing list." at Automated Edits code of conduct. Sorry for missing that - I stopped editing and submitted https://lists.openstreetmap.org/pipermail/talk-transit/2019-May/002167.html

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 https://forum.openstreetmap.org/viewtopic.php?id=66164 .

Source code

I license this code as GNU GPLv3. It is using https://github.com/matkoniecz/osm_bot_abstraction_layer library.

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

def edit_element(tags):
    if tags.get('highway') != None:
        return tags
    if tags.get('bus') != ("yes"):
        return tags
    if tags.get('public_transport') != ("platform"):
        return tags
    tags['highway'] = 'bus_stop'
    return tags

def query(area_name):#//[maxsize:4073741824]
  return """
// we want nodes with public_transport=platform bus=yes, without highway=bus_stop
// and without nearby highway=bus_stop
// within specified boundary (as bot edit permission applies to a specific country)

[out:xml][timeout:1000];
area[name='""" + area_name + """'];
node(area)[public_transport=platform][bus=yes][highway!=bus_stop]["highway"!~".*"]->.incomplete_bus_stop_nodes;

nwr(around.incomplete_bus_stop_nodes:250)[highway=bus_stop]->.properly_tagged_bus_stops_around_incomplete;

nwr(around.properly_tagged_bus_stops_around_incomplete:250)[public_transport=platform][bus=yes][highway!=bus_stop]->.incomplete_bus_stops_near_possibly_duplicating_correct_ones;


(.incomplete_bus_stop_nodes; - .incomplete_bus_stops_near_possibly_duplicating_correct_ones;);
out;

"""

def storage_path(filename):
  return '/media/mateusz/OSM_cache/OSM-cache/' + filename

def edit_part(area_name):
    run_simple_retagging_task(
        max_count_of_elements_in_one_changeset=500,
        objects_to_consider_query= query(area_name),
        objects_to_consider_query_storage_file=storage_path('adding_simple_bus_stops.osm'),
        is_in_manual_mode=False,
        changeset_comment='dodawanie highway=bus_stop tam gdzie go brak na podstawie istniejących danych (public_transport=platform bus=yes)',
        discussion_url='https://forum.openstreetmap.org/viewtopic.php?id=66164',
        osm_wiki_documentation_page='https://wiki.openstreetmap.org/wiki/Mechanical_Edits/Mateusz_Konieczny_-_bot_account/add_highway%3Dbus_stop_tag_where_only_public_transport%3Dplatform_bus%3Dyes_is_present_in_Poland',
        edit_element_function=edit_element,
    )

def main():
    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)

main()
print("http://overpass-turbo.eu/s/TVE for manual fixing")