458 lines
25 KiB
Python
458 lines
25 KiB
Python
"""
|
|
Models
|
|
======
|
|
Django database models representing the files of the GTFS Reference with all their fields
|
|
|
|
Attributes
|
|
----------
|
|
Classes
|
|
-------
|
|
Agency, Stop, Route, Trip, StopTime, Calendar, CalendarDate, FareAttribute, FareRule, Shape, Frequency, Transfer, Pathway, Level, FeedInfo, Location, BookingRule, Translation, Attribution, LocationGroup, LocationGroupStop, RouteNetwork, Network, StopArea, Area, FareMedium, FareProduct, FareLegRule, FareTransferRule, Timeframe
|
|
Different files as described in the GTFS Reference
|
|
"""
|
|
from django.db import models
|
|
from pt_map.gtfs_schema import gtfs_schema
|
|
|
|
class FeedInfo(models.Model):
|
|
"""
|
|
Represents feed_info.txt from the GTFS Reference.
|
|
"""
|
|
feed_id = models.BigAutoField(primary_key=True)
|
|
feed_publisher_name = models.CharField(max_length=255)
|
|
feed_publisher_url = models.URLField()
|
|
feed_lang = models.CharField(max_length=255)
|
|
default_lang = models.CharField(max_length=255, blank=True, null=True)
|
|
feed_start_date = models.DateField(blank=True, null=True)
|
|
feed_end_date = models.DateField(blank=True, null=True)
|
|
feed_version = models.CharField(max_length=255, blank=True, null=True)
|
|
feed_contact_email = models.EmailField(blank=True, null=True)
|
|
feed_contact_url = models.URLField(blank=True, null=True)
|
|
|
|
class Agency(models.Model):
|
|
"""
|
|
Represents agency.txt from the GTFS Reference.
|
|
"""
|
|
agency_id = models.CharField(max_length=255, primary_key=True)
|
|
agency_name = models.CharField(max_length=255)
|
|
agency_url = models.URLField()
|
|
agency_timezone = models.CharField(max_length=255)
|
|
agency_lang = models.CharField(max_length=2, blank=True, null=True)
|
|
agency_phone = models.CharField(max_length=50, blank=True, null=True)
|
|
agency_fare_url = models.URLField(blank=True, null=True)
|
|
agency_email = models.EmailField(blank=True, null=True)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class Level(models.Model):
|
|
"""
|
|
Represents level.txt from the GTFS Reference.
|
|
"""
|
|
level_id = models.CharField(max_length=255, primary_key=True)
|
|
level_index = models.FloatField()
|
|
level_name = models.CharField(max_length=255, blank=True, null=True)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class Stop(models.Model):
|
|
"""
|
|
Represents stop.txt from the GTFS Reference.
|
|
"""
|
|
stop_id = models.CharField(max_length=255, primary_key=True)
|
|
stop_code = models.CharField(max_length=50, blank=True, null=True)
|
|
stop_name = models.CharField(max_length=255)
|
|
stop_desc = models.TextField(blank=True, null=True)
|
|
tts_stop_name = models.CharField(max_length=255, blank=True)
|
|
stop_lat = models.FloatField(blank=True, null=True)
|
|
stop_lon = models.FloatField(blank=True, null=True)
|
|
zone_id = models.CharField(max_length=255, blank=True, null=True)
|
|
stop_url = models.URLField(blank=True, null=True)
|
|
location_type = models.IntegerField(blank=True, null=True)
|
|
parent_station = models.ForeignKey('self', on_delete=models.CASCADE, blank=True, null=True)
|
|
stop_timezone = models.CharField(max_length=255, blank=True, null=True)
|
|
wheelchair_boarding = models.IntegerField(blank=True, null=True)
|
|
level_id = models.ForeignKey(Level, on_delete=models.SET_NULL, blank=True, null=True)
|
|
platform_code = models.CharField(max_length=50, blank=True, null=True)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class Network(models.Model):
|
|
"""
|
|
Represents network.txt from the GTFS Reference.
|
|
"""
|
|
network_id = models.CharField(max_length=255, primary_key=True)
|
|
network_name = models.CharField(max_length=255, default="")
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class Route(models.Model):
|
|
"""
|
|
Represents route.txt from the GTFS Reference.
|
|
"""
|
|
route_id = models.CharField(max_length=255,primary_key=True)
|
|
agency_id = models.ForeignKey(Agency, on_delete=models.CASCADE, blank=True, null=True)
|
|
route_short_name = models.CharField(max_length=255)
|
|
route_long_name = models.CharField(max_length=255, blank=True, null=True)
|
|
route_desc = models.TextField(blank=True, null=True)
|
|
route_type = models.IntegerField(default=0)
|
|
route_url = models.URLField(blank=True, null=True)
|
|
route_color = models.CharField(max_length=10, blank=True, null=True)
|
|
route_text_color = models.CharField(max_length=10, blank=True, null=True)
|
|
route_sort_order = models.IntegerField(blank=True, null=True)
|
|
continuous_pickup = models.IntegerField(choices=[("Continous stopping pickup", 0), ("No continuous stopping pickup", 1), ("Must phone agency to arrange continuous stopping pickup off", 2), ("Must coordinate with driver to arrange continuous stopping pickup", 3)], blank=True, null=True)
|
|
continuous_drop_off = models.IntegerField(choices=[("Continous stopping pickup", 0), ("No continuous stopping pickup", 1), ("Must phone agency to arrange continuous stopping pickup off", 2), ("Must coordinate with driver to arrange continuous stopping pickup", 3)], blank=True, null=True)
|
|
network_id = models.ForeignKey(Network, on_delete=models.CASCADE, null=True)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class Shape(models.Model):
|
|
"""
|
|
Represents shape.txt from the GTFS Reference.
|
|
"""
|
|
shape_pk = models.BigAutoField(primary_key=True)
|
|
shape_id = models.CharField(max_length=255)
|
|
shape_pt_lat = models.FloatField()
|
|
shape_pt_lon = models.FloatField()
|
|
shape_pt_sequence = models.IntegerField()
|
|
shape_dist_traveled = models.FloatField(blank=True, null=True)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class Meta:
|
|
unique_together = (('shape_id', 'shape_pt_sequence'),)
|
|
|
|
class Calendar(models.Model):
|
|
"""
|
|
Represents calendar.txt from the GTFS Reference.
|
|
"""
|
|
service_id = models.CharField(max_length=255,primary_key=True)
|
|
monday = models.BooleanField()
|
|
tuesday = models.BooleanField()
|
|
wednesday = models.BooleanField()
|
|
thursday = models.BooleanField()
|
|
friday = models.BooleanField()
|
|
saturday = models.BooleanField()
|
|
sunday = models.BooleanField()
|
|
start_date = models.DateField()
|
|
end_date = models.DateField()
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class CalendarDate(models.Model):
|
|
"""
|
|
Represents calendar_date.txt from the GTFS Reference.
|
|
"""
|
|
calendar_date_id = models.BigAutoField(primary_key=True)
|
|
service_id = models.CharField(max_length=255)
|
|
date = models.DateField()
|
|
exception_type = models.IntegerField()
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class Meta:
|
|
unique_together = (('service_id', 'date'),)
|
|
|
|
class Trip(models.Model):
|
|
"""
|
|
Represents trip.txt from the GTFS Reference.
|
|
"""
|
|
trip_id = models.CharField(max_length=255, primary_key=True)
|
|
route_id = models.ForeignKey(Route, on_delete=models.CASCADE)
|
|
service_id = models.CharField(max_length=255)
|
|
shape_id = models.ForeignKey(Shape, on_delete=models.SET_NULL, null=True)
|
|
trip_headsign = models.CharField(max_length=255, blank=True, null=True)
|
|
trip_short_name = models.CharField(max_length=255, blank=True, null=True)
|
|
direction_id = models.IntegerField(blank=True, null=True)
|
|
block_id = models.CharField(max_length=255, blank=True, null=True)
|
|
shape_id = models.ManyToManyField(Shape, related_name='trips', blank=True)
|
|
wheelchair_accessible = models.IntegerField(blank=True, null=True)
|
|
bikes_allowed = models.IntegerField(blank=True, null=True)
|
|
|
|
def as_dict(self):
|
|
return {
|
|
"trip_id": self.trip_id,
|
|
"route_id": self.route_id.route_id,
|
|
"service_id": self.service_id,
|
|
"trip_headsign": self.trip_headsign,
|
|
"trip_short_name": self.trip_short_name,
|
|
"direction_id": self.direction_id,
|
|
"block_id": self.block_id,
|
|
"shape_id": self.shape_id.shape_id,
|
|
"wheelchair_accessible": self.wheelchair_accessible,
|
|
"bikes_allowed": self.bikes_allowed,
|
|
}
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class LocationGroup(models.Model):
|
|
"""
|
|
Represents location_group.txt from the GTFS Reference.
|
|
"""
|
|
location_group_id = models.CharField(max_length=255, primary_key=True)
|
|
location_group_name = models.CharField(max_length=255)
|
|
location_group_type = models.CharField(max_length=255)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class Location(models.Model):
|
|
"""
|
|
Represents locations.geojson from the GTFS Reference.
|
|
"""
|
|
location_id = models.CharField(max_length=255, primary_key=True)
|
|
stop_name = models.CharField(max_length=255, blank=True, null=True)
|
|
stop_desc = models.CharField(max_length=255, blank=True, null=True)
|
|
latitude = models.FloatField()
|
|
longitude = models.FloatField()
|
|
geometry_type = models.CharField(max_length=255, choices=[("Polygon", "Polygon"), ("MultiPolygon", "MultiPolygon")])
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class BookingRule(models.Model):
|
|
"""
|
|
Represents booking_rule.txt from the GTFS Reference.
|
|
"""
|
|
booking_rule_id = models.CharField(max_length=255, primary_key=True)
|
|
booking_type = models.CharField(max_length=255, blank=True, null=True)
|
|
prior_notice_duration_min = models.IntegerField(blank=True, null=True)
|
|
prior_notice_duration_max = models.IntegerField(blank=True, null=True)
|
|
prior_notice_last_day = models.IntegerField(blank=True, null=True)
|
|
prior_notice_last_time = models.TimeField(max_length=255, blank=True, null=True)
|
|
prior_notice_start_day = models.IntegerField(blank=True, null=True)
|
|
prior_notice_start_time = models.TimeField(max_length=255, blank=True, null=True)
|
|
prior_notice_service_id = models.CharField(max_length=255, blank=True, null=True)
|
|
message = models.CharField(max_length=255, blank=True, null=True)
|
|
pickup_message = models.CharField(max_length=255, blank=True, null=True)
|
|
drop_off_message = models.CharField(max_length=255, blank=True, null=True)
|
|
phone_number = models.CharField(max_length=255, blank=True, null=True)
|
|
info_url = models.URLField(blank=True, null=True)
|
|
booking_url = models.URLField(blank=True, null=True)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class StopTime(models.Model):
|
|
"""
|
|
Represents stop_time.txt from the GTFS Reference.
|
|
"""
|
|
stop_time_id = models.BigAutoField(primary_key=True)
|
|
trip_id = models.ForeignKey(Trip, on_delete=models.CASCADE)
|
|
arrival_time = models.CharField(max_length=255, blank=True, null=True)
|
|
departure_time = models.CharField(max_length=255, blank=True, null=True)
|
|
stop_id = models.ForeignKey(Stop, null=True, on_delete=models.CASCADE)
|
|
location_group_id = models.ForeignKey(LocationGroup, on_delete=models.SET_NULL, blank=True, null=True)
|
|
location_id = models.ForeignKey(Location, on_delete=models.SET_NULL, blank=True, null=True)
|
|
stop_sequence = models.IntegerField()
|
|
stop_headsign = models.CharField(max_length=255, blank=True, null=True)
|
|
pickup_type = models.IntegerField(blank=True, null=True, choices=[("Regularly scheduled pickup.", 0), ("No pickup available.", 1), ("Must phone agency to arrange pickup.", 2), ("Must coordinate with driver to arrange pickup.", 3)])
|
|
drop_off_type = models.IntegerField(blank=True, null=True, choices=[("Regularly scheduled drop off.", 0), ("No drop off available.", 1), ("Must phone agency to arrange drop off.", 2), ("Must coordinate with driver to arrange drop off.", 3)])
|
|
shape_dist_traveled = models.FloatField(blank=True, null=True)
|
|
timepoint = models.IntegerField(blank=True, null=True, choices=[("Times are considered approximate.", 0), ("Times are considered exact.", 1)])
|
|
start_pickup_drop_off_window = models.CharField(max_length=255, blank=True)
|
|
end_pickup_drop_off_window = models.CharField(max_length=255, blank=True)
|
|
continuous_pickup = models.IntegerField(choices=[("Continous stopping pickup", 0), ("No continuous stopping pickup", 1), ("Must phone agency to arrange continuous stopping pickup off", 2), ("Must coordinate with driver to arrange continuous stopping pickup", 3)], null=True)
|
|
continuous_drop_off = models.IntegerField(choices=[("Continous stopping drop off", 0), ("No continuous stopping drop off", 1), ("Must phone agency to arrange continuous stopping drop off", 2), ("Must coordinate with driver to arrange continuous stopping drop off", 3)], null=True)
|
|
pickup_booking_rule_id = models.ForeignKey(BookingRule, related_name="stop_times_pickup", null=True, on_delete=models.SET_NULL)
|
|
drop_off_booking_rule_id = models.ForeignKey(BookingRule, related_name="stop_times_drop_off", null=True, on_delete=models.SET_NULL)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class Meta:
|
|
unique_together = (('trip_id', 'stop_sequence'),)
|
|
|
|
class FareAttribute(models.Model):
|
|
"""
|
|
Represents fare_attribute.txt from the GTFS Reference.
|
|
"""
|
|
fare_id = models.CharField(max_length=255, primary_key=True)
|
|
price = models.FloatField()
|
|
currency_type = models.CharField(max_length=3)
|
|
payment_method = models.IntegerField()
|
|
transfers = models.IntegerField(blank=True, null=True)
|
|
agency_id = models.ForeignKey(Agency, on_delete=models.CASCADE, blank=True, null=True)
|
|
transfer_duration = models.IntegerField(blank=True, null=True)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class FareRule(models.Model):
|
|
"""
|
|
Represents fare_rule.txt from the GTFS Reference.
|
|
"""
|
|
fare_rule_id = models.BigAutoField(primary_key=True)
|
|
fare_id = models.ForeignKey(FareAttribute, on_delete=models.CASCADE)
|
|
route_id = models.ForeignKey(Route, on_delete=models.CASCADE, blank=True, null=True)
|
|
origin_id = models.ManyToManyField(Stop, related_name="fare_rules_for_zone_as_origin", blank=True)
|
|
destination_id = models.ManyToManyField(Stop, related_name="fare_rules_for_zone_as_destination", blank=True)
|
|
contains_id = models.ManyToManyField(Stop, related_name="fare_rules_for_zone_contains", blank=True)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class Frequency(models.Model):
|
|
"""
|
|
Represents frequency.txt from the GTFS Reference.
|
|
"""
|
|
frequency_id = models.BigAutoField(primary_key=True)
|
|
trip_id = models.ForeignKey(Trip, on_delete=models.CASCADE)
|
|
start_time = models.CharField(max_length=255)
|
|
end_time = models.CharField(max_length=255)
|
|
headway_secs = models.IntegerField()
|
|
exact_times = models.IntegerField(blank=True, null=True)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class Transfer(models.Model):
|
|
"""
|
|
Represents transfer.txt from the GTFS Reference.
|
|
"""
|
|
transfer_id = models.BigAutoField(primary_key=True)
|
|
from_stop_id = models.ForeignKey(Stop, on_delete=models.CASCADE, null=True, related_name='transfers_from_stop')
|
|
to_stop_id = models.ForeignKey(Stop, on_delete=models.CASCADE, null=True, related_name='transfers_to_stop')
|
|
from_route_id = models.ForeignKey(Route, on_delete=models.SET_NULL, blank=True, null=True, related_name='transfers_from_route')
|
|
to_route_id = models.ForeignKey(Route, on_delete=models.SET_NULL, blank=True, null=True, related_name='transfers_to_route')
|
|
from_trip_id = models.ForeignKey(Trip, on_delete=models.SET_NULL, blank=True, null=True, related_name='transfers_from_trip')
|
|
to_trip_id = models.ForeignKey(Trip, on_delete=models.SET_NULL, blank=True, null=True, related_name='transfers_to_trip')
|
|
transfer_type = models.IntegerField()
|
|
min_transfer_time = models.IntegerField(blank=True, null=True)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class Meta:
|
|
unique_together = (('from_stop_id', 'to_stop_id'),)
|
|
|
|
class Pathway(models.Model):
|
|
"""
|
|
Represents lathway.txt from the GTFS Reference.
|
|
"""
|
|
pathway_id = models.CharField(max_length=255, primary_key=True)
|
|
from_stop_id = models.ForeignKey(Stop, on_delete=models.CASCADE, related_name='pathways_from')
|
|
to_stop_id = models.ForeignKey(Stop, on_delete=models.CASCADE, related_name='pathways_to')
|
|
pathway_mode = models.IntegerField()
|
|
is_bidirectional = models.IntegerField()
|
|
length = models.FloatField(blank=True, null=True)
|
|
traversal_time = models.IntegerField(blank=True, null=True)
|
|
stair_count = models.IntegerField(blank=True, null=True)
|
|
max_slope = models.FloatField(blank=True, null=True)
|
|
min_width = models.FloatField(blank=True, null=True)
|
|
signposted_as = models.CharField(max_length=255, blank=True, null=True)
|
|
reversed_signposted_as = models.CharField(max_length=255, blank=True, null=True)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class Translation(models.Model):
|
|
"""
|
|
Represents translation.txt from the GTFS Reference.
|
|
"""
|
|
translation_id = models.BigAutoField(primary_key=True)
|
|
table_name = models.CharField(max_length=255, choices={"agency": "agency", "stops": "stops", "routes": "routes", "trips": "trips", "stop_times": "stop_times", "pathways": "pathways", "levels": "levels", "feed_info": "feed_info", "attributions": "attributions"})
|
|
field_name = models.CharField(max_length=255)
|
|
language = models.CharField(max_length=2)
|
|
translation = models.TextField()
|
|
record_id = models.CharField(max_length=255)
|
|
record_sub_id = models.CharField(max_length=255)
|
|
field_value = models.CharField(max_length=255)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class Attribution(models.Model):
|
|
"""
|
|
Represents attribution.txt from the GTFS Reference.
|
|
"""
|
|
attribution_id = models.CharField(max_length=255, primary_key=True)
|
|
agency_id = models.ForeignKey(Agency, on_delete=models.SET_NULL, blank=True, null=True)
|
|
route_id = models.ForeignKey(Route, on_delete=models.SET_NULL, blank=True, null=True)
|
|
trip_id = models.ForeignKey(Trip, on_delete=models.SET_NULL, blank=True, null=True)
|
|
organization_name = models.CharField(max_length=255)
|
|
is_producer = models.BooleanField(null=True)
|
|
is_operator = models.BooleanField(null=True)
|
|
is_authority = models.BooleanField(null=True)
|
|
attribution_name = models.CharField(max_length=255, blank=True, null=True)
|
|
attribution_url = models.URLField()
|
|
attribution_email = models.EmailField(blank=True, null=True)
|
|
attribution_phone = models.CharField(max_length=50, blank=True, null=True)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class LocationGroupStop(models.Model):
|
|
"""
|
|
Represents location_groupStop.txt from the GTFS Reference.
|
|
"""
|
|
location_group_stop_id = models.BigAutoField(primary_key=True)
|
|
location_group_id = models.ForeignKey(LocationGroup, on_delete=models.CASCADE)
|
|
stop_id = models.ForeignKey(Stop, on_delete=models.CASCADE)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class RouteNetwork(models.Model):
|
|
"""
|
|
Represents route_network.txt from the GTFS Reference.
|
|
"""
|
|
route_network_id = models.CharField(max_length=255, primary_key=True)
|
|
route_network_name = models.CharField(max_length=255)
|
|
network_id = models.ForeignKey(Network, on_delete=models.CASCADE)
|
|
route_id = models.ForeignKey(Route, on_delete=models.CASCADE)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class Area(models.Model):
|
|
"""
|
|
Represents area.txt from the GTFS Reference.
|
|
"""
|
|
area_id = models.CharField(max_length=255, primary_key=True)
|
|
area_name = models.CharField(max_length=255)
|
|
area_description = models.TextField(blank=True, null=True)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class StopArea(models.Model):
|
|
"""
|
|
Represents stop_area.txt from the GTFS Reference.
|
|
"""
|
|
stop_area_id = models.CharField(max_length=255, primary_key=True)
|
|
stop_area_name = models.CharField(max_length=255)
|
|
stop_area_description = models.TextField(blank=True, null=True)
|
|
area_id = models.ForeignKey(Area, on_delete=models.CASCADE)
|
|
stop_id = models.ForeignKey(Stop, on_delete=models.CASCADE)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class FareMedium(models.Model):
|
|
"""
|
|
Represents fare_medium.txt from the GTFS Reference.
|
|
"""
|
|
fare_media_id = models.CharField(max_length=255, primary_key=True)
|
|
fare_media_name = models.CharField(max_length=255)
|
|
fare_media_type = models.IntegerField(choices=[("None", 0), ("Physical paper ticket that allows a passenger to take either a certain number of pre-purchased trips or unlimited trips within a fixed period of time", 1), ("Physical transit card that has stored tickets, passes or monetary value", 2), ("cEMV (contactless Europay, Mastercard and Visa) as an open-loop token container for account-based ticketing", 3), ("Mobile app that have stored virtual transit cards, tickets, passes, or monetary value", 4)])
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class FareProduct(models.Model):
|
|
"""
|
|
Represents fare_product.txt from the GTFS Reference.
|
|
"""
|
|
fare_product_pk = models.BigAutoField(primary_key=True)
|
|
fare_product_id = models.CharField(max_length=255)
|
|
fare_product_name = models.CharField(max_length=255)
|
|
fare_media_id = models.ForeignKey(FareMedium, on_delete=models.SET_NULL, blank=True, null=True)
|
|
amount = models.FloatField()
|
|
currency = models.CharField(max_length=64)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class Meta:
|
|
unique_together = (("fare_product_id", "fare_media_id"),)
|
|
|
|
class Timeframe(models.Model):
|
|
"""
|
|
Represents timeframe.txt from the GTFS Reference.
|
|
"""
|
|
timeframe_group_id = models.CharField(max_length=255,primary_key=True)
|
|
service_id = models.CharField(max_length=255)
|
|
start_time = models.CharField(max_length=255)
|
|
end_time = models.CharField(max_length=255)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class FareLegRule(models.Model):
|
|
"""
|
|
Represents fare_legRule.txt from the GTFS Reference.
|
|
"""
|
|
fare_leg_rule_id = models.CharField(max_length=255, primary_key=True)
|
|
fare_leg_rule_name = models.CharField(max_length=255)
|
|
fare_leg_rule_description = models.TextField(blank=True, null=True)
|
|
leg_group_id = models.CharField(max_length=255, blank=True, null=True)
|
|
network_id = models.ForeignKey(Network, on_delete=models.CASCADE, null=True)
|
|
from_area_id = models.ForeignKey(Area, blank=True, null=True, on_delete=models.SET_NULL, related_name='farelegrule_from_area')
|
|
to_area_id = models.ForeignKey(Area, blank=True, null=True, on_delete=models.SET_NULL, related_name='farelegrule_to_area')
|
|
from_timeframe_group_id = models.ManyToManyField(Timeframe, related_name="fare_leg_rules_from", blank=True)
|
|
to_timeframe_group_id = models.ManyToManyField(Timeframe, related_name="fare_leg_rules_to", blank=True)
|
|
fare_product_id = models.ForeignKey(FareProduct, on_delete=models.CASCADE)
|
|
rule_priority = models.IntegerField(blank=True, null=True)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|
|
class FareTransferRule(models.Model):
|
|
"""
|
|
Represents faretransfer_rule.txt from the GTFS Reference.
|
|
"""
|
|
fare_transfer_rule_id = models.CharField(max_length=255, primary_key=True)
|
|
fare_transfer_rule_name = models.CharField(max_length=255)
|
|
fare_transfer_rule_description = models.TextField(blank=True, null=True)
|
|
transfer_count = models.IntegerField(blank=True, null=True)
|
|
duration_limit = models.IntegerField(blank=True, null=True)
|
|
duration_limit_type = models.CharField(max_length=255, choices=[("Between the departure fare validation of the current leg and the arrival fare validation of the next leg", 0), ("Between the departure fare validation of the current leg and the departure fare validation of the next leg", 1), ("Between the arrival fare validation of the current leg and the departure fare validation of the next leg", 2), ("Between the arrival fare validation of the current leg and the arrival fare validation of the next leg", 3)])
|
|
fare_transfer_type = models.CharField(max_length=255, choices=[("From-leg fare_leg_rules.fare_product_id plus fare_transfer_rules.fare_product_id; A + AB", 0), ("From-leg fare_leg_rules.fare_product_id plus fare_transfer_rules.fare_product_id plus to-leg fare_leg_rules.fare_product_id; A + AB + B", 1), ("fare_transfer_rules.fare_product_id; AB", 2)])
|
|
from_leg_group_id = models.ManyToManyField(FareLegRule, related_name="fare_transfer_rules_from", blank=True)
|
|
to_leg_group_id = models.ManyToManyField(FareLegRule, related_name="fare_transfer_rules_to", blank=True)
|
|
fare_product_id = models.ForeignKey(FareProduct, on_delete=models.SET_NULL, blank=True, null=True)
|
|
feed_info_id = models.ForeignKey(FeedInfo, on_delete=models.CASCADE)
|
|
|