gtfs 4.10.3 → 4.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/README.md +57 -9
  3. package/bin/gtfs-export.js +4 -0
  4. package/bin/gtfs-import.js +4 -1
  5. package/bin/gtfsrealtime-update.js +4 -1
  6. package/lib/advancedQuery.js +1 -1
  7. package/lib/file-utils.js +23 -26
  8. package/lib/geojson-utils.js +7 -7
  9. package/lib/gtfs/agencies.js +2 -2
  10. package/lib/gtfs/areas.js +1 -1
  11. package/lib/gtfs/attributions.js +2 -2
  12. package/lib/gtfs/booking-rules.js +32 -0
  13. package/lib/gtfs/calendar-dates.js +2 -2
  14. package/lib/gtfs/calendars.js +2 -2
  15. package/lib/gtfs/fare-attributes.js +2 -2
  16. package/lib/gtfs/fare-leg-rules.js +2 -2
  17. package/lib/gtfs/fare-products.js +2 -2
  18. package/lib/gtfs/fare-rules.js +2 -2
  19. package/lib/gtfs/fare-transfer-rules.js +2 -2
  20. package/lib/gtfs/feed-info.js +2 -2
  21. package/lib/gtfs/frequencies.js +2 -2
  22. package/lib/gtfs/levels.js +1 -1
  23. package/lib/gtfs/location-group-stops.js +32 -0
  24. package/lib/gtfs/location-groups.js +32 -0
  25. package/lib/gtfs/pathways.js +2 -2
  26. package/lib/gtfs/routes.js +3 -3
  27. package/lib/gtfs/shapes.js +5 -5
  28. package/lib/gtfs/stop-areas.js +2 -2
  29. package/lib/gtfs/stop-times.js +2 -2
  30. package/lib/gtfs/transfers.js +2 -2
  31. package/lib/gtfs/translations.js +2 -2
  32. package/lib/gtfs/trips.js +1 -1
  33. package/lib/gtfs-plus/calendar-attributes.js +2 -2
  34. package/lib/gtfs-plus/directions.js +2 -2
  35. package/lib/gtfs-plus/route-attributes.js +2 -2
  36. package/lib/gtfs-plus/stop-attributes.js +2 -2
  37. package/lib/gtfs-realtime/service-alerts.js +2 -2
  38. package/lib/gtfs-realtime/trip-updates.js +2 -2
  39. package/lib/gtfs-realtime/vehicle-positions.js +2 -2
  40. package/lib/gtfs-ride/board-alights.js +2 -2
  41. package/lib/gtfs-ride/ride-feed-infos.js +2 -2
  42. package/lib/gtfs-ride/rider-trips.js +2 -2
  43. package/lib/gtfs-ride/riderships.js +2 -2
  44. package/lib/gtfs-ride/trip-capacities.js +2 -2
  45. package/lib/gtfs.js +12 -0
  46. package/lib/import.js +15 -9
  47. package/lib/log-utils.js +1 -5
  48. package/lib/non-standard/timetable-notes-references.js +2 -2
  49. package/lib/non-standard/timetable-notes.js +2 -2
  50. package/lib/non-standard/timetable-pages.js +2 -2
  51. package/lib/non-standard/timetable-stop-order.js +2 -2
  52. package/lib/non-standard/timetables.js +2 -2
  53. package/lib/non-standard/trips-dated-vehicle-journey.js +2 -2
  54. package/lib/ods/deadhead-times.js +2 -2
  55. package/lib/ods/deadheads.js +2 -2
  56. package/lib/ods/ops-locations.js +2 -2
  57. package/lib/ods/run-events.js +2 -2
  58. package/lib/ods/runs-pieces.js +2 -2
  59. package/models/gtfs/attributions.js +2 -2
  60. package/models/gtfs/booking-rules.js +91 -0
  61. package/models/gtfs/fare-leg-rules.js +5 -0
  62. package/models/gtfs/location-group-stops.js +21 -0
  63. package/models/gtfs/location-groups.js +18 -0
  64. package/models/gtfs/stop-times.js +33 -0
  65. package/models/models.js +6 -0
  66. package/package.json +7 -7
  67. package/test/mocha/get-agencies.js +1 -1
  68. package/test/mocha/get-booking-rules.js +28 -0
  69. package/test/mocha/get-calendar-dates.js +1 -1
  70. package/test/mocha/get-fare-rules.js +1 -1
  71. package/test/mocha/get-location-group-stops.js +33 -0
  72. package/test/mocha/get-location-groups.js +28 -0
  73. package/test/mocha/get-routes.js +2 -2
  74. package/test/mocha/get-shapes.js +6 -6
  75. package/test/mocha/get-stoptimes.js +1 -1
@@ -16,7 +16,7 @@ export function getDeadheads(
16
16
  query = {},
17
17
  fields = [],
18
18
  orderBy = [],
19
- options = {}
19
+ options = {},
20
20
  ) {
21
21
  const db = options.db ?? openDb();
22
22
  const tableName = sqlString.escapeId(deadheads.filenameBase);
@@ -26,7 +26,7 @@ export function getDeadheads(
26
26
 
27
27
  return db
28
28
  .prepare(
29
- `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
30
30
  )
31
31
  .all();
32
32
  }
@@ -16,7 +16,7 @@ export function getOpsLocations(
16
16
  query = {},
17
17
  fields = [],
18
18
  orderBy = [],
19
- options = {}
19
+ options = {},
20
20
  ) {
21
21
  const db = options.db ?? openDb();
22
22
  const tableName = sqlString.escapeId(opsLocations.filenameBase);
@@ -26,7 +26,7 @@ export function getOpsLocations(
26
26
 
27
27
  return db
28
28
  .prepare(
29
- `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
30
30
  )
31
31
  .all();
32
32
  }
@@ -16,7 +16,7 @@ export function getRunEvents(
16
16
  query = {},
17
17
  fields = [],
18
18
  orderBy = [],
19
- options = {}
19
+ options = {},
20
20
  ) {
21
21
  const db = options.db ?? openDb();
22
22
  const tableName = sqlString.escapeId(runEvents.filenameBase);
@@ -26,7 +26,7 @@ export function getRunEvents(
26
26
 
27
27
  return db
28
28
  .prepare(
29
- `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
30
30
  )
31
31
  .all();
32
32
  }
@@ -16,7 +16,7 @@ export function getRunsPieces(
16
16
  query = {},
17
17
  fields = [],
18
18
  orderBy = [],
19
- options = {}
19
+ options = {},
20
20
  ) {
21
21
  const db = options.db ?? openDb();
22
22
  const tableName = sqlString.escapeId(runsPieces.filenameBase);
@@ -26,7 +26,7 @@ export function getRunsPieces(
26
26
 
27
27
  return db
28
28
  .prepare(
29
- `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
30
30
  )
31
31
  .all();
32
32
  }
@@ -10,13 +10,13 @@ const model = {
10
10
  },
11
11
  {
12
12
  name: 'agency_id',
13
- type: 'varchar(255)',
13
+ type: 'varchar(255)',
14
14
  prefix: true,
15
15
  },
16
16
  {
17
17
  name: 'route_id',
18
18
  type: 'varchar(255)',
19
- prefix: true,
19
+ prefix: true,
20
20
  },
21
21
  {
22
22
  name: 'trip_id',
@@ -0,0 +1,91 @@
1
+ const model = {
2
+ filenameBase: 'booking_rules',
3
+ schema: [
4
+ {
5
+ name: 'booking_rule_id',
6
+ type: 'varchar(255)',
7
+ primary: true,
8
+ prefix: true,
9
+ },
10
+ {
11
+ name: 'booking_type',
12
+ type: 'integer',
13
+ required: true,
14
+ min: 0,
15
+ max: 2,
16
+ },
17
+ {
18
+ name: 'prior_notice_duration_min',
19
+ type: 'integer',
20
+ min: 0,
21
+ },
22
+ {
23
+ name: 'prior_notice_duration_max',
24
+ type: 'integer',
25
+ min: 0,
26
+ },
27
+ {
28
+ name: 'prior_notice_last_day',
29
+ type: 'integer',
30
+ min: 0,
31
+ },
32
+ {
33
+ name: 'prior_notice_last_time',
34
+ type: 'varchar(255)',
35
+ },
36
+ {
37
+ name: 'prior_notice_last_timestamp',
38
+ type: 'integer',
39
+ index: true,
40
+ },
41
+ {
42
+ name: 'prior_notice_start_day',
43
+ type: 'integer',
44
+ min: 0,
45
+ },
46
+ {
47
+ name: 'prior_notice_start_time',
48
+ type: 'varchar(255)',
49
+ },
50
+ {
51
+ name: 'prior_notice_start_timestamp',
52
+ type: 'integer',
53
+ index: true,
54
+ },
55
+ {
56
+ name: 'prior_notice_service_id',
57
+ type: 'varchar(255)',
58
+ prefix: true,
59
+ },
60
+ {
61
+ name: 'message',
62
+ type: 'varchar(2047)',
63
+ nocase: true,
64
+ },
65
+ {
66
+ name: 'pickup_message',
67
+ type: 'varchar(2047)',
68
+ nocase: true,
69
+ },
70
+ {
71
+ name: 'drop_off_message',
72
+ type: 'varchar(2047)',
73
+ nocase: true,
74
+ },
75
+ {
76
+ name: 'phone_number',
77
+ type: 'varchar(64)',
78
+ nocase: true,
79
+ },
80
+ {
81
+ name: 'info_url',
82
+ type: 'varchar(2047)',
83
+ },
84
+ {
85
+ name: 'booking_url',
86
+ type: 'varchar(2047)',
87
+ },
88
+ ],
89
+ };
90
+
91
+ export default model;
@@ -43,6 +43,11 @@ const model = {
43
43
  primary: true,
44
44
  prefix: true,
45
45
  },
46
+ {
47
+ name: 'rule_priority',
48
+ type: 'integer',
49
+ min: 0,
50
+ },
46
51
  ],
47
52
  };
48
53
 
@@ -0,0 +1,21 @@
1
+ const model = {
2
+ filenameBase: 'location_group_stops',
3
+ schema: [
4
+ {
5
+ name: 'location_group_id',
6
+ type: 'varchar(255)',
7
+ prefix: true,
8
+ index: true,
9
+ required: true,
10
+ },
11
+ {
12
+ name: 'stop_id',
13
+ type: 'varchar(255)',
14
+ required: true,
15
+ prefix: true,
16
+ index: true,
17
+ },
18
+ ],
19
+ };
20
+
21
+ export default model;
@@ -0,0 +1,18 @@
1
+ const model = {
2
+ filenameBase: 'location_groups',
3
+ schema: [
4
+ {
5
+ name: 'location_group_id',
6
+ type: 'varchar(255)',
7
+ primary: true,
8
+ prefix: true,
9
+ },
10
+ {
11
+ name: 'location_group_name',
12
+ type: 'varchar(255)',
13
+ nocase: true,
14
+ },
15
+ ],
16
+ };
17
+
18
+ export default model;
@@ -26,6 +26,18 @@ const model = {
26
26
  type: 'integer',
27
27
  index: true,
28
28
  },
29
+ {
30
+ name: 'location_group_id',
31
+ type: 'varchar(255)',
32
+ prefix: true,
33
+ index: true,
34
+ },
35
+ {
36
+ name: 'location_id',
37
+ type: 'varchar(255)',
38
+ prefix: true,
39
+ index: true,
40
+ },
29
41
  {
30
42
  name: 'stop_id',
31
43
  type: 'varchar(255)',
@@ -45,6 +57,15 @@ const model = {
45
57
  type: 'varchar(255)',
46
58
  nocase: true,
47
59
  },
60
+ {
61
+ name: 'start_pickup_drop_off_window',
62
+ type: 'varchar(255)',
63
+ },
64
+ {
65
+ name: 'start_pickup_drop_off_window_timestamp',
66
+ type: 'integer',
67
+ index: true,
68
+ },
48
69
  {
49
70
  name: 'pickup_type',
50
71
  type: 'integer',
@@ -80,6 +101,18 @@ const model = {
80
101
  min: 0,
81
102
  max: 1,
82
103
  },
104
+ {
105
+ name: 'pickup_booking_rule_id',
106
+ type: 'varchar(255)',
107
+ prefix: true,
108
+ index: true,
109
+ },
110
+ {
111
+ name: 'drop_off_booking_rule_id',
112
+ type: 'varchar(255)',
113
+ prefix: true,
114
+ index: true,
115
+ },
83
116
  ],
84
117
  };
85
118
 
package/models/models.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import agency from '../models/gtfs/agency.js';
2
2
  import areas from '../models/gtfs/areas.js';
3
3
  import attributions from '../models/gtfs/attributions.js';
4
+ import bookingRules from '../models/gtfs/booking-rules.js';
4
5
  import calendarDates from '../models/gtfs/calendar-dates.js';
5
6
  import calendar from '../models/gtfs/calendar.js';
6
7
  import fareAttributes from '../models/gtfs/fare-attributes.js';
@@ -12,6 +13,8 @@ import fareTransferRules from '../models/gtfs/fare-transfer-rules.js';
12
13
  import feedInfo from '../models/gtfs/feed-info.js';
13
14
  import frequencies from '../models/gtfs/frequencies.js';
14
15
  import levels from '../models/gtfs/levels.js';
16
+ import locationGroups from '../models/gtfs/location-groups.js';
17
+ import locationGroupStops from '../models/gtfs/location-group-stops.js';
15
18
  import networks from '../models/gtfs/networks.js';
16
19
  import pathways from '../models/gtfs/pathways.js';
17
20
  import routeNetworks from '../models/gtfs/route-networks.js';
@@ -59,6 +62,7 @@ const models = [
59
62
  agency,
60
63
  areas,
61
64
  attributions,
65
+ bookingRules,
62
66
  calendarDates,
63
67
  calendar,
64
68
  fareAttributes,
@@ -70,6 +74,8 @@ const models = [
70
74
  feedInfo,
71
75
  frequencies,
72
76
  levels,
77
+ locationGroups,
78
+ locationGroupStops,
73
79
  networks,
74
80
  pathways,
75
81
  routeNetworks,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtfs",
3
- "version": "4.10.3",
3
+ "version": "4.11.0",
4
4
  "description": "Import GTFS transit data into SQLite and query routes, stops, times, fares and more",
5
5
  "keywords": [
6
6
  "transit",
@@ -77,9 +77,9 @@
77
77
  },
78
78
  "dependencies": {
79
79
  "@turf/helpers": "^6.5.0",
80
- "better-sqlite3": "^10.0.0",
81
- "csv-parse": "^5.5.5",
82
- "csv-stringify": "^6.4.6",
80
+ "better-sqlite3": "^11.0.0",
81
+ "csv-parse": "^5.5.6",
82
+ "csv-stringify": "^6.5.0",
83
83
  "gtfs-realtime-bindings": "^1.1.1",
84
84
  "lodash-es": "^4.17.21",
85
85
  "long": "^5.2.3",
@@ -95,13 +95,13 @@
95
95
  "tmp-promise": "^3.0.3",
96
96
  "untildify": "^5.0.0",
97
97
  "yargs": "^17.7.2",
98
- "yoctocolors": "^2.0.0"
98
+ "yoctocolors": "^2.0.2"
99
99
  },
100
100
  "devDependencies": {
101
101
  "husky": "^9.0.11",
102
- "lint-staged": "^15.2.2",
102
+ "lint-staged": "^15.2.5",
103
103
  "mocha": "^10.4.0",
104
- "prettier": "^3.2.5",
104
+ "prettier": "^3.3.0",
105
105
  "should": "^13.2.3"
106
106
  },
107
107
  "engines": {
@@ -75,7 +75,7 @@ describe('getAgencies():', () => {
75
75
  {
76
76
  agency_id: agencyId,
77
77
  },
78
- ['agency_url', 'agency_lang']
78
+ ['agency_url', 'agency_lang'],
79
79
  );
80
80
 
81
81
  const expectedResult = {
@@ -0,0 +1,28 @@
1
+ /* eslint-env mocha */
2
+
3
+ import should from 'should';
4
+
5
+ import config from '../test-config.js';
6
+ import { openDb, closeDb, importGtfs, getBookingRules } from '../../index.js';
7
+
8
+ describe('getBookingRules():', () => {
9
+ before(async () => {
10
+ openDb(config);
11
+ await importGtfs(config);
12
+ });
13
+
14
+ after(() => {
15
+ const db = openDb(config);
16
+ closeDb(db);
17
+ });
18
+
19
+ it('should return empty array if no booking rules', () => {
20
+ const bookingRuleId = 'not_real';
21
+
22
+ const results = getBookingRules({
23
+ booking_rule_id: bookingRuleId,
24
+ });
25
+ should.exists(results);
26
+ results.should.have.length(0);
27
+ });
28
+ });
@@ -79,7 +79,7 @@ describe('getCalendarDates():', () => {
79
79
  [
80
80
  ['date', 'ASC'],
81
81
  ['service_id', 'ASC'],
82
- ]
82
+ ],
83
83
  );
84
84
 
85
85
  const expectedResults = [
@@ -33,7 +33,7 @@ describe('getFareRules():', () => {
33
33
  {
34
34
  route_id: routeId,
35
35
  },
36
- ['fare_id', 'route_id', 'origin_id', 'destination_id']
36
+ ['fare_id', 'route_id', 'origin_id', 'destination_id'],
37
37
  );
38
38
 
39
39
  const expectedResult = {
@@ -0,0 +1,33 @@
1
+ /* eslint-env mocha */
2
+
3
+ import should from 'should';
4
+
5
+ import config from '../test-config.js';
6
+ import {
7
+ openDb,
8
+ closeDb,
9
+ importGtfs,
10
+ getLocationGroupStops,
11
+ } from '../../index.js';
12
+
13
+ describe('getLocationGroupStops():', () => {
14
+ before(async () => {
15
+ openDb(config);
16
+ await importGtfs(config);
17
+ });
18
+
19
+ after(() => {
20
+ const db = openDb(config);
21
+ closeDb(db);
22
+ });
23
+
24
+ it('should return empty array if no location group stops', () => {
25
+ const locationGroupId = 'not_real';
26
+
27
+ const results = getLocationGroupStops({
28
+ location_group_id: locationGroupId,
29
+ });
30
+ should.exists(results);
31
+ results.should.have.length(0);
32
+ });
33
+ });
@@ -0,0 +1,28 @@
1
+ /* eslint-env mocha */
2
+
3
+ import should from 'should';
4
+
5
+ import config from '../test-config.js';
6
+ import { openDb, closeDb, importGtfs, getLocationGroups } from '../../index.js';
7
+
8
+ describe('getLocationGroups():', () => {
9
+ before(async () => {
10
+ openDb(config);
11
+ await importGtfs(config);
12
+ });
13
+
14
+ after(() => {
15
+ const db = openDb(config);
16
+ closeDb(db);
17
+ });
18
+
19
+ it('should return empty array if no location groups', () => {
20
+ const locationGroupId = 'not_real';
21
+
22
+ const results = getLocationGroups({
23
+ location_group_id: locationGroupId,
24
+ });
25
+ should.exists(results);
26
+ results.should.have.length(0);
27
+ });
28
+ });
@@ -101,7 +101,7 @@ describe('getRoutes():', () => {
101
101
  const results = getRoutes(
102
102
  { stop_id: '70321' },
103
103
  [],
104
- [['route_long_name', 'ASC']]
104
+ [['route_long_name', 'ASC']],
105
105
  );
106
106
 
107
107
  const expectedResults = [
@@ -131,7 +131,7 @@ describe('getRoutes():', () => {
131
131
  const results = getRoutes(
132
132
  { stop_id: 'not-valid' },
133
133
  [],
134
- [['route_long_name', 'ASC']]
134
+ [['route_long_name', 'ASC']],
135
135
  );
136
136
 
137
137
  const expectedResults = [];
@@ -72,7 +72,7 @@ describe('getShapes():', () => {
72
72
  'shape_pt_lon',
73
73
  'shape_pt_sequence',
74
74
  'shape_dist_traveled',
75
- ]
75
+ ],
76
76
  );
77
77
 
78
78
  const expectedResult = {
@@ -99,7 +99,7 @@ describe('getShapes():', () => {
99
99
  'shape_pt_lon',
100
100
  'shape_pt_sequence',
101
101
  'shape_dist_traveled',
102
- ]
102
+ ],
103
103
  );
104
104
 
105
105
  const expectedResult = {
@@ -138,7 +138,7 @@ describe('getShapes():', () => {
138
138
  'shape_pt_lon',
139
139
  'shape_pt_sequence',
140
140
  'shape_dist_traveled',
141
- ]
141
+ ],
142
142
  );
143
143
 
144
144
  const expectedResult = {
@@ -166,7 +166,7 @@ describe('getShapes():', () => {
166
166
  'shape_pt_lon',
167
167
  'shape_pt_sequence',
168
168
  'shape_dist_traveled',
169
- ]
169
+ ],
170
170
  );
171
171
 
172
172
  const expectedResult = {
@@ -194,7 +194,7 @@ describe('getShapes():', () => {
194
194
  'shape_pt_lon',
195
195
  'shape_pt_sequence',
196
196
  'shape_dist_traveled',
197
- ]
197
+ ],
198
198
  );
199
199
 
200
200
  const expectedResult = {
@@ -222,7 +222,7 @@ describe('getShapes():', () => {
222
222
  'shape_pt_lon',
223
223
  'shape_pt_sequence',
224
224
  'shape_dist_traveled',
225
- ]
225
+ ],
226
226
  );
227
227
 
228
228
  const expectedResult = {
@@ -48,7 +48,7 @@ describe('getStoptimes():', () => {
48
48
  trip_id: tripId,
49
49
  },
50
50
  [],
51
- [['stop_sequence', 'ASC']]
51
+ [['stop_sequence', 'ASC']],
52
52
  );
53
53
 
54
54
  should.exist(results);