Only one message about tracks, fix transfers counting error

This commit is contained in:
Ilya Zverev 2017-10-26 15:23:13 +03:00
parent 2d2540f29f
commit 56ab22ee23
3 changed files with 17 additions and 7 deletions

1
.gitignore vendored
View file

@ -6,3 +6,4 @@ html/
*.geojson
*.osm
*.swp
*.yaml

View file

@ -170,7 +170,13 @@ def dump_data(city, f):
'itineraries': []
}
for variant in route:
v_stops = ['{} ({})'.format(s.station.name, s.station.id) for s in variant]
v_stops = []
for s in variant:
if s.id == s.station.id:
v_stops.append('{} ({})'.format(s.station.name, s.station.id))
else:
v_stops.append('{} ({}) in {} ({})'.format(s.station.name, s.station.id,
s.name, s.id))
rte['itineraries'].append(v_stops)
stops.update(v_stops)
routes.append(rte)
@ -249,9 +255,10 @@ if __name__ == '__main__':
cities = download_cities()
if options.city:
cities = [c for c in cities if c.name == options.city]
logging.info('Read %s metro networks', len(cities))
if not cities:
logging.error('No cities to process')
sys.exit(2)
logging.info('Read %s metro networks', len(cities))
# Reading cached json, loading XML or querying Overpass API
if options.source and os.path.exists(options.source):

View file

@ -127,13 +127,14 @@ class StopArea:
self.colour = stop_area['tags'].get('colour', self.colour)
# If we have a stop area, add all elements from it
warned_about_tracks = False
for m in stop_area['members']:
k = el_id(m)
m_el = city.elements.get(k)
if m_el and 'tags' in m_el:
if Station.is_station(m_el):
if k != station.id:
city.error('Stop area has two stations', stop_area)
city.error('Stop area has multiple stations', stop_area)
elif StopArea.is_stop_or_platform(m_el):
self.stops_and_platforms.add(k)
elif m_el['tags'].get('railway') == 'subway_entrance':
@ -143,7 +144,9 @@ class StopArea:
m['role'] != 'entry_only')
self.exits[k] = (is_entrance, is_exit)
elif m_el['tags'].get('railway') in ['rail'] + list(MODES):
city.error('Tracks in a stop_area relation', stop_area)
if not warned_about_tracks:
city.error('Tracks in a stop_area relation', stop_area)
warned_about_tracks = True
else:
# Otherwise add nearby entrances and stop positions
center = station.center
@ -459,9 +462,8 @@ class City:
transfer = set()
for m in sag['members']:
k = el_id(m)
if k not in self.stations:
return
transfer.add(self.stations[k][0])
if k in self.stations:
transfer.add(self.stations[k][0])
if len(transfer) > 1:
self.transfers.append(transfer)