Upstream fixes #3

Merged
biodranik merged 3 commits from upstream into master 2022-04-22 22:26:36 +00:00
4 changed files with 37 additions and 14 deletions

View file

@ -82,8 +82,10 @@ if you allow the `process_subway.py` to fetch data from Overpass API. Here are t
Summary information about all metro networks that are monitored is gathered in the
[Google Spreadsheet](https://docs.google.com/spreadsheets/d/1SEW1-NiNOnA2qDwievcxYV1FOaQl1mb1fdeyqAxHu3k).
Not so regular updates of validation results are available at
[this website](https://alexey-zakharenkov.github.io/subways/rapid/).
Regular updates of validation results are available at
[this website](https://maps.mail.ru/osm/tools/subways/latest/).
You can find more info about this validator instance in
[OSM Wiki](https://wiki.openstreetmap.org/wiki/Quality_assurance#subway-preprocessor).
## Adding Stop Areas To OSM

View file

@ -1,4 +1,5 @@
import csv
import itertools
import logging
import math
import urllib.parse
@ -965,11 +966,7 @@ class Route:
),
relation,
)
if not self.stops:
city.error('Route has no stops', relation)
elif len(self.stops) == 1:
city.error('Route has only one stop', relation)
else:
if len(self.stops) > 1:
self.is_circular = (
self.stops[0].stoparea == self.stops[-1].stoparea
)
@ -1382,7 +1379,7 @@ class City:
self.elements = {} # Dict el_id → el
self.stations = defaultdict(list) # Dict el_id → list of StopAreas
self.routes = {} # Dict route_ref → route
self.routes = {} # Dict route_master_ref → RouteMaster
self.masters = {} # Dict el_id of route → route_master
self.stop_areas = defaultdict(
list
@ -1552,6 +1549,13 @@ class City:
continue
route = Route(el, self, master)
if not route.stops:
self.warn('Route has no stops', el)
continue
elif len(route.stops) == 1:
self.warn('Route has only one stop', el)
continue
k = el_id(master) if master else route.ref
if k not in self.routes:
self.routes[k] = RouteMaster(master)
@ -1712,6 +1716,18 @@ class City:
if t not in have_return:
self.notice('Route does not have a return direction', rel)
def validate_route_refs(self):
master_refs = sorted(m.ref for m in self.routes.values())
for ref, group in itertools.groupby(master_refs):
if len(list(group)) > 1:
# This can occur if some routes with some ref belong to
# a route_master, but other with the same ref doesn't.
self.error("Route masters {} have the same ref".format(
', '.join(
m.id for m in self.routes.values() if m.ref == ref
)
))
def validate_lines(self):
self.found_light_lines = len(
[x for x in self.routes.values() if x.mode != 'subway']
@ -1778,6 +1794,8 @@ class City:
self.count_unused_entrances()
self.found_interchanges = len(self.transfers)
self.validate_route_refs()
if self.overground:
self.validate_overground_lines()
else:

View file

@ -121,7 +121,12 @@ INDEX_HEADER = '''
<body>
<main>
<h1>Subway Validation Results</h1>
<p>Total good metro networks: {good_cities} of {total_cities}.</p>
<p><b>{good_cities}</b> of <b>{total_cities}</b> networks validated without errors.
To make a network validate successfully please follow the
<a href="https://wiki.openstreetmap.org/wiki/Metro_Mapping">metro mapping instructions</a>.
Commit your changes to the OSM and then check back to the updated validation results after the next validation cycle, please.
See <a href="https://wiki.openstreetmap.org/wiki/Quality_assurance#subway-preprocessor">the validator instance&#0040;s&#0041; description</a>
for the schedule and capabilities.</p>
<p><a href="render.html">View networks on a map</a></p>
<table cellspacing="3" cellpadding="2" style="margin-bottom: 1em;">
'''.replace('(s)', STYLE)
@ -172,7 +177,7 @@ INDEX_COUNTRY = '''
INDEX_FOOTER = '''
</table>
</main>
<footer>Produced by <a href="https://github.com/mapsme/subways">Subway Preprocessor</a> on {date}.
<footer>Produced by <a href="https://github.com/alexey-zakharenkov/subways">Subway Preprocessor</a> on {date}.
See <a href="{google}">this spreadsheet</a> for the reference metro statistics and
<a href="https://en.wikipedia.org/wiki/List_of_metro_systems#List">this wiki page</a> for a list
of all metro systems.</footer>
@ -253,7 +258,7 @@ COUNTRY_CITY = '''
COUNTRY_FOOTER = '''
</table>
</main>
<footer>Produced by <a href="https://github.com/mapsme/subways">Subway Preprocessor</a> on {date}.</footer>
<footer>Produced by <a href="https://github.com/alexey-zakharenkov/subways">Subway Preprocessor</a> on {date}.</footer>
</body>
</html>
'''

View file

@ -7,8 +7,6 @@ import json
from subway_structure import SPREADSHEET_ID
from v2h_templates import *
date = datetime.datetime.now().strftime('%d.%m.%Y %H:%M')
class CityData:
def __init__(self, city=None):
@ -157,7 +155,7 @@ for c in data.values():
world = sum(continents.values(), CityData())
overground = 'traml_expected' in next(iter(data.values())).data
date = datetime.datetime.now().strftime('%d.%m.%Y %H:%M')
date = datetime.datetime.utcnow().strftime('%d.%m.%Y %H:%M UTC')
path = '.' if len(sys.argv) < 3 else sys.argv[2]
index = open(os.path.join(path, 'index.html'), 'w', encoding='utf-8')
index.write(tmpl(INDEX_HEADER, world))