trainvel/sncfgtfs/models.py

480 lines
10 KiB
Python

from django.db import models
from django.utils.translation import gettext_lazy as _
class LocationType(models.IntegerChoices):
STOP_PLATFORM = 0, _("Stop/platform")
STATION = 1, _("Station")
ENTRANCE_EXIT = 2, _("Entrance/exit")
GENERIC_NODE = 3, _("Generic node")
BOARDING_AREA = 4, _("Boarding area")
class AccessInformation(models.IntegerChoices):
NO_INFORMATION = 0, _("No information")
POSSIBLE = 1, _("Possible")
NOT_POSSIBLE = 2, _("Not possible")
class PickupType(models.IntegerChoices):
REGULAR = 0, _("Regular")
NONE = 1, _("None")
MUST_PHONE_AGENCY = 2, _("Must phone agency")
MUST_COORDINATE_WITH_DRIVER = 3, _("Must coordinate with driver")
class RouteType(models.IntegerChoices):
TRAM = 0, _("Tram")
METRO = 1, _("Metro")
RAIL = 2, _("Rail")
BUS = 3, _("Bus")
FERRY = 4, _("Ferry")
CABLE_CAR = 5, _("Cable car")
GONDOLA = 6, _("Gondola")
FUNICULAR = 7, _("Funicular")
class Direction(models.IntegerChoices):
OUTBOUND = 0, _("Outbound")
INBOUND = 1, _("Inbound")
class TransferType(models.IntegerChoices):
RECOMMENDED = 0, _("Recommended")
TIMED = 1, _("Timed")
MINIMUM_TIME = 2, _("Minimum time")
NOT_POSSIBLE = 3, _("Not possible")
class Agency(models.Model):
agency_id = models.CharField(
max_length=255,
primary_key=True,
verbose_name=_("Agency ID"),
)
agency_name = models.CharField(
max_length=255,
unique=True,
verbose_name=_("Agency name"),
)
agency_url = models.URLField(
verbose_name=_("Agency URL"),
)
agency_timezone = models.CharField(
max_length=255,
verbose_name=_("Agency timezone"),
)
agency_lang = models.CharField(
max_length=255,
verbose_name=_("Agency language"),
blank=True,
)
class Meta:
verbose_name = _("Agency")
verbose_name_plural = _("Agencies")
class Stop(models.Model):
stop_id = models.CharField(
max_length=255,
primary_key=True,
verbose_name=_("Stop ID"),
)
stop_code = models.CharField(
max_length=255,
verbose_name=_("Stop code"),
blank=True,
)
stop_name = models.CharField(
max_length=255,
verbose_name=_("Stop name"),
)
stop_desc = models.CharField(
max_length=255,
verbose_name=_("Stop description"),
blank=True,
)
stop_lon = models.FloatField(
verbose_name=_("Stop longitude"),
)
stop_lat = models.FloatField(
verbose_name=_("Stop latitude"),
)
zone_id = models.CharField(
max_length=255,
verbose_name=_("Zone ID"),
)
stop_url = models.URLField(
verbose_name=_("Stop URL"),
blank=True,
)
location_type = models.IntegerField(
verbose_name=_("Location type"),
blank=True,
choices=LocationType,
default=LocationType.STOP_PLATFORM,
)
parent_station = models.ForeignKey(
to="Stop",
on_delete=models.PROTECT,
verbose_name=_("Parent station"),
blank=True,
)
stop_timezone = models.CharField(
max_length=255,
verbose_name=_("Stop timezone"),
blank=True,
)
level_id = models.CharField(
max_length=255,
verbose_name=_("Level ID"),
blank=True,
)
wheelchair_boarding = models.IntegerField(
verbose_name=_("Wheelchair boarding"),
blank=True,
choices=AccessInformation,
default=AccessInformation.NO_INFORMATION,
)
platform_code = models.CharField(
max_length=255,
verbose_name=_("Platform code"),
)
class Meta:
verbose_name = _("Stop")
verbose_name_plural = _("Stops")
class Route(models.Model):
route_id = models.CharField(
max_length=255,
primary_key=True,
verbose_name=_("Route ID"),
)
agency = models.ForeignKey(
to="Agency",
on_delete=models.CASCADE,
verbose_name=_("Agency ID"),
)
route_short_name = models.CharField(
max_length=255,
verbose_name=_("Route short name"),
)
route_long_name = models.CharField(
max_length=255,
verbose_name=_("Route long name"),
)
route_desc = models.CharField(
max_length=255,
verbose_name=_("Route description"),
blank=True,
)
route_type = models.IntegerField(
verbose_name=_("Route type"),
choices=RouteType,
)
route_url = models.URLField(
verbose_name=_("Route URL"),
blank=True,
)
route_color = models.CharField(
max_length=255,
verbose_name=_("Route color"),
blank=True,
)
route_text_color = models.CharField(
max_length=255,
verbose_name=_("Route text color"),
blank=True,
)
class Meta:
verbose_name = _("Route")
verbose_name_plural = _("Routes")
class Trip(models.Model):
trip_id = models.CharField(
max_length=255,
primary_key=True,
verbose_name=_("Trip ID"),
)
route = models.ForeignKey(
to="Route",
on_delete=models.CASCADE,
verbose_name=_("Route ID"),
)
service_id = models.CharField(
max_length=255,
verbose_name=_("Service ID"),
)
trip_headsign = models.CharField(
max_length=255,
verbose_name=_("Trip headsign"),
blank=True,
)
trip_short_name = models.CharField(
max_length=255,
verbose_name=_("Trip short name"),
blank=True,
)
direction_id = models.IntegerField(
verbose_name=_("Direction"),
choices=Direction,
blank=True,
)
block_id = models.CharField(
max_length=255,
verbose_name=_("Block ID"),
blank=True,
)
shape_id = models.CharField(
max_length=255,
verbose_name=_("Shape ID"),
blank=True,
)
wheelchair_accessible = models.IntegerField(
verbose_name=_("Wheelchair accessible"),
choices=AccessInformation,
default=AccessInformation.NO_INFORMATION,
blank=True,
)
bikes_allowed = models.IntegerField(
verbose_name=_("Bikes allowed"),
choices=AccessInformation,
default=AccessInformation.NO_INFORMATION,
)
class Meta:
verbose_name = _("Trip")
verbose_name_plural = _("Trips")
class StopTime(models.Model):
trip_id = models.ForeignKey(
to="Trip",
on_delete=models.CASCADE,
verbose_name=_("Trip ID"),
)
arrival_time = models.TimeField(
verbose_name=_("Arrival time"),
)
departure_time = models.TimeField(
verbose_name=_("Departure time"),
)
stop = models.ForeignKey(
to="Stop",
on_delete=models.CASCADE,
verbose_name=_("Stop ID"),
)
stop_sequence = models.IntegerField(
verbose_name=_("Stop sequence"),
)
stop_headsign = models.CharField(
max_length=255,
verbose_name=_("Stop headsign"),
blank=True,
)
pickup_type = models.IntegerField(
verbose_name=_("Pickup type"),
choices=PickupType,
default=PickupType.REGULAR,
blank=True,
)
drop_off_type = models.IntegerField(
verbose_name=_("Drop off type"),
choices=PickupType,
default=PickupType.REGULAR,
blank=True,
)
timepoint = models.BooleanField(
verbose_name=_("Timepoint"),
default=True,
blank=True,
)
class Meta:
verbose_name = _("Stop time")
verbose_name_plural = _("Stop times")
class Calendar(models.Model):
service_id = models.CharField(
max_length=255,
primary_key=True,
verbose_name=_("Service ID"),
)
monday = models.BooleanField(
verbose_name=_("Monday"),
)
tuesday = models.BooleanField(
verbose_name=_("Tuesday"),
)
wednesday = models.BooleanField(
verbose_name=_("Wednesday"),
)
thursday = models.BooleanField(
verbose_name=_("Thursday"),
)
friday = models.BooleanField(
verbose_name=_("Friday"),
)
saturday = models.BooleanField(
verbose_name=_("Saturday"),
)
sunday = models.BooleanField(
verbose_name=_("Sunday"),
)
start_date = models.DateField(
verbose_name=_("Start date"),
)
end_date = models.DateField(
verbose_name=_("End date"),
)
class Meta:
verbose_name = _("Calendar")
verbose_name_plural = _("Calendars")
class CalendarDate(models.Model):
service_id = models.ForeignKey(
to="Calendar",
on_delete=models.CASCADE,
verbose_name=_("Service ID"),
)
date = models.DateField(
verbose_name=_("Date"),
)
exception_type = models.IntegerField(
verbose_name=_("Exception type"),
)
class Meta:
verbose_name = _("Calendar date")
verbose_name_plural = _("Calendar dates")
class Transfer(models.Model):
from_stop = models.ForeignKey(
to="Stop",
on_delete=models.CASCADE,
verbose_name=_("From stop"),
related_name="transfers_from",
)
to_stop = models.ForeignKey(
to="Stop",
on_delete=models.CASCADE,
verbose_name=_("To stop"),
related_name="transfers_to",
)
transfer_type = models.IntegerField(
verbose_name=_("Transfer type"),
choices=TransferType,
default=TransferType.RECOMMENDED,
)
min_transfer_time = models.IntegerField(
verbose_name=_("Minimum transfer time"),
blank=True,
)
class Meta:
verbose_name = _("Transfer")
verbose_name_plural = _("Transfers")
class FeedInfo(models.Model):
feed_id = models.SmallIntegerField(
primary_key=True,
verbose_name=_("Feed ID"),
)
feed_publisher_name = models.CharField(
max_length=255,
verbose_name=_("Feed publisher name"),
)
feed_publisher_url = models.URLField(
verbose_name=_("Feed publisher URL"),
)
feed_lang = models.CharField(
max_length=255,
verbose_name=_("Feed language"),
)
feed_start_date = models.DateField(
verbose_name=_("Feed start date"),
)
feed_end_date = models.DateField(
verbose_name=_("Feed end date"),
)
feed_version = models.CharField(
max_length=255,
verbose_name=_("Feed version"),
)
class Meta:
verbose_name = _("Feed info")
verbose_name_plural = _("Feed infos")