-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
find{Arrival,Departure}: fall back to matching by trip_headsign β
π
- Loading branch information
Showing
17 changed files
with
324 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
'use strict' | ||
|
||
const csv = require('../csv') | ||
|
||
const TRIPS = ` | ||
SELECT | ||
trip_id, | ||
trip_headsign | ||
FROM trips | ||
` | ||
|
||
const beforeAll = ` | ||
CREATE TABLE trips_normalized_headsigns ( | ||
trip_id TEXT NOT NULL, | ||
FOREIGN KEY (trip_id) REFERENCES trips, | ||
normalized_trip_headsign TEXT NOT NULL | ||
); | ||
COPY trips_normalized_headsigns FROM STDIN csv; | ||
` | ||
|
||
const createOnTrip = (gtfsRtInfo, gtfsInfo) => { | ||
// This assumes that the headsign contains a stop name, which is not the case in every region on earth. | ||
// todo [breaking]: make gtfs(Rt)Info.normalizeTripHeadsign mandatory | ||
const normalizeTripHeadsign = 'normalizeTripHeadsign' in gtfsInfo | ||
? gtfsInfo.normalizeTripHeadsign | ||
: gtfsInfo.normalizeStopName | ||
|
||
const onTrip = ({trip_id, trip_headsign}) => { | ||
// todo: handle trip_headsign being optional | ||
const normalizedHeadsign = normalizeTripHeadsign(trip_headsign) | ||
|
||
csv.write([ | ||
trip_id, | ||
normalizedHeadsign, | ||
]) | ||
} | ||
return onTrip | ||
} | ||
|
||
const afterAll = `\ | ||
\\. | ||
CREATE INDEX ON trips_normalized_headsigns (trip_id); | ||
CREATE INDEX ON trips_normalized_headsigns (normalized_trip_headsign); | ||
` | ||
|
||
module.exports = { | ||
query: TRIPS, | ||
beforeAll, | ||
createOnRow: createOnTrip, | ||
afterAll, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
agency_id,agency_name,agency_url,agency_timezone,agency_lang,agency_phone | ||
1,S-Bahn Berlin GmbH,http://www.s-bahn-berlin.de,Europe/Berlin,de, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
service_id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_date,end_date | ||
1883,0,0,0,0,0,0,0,20231221,20241214 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
service_id,date,exception_type | ||
1883,20240108,1 | ||
1883,20240115,1 | ||
1883,20240122,1 | ||
1883,20240129,1 | ||
1883,20240205,1 | ||
1883,20240212,1 | ||
1883,20240109,1 | ||
1883,20240116,1 | ||
1883,20240123,1 | ||
1883,20240130,1 | ||
1883,20240206,1 | ||
1883,20240213,1 | ||
1883,20240110,1 | ||
1883,20240117,1 | ||
1883,20240124,1 | ||
1883,20240131,1 | ||
1883,20240207,1 | ||
1883,20240214,1 | ||
1883,20240111,1 | ||
1883,20240118,1 | ||
1883,20240125,1 | ||
1883,20240201,1 | ||
1883,20240208,1 | ||
1883,20240215,1 | ||
1883,20240112,1 | ||
1883,20240119,1 | ||
1883,20240126,1 | ||
1883,20240202,1 | ||
1883,20240209,1 | ||
1883,20240106,1 | ||
1883,20240113,1 | ||
1883,20240120,1 | ||
1883,20240127,1 | ||
1883,20240203,1 | ||
1883,20240210,1 | ||
1883,20240107,1 | ||
1883,20240114,1 | ||
1883,20240121,1 | ||
1883,20240128,1 | ||
1883,20240204,1 | ||
1883,20240211,1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
set -o pipefail | ||
cd "$(dirname $0)" | ||
|
||
env | grep '^PG' || true | ||
|
||
set -x | ||
|
||
psql -c 'CREATE DATABASE test_headsign_matching' | ||
export PGDATABASE=test_headsign_matching | ||
|
||
../../node_modules/.bin/gtfs-to-sql \ | ||
-d --trips-without-shape-id \ | ||
*.csv \ | ||
| psql -b | ||
|
||
../../build-index.js ../gtfs-rt-info.js ../gtfs-info.js | psql -b | ||
|
||
node test-find-departure.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
route_id,agency_id,route_short_name,route_long_name,route_type,route_color,route_text_color,route_desc | ||
22009_700,1,S1A,,700,,, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
trip_id,arrival_time,departure_time,stop_id,stop_sequence,pickup_type,drop_off_type,stop_headsign | ||
225318702,14:50:00,14:50:00,de:11000:900058101::8,0,0,0, | ||
225318702,14:54:00,14:54:00,de:11000:900054104::2,1,0,0, | ||
225318702,14:58:00,14:58:00,de:11000:900054109::5,2,0,0, | ||
225318702,15:04:00,15:04:00,de:11000:900057103::3,3,0,0, | ||
225318702,15:12:00,15:12:00,de:11000:900012101::1,4,0,0, | ||
225318702,15:15:00,15:15:00,de:11000:900100022::1,5,0,0, | ||
225318702,15:17:00,15:17:00,de:11000:900100301::1,6,0,0, | ||
225318702,15:24:00,15:24:00,de:11000:900100001::6,7,0,0, | ||
225318415,15:24:00,15:24:00,de:11000:900100001::6,0,0,0, | ||
225318415,15:29:00,15:29:00,de:11000:900100301::1,1,0,0, | ||
225318415,15:32:00,15:32:00,de:11000:900100022::1,2,0,0, | ||
225318415,15:35:00,15:35:00,de:11000:900012101::1,3,0,0, | ||
225318415,15:43:00,15:43:00,de:11000:900058108::1,4,0,0, | ||
225318415,15:44:00,15:44:00,de:11000:900057101::1,5,0,0, | ||
225318415,15:49:00,15:49:00,de:11000:900054109::5,6,0,0, | ||
225318415,15:54:00,15:54:00,de:11000:900054104::2,7,0,0, | ||
225318415,15:58:00,15:58:00,de:11000:900058101::8,8,0,0, |
Oops, something went wrong.