Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename fare_zone_id column #546

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ create TABLE IF NOT EXISTS fare_rules (
contains INTEGER,
FOREIGN KEY(fare_id) REFERENCES fare_attributes(fare_id) deferrable initially deferred,
FOREIGN KEY(route_id) REFERENCES routes(route_id) deferrable initially deferred,
FOREIGN KEY(destination) REFERENCES fare_zones(fare_zone_id) deferrable initially deferred,
FOREIGN KEY(origin) REFERENCES fare_zones(fare_zone_id) deferrable initially deferred,
FOREIGN KEY(contains) REFERENCES fare_zones(fare_zone_id) deferrable initially deferred
FOREIGN KEY(destination) REFERENCES fare_zones(zone_id) deferrable initially deferred,
FOREIGN KEY(origin) REFERENCES fare_zones(zone_id) deferrable initially deferred,
FOREIGN KEY(contains) REFERENCES fare_zones(zone_id) deferrable initially deferred
);
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
--@ The *zones* tables holds information on the fare transit zones and
--@ the TAZs they are in.
--@
--@ **fare_zone_id** identifies the fare zone for a stop
--@ **zone_id** identifies the fare zone for a stop
--@
--@ **transit_zone** identifies the TAZ for a fare zone
--@
--@ **agency_id** identifies the agency fot the specified route

CREATE TABLE IF NOT EXISTS fare_zones (
fare_zone_id INTEGER PRIMARY KEY,
zone_id INTEGER PRIMARY KEY,
transit_zone TEXT NOT NULL,
agency_id INTEGER NOT NULL,
FOREIGN KEY(agency_id) REFERENCES agencies(agency_id) deferrable initially deferred
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
--@
--@ **street** identifies the address of a stop
--@
--@ **fare_zone_id** identifies the fare zone for a stop
--@ **zone_id** identifies the fare zone for a stop
--@
--@ **transit_zone** identifies the TAZ for a fare zone
--@
Expand All @@ -39,11 +39,11 @@ CREATE TABLE IF NOT EXISTS stops (
parent_station TEXT,
description TEXT,
street TEXT,
fare_zone_id INTEGER,
zone_id INTEGER,
transit_zone TEXT,
route_type INTEGER NOT NULL DEFAULT -1,
FOREIGN KEY(agency_id) REFERENCES agencies(agency_id),
FOREIGN KEY("fare_zone_id") REFERENCES fare_zones("fare_zone_id")
FOREIGN KEY("zone_id") REFERENCES fare_zones("zone_id")
);

--#
Expand Down
Binary file modified aequilibrae/reference_files/coquimbo.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion aequilibrae/transit/lib_gtfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def save_to_disk(self):

zones = [[y, x, self.gtfs_data.agency.agency_id] for x, y in list(zone_ids.items())]
if zones:
sql = "Insert into fare_zones (fare_zone_id, transit_zone, agency_id) values(?, ?, ?);"
sql = "Insert into fare_zones (zone_id, transit_zone, agency_id) values(?, ?, ?);"
conn.executemany(sql, zones)
conn.commit()

Expand Down
2 changes: 1 addition & 1 deletion aequilibrae/transit/transit_elements/stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def save_to_database(self, conn: Connection, commit=True) -> None:
"""Saves Transit Stop to the database"""

sql = """insert into stops (stop_id, stop, agency_id, link, dir, name,
parent_station, description, street, fare_zone_id, transit_zone, route_type, geometry)
parent_station, description, street, zone_id, transit_zone, route_type, geometry)
values (?,?,?,?,?,?,?,?,?,?,?,?, GeomFromWKB(?, ?));"""

dt = self.data
Expand Down
4 changes: 2 additions & 2 deletions tests/aequilibrae/project/test_transit_tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def create_project(project: Project):
["fare_id", "fare", "agency_id", "price", "currency", "payment_method", "transfer", "transfer_duration"],
),
("fare_rules", ["fare_id", "route_id", "origin", "destination", "contains"]),
("fare_zones", ["fare_zone_id", "transit_zone", "agency_id"]),
("fare_zones", ["zone_id", "transit_zone", "agency_id"]),
("pattern_mapping", ["pattern_id", "seq", "link", "dir", "geometry"]),
(
"routes",
Expand Down Expand Up @@ -49,7 +49,7 @@ def create_project(project: Project):
"parent_station",
"description",
"street",
"fare_zone_id",
"zone_id",
"transit_zone",
"route_type",
"geometry",
Expand Down