gtfs 4.0.3 → 4.1.1

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.
@@ -0,0 +1,32 @@
1
+ import sqlString from 'sqlstring-sqlite';
2
+
3
+ import { openDb } from '../db.js';
4
+
5
+ import {
6
+ formatOrderByClause,
7
+ formatSelectClause,
8
+ formatWhereClauses,
9
+ } from '../utils.js';
10
+ import calendarAttributes from '../../models/gtfs-plus/calendar-attributes.js';
11
+
12
+ /*
13
+ * Returns an array of all calendar_attributes that match the query parameters.
14
+ */
15
+ export function getCalendarAttributes(
16
+ query = {},
17
+ fields = [],
18
+ orderBy = [],
19
+ options = {}
20
+ ) {
21
+ const db = options.db ?? openDb();
22
+ const tableName = sqlString.escapeId(calendarAttributes.filenameBase);
23
+ const selectClause = formatSelectClause(fields);
24
+ const whereClause = formatWhereClauses(query);
25
+ const orderByClause = formatOrderByClause(orderBy);
26
+
27
+ return db
28
+ .prepare(
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
30
+ )
31
+ .all();
32
+ }
@@ -7,7 +7,7 @@ import {
7
7
  formatSelectClause,
8
8
  formatWhereClauses,
9
9
  } from '../utils.js';
10
- import directions from '../../models/non-standard/directions.js';
10
+ import directions from '../../models/gtfs-plus/directions.js';
11
11
 
12
12
  /*
13
13
  * Returns an array of all directions that match the query parameters.
@@ -0,0 +1,32 @@
1
+ import sqlString from 'sqlstring-sqlite';
2
+
3
+ import { openDb } from '../db.js';
4
+
5
+ import {
6
+ formatOrderByClause,
7
+ formatSelectClause,
8
+ formatWhereClauses,
9
+ } from '../utils.js';
10
+ import routeAttributes from '../../models/gtfs-plus/route-attributes.js';
11
+
12
+ /*
13
+ * Returns an array of all route_attributes that match the query parameters.
14
+ */
15
+ export function getRouteAttributes(
16
+ query = {},
17
+ fields = [],
18
+ orderBy = [],
19
+ options = {}
20
+ ) {
21
+ const db = options.db ?? openDb();
22
+ const tableName = sqlString.escapeId(routeAttributes.filenameBase);
23
+ const selectClause = formatSelectClause(fields);
24
+ const whereClause = formatWhereClauses(query);
25
+ const orderByClause = formatOrderByClause(orderBy);
26
+
27
+ return db
28
+ .prepare(
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
30
+ )
31
+ .all();
32
+ }
@@ -7,7 +7,7 @@ import {
7
7
  formatSelectClause,
8
8
  formatWhereClauses,
9
9
  } from '../utils.js';
10
- import stopAttributes from '../../models/non-standard/stop-attributes.js';
10
+ import stopAttributes from '../../models/gtfs-plus/stop-attributes.js';
11
11
 
12
12
  /*
13
13
  * Returns an array of all stop attributes that match the query parameters.
@@ -11,7 +11,7 @@ import serviceAlerts from '../../models/gtfs-realtime/service-alerts.js';
11
11
  import serviceAlertTargets from '../../models/gtfs-realtime/service-alert-targets.js';
12
12
 
13
13
  /*
14
- * Returns an array of all serivce alerts that match the query parameters.
14
+ * Returns an array of all service alerts that match the query parameters.
15
15
  */
16
16
  export function getServiceAlerts(
17
17
  query = {},
package/lib/gtfs.js CHANGED
@@ -28,9 +28,13 @@ import { getTransfers } from './gtfs/transfers.js';
28
28
  import { getTranslations } from './gtfs/translations.js';
29
29
  import { getTrips } from './gtfs/trips.js';
30
30
 
31
+ // GTFS Plus Filenames
32
+ import { getCalendarAttributes } from './gtfs-plus/calendar-attributes.js';
33
+ import { getDirections } from './gtfs-plus/directions.js';
34
+ import { getRouteAttributes } from './gtfs-plus/route-attributes.js';
35
+ import { getStopAttributes } from './gtfs-plus/stop-attributes.js';
36
+
31
37
  // Non-standard GTFS Filenames
32
- import { getDirections } from './non-standard/directions.js';
33
- import { getStopAttributes } from './non-standard/stop-attributes.js';
34
38
  import { getTimetables } from './non-standard/timetables.js';
35
39
  import { getTimetableStopOrders } from './non-standard/timetable-stop-order.js';
36
40
  import { getTimetablePages } from './non-standard/timetable-pages.js';
@@ -51,6 +55,13 @@ import { getTripUpdates } from './gtfs-realtime/trip-updates.js';
51
55
  import { getVehiclePositions } from './gtfs-realtime/vehicle-positions.js';
52
56
  import { getServiceAlerts } from './gtfs-realtime/service-alerts.js';
53
57
 
58
+ // ODS Filenames
59
+ import { getDeadheads } from './ods/deadheads.js';
60
+ import { getDeadheadTimes } from './ods/deadhead-times.js';
61
+ import { getOpsLocations } from './ods/ops-locations.js';
62
+ import { getRunEvents } from './ods/run-events.js';
63
+ import { getRunsPieces } from './ods/runs-pieces.js';
64
+
54
65
  // Expose database connection
55
66
  import { openDb, closeDb } from './db.js';
56
67
 
@@ -132,9 +143,15 @@ export { _getTrips as getTrips };
132
143
  const _getTranslations = getTranslations;
133
144
  export { _getTranslations as getTranslations };
134
145
 
146
+ const _getCalendarAttributes = getCalendarAttributes;
147
+ export { _getCalendarAttributes as getCalendarAttributes };
148
+
135
149
  const _getDirections = getDirections;
136
150
  export { _getDirections as getDirections };
137
151
 
152
+ const _getRouteAttributes = getRouteAttributes;
153
+ export { _getRouteAttributes as getRouteAttributes };
154
+
138
155
  const _getStopAttributes = getStopAttributes;
139
156
  export { _getStopAttributes as getStopAttributes };
140
157
 
@@ -186,6 +203,21 @@ export { _getVehiclePositions as getVehiclePositions };
186
203
  const _getServiceAlerts = getServiceAlerts;
187
204
  export { _getServiceAlerts as getServiceAlerts };
188
205
 
206
+ const _getDeadheads = getDeadheads;
207
+ export { _getDeadheads as getDeadheads };
208
+
209
+ const _getDeadheadTimes = getDeadheadTimes;
210
+ export { _getDeadheadTimes as getDeadheadTimes };
211
+
212
+ const _getOpsLocations = getOpsLocations;
213
+ export { _getOpsLocations as getOpsLocations };
214
+
215
+ const _getRunEvents = getRunEvents;
216
+ export { _getRunEvents as getRunEvents };
217
+
218
+ const _getRunsPieces = getRunsPieces;
219
+ export { _getRunsPieces as getRunsPieces };
220
+
189
221
  const _openDb = openDb;
190
222
  export { _openDb as openDb };
191
223
  const _closeDb = closeDb;
@@ -0,0 +1,32 @@
1
+ import sqlString from 'sqlstring-sqlite';
2
+
3
+ import { openDb } from '../db.js';
4
+
5
+ import {
6
+ formatOrderByClause,
7
+ formatSelectClause,
8
+ formatWhereClauses,
9
+ } from '../utils.js';
10
+ import deadheadTimes from '../../models/ods/deadhead-times.js';
11
+
12
+ /*
13
+ * Returns an array of all deadhead_times that match the query parameters.
14
+ */
15
+ export function getDeadheadTimes(
16
+ query = {},
17
+ fields = [],
18
+ orderBy = [],
19
+ options = {}
20
+ ) {
21
+ const db = options.db ?? openDb();
22
+ const tableName = sqlString.escapeId(deadheadTimes.filenameBase);
23
+ const selectClause = formatSelectClause(fields);
24
+ const whereClause = formatWhereClauses(query);
25
+ const orderByClause = formatOrderByClause(orderBy);
26
+
27
+ return db
28
+ .prepare(
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
30
+ )
31
+ .all();
32
+ }
@@ -0,0 +1,32 @@
1
+ import sqlString from 'sqlstring-sqlite';
2
+
3
+ import { openDb } from '../db.js';
4
+
5
+ import {
6
+ formatOrderByClause,
7
+ formatSelectClause,
8
+ formatWhereClauses,
9
+ } from '../utils.js';
10
+ import deadheads from '../../models/ods/deadheads.js';
11
+
12
+ /*
13
+ * Returns an array of all deadheads that match the query parameters.
14
+ */
15
+ export function getDeadheads(
16
+ query = {},
17
+ fields = [],
18
+ orderBy = [],
19
+ options = {}
20
+ ) {
21
+ const db = options.db ?? openDb();
22
+ const tableName = sqlString.escapeId(deadheads.filenameBase);
23
+ const selectClause = formatSelectClause(fields);
24
+ const whereClause = formatWhereClauses(query);
25
+ const orderByClause = formatOrderByClause(orderBy);
26
+
27
+ return db
28
+ .prepare(
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
30
+ )
31
+ .all();
32
+ }
@@ -0,0 +1,32 @@
1
+ import sqlString from 'sqlstring-sqlite';
2
+
3
+ import { openDb } from '../db.js';
4
+
5
+ import {
6
+ formatOrderByClause,
7
+ formatSelectClause,
8
+ formatWhereClauses,
9
+ } from '../utils.js';
10
+ import opsLocations from '../../models/ods/ops-locations.js';
11
+
12
+ /*
13
+ * Returns an array of all ops_locations that match the query parameters.
14
+ */
15
+ export function getOpsLocations(
16
+ query = {},
17
+ fields = [],
18
+ orderBy = [],
19
+ options = {}
20
+ ) {
21
+ const db = options.db ?? openDb();
22
+ const tableName = sqlString.escapeId(opsLocations.filenameBase);
23
+ const selectClause = formatSelectClause(fields);
24
+ const whereClause = formatWhereClauses(query);
25
+ const orderByClause = formatOrderByClause(orderBy);
26
+
27
+ return db
28
+ .prepare(
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
30
+ )
31
+ .all();
32
+ }
@@ -0,0 +1,32 @@
1
+ import sqlString from 'sqlstring-sqlite';
2
+
3
+ import { openDb } from '../db.js';
4
+
5
+ import {
6
+ formatOrderByClause,
7
+ formatSelectClause,
8
+ formatWhereClauses,
9
+ } from '../utils.js';
10
+ import runEvents from '../../models/ods/run-events.js';
11
+
12
+ /*
13
+ * Returns an array of all run_events that match the query parameters.
14
+ */
15
+ export function getRunEvents(
16
+ query = {},
17
+ fields = [],
18
+ orderBy = [],
19
+ options = {}
20
+ ) {
21
+ const db = options.db ?? openDb();
22
+ const tableName = sqlString.escapeId(runEvents.filenameBase);
23
+ const selectClause = formatSelectClause(fields);
24
+ const whereClause = formatWhereClauses(query);
25
+ const orderByClause = formatOrderByClause(orderBy);
26
+
27
+ return db
28
+ .prepare(
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
30
+ )
31
+ .all();
32
+ }
@@ -0,0 +1,32 @@
1
+ import sqlString from 'sqlstring-sqlite';
2
+
3
+ import { openDb } from '../db.js';
4
+
5
+ import {
6
+ formatOrderByClause,
7
+ formatSelectClause,
8
+ formatWhereClauses,
9
+ } from '../utils.js';
10
+ import runsPieces from '../../models/ods/runs-pieces.js';
11
+
12
+ /*
13
+ * Returns an array of all runs_pieces that match the query parameters.
14
+ */
15
+ export function getRunsPieces(
16
+ query = {},
17
+ fields = [],
18
+ orderBy = [],
19
+ options = {}
20
+ ) {
21
+ const db = options.db ?? openDb();
22
+ const tableName = sqlString.escapeId(runsPieces.filenameBase);
23
+ const selectClause = formatSelectClause(fields);
24
+ const whereClause = formatWhereClauses(query);
25
+ const orderByClause = formatOrderByClause(orderBy);
26
+
27
+ return db
28
+ .prepare(
29
+ `${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`
30
+ )
31
+ .all();
32
+ }
@@ -0,0 +1,20 @@
1
+ const model = {
2
+ filenameBase: 'calendar_attributes',
3
+ nonstandard: true,
4
+ extension: 'gtfs-plus',
5
+ schema: [
6
+ {
7
+ name: 'service_id',
8
+ type: 'varchar(255)',
9
+ primary: true,
10
+ },
11
+ {
12
+ name: 'service_description',
13
+ type: 'varchar(255)',
14
+ required: true,
15
+ nocase: true,
16
+ },
17
+ ],
18
+ };
19
+
20
+ export default model;
@@ -1,6 +1,7 @@
1
1
  const model = {
2
2
  filenameBase: 'directions',
3
3
  nonstandard: true,
4
+ extension: 'gtfs-plus',
4
5
  schema: [
5
6
  {
6
7
  name: 'id',
@@ -0,0 +1,32 @@
1
+ const model = {
2
+ filenameBase: 'route_attributes',
3
+ nonstandard: true,
4
+ extension: 'gtfs-plus',
5
+ schema: [
6
+ {
7
+ name: 'route_id',
8
+ type: 'varchar(255)',
9
+ primary: true,
10
+ },
11
+ {
12
+ name: 'category',
13
+ type: 'integer',
14
+ min: 0,
15
+ required: true,
16
+ },
17
+ {
18
+ name: 'subcategory',
19
+ type: 'integer',
20
+ min: 101,
21
+ required: true,
22
+ },
23
+ {
24
+ name: 'running_way',
25
+ type: 'integer',
26
+ min: 1,
27
+ required: true,
28
+ },
29
+ ],
30
+ };
31
+
32
+ export default model;
@@ -1,6 +1,7 @@
1
1
  const model = {
2
2
  filenameBase: 'stop_attributes',
3
3
  nonstandard: true,
4
+ extension: 'gtfs-plus',
4
5
  schema: [
5
6
  {
6
7
  name: 'id',
@@ -13,6 +14,19 @@ const model = {
13
14
  required: true,
14
15
  index: true,
15
16
  },
17
+ {
18
+ name: 'accessibility_id',
19
+ type: 'integer',
20
+ min: 0,
21
+ },
22
+ {
23
+ name: 'cardinal_direction',
24
+ type: 'varchar(255)',
25
+ },
26
+ {
27
+ name: 'relative_position',
28
+ type: 'varchar(255)',
29
+ },
16
30
  {
17
31
  name: 'stop_city',
18
32
  type: 'varchar(255)',
package/models/models.js CHANGED
@@ -21,8 +21,6 @@ import transfers from '../models/gtfs/transfers.js';
21
21
  import translations from '../models/gtfs/translations.js';
22
22
  import trips from '../models/gtfs/trips.js';
23
23
 
24
- import directions from '../models/non-standard/directions.js';
25
- import stopAttributes from '../models/non-standard/stop-attributes.js';
26
24
  import timetables from '../models/non-standard/timetables.js';
27
25
  import timetablePages from '../models/non-standard/timetable-pages.js';
28
26
  import timetableStopOrder from '../models/non-standard/timetable-stop-order.js';
@@ -30,6 +28,11 @@ import timetableNotes from '../models/non-standard/timetable-notes.js';
30
28
  import timetableNotesReferences from '../models/non-standard/timetable-notes-references.js';
31
29
  import tripsDatedVehicleJourney from '../models/non-standard/trips-dated-vehicle-journey.js';
32
30
 
31
+ import calendarAttributes from '../models/gtfs-plus/calendar-attributes.js';
32
+ import directions from '../models/gtfs-plus/directions.js';
33
+ import routeAttributes from '../models/gtfs-plus/route-attributes.js';
34
+ import stopAttributes from '../models/gtfs-plus/stop-attributes.js';
35
+
33
36
  import boardAlight from '../models/gtfs-ride/board-alight.js';
34
37
  import riderTrip from '../models/gtfs-ride/rider-trip.js';
35
38
  import ridership from '../models/gtfs-ride/ridership.js';
@@ -42,6 +45,12 @@ import vehiclePositions from './gtfs-realtime/vehicle-positions.js';
42
45
  import serviceAlerts from './gtfs-realtime/service-alerts.js';
43
46
  import serviceAlertTargets from './gtfs-realtime/service-alert-targets.js';
44
47
 
48
+ import deadheadTimes from './ods/deadhead-times.js';
49
+ import deadheads from './ods/deadheads.js';
50
+ import opsLocations from './ods/ops-locations.js';
51
+ import runEvents from './ods/run-events.js';
52
+ import runsPieces from './ods/runs-pieces.js';
53
+
45
54
  const models = [
46
55
  agency,
47
56
  areas,
@@ -65,14 +74,16 @@ const models = [
65
74
  transfers,
66
75
  translations,
67
76
  trips,
68
- directions,
69
- stopAttributes,
70
77
  timetables,
71
78
  timetablePages,
72
79
  timetableStopOrder,
73
80
  timetableNotes,
74
81
  timetableNotesReferences,
75
82
  tripsDatedVehicleJourney,
83
+ calendarAttributes,
84
+ directions,
85
+ routeAttributes,
86
+ stopAttributes,
76
87
  boardAlight,
77
88
  rideFeedInfo,
78
89
  riderTrip,
@@ -83,6 +94,11 @@ const models = [
83
94
  vehiclePositions,
84
95
  serviceAlerts,
85
96
  serviceAlertTargets,
97
+ deadheadTimes,
98
+ deadheads,
99
+ opsLocations,
100
+ runEvents,
101
+ runsPieces,
86
102
  ];
87
103
 
88
104
  export default models;
@@ -0,0 +1,60 @@
1
+ const model = {
2
+ filenameBase: 'deadhead_times',
3
+ nonstandard: true,
4
+ extension: 'ods',
5
+ schema: [
6
+ {
7
+ name: 'id',
8
+ type: 'integer',
9
+ primary: true,
10
+ },
11
+ {
12
+ name: 'deadhead_id',
13
+ type: 'varchar(255)',
14
+ required: true,
15
+ index: true,
16
+ },
17
+ {
18
+ name: 'arrival_time',
19
+ type: 'varchar(255)',
20
+ required: true,
21
+ },
22
+ {
23
+ name: 'arrival_timestamp',
24
+ type: 'integer',
25
+ index: true,
26
+ },
27
+ {
28
+ name: 'departure_time',
29
+ type: 'varchar(255)',
30
+ required: true,
31
+ },
32
+ {
33
+ name: 'departure_timestamp',
34
+ type: 'integer',
35
+ index: true,
36
+ },
37
+ {
38
+ name: 'ops_location_id',
39
+ type: 'varchar(255)',
40
+ },
41
+ {
42
+ name: 'stop_id',
43
+ type: 'varchar(255)',
44
+ },
45
+ {
46
+ name: 'location_sequence',
47
+ type: 'integer',
48
+ required: true,
49
+ min: 0,
50
+ index: true,
51
+ },
52
+ {
53
+ name: 'shape_dist_traveled',
54
+ type: 'real',
55
+ min: 0,
56
+ },
57
+ ],
58
+ };
59
+
60
+ export default model;
@@ -0,0 +1,51 @@
1
+ const model = {
2
+ filenameBase: 'deadheads',
3
+ nonstandard: true,
4
+ extension: 'ods',
5
+ schema: [
6
+ {
7
+ name: 'deadhead_id',
8
+ type: 'varchar(255)',
9
+ primary: true,
10
+ required: true,
11
+ },
12
+ {
13
+ name: 'service_id',
14
+ type: 'varchar(255)',
15
+ required: true,
16
+ },
17
+ {
18
+ name: 'block_id',
19
+ type: 'varchar(255)',
20
+ required: true,
21
+ index: true,
22
+ },
23
+ {
24
+ name: 'shape_id',
25
+ type: 'varchar(255)',
26
+ index: true,
27
+ },
28
+ {
29
+ name: 'to_trip_id',
30
+ type: 'varchar(255)',
31
+ index: true,
32
+ },
33
+ {
34
+ name: 'from_trip_id',
35
+ type: 'varchar(255)',
36
+ index: true,
37
+ },
38
+ {
39
+ name: 'to_deadhead_id',
40
+ type: 'varchar(255)',
41
+ index: true,
42
+ },
43
+ {
44
+ name: 'from_deadhead_id',
45
+ type: 'varchar(255)',
46
+ index: true,
47
+ },
48
+ ],
49
+ };
50
+
51
+ export default model;
@@ -0,0 +1,44 @@
1
+ const model = {
2
+ filenameBase: 'ops_locations',
3
+ nonstandard: true,
4
+ extension: 'ods',
5
+ schema: [
6
+ {
7
+ name: 'ops_location_id',
8
+ type: 'varchar(255)',
9
+ primary: true,
10
+ required: true,
11
+ },
12
+ {
13
+ name: 'ops_location_code',
14
+ type: 'varchar(255)',
15
+ },
16
+ {
17
+ name: 'ops_location_name',
18
+ type: 'varchar(255)',
19
+ required: true,
20
+ nocase: true,
21
+ },
22
+ {
23
+ name: 'ops_location_desc',
24
+ type: 'varchar(255)',
25
+ nocase: true,
26
+ },
27
+ {
28
+ name: 'ops_location_lat',
29
+ type: 'real',
30
+ required: true,
31
+ min: -90,
32
+ max: 90,
33
+ },
34
+ {
35
+ name: 'ops_location_lon',
36
+ type: 'real',
37
+ required: true,
38
+ min: -180,
39
+ max: 180,
40
+ },
41
+ ],
42
+ };
43
+
44
+ export default model;