From 375a4439ed0230207e214681bd8266b419a8c852 Mon Sep 17 00:00:00 2001 From: Adrian Date: Fri, 19 Apr 2024 11:10:11 +0200 Subject: [PATCH] test: trips where the sequence is broken --- expected/pgtfs_test.out | 27 +++++++++++++++++++++++++++ sql/pgtfs_test.sql | 20 ++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/expected/pgtfs_test.out b/expected/pgtfs_test.out index 496b67a..6cbf0b6 100644 --- a/expected/pgtfs_test.out +++ b/expected/pgtfs_test.out @@ -27,6 +27,33 @@ $$ 2 | 1 | 1712759936 | 1753 (2 rows) +-- simple connectivity test where sequence has a gap (3 is missing) +select + stop_id, + stop_sequence, + arrival_time, + trip_id +from pgtfs_csa( + '1', '4', 1712707200.0, + $$ +select trip_id, stop_id, arrival_time::double precision, departure_time::double precision, stop_sequence::int from ( + values + ('1753','1',NULL,1712757660,1), + ('1753','2',1712759880,1712759940,2), + ('1753','3',1712762040,1712762100,4), + ('1753','4',1712762100,NULL,5) + ) + as data (trip_id, stop_id, arrival_time, departure_time, stop_sequence); +$$ +); + stop_id | stop_sequence | arrival_time | trip_id +---------+---------------+--------------+--------- + 1 | 0 | 1712707200 | + 2 | 1 | 1712759936 | 1753 + 3 | 2 | 1712761984 | 1753 + 4 | 3 | 1712762112 | 1753 +(4 rows) + -- connected and route on single trip select stop_id, diff --git a/sql/pgtfs_test.sql b/sql/pgtfs_test.sql index 71755d2..c966dea 100644 --- a/sql/pgtfs_test.sql +++ b/sql/pgtfs_test.sql @@ -24,6 +24,26 @@ select trip_id, stop_id, arrival_time::double precision, departure_time::double $$ ); +-- simple connectivity test where sequence has a gap (3 is missing) +select + stop_id, + stop_sequence, + arrival_time, + trip_id +from pgtfs_csa( + '1', '4', 1712707200.0, + $$ +select trip_id, stop_id, arrival_time::double precision, departure_time::double precision, stop_sequence::int from ( + values + ('1753','1',NULL,1712757660,1), + ('1753','2',1712759880,1712759940,2), + ('1753','3',1712762040,1712762100,4), + ('1753','4',1712762100,NULL,5) + ) + as data (trip_id, stop_id, arrival_time, departure_time, stop_sequence); +$$ +); + -- connected and route on single trip select stop_id,