Commit 8f05a40b authored by Branko Kokanovic's avatar Branko Kokanovic

more fixes for building_fix_apartments

parent 689f661e
...@@ -2,7 +2,7 @@ import csv ...@@ -2,7 +2,7 @@ import csv
import logging import logging
import logging.handlers import logging.handlers
import osmapi import osmapi
import time
def setup_logger(filename: str): def setup_logger(filename: str):
"""Simple logger used throughout whole scrapper - logs both to file and console.""" """Simple logger used throughout whole scrapper - logs both to file and console."""
...@@ -26,7 +26,7 @@ def setup_logger(filename: str): ...@@ -26,7 +26,7 @@ def setup_logger(filename: str):
logger = setup_logger('fixes.log') logger = setup_logger('fixes.log')
api = osmapi.OsmApi(passwordfile='osm-password', api = osmapi.OsmApi(passwordfile='osm-password',
changesetauto=True, changesetautosize=50, changesetautotags= changesetauto=True, changesetautosize=100, changesetautotags=
{u"comment": u"Serbian lint bot " {u"comment": u"Serbian lint bot "
"(https://gitlab.com/stalker314314/stambene-zajednice-analysis). " "(https://gitlab.com/stalker314314/stambene-zajednice-analysis). "
"Adding building=apartments on government provided open dataset", "Adding building=apartments on government provided open dataset",
...@@ -61,21 +61,24 @@ def main(): ...@@ -61,21 +61,24 @@ def main():
for sz in stambene_zajednice: for sz in stambene_zajednice:
if sz['processed'] and sz['way'] and sz['building_tag_present'] and not sz['building_is_apartments']: if sz['processed'] and sz['way'] and sz['building_tag_present'] and not sz['building_is_apartments']:
i = i + 1 i = i + 1
logger.info('Progress: {0}/{1}'.format(i, count)) if i < 0: # If you need to skip already processed, set this to value greater than 0
if i < 20: # Skip already processed if i % 100 == 0:
logger.info('Progress: {0}/{1}'.format(i, count))
continue continue
logger.info('Progress: {0}/{1}'.format(i, count))
way = api.WayGet(sz['way']) way = api.WayGet(sz['way'])
if 'building' not in way['tag']: if 'building' not in way['tag']:
logger.warning('{0} is missing building tag, skipping'.format(sz['way'])) logger.warning('{0} is missing building tag, skipping'.format(sz['way']))
continue continue
if way['tag']['building'] == 'apartments': if way['tag']['building'] == 'apartments':
logger.warning('{0} already have building=apartments tag, skipping'.format(sz['way'])) logger.warning('{0} already have building=apartments tag, skipping'.format(sz['way']))
time.sleep(5)
continue continue
for k, v in way['tag'].items(): for k, v in way['tag'].items():
logger.info('{0}: {1}'.format(k, v)) logger.info('{0}: {1}'.format(k, v))
logger.info('https://www.openstreetmap.org/way/{0}'.format(sz['way'])) logger.info('https://www.openstreetmap.org/way/{0}'.format(sz['way']))
to_continue = input('Proceed (y/n):') to_continue = input('Proceed (y/n):')
if to_continue == 'y': if to_continue == '' or to_continue == 'y':
way['tag']['building'] = 'apartments' way['tag']['building'] = 'apartments'
api.WayUpdate(way) api.WayUpdate(way)
api.flush() api.flush()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment