gtfs 4.15.11 → 4.15.13
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/dist/bin/gtfs-export.js +11 -6
- package/dist/bin/gtfs-export.js.map +1 -1
- package/dist/bin/gtfs-import.js +23 -11
- package/dist/bin/gtfs-import.js.map +1 -1
- package/dist/bin/gtfsrealtime-update.js +16 -9
- package/dist/bin/gtfsrealtime-update.js.map +1 -1
- package/dist/index.d.ts +33 -31
- package/dist/index.js +27 -12
- package/dist/index.js.map +1 -1
- package/dist/models/models.js +11 -6
- package/dist/models/models.js.map +1 -1
- package/package.json +11 -11
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Options } from 'csv-parse';
|
|
|
2
2
|
import Database$1, { Database } from 'better-sqlite3';
|
|
3
3
|
import { FeatureCollection } from 'geojson';
|
|
4
4
|
|
|
5
|
+
type UnixTimestamp = number;
|
|
5
6
|
interface ConfigAgency {
|
|
6
7
|
exclude?: string[];
|
|
7
8
|
url?: string;
|
|
@@ -36,7 +37,7 @@ interface Config {
|
|
|
36
37
|
}
|
|
37
38
|
interface ModelColumn {
|
|
38
39
|
name: string;
|
|
39
|
-
type:
|
|
40
|
+
type: 'text' | 'integer' | 'real' | 'json' | 'date' | 'time';
|
|
40
41
|
min?: number;
|
|
41
42
|
max?: number;
|
|
42
43
|
required?: boolean;
|
|
@@ -103,10 +104,10 @@ interface BookingRule {
|
|
|
103
104
|
prior_notice_duration_max?: number;
|
|
104
105
|
prior_notice_last_day?: number;
|
|
105
106
|
prior_notice_last_time?: string;
|
|
106
|
-
prior_notice_last_timestamp?:
|
|
107
|
+
prior_notice_last_timestamp?: UnixTimestamp;
|
|
107
108
|
prior_notice_start_day?: number;
|
|
108
109
|
prior_notice_start_time?: string;
|
|
109
|
-
prior_notice_start_timestamp?:
|
|
110
|
+
prior_notice_start_timestamp?: UnixTimestamp;
|
|
110
111
|
prior_notice_service_id?: string;
|
|
111
112
|
message?: string;
|
|
112
113
|
pickup_message?: string;
|
|
@@ -194,9 +195,9 @@ interface FeedInfo {
|
|
|
194
195
|
interface Frequency {
|
|
195
196
|
trip_id: string;
|
|
196
197
|
start_time: string;
|
|
197
|
-
start_timestamp:
|
|
198
|
+
start_timestamp: UnixTimestamp;
|
|
198
199
|
end_time: string;
|
|
199
|
-
end_timestamp:
|
|
200
|
+
end_timestamp: UnixTimestamp;
|
|
200
201
|
headway_secs: number;
|
|
201
202
|
exact_times?: 0 | 1;
|
|
202
203
|
}
|
|
@@ -267,16 +268,16 @@ interface StopArea {
|
|
|
267
268
|
interface StopTime {
|
|
268
269
|
trip_id: string;
|
|
269
270
|
arrival_time?: string;
|
|
270
|
-
arrival_timestamp?:
|
|
271
|
+
arrival_timestamp?: UnixTimestamp;
|
|
271
272
|
departure_time?: string;
|
|
272
|
-
departure_timestamp?:
|
|
273
|
+
departure_timestamp?: UnixTimestamp;
|
|
273
274
|
location_group_id?: string;
|
|
274
275
|
location_id?: string;
|
|
275
276
|
stop_id?: string;
|
|
276
277
|
stop_sequence: number;
|
|
277
278
|
stop_headsign?: string;
|
|
278
279
|
start_pickup_drop_off_window?: string;
|
|
279
|
-
start_pickup_drop_off_window_timestamp?:
|
|
280
|
+
start_pickup_drop_off_window_timestamp?: UnixTimestamp;
|
|
280
281
|
pickup_type?: 0 | 1 | 2 | 3;
|
|
281
282
|
drop_off_type?: 0 | 1 | 2 | 3;
|
|
282
283
|
continuous_pickup?: 0 | 1 | 2 | 3;
|
|
@@ -354,9 +355,9 @@ interface Timetable {
|
|
|
354
355
|
saturday: 0 | 1;
|
|
355
356
|
sunday: 0 | 1;
|
|
356
357
|
start_time?: string;
|
|
357
|
-
start_timestamp?:
|
|
358
|
+
start_timestamp?: UnixTimestamp;
|
|
358
359
|
end_time?: string;
|
|
359
|
-
end_timestamp?:
|
|
360
|
+
end_timestamp?: UnixTimestamp;
|
|
360
361
|
timetable_label?: string;
|
|
361
362
|
service_notes?: string;
|
|
362
363
|
orientation?: string;
|
|
@@ -382,6 +383,7 @@ interface TimetableNote {
|
|
|
382
383
|
note: string;
|
|
383
384
|
}
|
|
384
385
|
interface TimetableNotesReference {
|
|
386
|
+
note_id: string;
|
|
385
387
|
timetable_id: string;
|
|
386
388
|
route_id?: string;
|
|
387
389
|
trip_id?: string;
|
|
@@ -398,9 +400,9 @@ interface TripsDatedVehicleJourney {
|
|
|
398
400
|
interface DeadheadTime {
|
|
399
401
|
deadhead_id: string;
|
|
400
402
|
arrival_time: string;
|
|
401
|
-
arrival_timestamp:
|
|
403
|
+
arrival_timestamp: UnixTimestamp;
|
|
402
404
|
departure_time: string;
|
|
403
|
-
departure_timestamp:
|
|
405
|
+
departure_timestamp: UnixTimestamp;
|
|
404
406
|
ops_location_id?: string;
|
|
405
407
|
stop_id?: string;
|
|
406
408
|
location_sequence: number;
|
|
@@ -452,8 +454,8 @@ interface ServiceAlert {
|
|
|
452
454
|
end_time: string;
|
|
453
455
|
headline: string;
|
|
454
456
|
description: string;
|
|
455
|
-
created_timestamp:
|
|
456
|
-
expiration_timestamp:
|
|
457
|
+
created_timestamp: UnixTimestamp;
|
|
458
|
+
expiration_timestamp: UnixTimestamp;
|
|
457
459
|
}
|
|
458
460
|
interface StopTimeUpdate {
|
|
459
461
|
trip_id?: string;
|
|
@@ -464,11 +466,11 @@ interface StopTimeUpdate {
|
|
|
464
466
|
stop_sequence?: number;
|
|
465
467
|
arrival_delay?: number;
|
|
466
468
|
departure_delay?: number;
|
|
467
|
-
departure_timestamp?:
|
|
468
|
-
arrival_timestamp?:
|
|
469
|
+
departure_timestamp?: UnixTimestamp;
|
|
470
|
+
arrival_timestamp?: UnixTimestamp;
|
|
469
471
|
schedule_relationship?: string;
|
|
470
|
-
created_timestamp:
|
|
471
|
-
expiration_timestamp:
|
|
472
|
+
created_timestamp: UnixTimestamp;
|
|
473
|
+
expiration_timestamp: UnixTimestamp;
|
|
472
474
|
}
|
|
473
475
|
interface TripUpdate {
|
|
474
476
|
update_id: string;
|
|
@@ -478,10 +480,10 @@ interface TripUpdate {
|
|
|
478
480
|
direction_id?: 0 | 1;
|
|
479
481
|
route_id?: string;
|
|
480
482
|
start_date?: number;
|
|
481
|
-
timestamp?:
|
|
483
|
+
timestamp?: UnixTimestamp;
|
|
482
484
|
schedule_relationship?: string;
|
|
483
|
-
created_timestamp:
|
|
484
|
-
expiration_timestamp:
|
|
485
|
+
created_timestamp: UnixTimestamp;
|
|
486
|
+
expiration_timestamp: UnixTimestamp;
|
|
485
487
|
}
|
|
486
488
|
interface VehiclePosition {
|
|
487
489
|
update_id: string;
|
|
@@ -501,9 +503,9 @@ interface VehiclePosition {
|
|
|
501
503
|
vehicle_label?: string;
|
|
502
504
|
vehicle_license_plate?: string;
|
|
503
505
|
vehicle_wheelchair_accessible?: number;
|
|
504
|
-
timestamp?:
|
|
505
|
-
created_timestamp:
|
|
506
|
-
expiration_timestamp:
|
|
506
|
+
timestamp?: UnixTimestamp;
|
|
507
|
+
created_timestamp: UnixTimestamp;
|
|
508
|
+
expiration_timestamp: UnixTimestamp;
|
|
507
509
|
}
|
|
508
510
|
interface BoardAlight {
|
|
509
511
|
trip_id: string;
|
|
@@ -524,9 +526,9 @@ interface BoardAlight {
|
|
|
524
526
|
ramp_alightings?: number;
|
|
525
527
|
service_date?: number;
|
|
526
528
|
service_arrival_time?: string;
|
|
527
|
-
service_arrival_timestamp?:
|
|
529
|
+
service_arrival_timestamp?: UnixTimestamp;
|
|
528
530
|
service_departure_time?: string;
|
|
529
|
-
service_departure_timestamp?:
|
|
531
|
+
service_departure_timestamp?: UnixTimestamp;
|
|
530
532
|
source?: 0 | 1 | 2 | 3 | 4;
|
|
531
533
|
}
|
|
532
534
|
interface RideFeedInfo {
|
|
@@ -547,9 +549,9 @@ interface RiderTrip {
|
|
|
547
549
|
alighting_stop_sequence?: number;
|
|
548
550
|
service_date?: number;
|
|
549
551
|
boarding_time?: string;
|
|
550
|
-
boarding_timestamp?:
|
|
552
|
+
boarding_timestamp?: UnixTimestamp;
|
|
551
553
|
alighting_time?: string;
|
|
552
|
-
alighting_timestamp?:
|
|
554
|
+
alighting_timestamp?: UnixTimestamp;
|
|
553
555
|
rider_type?: number;
|
|
554
556
|
rider_type_description?: string;
|
|
555
557
|
fare_paid?: number;
|
|
@@ -564,9 +566,9 @@ interface Ridership {
|
|
|
564
566
|
ridership_start_date?: number;
|
|
565
567
|
ridership_end_date?: number;
|
|
566
568
|
ridership_start_time?: string;
|
|
567
|
-
ridership_start_timestamp?:
|
|
569
|
+
ridership_start_timestamp?: UnixTimestamp;
|
|
568
570
|
ridership_end_time?: string;
|
|
569
|
-
ridership_end_timestamp?:
|
|
571
|
+
ridership_end_timestamp?: UnixTimestamp;
|
|
570
572
|
service_id?: string;
|
|
571
573
|
monday?: 0 | 1;
|
|
572
574
|
tuesday?: 0 | 1;
|
|
@@ -747,4 +749,4 @@ declare function getRunEvents<Fields extends keyof RunEvent>(query?: SqlWhere, f
|
|
|
747
749
|
|
|
748
750
|
declare function getRunsPieces<Fields extends keyof RunPiece>(query?: SqlWhere, fields?: Fields[], orderBy?: SqlOrderBy, options?: QueryOptions): QueryResult<RunPiece, Fields>[];
|
|
749
751
|
|
|
750
|
-
export { type Agency, type Area, type Attribution, type BoardAlight, type BookingRule, type Calendar, type CalendarAttribute, type CalendarDate, type Config, type ConfigAgency, type Deadhead, type DeadheadTime, type Direction, type FareAttribute, type FareLegRule, type FareMedia, type FareProduct, type FareRule, type FareTransferRule, type FeedInfo, type Frequency, type JoinOptions, type Level, type Location, type LocationGroup, type LocationGroupStop, type Model, type ModelColumn, type Network, type OpsLocation, type Pathway, type QueryOptions, type QueryResult, type RideFeedInfo, type RiderTrip, type Ridership, type Route, type RouteAttribute, type RouteNetwork, type RunEvent, type RunPiece, type ServiceAlert, type Shape, type SqlOrderBy, type SqlValue, type SqlWhere, type Stop, type StopArea, type StopAttribute, type StopTime, type StopTimeUpdate, type Timeframe, type Timetable, type TimetableNote, type TimetableNotesReference, type TimetablePage, type TimetableStopOrder, type Transfer, type Translation, type Trip, type TripCapacity, type TripUpdate, type TripsDatedVehicleJourney, type VehiclePosition, advancedQuery, closeDb, deleteDb, exportGtfs, getAgencies, getAreas, getAttributions, getBoardAlights, getBookingRules, getCalendarAttributes, getCalendarDates, getCalendars, getDeadheadTimes, getDeadheads, getDirections, getFareAttributes, getFareLegRules, getFareMedia, getFareProducts, getFareRules, getFareTransferRules, getFeedInfo, getFrequencies, getLevels, getLocationGroupStops, getLocationGroups, getLocations, getNetworks, getOpsLocations, getPathways, getRideFeedInfo, getRiderTrips, getRidership, getRouteAttributes, getRouteNetworks, getRoutes, getRunEvents, getRunsPieces, getServiceAlerts, getServiceIdsByDate, getShapes, getShapesAsGeoJSON, getStopAreas, getStopAttributes, getStopTimeUpdates, getStops, getStopsAsGeoJSON, getStoptimes, getTimeframes, getTimetableNotes, getTimetableNotesReferences, getTimetablePages, getTimetableStopOrders, getTimetables, getTransfers, getTranslations, getTripCapacities, getTripUpdates, getTrips, getTripsDatedVehicleJourneys, getVehiclePositions, importGtfs, openDb, updateGtfsRealtime };
|
|
752
|
+
export { type Agency, type Area, type Attribution, type BoardAlight, type BookingRule, type Calendar, type CalendarAttribute, type CalendarDate, type Config, type ConfigAgency, type Deadhead, type DeadheadTime, type Direction, type FareAttribute, type FareLegRule, type FareMedia, type FareProduct, type FareRule, type FareTransferRule, type FeedInfo, type Frequency, type JoinOptions, type Level, type Location, type LocationGroup, type LocationGroupStop, type Model, type ModelColumn, type Network, type OpsLocation, type Pathway, type QueryOptions, type QueryResult, type RideFeedInfo, type RiderTrip, type Ridership, type Route, type RouteAttribute, type RouteNetwork, type RunEvent, type RunPiece, type ServiceAlert, type Shape, type SqlOrderBy, type SqlValue, type SqlWhere, type Stop, type StopArea, type StopAttribute, type StopTime, type StopTimeUpdate, type Timeframe, type Timetable, type TimetableNote, type TimetableNotesReference, type TimetablePage, type TimetableStopOrder, type Transfer, type Translation, type Trip, type TripCapacity, type TripUpdate, type TripsDatedVehicleJourney, type UnixTimestamp, type VehiclePosition, advancedQuery, closeDb, deleteDb, exportGtfs, getAgencies, getAreas, getAttributions, getBoardAlights, getBookingRules, getCalendarAttributes, getCalendarDates, getCalendars, getDeadheadTimes, getDeadheads, getDirections, getFareAttributes, getFareLegRules, getFareMedia, getFareProducts, getFareRules, getFareTransferRules, getFeedInfo, getFrequencies, getLevels, getLocationGroupStops, getLocationGroups, getLocations, getNetworks, getOpsLocations, getPathways, getRideFeedInfo, getRiderTrips, getRidership, getRouteAttributes, getRouteNetworks, getRoutes, getRunEvents, getRunsPieces, getServiceAlerts, getServiceIdsByDate, getShapes, getShapesAsGeoJSON, getStopAreas, getStopAttributes, getStopTimeUpdates, getStops, getStopsAsGeoJSON, getStoptimes, getTimeframes, getTimetableNotes, getTimetableNotesReferences, getTimetablePages, getTimetableStopOrders, getTimetables, getTransfers, getTranslations, getTripCapacities, getTripUpdates, getTrips, getTripsDatedVehicleJourneys, getVehiclePositions, importGtfs, openDb, updateGtfsRealtime };
|
package/dist/index.js
CHANGED
|
@@ -2647,6 +2647,11 @@ var serviceAlerts = {
|
|
|
2647
2647
|
index: true,
|
|
2648
2648
|
source: "id"
|
|
2649
2649
|
},
|
|
2650
|
+
{
|
|
2651
|
+
name: "active_period",
|
|
2652
|
+
type: "json",
|
|
2653
|
+
source: "alert.activePeriod"
|
|
2654
|
+
},
|
|
2650
2655
|
{
|
|
2651
2656
|
name: "cause",
|
|
2652
2657
|
type: "text",
|
|
@@ -2660,7 +2665,7 @@ var serviceAlerts = {
|
|
|
2660
2665
|
{
|
|
2661
2666
|
name: "url",
|
|
2662
2667
|
type: "text",
|
|
2663
|
-
source: "alert.url",
|
|
2668
|
+
source: "alert.url.translation[0].text",
|
|
2664
2669
|
default: ""
|
|
2665
2670
|
},
|
|
2666
2671
|
{
|
|
@@ -2678,31 +2683,31 @@ var serviceAlerts = {
|
|
|
2678
2683
|
default: ""
|
|
2679
2684
|
},
|
|
2680
2685
|
{
|
|
2681
|
-
name: "
|
|
2686
|
+
name: "header_text",
|
|
2682
2687
|
type: "text",
|
|
2683
2688
|
required: true,
|
|
2684
2689
|
source: "alert.headerText.translation[0].text",
|
|
2685
2690
|
default: ""
|
|
2686
2691
|
},
|
|
2687
2692
|
{
|
|
2688
|
-
name: "
|
|
2693
|
+
name: "description_text",
|
|
2689
2694
|
type: "text",
|
|
2690
2695
|
required: true,
|
|
2691
2696
|
source: "alert.descriptionText.translation[0].text",
|
|
2692
2697
|
default: ""
|
|
2693
2698
|
},
|
|
2694
2699
|
{
|
|
2695
|
-
name: "
|
|
2700
|
+
name: "tts_header_text",
|
|
2696
2701
|
type: "text",
|
|
2697
2702
|
source: "alert.ttsHeaderText.translation[0].text"
|
|
2698
2703
|
},
|
|
2699
2704
|
{
|
|
2700
|
-
name: "
|
|
2705
|
+
name: "tts_description_text",
|
|
2701
2706
|
type: "text",
|
|
2702
2707
|
source: "alert.ttsDescriptionText.translation[0].text"
|
|
2703
2708
|
},
|
|
2704
2709
|
{
|
|
2705
|
-
name: "
|
|
2710
|
+
name: "severity_level",
|
|
2706
2711
|
type: "text",
|
|
2707
2712
|
source: "alert.severityLevel"
|
|
2708
2713
|
},
|
|
@@ -3359,9 +3364,11 @@ function convertLongTimeToDate(longDate) {
|
|
|
3359
3364
|
).toISOString();
|
|
3360
3365
|
}
|
|
3361
3366
|
function calculateSecondsFromMidnight(time) {
|
|
3362
|
-
if (!time || typeof time !== "string")
|
|
3367
|
+
if (!time || typeof time !== "string") {
|
|
3368
|
+
return null;
|
|
3369
|
+
}
|
|
3363
3370
|
const [hours, minutes, seconds] = time.split(":").map(Number);
|
|
3364
|
-
if ([hours, minutes, seconds].some(isNaN) ||
|
|
3371
|
+
if ([hours, minutes, seconds].some(isNaN) || minutes >= 60 || seconds >= 60) {
|
|
3365
3372
|
return null;
|
|
3366
3373
|
}
|
|
3367
3374
|
return hours * 3600 + minutes * 60 + seconds;
|
|
@@ -3570,9 +3577,11 @@ function prepareRealtimeFieldValue(entity, column, task) {
|
|
|
3570
3577
|
if (column.name === "expiration_timestamp") {
|
|
3571
3578
|
return task.currentTimestamp + task.gtfsRealtimeExpirationSeconds;
|
|
3572
3579
|
}
|
|
3573
|
-
|
|
3574
|
-
|
|
3575
|
-
|
|
3580
|
+
const value = getNestedProperty(entity, column.default, column.source);
|
|
3581
|
+
if (column.type === "json") {
|
|
3582
|
+
return sqlString2.escape(JSON.stringify(value));
|
|
3583
|
+
}
|
|
3584
|
+
return sqlString2.escape(value);
|
|
3576
3585
|
}
|
|
3577
3586
|
async function processRealtimeAlerts(db, gtfsRealtimeData, task) {
|
|
3578
3587
|
task.log(`Download successful`);
|
|
@@ -3965,6 +3974,9 @@ var formatGtfsLine = (line, model, totalLineCount) => {
|
|
|
3965
3974
|
value = timeAsString;
|
|
3966
3975
|
formattedLine[getTimestampColumnName(name)] = timeAsSecondsFromMidnight ?? null;
|
|
3967
3976
|
}
|
|
3977
|
+
if (type === "json") {
|
|
3978
|
+
value = JSON.stringify(value);
|
|
3979
|
+
}
|
|
3968
3980
|
formattedLine[name] = value;
|
|
3969
3981
|
}
|
|
3970
3982
|
return formattedLine;
|
|
@@ -4778,7 +4790,7 @@ function getStops(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4778
4790
|
const tableName = "stops";
|
|
4779
4791
|
const selectClause = formatSelectClause(fields);
|
|
4780
4792
|
let whereClause = "";
|
|
4781
|
-
|
|
4793
|
+
let orderByClause = formatOrderByClause(orderBy2);
|
|
4782
4794
|
const stopQueryOmitKeys = [
|
|
4783
4795
|
"route_id",
|
|
4784
4796
|
"trip_id",
|
|
@@ -4808,6 +4820,9 @@ function getStops(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4808
4820
|
options.bounding_box_side_m
|
|
4809
4821
|
)
|
|
4810
4822
|
);
|
|
4823
|
+
if (orderBy2.length === 0) {
|
|
4824
|
+
orderByClause = `ORDER BY (((stop_lat - ${query.stop_lat}) * (stop_lat - ${query.stop_lat})) + ((stop_lon - ${query.stop_lon}) * (stop_lon - ${query.stop_lon}))) ASC`;
|
|
4825
|
+
}
|
|
4811
4826
|
}
|
|
4812
4827
|
if (Object.values(tripQuery).length > 0) {
|
|
4813
4828
|
whereClauses.push(`stop_id IN (${buildStoptimeSubquery2(tripQuery)})`);
|