def __init__(self, transit_data, fare_id, price, currency_type, payment_method, transfers, agency_id=None, transfer_duration=None, **kwargs): self._id = fare_id self.price = float(price) self.currency_type = currency_type self.payment_method = int(payment_method) self.transfers = parse_or_default(transfers, None, int) self.attributes = { k: v for k, v in kwargs.iteritems() if not_none_or_empty(v) } if not_none_or_empty(agency_id): self.attributes["agency_id"] = transit_data.agencies[int( agency_id)] if not_none_or_empty(transfer_duration): self.attributes["transfer_duration"] = int(transfer_duration)
def __init__(self, transit_data, fare_id, route_id=None, origin_id=None, destination_id=None, contains_id=None, **kwargs): """ :type transit_data: gtfspy.transit_data_object.TransitData :type fare_id: str :type route_id: str | None :type origin_id: str | int | None :type destination_id: str | int | None :type contains_id: str | int | None """ self.fare = transit_data.fare_attributes[fare_id] self.attributes = { k: v for k, v in kwargs.iteritems() if not_none_or_empty(v) } if not_none_or_empty(route_id): self.attributes["route_id"] = transit_data.routes[route_id] if not_none_or_empty(origin_id): self.attributes["origin_id"] = int(origin_id) if not_none_or_empty(destination_id): self.attributes["destination_id"] = int(destination_id) if not_none_or_empty(contains_id): self.attributes["contains_id"] = int(contains_id)
def __init__(self, transit_data, agency_id, agency_name, agency_url, agency_timezone, agency_lang=None, agency_phone=None, agency_email=None, agency_fare_url=None, **kwargs): """ :type transit_data: gtfspy.transit_data_object.TransitData :type agency_id: str | int :type agency_name: str :type agency_url: str :type agency_timezone: str :type agency_lang: str | None :type agency_phone: str | None :type agency_email: str | None :type agency_fare_url: str | None """ self._id = int(agency_id) self.agency_name = agency_name self.agency_url = agency_url self.agency_timezone = agency_timezone self.attributes = { k: v for k, v in kwargs.iteritems() if not_none_or_empty(v) } if not_none_or_empty(agency_lang): self.attributes["agency_lang"] = str(agency_lang) if not_none_or_empty(agency_phone): self.attributes["agency_phone"] = str(agency_phone) if not_none_or_empty(agency_email): self.attributes["agency_email"] = str(agency_email) if not_none_or_empty(agency_fare_url): self.attributes["agency_fare_url"] = str(agency_fare_url) self.lines = LineCollection(transit_data, self)
def __init__(self, shape_pt_lat, shape_pt_lon, shape_pt_sequence, shape_dist_traveled=None, **kwargs): """ :type shape_pt_lat: str | float :type shape_pt_lon: str | float :type shape_pt_sequence: str | int :type shape_dist_traveled: str | float | None """ self.latitude = float(shape_pt_lat) self.longitude = float(shape_pt_lon) self.sequence = int(shape_pt_sequence) self.attributes = { k: v for k, v in kwargs.iteritems() if not_none_or_empty(v) } if not_none_or_empty(shape_dist_traveled): self.attributes["shape_dist_traveled"] = float(shape_dist_traveled)
def __init__(self, service_id, start_date, end_date, sunday=None, monday=None, tuesday=None, wednesday=None, thursday=None, friday=None, saturday=None, **kwargs): """ :type service_id: str | int :type start_date: date | str :type end_date: date | str :type sunday: str | bool | None :type monday: str | bool | None :type tuesday: str | bool | None :type wednesday: str | bool | None :type thursday: str | bool | None :type friday: str | bool | None :type saturday: str | bool | None """ self._id = int(service_id) self.start_date = start_date if isinstance( start_date, date) else datetime.strptime(start_date, "%Y%m%d").date() self.end_date = end_date if isinstance( end_date, date) else datetime.strptime(end_date, "%Y%m%d").date() sunday = parse_or_default(sunday, False, str_to_bool) monday = parse_or_default(monday, False, str_to_bool) tuesday = parse_or_default(tuesday, False, str_to_bool) wednesday = parse_or_default(wednesday, False, str_to_bool) thursday = parse_or_default(thursday, False, str_to_bool) friday = parse_or_default(friday, False, str_to_bool) saturday = parse_or_default(saturday, False, str_to_bool) self.days_relevance = [ sunday, monday, tuesday, wednesday, thursday, friday, saturday ] self.attributes = { k: v for k, v in kwargs.iteritems() if not_none_or_empty(v) }
def __init__(self, transit_data, route_id, route_short_name, route_long_name, route_type, agency_id, route_desc=None, route_url=None, route_color=None, route_text_color=None, route_sort_order=None, **kwargs): """ :type transit_data: gtfspy.transit_data_object.TransitData :type route_id: str :type route_short_name: str :type route_long_name: str :type route_type: str | int :type agency_id: str | int :type route_desc: str | None :type route_url: str | None :type route_color: str | None :type route_text_color: str | None :type route_sort_order: str | int | None """ self._id = route_id self.route_short_name = route_short_name self.route_long_name = route_long_name # TODO: create dedicated object to route type self.route_type = int(route_type) self.agency = transit_data.agencies[int(agency_id)] self.attributes = { k: v for k, v in kwargs.iteritems() if not_none_or_empty(v) } if not_none_or_empty(route_desc): self.attributes["route_desc"] = str(route_desc) if not_none_or_empty(route_url): self.attributes["route_url"] = str(route_url) if not_none_or_empty(route_color): # TODO: find type for the route color self.attributes["route_color"] = str(route_color) if not_none_or_empty(route_text_color): self.attributes["route_text_color"] = str(route_text_color) if not_none_or_empty(route_sort_order): self.attributes["route_sort_order"] = int(route_sort_order) self.line = self.agency.get_line(self) self.trips = []
def __init__(self, transit_data, trip_id, arrival_time, departure_time, stop_id, stop_sequence, pickup_type=None, drop_off_type=None, shape_dist_traveled=None, stop_headsign=None, timepoint=None, **kwargs): """ :type transit_data: gtfspy.transit_data_object.TransitData :type trip_id: str :type arrival_time: str | timedelta :type departure_time: str | timedelta :type stop_id: str | int :type stop_sequence: str | int :type pickup_type: str | int | bool | None :type drop_off_type: str | int | bool | None :type shape_dist_traveled: str | int | float | None :type stop_headsign: str :type timepoint: str | int | None """ self.trip = transit_data.trips[trip_id] self.arrival_time = parse_timedelta(arrival_time) self.departure_time = parse_timedelta(departure_time) self.stop = transit_data.stops[int(stop_id)] self.stop_sequence = int(stop_sequence) self.attributes = { k: v for k, v in kwargs.iteritems() if not_none_or_empty(v) } if not_none_or_empty(pickup_type): self.attributes["pickup_type"] = int(pickup_type) if not_none_or_empty(drop_off_type): self.attributes["drop_off_type"] = int(drop_off_type) if not_none_or_empty(shape_dist_traveled): self.attributes["shape_dist_traveled"] = float(shape_dist_traveled) if not_none_or_empty(stop_headsign): self.attributes["stop_headsign"] = str(stop_headsign) if not_none_or_empty(timepoint): self.attributes["timepoint"] = int(timepoint)
def __init__(self, transit_data, trip_id, route_id, service_id, trip_headsign=None, trip_short_name=None, direction_id=None, block_id=None, shape_id=None, bikes_allowed=None, wheelchair_accessible=None, original_trip_id=None, **kwargs): """ :type transit_data: gtfspy.transit_data_object.TransitData :type trip_id: str :type route_id: str :type service_id: str | int :type trip_headsign: str | None :type trip_short_name: str | None :type direction_id: str | int | None :type block_id: str | None :type shape_id: str | int | None :type bikes_allowed: str | int | None :type wheelchair_accessible: str | int | None :type original_trip_id: str | None """ self._id = trip_id self.route = transit_data.routes[route_id] self.service = transit_data.calendar[int(service_id)] self.attributes = { k: v for k, v in kwargs.iteritems() if not_none_or_empty(v) } if not_none_or_empty(trip_headsign): self.attributes["trip_headsign"] = str(trip_headsign) if not_none_or_empty(trip_short_name): self.attributes["trip_short_name"] = str(trip_short_name) if not_none_or_empty(direction_id): self.attributes["direction_id"] = int(direction_id) if not_none_or_empty(block_id): self.attributes["block_id"] = int(block_id) if not_none_or_empty(shape_id): self.attributes["shape_id"] = transit_data.shapes[int(shape_id)] if not_none_or_empty(bikes_allowed): if isinstance(bikes_allowed, bool): self.attributes["bikes_allowed"] = yes_no_unknown_to_int( bikes_allowed) else: self.attributes["bikes_allowed"] = int(bikes_allowed) if not_none_or_empty(wheelchair_accessible): if isinstance(wheelchair_accessible, bool): self.attributes[ "wheelchair_accessible"] = yes_no_unknown_to_int( wheelchair_accessible) else: self.attributes["wheelchair_accessible"] = int( wheelchair_accessible) if not_none_or_empty(original_trip_id): self.attributes["original_trip_id"] = str(original_trip_id) self.stop_times = SortedList(key=attrgetter("stop_sequence"))
def __init__(self, transit_data, stop_id, stop_name, stop_lat, stop_lon, stop_code=None, stop_desc=None, zone_id=None, stop_url=None, location_type=None, parent_station=None, stop_timezone=None, wheelchair_boarding=None, **kwargs): """ :type transit_data: gtfspy.transit_data_object.TransitData :type stop_id: str | int :type stop_name: str :type stop_lat: str | float :type stop_lon: str | float :type stop_code: str | None :type stop_desc: str | None :type zone_id: str | int | None :type stop_url: str | None :type location_type: str | bool | None :type parent_station: str | int | None :type stop_timezone: str | None :type wheelchair_boarding: str | int | None """ self._id = int(stop_id) self.stop_name = stop_name self.stop_lat = float(stop_lat) self.stop_lon = float(stop_lon) self.attributes = { k: v for k, v in kwargs.iteritems() if not_none_or_empty(v) } if not_none_or_empty(stop_code): self.attributes["stop_code"] = str(stop_code) if not_none_or_empty(stop_desc): self.attributes["stop_desc"] = str(stop_desc) if not_none_or_empty(zone_id): self.attributes["zone_id"] = int(zone_id) if not_none_or_empty(stop_url): self.attributes["stop_url"] = str(stop_url) if not_none_or_empty(location_type): self.attributes["location_type"] = int(location_type) if not_none_or_empty(parent_station): self.attributes["parent_station"] = transit_data.stops[int( parent_station)] if not_none_or_empty(stop_timezone): self.attributes["stop_timezone"] = str(stop_timezone) if not_none_or_empty(wheelchair_boarding): if isinstance(wheelchair_boarding, bool): self.attributes["wheelchair_boarding"] = yes_no_unknown_to_int( wheelchair_boarding) else: self.attributes["wheelchair_boarding"] = int( wheelchair_boarding) self.stop_times = []