From 9c288ef238abeae4e53fe50d321b7e7bd7a90fd7 Mon Sep 17 00:00:00 2001 From: Ilya Zverev Date: Wed, 18 Oct 2017 12:52:31 +0300 Subject: [PATCH] Small fixes --- filter_all_subways.sh | 3 +-- subway_structure.py | 3 ++- validation_to_html.py | 20 +------------------- 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/filter_all_subways.sh b/filter_all_subways.sh index 3be5fc9..730151c 100755 --- a/filter_all_subways.sh +++ b/filter_all_subways.sh @@ -3,5 +3,4 @@ OSMFILTER=${2-./osmfilter} QRELATIONS="route=subway =light_rail =monorail route_master=subway =light_rail =monorail public_transport=stop_area =stop_area_group" QNODES="station=subway =light_rail =monorail railway=subway_entrance subway=yes light_rail=yes monorail=yes" -"$OSMFILTER" "$1" --keep= --keep-relations="$QRELATIONS" --keep-nodes="$QNODES" -o=subways-$(date +%y%m%d).osm -# "$OSMFILTER" "$1" --keep= --keep-relations="$QRELATIONS" --keep-nodes="$QNODES" --drop-author -o=subways-$(date +%y%m%d).osm +"$OSMFILTER" "$1" --keep= --keep-relations="$QRELATIONS" --keep-nodes="$QNODES" --drop-author -o=subways-$(date +%y%m%d).osm diff --git a/subway_structure.py b/subway_structure.py index ff75a2d..312bbe8 100644 --- a/subway_structure.py +++ b/subway_structure.py @@ -502,7 +502,8 @@ def get_unused_entrances_geojson(elements): el['tags'].get('railway') == 'subway_entrance'): if el_id(el) not in used_entrances: geometry = {'type': 'Point', 'coordinates': el_center(el)} - properties = {k: v for k, v in el['tags'].items() if k != 'railway'} + properties = {k: v for k, v in el['tags'].items() + if k not in ('railway', 'entrance')} features.append({'type': 'Feature', 'geometry': geometry, 'properties': properties}) return {'type': 'FeatureCollection', 'features': features} diff --git a/validation_to_html.py b/validation_to_html.py index af01158..410b2ee 100755 --- a/validation_to_html.py +++ b/validation_to_html.py @@ -60,23 +60,6 @@ class CityData: s = s.replace('{='+k+'}', test_eq(self.data['num_'+k], 0)) return s - def add_warning(self, msg): - self.warnings.append(msg) - self.data['num_warnings'] += 1 - - def add_error(self, msg): - for k, reg in CityData.REGEXPS: - m = reg.search(msg) - if m: - self.data[k+'_found'] = int(m[1]) - self.data[k+'_expected'] = int(m[2]) - m = re.search(r'Found (\d+) unused subway e', msg) - if m: - self.data['unused_entrances'] = int(m[1]) - self.errors.append(msg) - self.data['num_errors'] += 1 - self.data['good_cities'] = 0 - def tmpl(s, data=None, **kwargs): if data: @@ -93,14 +76,13 @@ def tmpl(s, data=None, **kwargs): EXPAND_OSM_TYPE = {'n': 'node', 'w': 'way', 'r': 'relation'} RE_SHORT = re.compile(r'([nwr])(\d+)') RE_FULL = re.compile(r'(node|way|relation) (\d+)') -LOG_LINE = re.compile(r'^(\d\d:\d\d:\d\d)\s+([A-Z]+)\s+([^:]+):\s+(.+?)\s*$') def osm_links(s): """Converts object mentions to HTML links.""" def link(m): return '{}'.format( - EXPAND_OSM_TYPE[m[1][0]], m[2], m[0]) + EXPAND_OSM_TYPE[m.group(1)[0]], m.group(2), m.group(0)) s = RE_SHORT.sub(link, s) s = RE_FULL.sub(link, s) return s