Skip to content

Commit

Permalink
added check for known OSM route types
Browse files Browse the repository at this point in the history
  • Loading branch information
ialokim authored and grote committed Mar 1, 2018
1 parent 7c8d18c commit bc0a5ca
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions osm2gtfs/core/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,38 @@ def __attrs_post_init__(self):

# pylint: disable=unsupported-membership-test,unsubscriptable-object
if 'route_master' in self.tags:
self.route_type = self.tags['route_master'].capitalize()
self.route_type = self.tags['route_master']
else:
sys.stderr.write(
"Warning: Route master relation without a route_master tag:\n")
sys.stderr.write(" " + self.osm_url + "\n")

# Try to guess the type differently
if 'route' in self.tags:
self.route_type = self.tags['route'].capitalize()
self.route_type = self.tags['route']
else:
self.route_type = "Bus"
self.route_type = "bus"
sys.stderr.write(" Assuming it to be a bus line (standard).\n")

known_route_types = {
'tram': 'Tram',
'light_rail': 'Tram',
'subway': 'Subway',
'train': 'Rail',
'bus': 'Bus',
'trolleybus': 'Bus',
'ferry': 'Ferry'
}

if self.route_type not in known_route_types:
sys.stderr.write(
"Warning: Route master relation with an unknown route type (" +
self.route_type + "):\n")
sys.stderr.write(" " + self.osm_url + "\n")
sys.stderr.write(" Assuming it to be a bus line (standard).\n")
self.route_type = known_route_types['bus']
else:
self.route_type = known_route_types[self.route_type]

def add_itinerary(self, itinerary):

Expand Down

0 comments on commit bc0a5ca

Please sign in to comment.