Mechanical Edits/Mateusz Konieczny - bot account/retag addr:postcode to postal code where needed (in Poland)
https://forum.openstreetmap.org/viewtopic.php?id=72245 Propozycja automatycznej zmiany addr:postcode -> postal_code https://overpass-turbo.eu/s/16g8 below page is for rewrite to fit this edit
Page content created as advised on Automated_Edits_code_of_conduct#Document_and_discuss_your_plans.
This edit will remove replace addr:postcode=* by postal_code=* on elements with place=*.
Why
It will match the correct and preferred tagging schema.
Yes, making an edit requires modifying objects. The same would happen if mapper would remove them manually.
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.
Numbers
High enough that writing a bot is a good idea.
How
https://www.openstreetmap.org/node/1371104727:
state before a mechanical edit:
- addr:postcode=28-100
- name=Owczary
- place=village
- teryt:simc=0232383
- wikipedia=pl:Owczary (województwo świętokrzyskie)
- wikidata=Q7114338
state after a mechanical edit:
- postal_code=28-100
- name=Owczary
- place=village
- teryt:simc=0232383
- wikipedia=pl:Owczary (województwo świętokrzyskie)
- wikidata=Q7114338
Changeset would be described and tagged with tags that mark it as automatic, provide link to discussion approving edit etc
Source code
from osm_bot_abstraction_layer.generic_bot_retagging import run_simple_retagging_task def edit_element(tags): if 'addr:postcode' not in tags: return tags if 'place' not in tags: return tags if 'addr:housenumber' in tags: print("unexpected addr:housenumber") return tags if tags.get('place') not in ["hamlet", "village", "isolated_dwelling"]: print("unexpected place value", tags.get("place")) return tags if 'postal_code' in tags: print("has postal_code already!") return tags tags['postal_code'] = tags["addr:postcode"] tags.pop('addr:postcode', None) return tags def main(): run_simple_retagging_task( max_count_of_elements_in_one_changeset=500, objects_to_consider_query=""" [out:xml][timeout:25000]; area[name="Polska"]->.a; ( nwr["addr:postcode"]["place"](area.a); ); out body; >; out skel qt; """, objects_to_consider_query_storage_file='/media/mateusz/OSM_cache/osm_bot_cache/tags_for_retagging_post_codes.osm', is_in_manual_mode=False, changeset_comment='addr:postcode do postal_code na miejscowościach', discussion_url='https://forum.openstreetmap.org/viewtopic.php?id=72245', osm_wiki_documentation_page='https://wiki.openstreetmap.org/wiki/Mechanical_Edits/Mateusz_Konieczny_-_bot_account/retag_addr:postcode_to_postal_code_where_needed_(in_Poland)', edit_element_function=edit_element, ) main()
Discussion
https://forum.openstreetmap.org/viewtopic.php?id=72245
Repetition
This is a single run that will not be repeated.
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.