gtfs 4.12.0 → 4.13.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.
- package/README.md +27 -5
- package/dist/bin/gtfs-export.d.ts +1 -0
- package/dist/bin/gtfs-export.js +3646 -0
- package/dist/bin/gtfs-export.js.map +1 -0
- package/dist/bin/gtfs-import.d.ts +1 -0
- package/dist/bin/gtfs-import.js +4146 -0
- package/dist/bin/gtfs-import.js.map +1 -0
- package/dist/bin/gtfsrealtime-update.d.ts +1 -0
- package/dist/bin/gtfsrealtime-update.js +3802 -0
- package/dist/bin/gtfsrealtime-update.js.map +1 -0
- package/dist/index.d.ts +169 -0
- package/dist/index.js +5205 -0
- package/dist/index.js.map +1 -0
- package/package.json +26 -12
- package/.eslintrc.json +0 -28
- package/.github/workflows/nodejs.yml +0 -21
- package/.husky/pre-commit +0 -4
- package/@types/index.d.ts +0 -606
- package/@types/tests.ts +0 -31
- package/@types/tsconfig.json +0 -17
- package/CHANGELOG.md +0 -905
- package/bin/gtfs-export.js +0 -42
- package/bin/gtfs-import.js +0 -52
- package/bin/gtfsrealtime-update.js +0 -35
- package/config-sample-full.json +0 -20
- package/config-sample-rtupdates.json +0 -16
- package/config-sample.json +0 -8
- package/docs/images/node-gtfs-logo.svg +0 -18
- package/index.js +0 -1
- package/lib/advancedQuery.js +0 -36
- package/lib/db.js +0 -92
- package/lib/export.js +0 -141
- package/lib/file-utils.js +0 -103
- package/lib/geojson-utils.js +0 -138
- package/lib/gtfs/agencies.js +0 -32
- package/lib/gtfs/areas.js +0 -27
- package/lib/gtfs/attributions.js +0 -32
- package/lib/gtfs/booking-rules.js +0 -32
- package/lib/gtfs/calendar-dates.js +0 -32
- package/lib/gtfs/calendars.js +0 -32
- package/lib/gtfs/fare-attributes.js +0 -32
- package/lib/gtfs/fare-leg-rules.js +0 -32
- package/lib/gtfs/fare-media.js +0 -32
- package/lib/gtfs/fare-products.js +0 -32
- package/lib/gtfs/fare-rules.js +0 -32
- package/lib/gtfs/fare-transfer-rules.js +0 -32
- package/lib/gtfs/feed-info.js +0 -32
- package/lib/gtfs/frequencies.js +0 -32
- package/lib/gtfs/levels.js +0 -27
- package/lib/gtfs/location-group-stops.js +0 -32
- package/lib/gtfs/location-groups.js +0 -32
- package/lib/gtfs/locations.js +0 -32
- package/lib/gtfs/networks.js +0 -32
- package/lib/gtfs/pathways.js +0 -32
- package/lib/gtfs/route-networks.js +0 -32
- package/lib/gtfs/routes.js +0 -72
- package/lib/gtfs/shapes.js +0 -119
- package/lib/gtfs/stop-areas.js +0 -32
- package/lib/gtfs/stop-times.js +0 -32
- package/lib/gtfs/stops.js +0 -136
- package/lib/gtfs/timeframes.js +0 -32
- package/lib/gtfs/transfers.js +0 -32
- package/lib/gtfs/translations.js +0 -32
- package/lib/gtfs/trips.js +0 -27
- package/lib/gtfs-plus/calendar-attributes.js +0 -32
- package/lib/gtfs-plus/directions.js +0 -32
- package/lib/gtfs-plus/route-attributes.js +0 -32
- package/lib/gtfs-plus/stop-attributes.js +0 -32
- package/lib/gtfs-realtime/service-alerts.js +0 -34
- package/lib/gtfs-realtime/stop-time-updates.js +0 -32
- package/lib/gtfs-realtime/trip-updates.js +0 -32
- package/lib/gtfs-realtime/vehicle-positions.js +0 -32
- package/lib/gtfs-ride/board-alights.js +0 -32
- package/lib/gtfs-ride/ride-feed-infos.js +0 -32
- package/lib/gtfs-ride/rider-trips.js +0 -32
- package/lib/gtfs-ride/riderships.js +0 -32
- package/lib/gtfs-ride/trip-capacities.js +0 -32
- package/lib/gtfs.js +0 -261
- package/lib/import.js +0 -803
- package/lib/log-utils.js +0 -73
- package/lib/non-standard/timetable-notes-references.js +0 -32
- package/lib/non-standard/timetable-notes.js +0 -32
- package/lib/non-standard/timetable-pages.js +0 -32
- package/lib/non-standard/timetable-stop-order.js +0 -32
- package/lib/non-standard/timetables.js +0 -32
- package/lib/non-standard/trips-dated-vehicle-journey.js +0 -32
- package/lib/ods/deadhead-times.js +0 -32
- package/lib/ods/deadheads.js +0 -32
- package/lib/ods/ops-locations.js +0 -32
- package/lib/ods/run-events.js +0 -32
- package/lib/ods/runs-pieces.js +0 -32
- package/lib/utils.js +0 -178
- package/models/gtfs/agency.js +0 -49
- package/models/gtfs/areas.js +0 -19
- package/models/gtfs/attributions.js +0 -68
- package/models/gtfs/booking-rules.js +0 -92
- package/models/gtfs/calendar-dates.js +0 -34
- package/models/gtfs/calendar.js +0 -76
- package/models/gtfs/fare-attributes.js +0 -48
- package/models/gtfs/fare-leg-rules.js +0 -55
- package/models/gtfs/fare-media.js +0 -26
- package/models/gtfs/fare-products.js +0 -35
- package/models/gtfs/fare-rules.js +0 -34
- package/models/gtfs/fare-transfer-rules.js +0 -56
- package/models/gtfs/feed-info.js +0 -50
- package/models/gtfs/frequencies.js +0 -46
- package/models/gtfs/levels.js +0 -25
- package/models/gtfs/location-group-stops.js +0 -22
- package/models/gtfs/location-groups.js +0 -19
- package/models/gtfs/locations.js +0 -12
- package/models/gtfs/networks.js +0 -20
- package/models/gtfs/pathways.js +0 -74
- package/models/gtfs/route-networks.js +0 -21
- package/models/gtfs/routes.js +0 -79
- package/models/gtfs/shapes.js +0 -41
- package/models/gtfs/stop-areas.js +0 -20
- package/models/gtfs/stop-times.js +0 -120
- package/models/gtfs/stops.js +0 -85
- package/models/gtfs/timeframes.js +0 -29
- package/models/gtfs/transfers.js +0 -56
- package/models/gtfs/translations.js +0 -48
- package/models/gtfs/trips.js +0 -70
- package/models/gtfs-plus/calendar-attributes.js +0 -22
- package/models/gtfs-plus/directions.js +0 -29
- package/models/gtfs-plus/route-attributes.js +0 -34
- package/models/gtfs-plus/stop-attributes.js +0 -35
- package/models/gtfs-realtime/service-alert-targets.js +0 -37
- package/models/gtfs-realtime/service-alerts.js +0 -60
- package/models/gtfs-realtime/stop-time-updates.js +0 -85
- package/models/gtfs-realtime/trip-updates.js +0 -75
- package/models/gtfs-realtime/vehicle-positions.js +0 -135
- package/models/gtfs-ride/board-alight.js +0 -132
- package/models/gtfs-ride/ride-feed-info.js +0 -40
- package/models/gtfs-ride/rider-trip.js +0 -113
- package/models/gtfs-ride/ridership.js +0 -127
- package/models/gtfs-ride/trip-capacity.js +0 -51
- package/models/models.js +0 -120
- package/models/non-standard/timetable-notes-references.js +0 -50
- package/models/non-standard/timetable-notes.js +0 -24
- package/models/non-standard/timetable-pages.js +0 -23
- package/models/non-standard/timetable-stop-order.js +0 -32
- package/models/non-standard/timetables.js +0 -144
- package/models/non-standard/trips-dated-vehicle-journey.js +0 -34
- package/models/ods/deadhead-times.js +0 -65
- package/models/ods/deadheads.js +0 -60
- package/models/ods/ops-locations.js +0 -46
- package/models/ods/run-events.js +0 -70
- package/models/ods/runs-pieces.js +0 -59
- package/test/fixture/caltrain_20160406.zip +0 -0
- package/test/mocha/advanced-query.js +0 -74
- package/test/mocha/delete-db.js +0 -62
- package/test/mocha/export-gtfs.js +0 -147
- package/test/mocha/fare-transfer-rules.js +0 -32
- package/test/mocha/get-agencies.js +0 -90
- package/test/mocha/get-areas.js +0 -27
- package/test/mocha/get-attributions.js +0 -27
- package/test/mocha/get-board-alights.js +0 -28
- package/test/mocha/get-booking-rules.js +0 -28
- package/test/mocha/get-calendar-attributes.js +0 -33
- package/test/mocha/get-calendar-dates.js +0 -107
- package/test/mocha/get-calendars.js +0 -94
- package/test/mocha/get-directions.js +0 -28
- package/test/mocha/get-fare-attributes.js +0 -51
- package/test/mocha/get-fare-leg-rules.js +0 -27
- package/test/mocha/get-fare-media.js +0 -27
- package/test/mocha/get-fare-products.js +0 -27
- package/test/mocha/get-fare-rules.js +0 -50
- package/test/mocha/get-feed-info.js +0 -28
- package/test/mocha/get-frequencies.js +0 -28
- package/test/mocha/get-levels.js +0 -28
- package/test/mocha/get-location-group-stops.js +0 -33
- package/test/mocha/get-location-groups.js +0 -28
- package/test/mocha/get-locations.js +0 -69
- package/test/mocha/get-networks.js +0 -28
- package/test/mocha/get-pathways.js +0 -28
- package/test/mocha/get-ride-feed-infos.js +0 -24
- package/test/mocha/get-rider-trips.js +0 -28
- package/test/mocha/get-riderships.js +0 -28
- package/test/mocha/get-route-attributes.js +0 -33
- package/test/mocha/get-route-networks.js +0 -28
- package/test/mocha/get-routes.js +0 -143
- package/test/mocha/get-shapes-as-geojson.js +0 -92
- package/test/mocha/get-shapes.js +0 -240
- package/test/mocha/get-stop-attributes.js +0 -28
- package/test/mocha/get-stops-as-geojson.js +0 -87
- package/test/mocha/get-stops.js +0 -343
- package/test/mocha/get-stoptimes.js +0 -67
- package/test/mocha/get-timeframes.js +0 -28
- package/test/mocha/get-timetable-pages.js +0 -28
- package/test/mocha/get-timetable-stop-orders.js +0 -33
- package/test/mocha/get-timetables.js +0 -28
- package/test/mocha/get-transfers.js +0 -28
- package/test/mocha/get-translations.js +0 -28
- package/test/mocha/get-trip-capacities.js +0 -28
- package/test/mocha/get-trips.js +0 -53
- package/test/mocha/import-gtfs.js +0 -173
- package/test/mocha/open-db.js +0 -149
- package/test/mocha/raw-query.js +0 -34
- package/test/test-config.js +0 -12
package/lib/geojson-utils.js
DELETED
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
cloneDeep,
|
|
3
|
-
filter,
|
|
4
|
-
groupBy,
|
|
5
|
-
last,
|
|
6
|
-
omit,
|
|
7
|
-
sortBy,
|
|
8
|
-
omitBy,
|
|
9
|
-
} from 'lodash-es';
|
|
10
|
-
import { feature, featureCollection } from '@turf/helpers';
|
|
11
|
-
|
|
12
|
-
export function isValidJSON(string) {
|
|
13
|
-
try {
|
|
14
|
-
JSON.parse(string);
|
|
15
|
-
} catch (error) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
return true;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
function isValidLineString(lineString) {
|
|
22
|
-
if (!lineString) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (lineString.length <= 1) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Reject linestrings with two identical points
|
|
31
|
-
if (
|
|
32
|
-
lineString.length === 2 &&
|
|
33
|
-
lineString[0][0] === lineString[1][0] &&
|
|
34
|
-
lineString[0][1] === lineString[1][1]
|
|
35
|
-
) {
|
|
36
|
-
return false;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return true;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function consolidateShapes(shapes) {
|
|
43
|
-
const keys = new Set();
|
|
44
|
-
const segmentsArray = shapes.map((shape) =>
|
|
45
|
-
shape.reduce((memo, point, idx) => {
|
|
46
|
-
if (idx > 0) {
|
|
47
|
-
memo.push([
|
|
48
|
-
[shape[idx - 1].shape_pt_lon, shape[idx - 1].shape_pt_lat],
|
|
49
|
-
[point.shape_pt_lon, point.shape_pt_lat],
|
|
50
|
-
]);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return memo;
|
|
54
|
-
}, []),
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
const consolidatedLineStrings = [];
|
|
58
|
-
|
|
59
|
-
for (const segments of segmentsArray) {
|
|
60
|
-
consolidatedLineStrings.push([]);
|
|
61
|
-
|
|
62
|
-
for (const segment of segments) {
|
|
63
|
-
const key1 = `${segment[0][0]},${segment[0][1]},${segment[1][0]},${segment[1][1]}`;
|
|
64
|
-
const key2 = `${segment[1][0]},${segment[1][1]},${segment[0][0]},${segment[0][1]}`;
|
|
65
|
-
const currentLine = last(consolidatedLineStrings);
|
|
66
|
-
|
|
67
|
-
if (keys.has(key1) || keys.has(key2)) {
|
|
68
|
-
consolidatedLineStrings.push([]);
|
|
69
|
-
} else {
|
|
70
|
-
// If its the first segment in a linestring, add both points
|
|
71
|
-
if (currentLine.length === 0) {
|
|
72
|
-
currentLine.push(segment[0]);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
currentLine.push(segment[1]);
|
|
76
|
-
keys.add(key1);
|
|
77
|
-
keys.add(key2);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
return filter(consolidatedLineStrings, isValidLineString);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function formatHexColor(color) {
|
|
86
|
-
if (color === null || color === undefined) {
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return `#${color}`;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function formatProperties(properties) {
|
|
94
|
-
const formattedProperties = {
|
|
95
|
-
...cloneDeep(omitBy(properties, (value) => value === null)),
|
|
96
|
-
route_color: formatHexColor(properties.route_color),
|
|
97
|
-
route_text_color: formatHexColor(properties.route_text_color),
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
if (properties.routes) {
|
|
101
|
-
formattedProperties.routes = properties.routes.map((route) =>
|
|
102
|
-
formatProperties(route),
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return formattedProperties;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export function shapesToGeoJSONFeatures(shapes, properties = {}) {
|
|
110
|
-
const shapeGroups = Object.values(groupBy(shapes, 'shape_id')).map(
|
|
111
|
-
(shapeGroup) => sortBy(shapeGroup, 'shape_pt_sequence'),
|
|
112
|
-
);
|
|
113
|
-
const lineStrings = consolidateShapes(shapeGroups);
|
|
114
|
-
|
|
115
|
-
return lineStrings.map((lineString) =>
|
|
116
|
-
feature(
|
|
117
|
-
{
|
|
118
|
-
type: 'LineString',
|
|
119
|
-
coordinates: lineString,
|
|
120
|
-
},
|
|
121
|
-
formatProperties(properties),
|
|
122
|
-
),
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export function stopsToGeoJSON(stops) {
|
|
127
|
-
const features = stops.map((stop) =>
|
|
128
|
-
feature(
|
|
129
|
-
{
|
|
130
|
-
type: 'Point',
|
|
131
|
-
coordinates: [stop.stop_lon, stop.stop_lat],
|
|
132
|
-
},
|
|
133
|
-
formatProperties(omit(stop, ['stop_lat', 'stop_lon'])),
|
|
134
|
-
),
|
|
135
|
-
);
|
|
136
|
-
|
|
137
|
-
return featureCollection(features);
|
|
138
|
-
}
|
package/lib/gtfs/agencies.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
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 agency from '../../models/gtfs/agency.js';
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
* Returns an array of all agencies that match the query parameters.
|
|
14
|
-
*/
|
|
15
|
-
export function getAgencies(
|
|
16
|
-
query = {},
|
|
17
|
-
fields = [],
|
|
18
|
-
orderBy = [],
|
|
19
|
-
options = {},
|
|
20
|
-
) {
|
|
21
|
-
const db = options.db ?? openDb();
|
|
22
|
-
const tableName = sqlString.escapeId(agency.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
|
-
}
|
package/lib/gtfs/areas.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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 areas from '../../models/gtfs/areas.js';
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
* Returns an array of all areas that match the query parameters.
|
|
14
|
-
*/
|
|
15
|
-
export function getAreas(query = {}, fields = [], orderBy = [], options = {}) {
|
|
16
|
-
const db = options.db ?? openDb();
|
|
17
|
-
const tableName = sqlString.escapeId(areas.filenameBase);
|
|
18
|
-
const selectClause = formatSelectClause(fields);
|
|
19
|
-
const whereClause = formatWhereClauses(query);
|
|
20
|
-
const orderByClause = formatOrderByClause(orderBy);
|
|
21
|
-
|
|
22
|
-
return db
|
|
23
|
-
.prepare(
|
|
24
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
25
|
-
)
|
|
26
|
-
.all();
|
|
27
|
-
}
|
package/lib/gtfs/attributions.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
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 attributions from '../../models/gtfs/attributions.js';
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
* Returns an array of all attributions that match the query parameters.
|
|
14
|
-
*/
|
|
15
|
-
export function getAttributions(
|
|
16
|
-
query = {},
|
|
17
|
-
fields = [],
|
|
18
|
-
orderBy = [],
|
|
19
|
-
options = {},
|
|
20
|
-
) {
|
|
21
|
-
const db = options.db ?? openDb();
|
|
22
|
-
const tableName = sqlString.escapeId(attributions.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
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
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 bookingRules from '../../models/gtfs/booking-rules.js';
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
* Returns an array of all booking rules that match the query parameters.
|
|
14
|
-
*/
|
|
15
|
-
export function getBookingRules(
|
|
16
|
-
query = {},
|
|
17
|
-
fields = [],
|
|
18
|
-
orderBy = [],
|
|
19
|
-
options = {},
|
|
20
|
-
) {
|
|
21
|
-
const db = options.db ?? openDb();
|
|
22
|
-
const tableName = sqlString.escapeId(bookingRules.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
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
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 calendarDates from '../../models/gtfs/calendar-dates.js';
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
* Returns an array of calendarDates that match the query parameters.
|
|
14
|
-
*/
|
|
15
|
-
export function getCalendarDates(
|
|
16
|
-
query = {},
|
|
17
|
-
fields = [],
|
|
18
|
-
orderBy = [],
|
|
19
|
-
options = {},
|
|
20
|
-
) {
|
|
21
|
-
const db = options.db ?? openDb();
|
|
22
|
-
const tableName = sqlString.escapeId(calendarDates.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
|
-
}
|
package/lib/gtfs/calendars.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
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 calendars from '../../models/gtfs/calendar.js';
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
* Returns an array of calendars that match the query parameters.
|
|
14
|
-
*/
|
|
15
|
-
export function getCalendars(
|
|
16
|
-
query = {},
|
|
17
|
-
fields = [],
|
|
18
|
-
orderBy = [],
|
|
19
|
-
options = {},
|
|
20
|
-
) {
|
|
21
|
-
const db = options.db ?? openDb();
|
|
22
|
-
const tableName = sqlString.escapeId(calendars.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
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
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 fareAttributes from '../../models/gtfs/fare-attributes.js';
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
* Returns an array of all fare attributes that match the query parameters.
|
|
14
|
-
*/
|
|
15
|
-
export function getFareAttributes(
|
|
16
|
-
query = {},
|
|
17
|
-
fields = [],
|
|
18
|
-
orderBy = [],
|
|
19
|
-
options = {},
|
|
20
|
-
) {
|
|
21
|
-
const db = options.db ?? openDb();
|
|
22
|
-
const tableName = sqlString.escapeId(fareAttributes.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
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
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 fareLegRules from '../../models/gtfs/fare-leg-rules.js';
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
* Returns an array of all fare leg rules that match the query parameters.
|
|
14
|
-
*/
|
|
15
|
-
export function getFareLegRules(
|
|
16
|
-
query = {},
|
|
17
|
-
fields = [],
|
|
18
|
-
orderBy = [],
|
|
19
|
-
options = {},
|
|
20
|
-
) {
|
|
21
|
-
const db = options.db ?? openDb();
|
|
22
|
-
const tableName = sqlString.escapeId(fareLegRules.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
|
-
}
|
package/lib/gtfs/fare-media.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
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 fareMedia from '../../models/gtfs/fare-media.js';
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
* Returns an array of all fare media that match the query parameters.
|
|
14
|
-
*/
|
|
15
|
-
export function getFareMedia(
|
|
16
|
-
query = {},
|
|
17
|
-
fields = [],
|
|
18
|
-
orderBy = [],
|
|
19
|
-
options = {},
|
|
20
|
-
) {
|
|
21
|
-
const db = options.db ?? openDb();
|
|
22
|
-
const tableName = sqlString.escapeId(fareMedia.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
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
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 fareProducts from '../../models/gtfs/fare-products.js';
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
* Returns an array of all fare products that match the query parameters.
|
|
14
|
-
*/
|
|
15
|
-
export function getFareProducts(
|
|
16
|
-
query = {},
|
|
17
|
-
fields = [],
|
|
18
|
-
orderBy = [],
|
|
19
|
-
options = {},
|
|
20
|
-
) {
|
|
21
|
-
const db = options.db ?? openDb();
|
|
22
|
-
const tableName = sqlString.escapeId(fareProducts.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
|
-
}
|
package/lib/gtfs/fare-rules.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
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 fareRules from '../../models/gtfs/fare-rules.js';
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
* Returns an array of all fare rules that match the query parameters.
|
|
14
|
-
*/
|
|
15
|
-
export function getFareRules(
|
|
16
|
-
query = {},
|
|
17
|
-
fields = [],
|
|
18
|
-
orderBy = [],
|
|
19
|
-
options = {},
|
|
20
|
-
) {
|
|
21
|
-
const db = options.db ?? openDb();
|
|
22
|
-
const tableName = sqlString.escapeId(fareRules.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
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
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 fareTransferRules from '../../models/gtfs/fare-transfer-rules.js';
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
* Returns an array of all fare transfer rules that match the query parameters.
|
|
14
|
-
*/
|
|
15
|
-
export function getFareTransferRules(
|
|
16
|
-
query = {},
|
|
17
|
-
fields = [],
|
|
18
|
-
orderBy = [],
|
|
19
|
-
options = {},
|
|
20
|
-
) {
|
|
21
|
-
const db = options.db ?? openDb();
|
|
22
|
-
const tableName = sqlString.escapeId(fareTransferRules.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
|
-
}
|
package/lib/gtfs/feed-info.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
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 feedInfo from '../../models/gtfs/feed-info.js';
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
* Returns an array of all feed info that match the query parameters.
|
|
14
|
-
*/
|
|
15
|
-
export function getFeedInfo(
|
|
16
|
-
query = {},
|
|
17
|
-
fields = [],
|
|
18
|
-
orderBy = [],
|
|
19
|
-
options = {},
|
|
20
|
-
) {
|
|
21
|
-
const db = options.db ?? openDb();
|
|
22
|
-
const tableName = sqlString.escapeId(feedInfo.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
|
-
}
|
package/lib/gtfs/frequencies.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
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 frequencies from '../../models/gtfs/frequencies.js';
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
* Returns an array of all frequencies that match the query parameters.
|
|
14
|
-
*/
|
|
15
|
-
export function getFrequencies(
|
|
16
|
-
query = {},
|
|
17
|
-
fields = [],
|
|
18
|
-
orderBy = [],
|
|
19
|
-
options = {},
|
|
20
|
-
) {
|
|
21
|
-
const db = options.db ?? openDb();
|
|
22
|
-
const tableName = sqlString.escapeId(frequencies.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
|
-
}
|
package/lib/gtfs/levels.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
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 levels from '../../models/gtfs/levels.js';
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
* Returns an array of all levels that match the query parameters.
|
|
14
|
-
*/
|
|
15
|
-
export function getLevels(query = {}, fields = [], orderBy = [], options = {}) {
|
|
16
|
-
const db = options.db ?? openDb();
|
|
17
|
-
const tableName = sqlString.escapeId(levels.filenameBase);
|
|
18
|
-
const selectClause = formatSelectClause(fields);
|
|
19
|
-
const whereClause = formatWhereClauses(query);
|
|
20
|
-
const orderByClause = formatOrderByClause(orderBy);
|
|
21
|
-
|
|
22
|
-
return db
|
|
23
|
-
.prepare(
|
|
24
|
-
`${selectClause} FROM ${tableName} ${whereClause} ${orderByClause};`,
|
|
25
|
-
)
|
|
26
|
-
.all();
|
|
27
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
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 locationGroupStops from '../../models/gtfs/location-group-stops.js';
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
* Returns an array of all location group stops that match the query parameters.
|
|
14
|
-
*/
|
|
15
|
-
export function getLocationGroupStops(
|
|
16
|
-
query = {},
|
|
17
|
-
fields = [],
|
|
18
|
-
orderBy = [],
|
|
19
|
-
options = {},
|
|
20
|
-
) {
|
|
21
|
-
const db = options.db ?? openDb();
|
|
22
|
-
const tableName = sqlString.escapeId(locationGroupStops.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
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
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 locationGroups from '../../models/gtfs/location-groups.js';
|
|
11
|
-
|
|
12
|
-
/*
|
|
13
|
-
* Returns an array of all location groups that match the query parameters.
|
|
14
|
-
*/
|
|
15
|
-
export function getLocationGroups(
|
|
16
|
-
query = {},
|
|
17
|
-
fields = [],
|
|
18
|
-
orderBy = [],
|
|
19
|
-
options = {},
|
|
20
|
-
) {
|
|
21
|
-
const db = options.db ?? openDb();
|
|
22
|
-
const tableName = sqlString.escapeId(locationGroups.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
|
-
}
|