Fix transfers
This commit is contained in:
parent
bd8d39fc1e
commit
bc23d63c43
|
@ -377,11 +377,30 @@ class Command(BaseCommand):
|
|||
to_stop_id = transfer_dict['to_stop_id']
|
||||
from_stop_id = f"{gtfs_code}-{from_stop_id}"
|
||||
to_stop_id = f"{gtfs_code}-{to_stop_id}"
|
||||
from_route_id = transfer_dict.get('from_route_id', None)
|
||||
from_route_id = f"{gtfs_code}-{from_route_id}" if from_route_id else None
|
||||
to_route_id = transfer_dict.get('to_route_id', None)
|
||||
to_route_id = f"{gtfs_code}-{to_route_id}" if to_route_id else None
|
||||
from_trip_id = transfer_dict.get('from_trip_id', None)
|
||||
from_trip_id = f"{gtfs_code}-{from_trip_id}" if from_trip_id else None
|
||||
to_trip_id = transfer_dict.get('to_trip_id', None)
|
||||
to_trip_id = f"{gtfs_code}-{to_trip_id}" if to_trip_id else None
|
||||
|
||||
transfer_id = f"{gtfs_code}-{transfer_dict['from_stop_id']}-{transfer_dict['to_stop_id']}"
|
||||
if from_route_id and to_route_id:
|
||||
transfer_id += f"-{from_route_id}-{to_route_id}"
|
||||
if from_trip_id and to_trip_id:
|
||||
transfer_id += f"-{from_trip_id}-{to_trip_id}"
|
||||
transfer_id += f"-{transfer_dict['transfer_type']}"
|
||||
|
||||
transfer = Transfer(
|
||||
id=f"{gtfs_code}-{transfer_dict['from_stop_id']}-{transfer_dict['to_stop_id']}",
|
||||
id=transfer_id,
|
||||
from_stop_id=from_stop_id,
|
||||
to_stop_id=to_stop_id,
|
||||
from_route_id=from_route_id,
|
||||
to_route_id=to_route_id,
|
||||
from_trip_id=from_trip_id,
|
||||
to_trip_id=to_trip_id,
|
||||
transfer_type=transfer_dict['transfer_type'],
|
||||
min_transfer_time=transfer_dict.get('min_transfer_time', 0) or 0,
|
||||
)
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
# Generated by Django 5.0.6 on 2024-08-12 18:33
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("gtfs", "0004_trip_long_distance_trip_route_name_trip_route_type_and_more"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="transfer",
|
||||
name="from_route",
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
default=None,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="transfers_from",
|
||||
to="gtfs.route",
|
||||
verbose_name="From route",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="transfer",
|
||||
name="from_trip",
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
default=None,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="transfers_from",
|
||||
to="gtfs.trip",
|
||||
verbose_name="From trip",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="transfer",
|
||||
name="to_route",
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
default=None,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="transfers_to",
|
||||
to="gtfs.route",
|
||||
verbose_name="To route",
|
||||
),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name="transfer",
|
||||
name="to_trip",
|
||||
field=models.ForeignKey(
|
||||
blank=True,
|
||||
default=None,
|
||||
null=True,
|
||||
on_delete=django.db.models.deletion.CASCADE,
|
||||
related_name="transfers_to",
|
||||
to="gtfs.trip",
|
||||
verbose_name="To trip",
|
||||
),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name="transfer",
|
||||
name="min_transfer_time",
|
||||
field=models.IntegerField(
|
||||
blank=True, default=None, verbose_name="Minimum transfer time"
|
||||
),
|
||||
),
|
||||
]
|
Loading…
Reference in New Issue