gtfs 4.13.3 → 4.14.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 +43 -27
- package/dist/bin/gtfs-export.js +135 -341
- package/dist/bin/gtfs-export.js.map +1 -1
- package/dist/bin/gtfs-import.js +260 -454
- package/dist/bin/gtfs-import.js.map +1 -1
- package/dist/bin/gtfsrealtime-update.js +210 -3226
- package/dist/bin/gtfsrealtime-update.js.map +1 -1
- package/dist/index.d.ts +23 -12
- package/dist/index.js +364 -457
- package/dist/index.js.map +1 -1
- package/dist/models/models.d.ts +2231 -0
- package/dist/models/models.js +3076 -0
- package/dist/models/models.js.map +1 -0
- package/package.json +18 -8
package/dist/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
1
7
|
// src/lib/import.ts
|
|
2
8
|
import path from "node:path";
|
|
3
9
|
import { createReadStream, existsSync, lstatSync } from "node:fs";
|
|
@@ -11,8 +17,68 @@ import mapSeries from "promise-map-series";
|
|
|
11
17
|
import GtfsRealtimeBindings from "gtfs-realtime-bindings";
|
|
12
18
|
import sqlString2 from "sqlstring-sqlite";
|
|
13
19
|
|
|
20
|
+
// src/models/models.ts
|
|
21
|
+
var models_exports = {};
|
|
22
|
+
__export(models_exports, {
|
|
23
|
+
agency: () => agency,
|
|
24
|
+
areas: () => areas,
|
|
25
|
+
attributions: () => attributions,
|
|
26
|
+
boardAlight: () => boardAlight,
|
|
27
|
+
bookingRules: () => bookingRules,
|
|
28
|
+
calendar: () => calendar,
|
|
29
|
+
calendarAttributes: () => calendarAttributes,
|
|
30
|
+
calendarDates: () => calendarDates,
|
|
31
|
+
deadheadTimes: () => deadheadTimes,
|
|
32
|
+
deadheads: () => deadheads,
|
|
33
|
+
directions: () => directions,
|
|
34
|
+
fareAttributes: () => fareAttributes,
|
|
35
|
+
fareLegRules: () => fareLegRules,
|
|
36
|
+
fareMedia: () => fareMedia,
|
|
37
|
+
fareProducts: () => fareProducts,
|
|
38
|
+
fareRules: () => fareRules,
|
|
39
|
+
fareTransferRules: () => fareTransferRules,
|
|
40
|
+
feedInfo: () => feedInfo,
|
|
41
|
+
frequencies: () => frequencies,
|
|
42
|
+
levels: () => levels,
|
|
43
|
+
locationGroupStops: () => locationGroupStops,
|
|
44
|
+
locationGroups: () => locationGroups,
|
|
45
|
+
locations: () => locations,
|
|
46
|
+
networks: () => networks,
|
|
47
|
+
opsLocations: () => opsLocations,
|
|
48
|
+
pathways: () => pathways,
|
|
49
|
+
rideFeedInfo: () => rideFeedInfo,
|
|
50
|
+
riderTrip: () => riderTrip,
|
|
51
|
+
ridership: () => ridership,
|
|
52
|
+
routeAttributes: () => routeAttributes,
|
|
53
|
+
routeNetworks: () => routeNetworks,
|
|
54
|
+
routes: () => routes,
|
|
55
|
+
runEvents: () => runEvents,
|
|
56
|
+
runsPieces: () => runsPieces,
|
|
57
|
+
serviceAlertTargets: () => serviceAlertTargets,
|
|
58
|
+
serviceAlerts: () => serviceAlerts,
|
|
59
|
+
shapes: () => shapes,
|
|
60
|
+
stopAreas: () => stopAreas,
|
|
61
|
+
stopAttributes: () => stopAttributes,
|
|
62
|
+
stopTimeUpdates: () => stopTimeUpdates,
|
|
63
|
+
stopTimes: () => stopTimes,
|
|
64
|
+
stops: () => stops,
|
|
65
|
+
timeframes: () => timeframes,
|
|
66
|
+
timetableNotes: () => timetableNotes,
|
|
67
|
+
timetableNotesReferences: () => timetableNotesReferences,
|
|
68
|
+
timetablePages: () => timetablePages,
|
|
69
|
+
timetableStopOrder: () => timetableStopOrder,
|
|
70
|
+
timetables: () => timetables,
|
|
71
|
+
transfers: () => transfers,
|
|
72
|
+
translations: () => translations,
|
|
73
|
+
tripCapacity: () => tripCapacity,
|
|
74
|
+
tripUpdates: () => tripUpdates,
|
|
75
|
+
trips: () => trips,
|
|
76
|
+
tripsDatedVehicleJourney: () => tripsDatedVehicleJourney,
|
|
77
|
+
vehiclePositions: () => vehiclePositions
|
|
78
|
+
});
|
|
79
|
+
|
|
14
80
|
// src/models/gtfs/agency.ts
|
|
15
|
-
var
|
|
81
|
+
var agency = {
|
|
16
82
|
filenameBase: "agency",
|
|
17
83
|
filenameExtension: "txt",
|
|
18
84
|
schema: [
|
|
@@ -59,10 +125,9 @@ var model = {
|
|
|
59
125
|
}
|
|
60
126
|
]
|
|
61
127
|
};
|
|
62
|
-
var agency_default = model;
|
|
63
128
|
|
|
64
129
|
// src/models/gtfs/areas.ts
|
|
65
|
-
var
|
|
130
|
+
var areas = {
|
|
66
131
|
filenameBase: "areas",
|
|
67
132
|
filenameExtension: "txt",
|
|
68
133
|
schema: [
|
|
@@ -79,10 +144,9 @@ var model2 = {
|
|
|
79
144
|
}
|
|
80
145
|
]
|
|
81
146
|
};
|
|
82
|
-
var areas_default = model2;
|
|
83
147
|
|
|
84
148
|
// src/models/gtfs/attributions.ts
|
|
85
|
-
var
|
|
149
|
+
var attributions = {
|
|
86
150
|
filenameBase: "attributions",
|
|
87
151
|
filenameExtension: "txt",
|
|
88
152
|
schema: [
|
|
@@ -146,10 +210,9 @@ var model3 = {
|
|
|
146
210
|
}
|
|
147
211
|
]
|
|
148
212
|
};
|
|
149
|
-
var attributions_default = model3;
|
|
150
213
|
|
|
151
214
|
// src/models/gtfs/booking-rules.ts
|
|
152
|
-
var
|
|
215
|
+
var bookingRules = {
|
|
153
216
|
filenameBase: "booking_rules",
|
|
154
217
|
filenameExtension: "txt",
|
|
155
218
|
schema: [
|
|
@@ -239,10 +302,9 @@ var model4 = {
|
|
|
239
302
|
}
|
|
240
303
|
]
|
|
241
304
|
};
|
|
242
|
-
var booking_rules_default = model4;
|
|
243
305
|
|
|
244
306
|
// src/models/gtfs/calendar-dates.ts
|
|
245
|
-
var
|
|
307
|
+
var calendarDates = {
|
|
246
308
|
filenameBase: "calendar_dates",
|
|
247
309
|
filenameExtension: "txt",
|
|
248
310
|
schema: [
|
|
@@ -274,10 +336,9 @@ var model5 = {
|
|
|
274
336
|
}
|
|
275
337
|
]
|
|
276
338
|
};
|
|
277
|
-
var calendar_dates_default = model5;
|
|
278
339
|
|
|
279
340
|
// src/models/gtfs/calendar.ts
|
|
280
|
-
var
|
|
341
|
+
var calendar = {
|
|
281
342
|
filenameBase: "calendar",
|
|
282
343
|
filenameExtension: "txt",
|
|
283
344
|
schema: [
|
|
@@ -351,10 +412,9 @@ var model6 = {
|
|
|
351
412
|
}
|
|
352
413
|
]
|
|
353
414
|
};
|
|
354
|
-
var calendar_default = model6;
|
|
355
415
|
|
|
356
416
|
// src/models/gtfs/fare-attributes.ts
|
|
357
|
-
var
|
|
417
|
+
var fareAttributes = {
|
|
358
418
|
filenameBase: "fare_attributes",
|
|
359
419
|
filenameExtension: "txt",
|
|
360
420
|
schema: [
|
|
@@ -400,10 +460,9 @@ var model7 = {
|
|
|
400
460
|
}
|
|
401
461
|
]
|
|
402
462
|
};
|
|
403
|
-
var fare_attributes_default = model7;
|
|
404
463
|
|
|
405
464
|
// src/models/gtfs/fare-leg-rules.ts
|
|
406
|
-
var
|
|
465
|
+
var fareLegRules = {
|
|
407
466
|
filenameBase: "fare_leg_rules",
|
|
408
467
|
filenameExtension: "txt",
|
|
409
468
|
schema: [
|
|
@@ -456,10 +515,9 @@ var model8 = {
|
|
|
456
515
|
}
|
|
457
516
|
]
|
|
458
517
|
};
|
|
459
|
-
var fare_leg_rules_default = model8;
|
|
460
518
|
|
|
461
519
|
// src/models/gtfs/fare-media.ts
|
|
462
|
-
var
|
|
520
|
+
var fareMedia = {
|
|
463
521
|
filenameBase: "fare_media",
|
|
464
522
|
filenameExtension: "txt",
|
|
465
523
|
schema: [
|
|
@@ -483,10 +541,9 @@ var model9 = {
|
|
|
483
541
|
}
|
|
484
542
|
]
|
|
485
543
|
};
|
|
486
|
-
var fare_media_default = model9;
|
|
487
544
|
|
|
488
545
|
// src/models/gtfs/fare-products.ts
|
|
489
|
-
var
|
|
546
|
+
var fareProducts = {
|
|
490
547
|
filenameBase: "fare_products",
|
|
491
548
|
filenameExtension: "txt",
|
|
492
549
|
schema: [
|
|
@@ -519,10 +576,9 @@ var model10 = {
|
|
|
519
576
|
}
|
|
520
577
|
]
|
|
521
578
|
};
|
|
522
|
-
var fare_products_default = model10;
|
|
523
579
|
|
|
524
580
|
// src/models/gtfs/fare-rules.ts
|
|
525
|
-
var
|
|
581
|
+
var fareRules = {
|
|
526
582
|
filenameBase: "fare_rules",
|
|
527
583
|
filenameExtension: "txt",
|
|
528
584
|
schema: [
|
|
@@ -554,10 +610,9 @@ var model11 = {
|
|
|
554
610
|
}
|
|
555
611
|
]
|
|
556
612
|
};
|
|
557
|
-
var fare_rules_default = model11;
|
|
558
613
|
|
|
559
614
|
// src/models/gtfs/fare-transfer-rules.ts
|
|
560
|
-
var
|
|
615
|
+
var fareTransferRules = {
|
|
561
616
|
filenameBase: "fare_transfer_rules",
|
|
562
617
|
filenameExtension: "txt",
|
|
563
618
|
schema: [
|
|
@@ -611,10 +666,9 @@ var model12 = {
|
|
|
611
666
|
}
|
|
612
667
|
]
|
|
613
668
|
};
|
|
614
|
-
var fare_transfer_rules_default = model12;
|
|
615
669
|
|
|
616
670
|
// src/models/gtfs/feed-info.ts
|
|
617
|
-
var
|
|
671
|
+
var feedInfo = {
|
|
618
672
|
filenameBase: "feed_info",
|
|
619
673
|
filenameExtension: "txt",
|
|
620
674
|
schema: [
|
|
@@ -662,10 +716,9 @@ var model13 = {
|
|
|
662
716
|
}
|
|
663
717
|
]
|
|
664
718
|
};
|
|
665
|
-
var feed_info_default = model13;
|
|
666
719
|
|
|
667
720
|
// src/models/gtfs/frequencies.ts
|
|
668
|
-
var
|
|
721
|
+
var frequencies = {
|
|
669
722
|
filenameBase: "frequencies",
|
|
670
723
|
filenameExtension: "txt",
|
|
671
724
|
schema: [
|
|
@@ -709,10 +762,9 @@ var model14 = {
|
|
|
709
762
|
}
|
|
710
763
|
]
|
|
711
764
|
};
|
|
712
|
-
var frequencies_default = model14;
|
|
713
765
|
|
|
714
766
|
// src/models/gtfs/levels.ts
|
|
715
|
-
var
|
|
767
|
+
var levels = {
|
|
716
768
|
filenameBase: "levels",
|
|
717
769
|
filenameExtension: "txt",
|
|
718
770
|
schema: [
|
|
@@ -735,10 +787,9 @@ var model15 = {
|
|
|
735
787
|
}
|
|
736
788
|
]
|
|
737
789
|
};
|
|
738
|
-
var levels_default = model15;
|
|
739
790
|
|
|
740
791
|
// src/models/gtfs/location-groups.ts
|
|
741
|
-
var
|
|
792
|
+
var locationGroups = {
|
|
742
793
|
filenameBase: "location_groups",
|
|
743
794
|
filenameExtension: "txt",
|
|
744
795
|
schema: [
|
|
@@ -755,10 +806,9 @@ var model16 = {
|
|
|
755
806
|
}
|
|
756
807
|
]
|
|
757
808
|
};
|
|
758
|
-
var location_groups_default = model16;
|
|
759
809
|
|
|
760
810
|
// src/models/gtfs/location-group-stops.ts
|
|
761
|
-
var
|
|
811
|
+
var locationGroupStops = {
|
|
762
812
|
filenameBase: "location_group_stops",
|
|
763
813
|
filenameExtension: "txt",
|
|
764
814
|
schema: [
|
|
@@ -778,10 +828,9 @@ var model17 = {
|
|
|
778
828
|
}
|
|
779
829
|
]
|
|
780
830
|
};
|
|
781
|
-
var location_group_stops_default = model17;
|
|
782
831
|
|
|
783
832
|
// src/models/gtfs/locations.ts
|
|
784
|
-
var
|
|
833
|
+
var locations = {
|
|
785
834
|
filenameBase: "locations",
|
|
786
835
|
filenameExtension: "geojson",
|
|
787
836
|
schema: [
|
|
@@ -791,10 +840,9 @@ var model18 = {
|
|
|
791
840
|
}
|
|
792
841
|
]
|
|
793
842
|
};
|
|
794
|
-
var locations_default = model18;
|
|
795
843
|
|
|
796
844
|
// src/models/gtfs/networks.ts
|
|
797
|
-
var
|
|
845
|
+
var networks = {
|
|
798
846
|
filenameBase: "networks",
|
|
799
847
|
filenameExtension: "txt",
|
|
800
848
|
schema: [
|
|
@@ -812,10 +860,9 @@ var model19 = {
|
|
|
812
860
|
}
|
|
813
861
|
]
|
|
814
862
|
};
|
|
815
|
-
var networks_default = model19;
|
|
816
863
|
|
|
817
864
|
// src/models/gtfs/pathways.ts
|
|
818
|
-
var
|
|
865
|
+
var pathways = {
|
|
819
866
|
filenameBase: "pathways",
|
|
820
867
|
filenameExtension: "txt",
|
|
821
868
|
schema: [
|
|
@@ -887,10 +934,9 @@ var model20 = {
|
|
|
887
934
|
}
|
|
888
935
|
]
|
|
889
936
|
};
|
|
890
|
-
var pathways_default = model20;
|
|
891
937
|
|
|
892
938
|
// src/models/gtfs/route-networks.ts
|
|
893
|
-
var
|
|
939
|
+
var routeNetworks = {
|
|
894
940
|
filenameBase: "route_networks",
|
|
895
941
|
filenameExtension: "txt",
|
|
896
942
|
schema: [
|
|
@@ -909,10 +955,9 @@ var model21 = {
|
|
|
909
955
|
}
|
|
910
956
|
]
|
|
911
957
|
};
|
|
912
|
-
var route_networks_default = model21;
|
|
913
958
|
|
|
914
959
|
// src/models/gtfs/routes.ts
|
|
915
|
-
var
|
|
960
|
+
var routes = {
|
|
916
961
|
filenameBase: "routes",
|
|
917
962
|
filenameExtension: "txt",
|
|
918
963
|
schema: [
|
|
@@ -989,10 +1034,9 @@ var model22 = {
|
|
|
989
1034
|
}
|
|
990
1035
|
]
|
|
991
1036
|
};
|
|
992
|
-
var routes_default = model22;
|
|
993
1037
|
|
|
994
1038
|
// src/models/gtfs/shapes.ts
|
|
995
|
-
var
|
|
1039
|
+
var shapes = {
|
|
996
1040
|
filenameBase: "shapes",
|
|
997
1041
|
filenameExtension: "txt",
|
|
998
1042
|
schema: [
|
|
@@ -1031,10 +1075,9 @@ var model23 = {
|
|
|
1031
1075
|
}
|
|
1032
1076
|
]
|
|
1033
1077
|
};
|
|
1034
|
-
var shapes_default = model23;
|
|
1035
1078
|
|
|
1036
1079
|
// src/models/gtfs/stop-areas.ts
|
|
1037
|
-
var
|
|
1080
|
+
var stopAreas = {
|
|
1038
1081
|
filenameBase: "stop_areas",
|
|
1039
1082
|
filenameExtension: "txt",
|
|
1040
1083
|
schema: [
|
|
@@ -1052,10 +1095,9 @@ var model24 = {
|
|
|
1052
1095
|
}
|
|
1053
1096
|
]
|
|
1054
1097
|
};
|
|
1055
|
-
var stop_areas_default = model24;
|
|
1056
1098
|
|
|
1057
1099
|
// src/models/gtfs/stop-times.ts
|
|
1058
|
-
var
|
|
1100
|
+
var stopTimes = {
|
|
1059
1101
|
filenameBase: "stop_times",
|
|
1060
1102
|
filenameExtension: "txt",
|
|
1061
1103
|
schema: [
|
|
@@ -1173,10 +1215,9 @@ var model25 = {
|
|
|
1173
1215
|
}
|
|
1174
1216
|
]
|
|
1175
1217
|
};
|
|
1176
|
-
var stop_times_default = model25;
|
|
1177
1218
|
|
|
1178
1219
|
// src/models/gtfs/stops.ts
|
|
1179
|
-
var
|
|
1220
|
+
var stops = {
|
|
1180
1221
|
filenameBase: "stops",
|
|
1181
1222
|
filenameExtension: "txt",
|
|
1182
1223
|
schema: [
|
|
@@ -1259,10 +1300,9 @@ var model26 = {
|
|
|
1259
1300
|
}
|
|
1260
1301
|
]
|
|
1261
1302
|
};
|
|
1262
|
-
var stops_default = model26;
|
|
1263
1303
|
|
|
1264
1304
|
// src/models/gtfs/timeframes.ts
|
|
1265
|
-
var
|
|
1305
|
+
var timeframes = {
|
|
1266
1306
|
filenameBase: "timeframes",
|
|
1267
1307
|
filenameExtension: "txt",
|
|
1268
1308
|
schema: [
|
|
@@ -1289,10 +1329,9 @@ var model27 = {
|
|
|
1289
1329
|
}
|
|
1290
1330
|
]
|
|
1291
1331
|
};
|
|
1292
|
-
var timeframes_default = model27;
|
|
1293
1332
|
|
|
1294
1333
|
// src/models/gtfs/transfers.ts
|
|
1295
|
-
var
|
|
1334
|
+
var transfers = {
|
|
1296
1335
|
filenameBase: "transfers",
|
|
1297
1336
|
filenameExtension: "txt",
|
|
1298
1337
|
schema: [
|
|
@@ -1346,10 +1385,9 @@ var model28 = {
|
|
|
1346
1385
|
}
|
|
1347
1386
|
]
|
|
1348
1387
|
};
|
|
1349
|
-
var transfers_default = model28;
|
|
1350
1388
|
|
|
1351
1389
|
// src/models/gtfs/translations.ts
|
|
1352
|
-
var
|
|
1390
|
+
var translations = {
|
|
1353
1391
|
filenameBase: "translations",
|
|
1354
1392
|
filenameExtension: "txt",
|
|
1355
1393
|
schema: [
|
|
@@ -1395,10 +1433,9 @@ var model29 = {
|
|
|
1395
1433
|
}
|
|
1396
1434
|
]
|
|
1397
1435
|
};
|
|
1398
|
-
var translations_default = model29;
|
|
1399
1436
|
|
|
1400
1437
|
// src/models/gtfs/trips.ts
|
|
1401
|
-
var
|
|
1438
|
+
var trips = {
|
|
1402
1439
|
filenameBase: "trips",
|
|
1403
1440
|
filenameExtension: "txt",
|
|
1404
1441
|
schema: [
|
|
@@ -1466,10 +1503,9 @@ var model30 = {
|
|
|
1466
1503
|
}
|
|
1467
1504
|
]
|
|
1468
1505
|
};
|
|
1469
|
-
var trips_default = model30;
|
|
1470
1506
|
|
|
1471
1507
|
// src/models/non-standard/timetables.ts
|
|
1472
|
-
var
|
|
1508
|
+
var timetables = {
|
|
1473
1509
|
filenameBase: "timetables",
|
|
1474
1510
|
filenameExtension: "txt",
|
|
1475
1511
|
nonstandard: true,
|
|
@@ -1611,10 +1647,9 @@ var model31 = {
|
|
|
1611
1647
|
}
|
|
1612
1648
|
]
|
|
1613
1649
|
};
|
|
1614
|
-
var timetables_default = model31;
|
|
1615
1650
|
|
|
1616
1651
|
// src/models/non-standard/timetable-pages.ts
|
|
1617
|
-
var
|
|
1652
|
+
var timetablePages = {
|
|
1618
1653
|
filenameBase: "timetable_pages",
|
|
1619
1654
|
filenameExtension: "txt",
|
|
1620
1655
|
nonstandard: true,
|
|
@@ -1635,10 +1670,9 @@ var model32 = {
|
|
|
1635
1670
|
}
|
|
1636
1671
|
]
|
|
1637
1672
|
};
|
|
1638
|
-
var timetable_pages_default = model32;
|
|
1639
1673
|
|
|
1640
1674
|
// src/models/non-standard/timetable-stop-order.ts
|
|
1641
|
-
var
|
|
1675
|
+
var timetableStopOrder = {
|
|
1642
1676
|
filenameBase: "timetable_stop_order",
|
|
1643
1677
|
filenameExtension: "txt",
|
|
1644
1678
|
nonstandard: true,
|
|
@@ -1668,10 +1702,9 @@ var model33 = {
|
|
|
1668
1702
|
}
|
|
1669
1703
|
]
|
|
1670
1704
|
};
|
|
1671
|
-
var timetable_stop_order_default = model33;
|
|
1672
1705
|
|
|
1673
1706
|
// src/models/non-standard/timetable-notes.ts
|
|
1674
|
-
var
|
|
1707
|
+
var timetableNotes = {
|
|
1675
1708
|
filenameBase: "timetable_notes",
|
|
1676
1709
|
filenameExtension: "txt",
|
|
1677
1710
|
nonstandard: true,
|
|
@@ -1693,10 +1726,9 @@ var model34 = {
|
|
|
1693
1726
|
}
|
|
1694
1727
|
]
|
|
1695
1728
|
};
|
|
1696
|
-
var timetable_notes_default = model34;
|
|
1697
1729
|
|
|
1698
1730
|
// src/models/non-standard/timetable-notes-references.ts
|
|
1699
|
-
var
|
|
1731
|
+
var timetableNotesReferences = {
|
|
1700
1732
|
filenameBase: "timetable_notes_references",
|
|
1701
1733
|
filenameExtension: "txt",
|
|
1702
1734
|
nonstandard: true,
|
|
@@ -1744,11 +1776,10 @@ var model35 = {
|
|
|
1744
1776
|
}
|
|
1745
1777
|
]
|
|
1746
1778
|
};
|
|
1747
|
-
var timetable_notes_references_default = model35;
|
|
1748
1779
|
|
|
1749
1780
|
// src/models/non-standard/trips-dated-vehicle-journey.ts
|
|
1750
|
-
var
|
|
1751
|
-
filenameBase: "
|
|
1781
|
+
var tripsDatedVehicleJourney = {
|
|
1782
|
+
filenameBase: "trips_dated_vehicle_journey",
|
|
1752
1783
|
filenameExtension: "txt",
|
|
1753
1784
|
nonstandard: true,
|
|
1754
1785
|
schema: [
|
|
@@ -1779,10 +1810,9 @@ var model36 = {
|
|
|
1779
1810
|
}
|
|
1780
1811
|
]
|
|
1781
1812
|
};
|
|
1782
|
-
var trips_dated_vehicle_journey_default = model36;
|
|
1783
1813
|
|
|
1784
1814
|
// src/models/gtfs-plus/calendar-attributes.ts
|
|
1785
|
-
var
|
|
1815
|
+
var calendarAttributes = {
|
|
1786
1816
|
filenameBase: "calendar_attributes",
|
|
1787
1817
|
filenameExtension: "txt",
|
|
1788
1818
|
nonstandard: true,
|
|
@@ -1802,10 +1832,9 @@ var model37 = {
|
|
|
1802
1832
|
}
|
|
1803
1833
|
]
|
|
1804
1834
|
};
|
|
1805
|
-
var calendar_attributes_default = model37;
|
|
1806
1835
|
|
|
1807
1836
|
// src/models/gtfs-plus/directions.ts
|
|
1808
|
-
var
|
|
1837
|
+
var directions = {
|
|
1809
1838
|
filenameBase: "directions",
|
|
1810
1839
|
filenameExtension: "txt",
|
|
1811
1840
|
nonstandard: true,
|
|
@@ -1832,10 +1861,9 @@ var model38 = {
|
|
|
1832
1861
|
}
|
|
1833
1862
|
]
|
|
1834
1863
|
};
|
|
1835
|
-
var directions_default = model38;
|
|
1836
1864
|
|
|
1837
1865
|
// src/models/gtfs-plus/route-attributes.ts
|
|
1838
|
-
var
|
|
1866
|
+
var routeAttributes = {
|
|
1839
1867
|
filenameBase: "route_attributes",
|
|
1840
1868
|
filenameExtension: "txt",
|
|
1841
1869
|
nonstandard: true,
|
|
@@ -1867,10 +1895,9 @@ var model39 = {
|
|
|
1867
1895
|
}
|
|
1868
1896
|
]
|
|
1869
1897
|
};
|
|
1870
|
-
var route_attributes_default = model39;
|
|
1871
1898
|
|
|
1872
1899
|
// src/models/gtfs-plus/stop-attributes.ts
|
|
1873
|
-
var
|
|
1900
|
+
var stopAttributes = {
|
|
1874
1901
|
filenameBase: "stop_attributes",
|
|
1875
1902
|
filenameExtension: "txt",
|
|
1876
1903
|
nonstandard: true,
|
|
@@ -1903,10 +1930,9 @@ var model40 = {
|
|
|
1903
1930
|
}
|
|
1904
1931
|
]
|
|
1905
1932
|
};
|
|
1906
|
-
var stop_attributes_default = model40;
|
|
1907
1933
|
|
|
1908
1934
|
// src/models/gtfs-ride/board-alight.ts
|
|
1909
|
-
var
|
|
1935
|
+
var boardAlight = {
|
|
1910
1936
|
filenameBase: "board_alight",
|
|
1911
1937
|
filenameExtension: "txt",
|
|
1912
1938
|
nonstandard: true,
|
|
@@ -2036,10 +2062,9 @@ var model41 = {
|
|
|
2036
2062
|
}
|
|
2037
2063
|
]
|
|
2038
2064
|
};
|
|
2039
|
-
var board_alight_default = model41;
|
|
2040
2065
|
|
|
2041
2066
|
// src/models/gtfs-ride/rider-trip.ts
|
|
2042
|
-
var
|
|
2067
|
+
var riderTrip = {
|
|
2043
2068
|
filenameBase: "rider_trip",
|
|
2044
2069
|
filenameExtension: "txt",
|
|
2045
2070
|
nonstandard: true,
|
|
@@ -2150,10 +2175,9 @@ var model42 = {
|
|
|
2150
2175
|
}
|
|
2151
2176
|
]
|
|
2152
2177
|
};
|
|
2153
|
-
var rider_trip_default = model42;
|
|
2154
2178
|
|
|
2155
2179
|
// src/models/gtfs-ride/ridership.ts
|
|
2156
|
-
var
|
|
2180
|
+
var ridership = {
|
|
2157
2181
|
filenameBase: "ridership",
|
|
2158
2182
|
filenameExtension: "txt",
|
|
2159
2183
|
nonstandard: true,
|
|
@@ -2278,10 +2302,9 @@ var model43 = {
|
|
|
2278
2302
|
}
|
|
2279
2303
|
]
|
|
2280
2304
|
};
|
|
2281
|
-
var ridership_default = model43;
|
|
2282
2305
|
|
|
2283
2306
|
// src/models/gtfs-ride/trip-capacity.ts
|
|
2284
|
-
var
|
|
2307
|
+
var tripCapacity = {
|
|
2285
2308
|
filenameBase: "trip_capacity",
|
|
2286
2309
|
filenameExtension: "txt",
|
|
2287
2310
|
nonstandard: true,
|
|
@@ -2330,10 +2353,9 @@ var model44 = {
|
|
|
2330
2353
|
}
|
|
2331
2354
|
]
|
|
2332
2355
|
};
|
|
2333
|
-
var trip_capacity_default = model44;
|
|
2334
2356
|
|
|
2335
2357
|
// src/models/gtfs-ride/ride-feed-info.ts
|
|
2336
|
-
var
|
|
2358
|
+
var rideFeedInfo = {
|
|
2337
2359
|
filenameBase: "ride_feed_info",
|
|
2338
2360
|
filenameExtension: "txt",
|
|
2339
2361
|
nonstandard: true,
|
|
@@ -2371,10 +2393,9 @@ var model45 = {
|
|
|
2371
2393
|
}
|
|
2372
2394
|
]
|
|
2373
2395
|
};
|
|
2374
|
-
var ride_feed_info_default = model45;
|
|
2375
2396
|
|
|
2376
2397
|
// src/models/gtfs-realtime/trip-updates.ts
|
|
2377
|
-
var
|
|
2398
|
+
var tripUpdates = {
|
|
2378
2399
|
filenameBase: "trip_updates",
|
|
2379
2400
|
extension: "gtfs-realtime",
|
|
2380
2401
|
schema: [
|
|
@@ -2449,10 +2470,9 @@ var model46 = {
|
|
|
2449
2470
|
}
|
|
2450
2471
|
]
|
|
2451
2472
|
};
|
|
2452
|
-
var trip_updates_default = model46;
|
|
2453
2473
|
|
|
2454
2474
|
// src/models/gtfs-realtime/stop-time-updates.ts
|
|
2455
|
-
var
|
|
2475
|
+
var stopTimeUpdates = {
|
|
2456
2476
|
filenameBase: "stop_time_updates",
|
|
2457
2477
|
extension: "gtfs-realtime",
|
|
2458
2478
|
schema: [
|
|
@@ -2537,10 +2557,9 @@ var model47 = {
|
|
|
2537
2557
|
}
|
|
2538
2558
|
]
|
|
2539
2559
|
};
|
|
2540
|
-
var stop_time_updates_default = model47;
|
|
2541
2560
|
|
|
2542
2561
|
// src/models/gtfs-realtime/vehicle-positions.ts
|
|
2543
|
-
var
|
|
2562
|
+
var vehiclePositions = {
|
|
2544
2563
|
filenameBase: "vehicle_positions",
|
|
2545
2564
|
extension: "gtfs-realtime",
|
|
2546
2565
|
schema: [
|
|
@@ -2675,10 +2694,9 @@ var model48 = {
|
|
|
2675
2694
|
}
|
|
2676
2695
|
]
|
|
2677
2696
|
};
|
|
2678
|
-
var vehicle_positions_default = model48;
|
|
2679
2697
|
|
|
2680
2698
|
// src/models/gtfs-realtime/service-alerts.ts
|
|
2681
|
-
var
|
|
2699
|
+
var serviceAlerts = {
|
|
2682
2700
|
filenameBase: "service_alerts",
|
|
2683
2701
|
extension: "gtfs-realtime",
|
|
2684
2702
|
schema: [
|
|
@@ -2738,10 +2756,9 @@ var model49 = {
|
|
|
2738
2756
|
}
|
|
2739
2757
|
]
|
|
2740
2758
|
};
|
|
2741
|
-
var service_alerts_default = model49;
|
|
2742
2759
|
|
|
2743
2760
|
// src/models/gtfs-realtime/service-alert-targets.ts
|
|
2744
|
-
var
|
|
2761
|
+
var serviceAlertTargets = {
|
|
2745
2762
|
filenameBase: "service_alert_targets",
|
|
2746
2763
|
extension: "gtfs-realtime",
|
|
2747
2764
|
schema: [
|
|
@@ -2778,10 +2795,9 @@ var model50 = {
|
|
|
2778
2795
|
}
|
|
2779
2796
|
]
|
|
2780
2797
|
};
|
|
2781
|
-
var service_alert_targets_default = model50;
|
|
2782
2798
|
|
|
2783
2799
|
// src/models/ods/deadhead-times.ts
|
|
2784
|
-
var
|
|
2800
|
+
var deadheadTimes = {
|
|
2785
2801
|
filenameBase: "deadhead_times",
|
|
2786
2802
|
filenameExtension: "txt",
|
|
2787
2803
|
nonstandard: true,
|
|
@@ -2844,10 +2860,9 @@ var model51 = {
|
|
|
2844
2860
|
}
|
|
2845
2861
|
]
|
|
2846
2862
|
};
|
|
2847
|
-
var deadhead_times_default = model51;
|
|
2848
2863
|
|
|
2849
2864
|
// src/models/ods/deadheads.ts
|
|
2850
|
-
var
|
|
2865
|
+
var deadheads = {
|
|
2851
2866
|
filenameBase: "deadheads",
|
|
2852
2867
|
filenameExtension: "txt",
|
|
2853
2868
|
nonstandard: true,
|
|
@@ -2905,10 +2920,9 @@ var model52 = {
|
|
|
2905
2920
|
}
|
|
2906
2921
|
]
|
|
2907
2922
|
};
|
|
2908
|
-
var deadheads_default = model52;
|
|
2909
2923
|
|
|
2910
2924
|
// src/models/ods/ops-locations.ts
|
|
2911
|
-
var
|
|
2925
|
+
var opsLocations = {
|
|
2912
2926
|
filenameBase: "ops_locations",
|
|
2913
2927
|
filenameExtension: "txt",
|
|
2914
2928
|
nonstandard: true,
|
|
@@ -2952,10 +2966,9 @@ var model53 = {
|
|
|
2952
2966
|
}
|
|
2953
2967
|
]
|
|
2954
2968
|
};
|
|
2955
|
-
var ops_locations_default = model53;
|
|
2956
2969
|
|
|
2957
2970
|
// src/models/ods/run-events.ts
|
|
2958
|
-
var
|
|
2971
|
+
var runEvents = {
|
|
2959
2972
|
filenameBase: "run_event",
|
|
2960
2973
|
filenameExtension: "txt",
|
|
2961
2974
|
nonstandard: true,
|
|
@@ -3023,10 +3036,9 @@ var model54 = {
|
|
|
3023
3036
|
}
|
|
3024
3037
|
]
|
|
3025
3038
|
};
|
|
3026
|
-
var run_events_default = model54;
|
|
3027
3039
|
|
|
3028
3040
|
// src/models/ods/runs-pieces.ts
|
|
3029
|
-
var
|
|
3041
|
+
var runsPieces = {
|
|
3030
3042
|
filenameBase: "runs_pieces",
|
|
3031
3043
|
filenameExtension: "txt",
|
|
3032
3044
|
nonstandard: true,
|
|
@@ -3083,67 +3095,6 @@ var model55 = {
|
|
|
3083
3095
|
}
|
|
3084
3096
|
]
|
|
3085
3097
|
};
|
|
3086
|
-
var runs_pieces_default = model55;
|
|
3087
|
-
|
|
3088
|
-
// src/models/models.ts
|
|
3089
|
-
var models = [
|
|
3090
|
-
agency_default,
|
|
3091
|
-
areas_default,
|
|
3092
|
-
attributions_default,
|
|
3093
|
-
booking_rules_default,
|
|
3094
|
-
calendar_dates_default,
|
|
3095
|
-
calendar_default,
|
|
3096
|
-
fare_attributes_default,
|
|
3097
|
-
fare_leg_rules_default,
|
|
3098
|
-
fare_media_default,
|
|
3099
|
-
fare_products_default,
|
|
3100
|
-
fare_rules_default,
|
|
3101
|
-
fare_transfer_rules_default,
|
|
3102
|
-
feed_info_default,
|
|
3103
|
-
frequencies_default,
|
|
3104
|
-
levels_default,
|
|
3105
|
-
location_groups_default,
|
|
3106
|
-
location_group_stops_default,
|
|
3107
|
-
locations_default,
|
|
3108
|
-
networks_default,
|
|
3109
|
-
pathways_default,
|
|
3110
|
-
route_networks_default,
|
|
3111
|
-
routes_default,
|
|
3112
|
-
shapes_default,
|
|
3113
|
-
stop_areas_default,
|
|
3114
|
-
stop_times_default,
|
|
3115
|
-
stops_default,
|
|
3116
|
-
timeframes_default,
|
|
3117
|
-
transfers_default,
|
|
3118
|
-
translations_default,
|
|
3119
|
-
trips_default,
|
|
3120
|
-
timetables_default,
|
|
3121
|
-
timetable_pages_default,
|
|
3122
|
-
timetable_stop_order_default,
|
|
3123
|
-
timetable_notes_default,
|
|
3124
|
-
timetable_notes_references_default,
|
|
3125
|
-
trips_dated_vehicle_journey_default,
|
|
3126
|
-
calendar_attributes_default,
|
|
3127
|
-
directions_default,
|
|
3128
|
-
route_attributes_default,
|
|
3129
|
-
stop_attributes_default,
|
|
3130
|
-
board_alight_default,
|
|
3131
|
-
ride_feed_info_default,
|
|
3132
|
-
rider_trip_default,
|
|
3133
|
-
ridership_default,
|
|
3134
|
-
trip_capacity_default,
|
|
3135
|
-
trip_updates_default,
|
|
3136
|
-
stop_time_updates_default,
|
|
3137
|
-
vehicle_positions_default,
|
|
3138
|
-
service_alerts_default,
|
|
3139
|
-
service_alert_targets_default,
|
|
3140
|
-
deadhead_times_default,
|
|
3141
|
-
deadheads_default,
|
|
3142
|
-
ops_locations_default,
|
|
3143
|
-
run_events_default,
|
|
3144
|
-
runs_pieces_default
|
|
3145
|
-
];
|
|
3146
|
-
var models_default = models;
|
|
3147
3098
|
|
|
3148
3099
|
// src/lib/db.ts
|
|
3149
3100
|
import fs from "fs";
|
|
@@ -3269,9 +3220,9 @@ function isValidLineString(lineString) {
|
|
|
3269
3220
|
}
|
|
3270
3221
|
return true;
|
|
3271
3222
|
}
|
|
3272
|
-
function consolidateShapes(
|
|
3223
|
+
function consolidateShapes(shapes2) {
|
|
3273
3224
|
const keys = /* @__PURE__ */ new Set();
|
|
3274
|
-
const segmentsArray =
|
|
3225
|
+
const segmentsArray = shapes2.map(
|
|
3275
3226
|
(shape) => shape.reduce(
|
|
3276
3227
|
(memo, point, idx) => {
|
|
3277
3228
|
if (idx > 0) {
|
|
@@ -3331,8 +3282,8 @@ function formatProperties(properties) {
|
|
|
3331
3282
|
}
|
|
3332
3283
|
return formattedProperties;
|
|
3333
3284
|
}
|
|
3334
|
-
function shapesToGeoJSONFeature(
|
|
3335
|
-
const shapeGroups = Object.values(groupBy(
|
|
3285
|
+
function shapesToGeoJSONFeature(shapes2, properties = {}) {
|
|
3286
|
+
const shapeGroups = Object.values(groupBy(shapes2, "shape_id")).map(
|
|
3336
3287
|
(shapeGroup) => sortBy(shapeGroup, "shape_pt_sequence")
|
|
3337
3288
|
);
|
|
3338
3289
|
const lineStrings = consolidateShapes(shapeGroups);
|
|
@@ -3344,8 +3295,8 @@ function shapesToGeoJSONFeature(shapes, properties = {}) {
|
|
|
3344
3295
|
formatProperties(properties)
|
|
3345
3296
|
);
|
|
3346
3297
|
}
|
|
3347
|
-
function stopsToGeoJSONFeatureCollection(
|
|
3348
|
-
const features =
|
|
3298
|
+
function stopsToGeoJSONFeatureCollection(stops2) {
|
|
3299
|
+
const features = stops2.map(
|
|
3349
3300
|
(stop) => feature(
|
|
3350
3301
|
{
|
|
3351
3302
|
type: "Point",
|
|
@@ -3418,8 +3369,8 @@ function validateConfigForImport(config) {
|
|
|
3418
3369
|
if (!config.agencies || config.agencies.length === 0) {
|
|
3419
3370
|
throw new Error("No `agencies` specified in config");
|
|
3420
3371
|
}
|
|
3421
|
-
for (const [index,
|
|
3422
|
-
if (!
|
|
3372
|
+
for (const [index, agency2] of config.agencies.entries()) {
|
|
3373
|
+
if (!agency2.path && !agency2.url) {
|
|
3423
3374
|
throw new Error(
|
|
3424
3375
|
`No Agency \`url\` or \`path\` specified in config for agency index ${index}.`
|
|
3425
3376
|
);
|
|
@@ -3529,31 +3480,34 @@ function formatOrderByClause(orderBy2) {
|
|
|
3529
3480
|
|
|
3530
3481
|
// src/lib/import.ts
|
|
3531
3482
|
var downloadFiles = async (task) => {
|
|
3532
|
-
task.log(`Downloading GTFS from ${task.
|
|
3483
|
+
task.log(`Downloading GTFS from ${task.url}`);
|
|
3533
3484
|
task.path = `${task.downloadDir}/gtfs.zip`;
|
|
3534
|
-
const response = await fetch(task.
|
|
3485
|
+
const response = await fetch(task.url, {
|
|
3535
3486
|
method: "GET",
|
|
3536
3487
|
headers: task.headers || {},
|
|
3537
3488
|
signal: task.downloadTimeout ? AbortSignal.timeout(task.downloadTimeout) : void 0
|
|
3538
3489
|
});
|
|
3539
3490
|
if (response.status !== 200) {
|
|
3540
|
-
throw new Error(`Unable to download GTFS from ${task.
|
|
3491
|
+
throw new Error(`Unable to download GTFS from ${task.url}`);
|
|
3541
3492
|
}
|
|
3542
3493
|
const buffer = await response.arrayBuffer();
|
|
3543
3494
|
await writeFile(task.path, Buffer.from(buffer));
|
|
3544
3495
|
task.log("Download successful");
|
|
3545
3496
|
};
|
|
3546
|
-
var downloadGtfsRealtimeData = async (
|
|
3547
|
-
|
|
3497
|
+
var downloadGtfsRealtimeData = async (urlAndHeaders, task) => {
|
|
3498
|
+
task.log(`Downloading GTFS-Realtime from ${urlAndHeaders.url}`);
|
|
3499
|
+
const response = await fetch(urlAndHeaders.url, {
|
|
3548
3500
|
method: "GET",
|
|
3549
3501
|
headers: {
|
|
3550
|
-
...
|
|
3502
|
+
...urlAndHeaders.headers ?? {},
|
|
3551
3503
|
"Accept-Encoding": "gzip"
|
|
3552
3504
|
},
|
|
3553
3505
|
signal: task.downloadTimeout ? AbortSignal.timeout(task.downloadTimeout) : void 0
|
|
3554
3506
|
});
|
|
3555
3507
|
if (response.status !== 200) {
|
|
3556
|
-
task.logWarning(
|
|
3508
|
+
task.logWarning(
|
|
3509
|
+
`Unable to download GTFS-Realtime from ${urlAndHeaders.url}`
|
|
3510
|
+
);
|
|
3557
3511
|
return null;
|
|
3558
3512
|
}
|
|
3559
3513
|
const buffer = await response.arrayBuffer();
|
|
@@ -3634,71 +3588,74 @@ var prepareRealtimeValue = (entity, column, task) => {
|
|
|
3634
3588
|
);
|
|
3635
3589
|
};
|
|
3636
3590
|
var updateRealtimeData = async (task) => {
|
|
3637
|
-
if (
|
|
3591
|
+
if (task.realtimeAlerts === void 0 && task.realtimeTripUpdates === void 0 && task.realtimeVehiclePositions === void 0) {
|
|
3638
3592
|
return;
|
|
3639
3593
|
}
|
|
3640
3594
|
const db = openDb({
|
|
3641
3595
|
sqlitePath: task.sqlitePath
|
|
3642
3596
|
});
|
|
3643
|
-
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
3655
|
-
|
|
3656
|
-
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
model56 = tripUpdatesModel;
|
|
3680
|
-
}
|
|
3681
|
-
if (entity.alert) {
|
|
3682
|
-
model56 = serviceAlertsModel;
|
|
3683
|
-
}
|
|
3684
|
-
if (!model56) {
|
|
3685
|
-
break;
|
|
3686
|
-
}
|
|
3687
|
-
const fieldValues = model56.schema.map(
|
|
3688
|
-
(column) => prepareRealtimeValue(entity, column, task)
|
|
3689
|
-
);
|
|
3690
|
-
try {
|
|
3691
|
-
db.prepare(
|
|
3692
|
-
`REPLACE INTO ${model56.filenameBase} (${model56.schema.map((column) => column.name).join(", ")}) VALUES (${fieldValues.join(", ")})`
|
|
3693
|
-
).run();
|
|
3694
|
-
} catch (error) {
|
|
3695
|
-
task.logWarning("Import error: " + error.message);
|
|
3597
|
+
if (task.realtimeAlerts?.url) {
|
|
3598
|
+
const gtfsRealtimeData = await downloadGtfsRealtimeData(
|
|
3599
|
+
task.realtimeAlerts,
|
|
3600
|
+
task
|
|
3601
|
+
);
|
|
3602
|
+
if (gtfsRealtimeData?.entity) {
|
|
3603
|
+
task.log(`Download successful`);
|
|
3604
|
+
let totalLineCount = 0;
|
|
3605
|
+
for (const entity of gtfsRealtimeData.entity) {
|
|
3606
|
+
const fieldValues = serviceAlerts.schema.map(
|
|
3607
|
+
(column) => prepareRealtimeValue(entity, column, task)
|
|
3608
|
+
);
|
|
3609
|
+
try {
|
|
3610
|
+
db.prepare(
|
|
3611
|
+
`REPLACE INTO ${serviceAlerts.filenameBase} (${serviceAlerts.schema.map((column) => column.name).join(", ")}) VALUES (${fieldValues.join(", ")})`
|
|
3612
|
+
).run();
|
|
3613
|
+
} catch (error) {
|
|
3614
|
+
task.logWarning("Import error: " + error.message);
|
|
3615
|
+
}
|
|
3616
|
+
const alertTargetArray = [];
|
|
3617
|
+
for (const informedEntity of entity.alert.informedEntity) {
|
|
3618
|
+
informedEntity.parent = entity;
|
|
3619
|
+
const subValues = serviceAlertTargets.schema.map(
|
|
3620
|
+
(column) => prepareRealtimeValue(informedEntity, column, task)
|
|
3621
|
+
);
|
|
3622
|
+
alertTargetArray.push(`(${subValues.join(", ")})`);
|
|
3623
|
+
totalLineCount++;
|
|
3624
|
+
}
|
|
3625
|
+
try {
|
|
3626
|
+
db.prepare(
|
|
3627
|
+
`REPLACE INTO ${serviceAlertTargets.filenameBase} (${serviceAlertTargets.schema.map((column) => column.name).join(", ")}) VALUES ${alertTargetArray.join(", ")}`
|
|
3628
|
+
).run();
|
|
3629
|
+
} catch (error) {
|
|
3630
|
+
task.logWarning("Import error: " + error.message);
|
|
3631
|
+
}
|
|
3632
|
+
task.log(`Importing - ${totalLineCount++} entries imported\r`, true);
|
|
3696
3633
|
}
|
|
3697
|
-
|
|
3634
|
+
}
|
|
3635
|
+
}
|
|
3636
|
+
if (task.realtimeTripUpdates?.url) {
|
|
3637
|
+
const gtfsRealtimeData = await downloadGtfsRealtimeData(
|
|
3638
|
+
task.realtimeTripUpdates,
|
|
3639
|
+
task
|
|
3640
|
+
);
|
|
3641
|
+
if (gtfsRealtimeData?.entity) {
|
|
3642
|
+
task.log(`Download successful`);
|
|
3643
|
+
let totalLineCount = 0;
|
|
3644
|
+
for (const entity of gtfsRealtimeData.entity) {
|
|
3645
|
+
const fieldValues = tripUpdates.schema.map(
|
|
3646
|
+
(column) => prepareRealtimeValue(entity, column, task)
|
|
3647
|
+
);
|
|
3648
|
+
try {
|
|
3649
|
+
db.prepare(
|
|
3650
|
+
`REPLACE INTO ${tripUpdates.filenameBase} (${tripUpdates.schema.map((column) => column.name).join(", ")}) VALUES (${fieldValues.join(", ")})`
|
|
3651
|
+
).run();
|
|
3652
|
+
} catch (error) {
|
|
3653
|
+
task.logWarning("Import error: " + error.message);
|
|
3654
|
+
}
|
|
3698
3655
|
const stopTimeUpdateArray = [];
|
|
3699
3656
|
for (const stopTimeUpdate of entity.tripUpdate.stopTimeUpdate) {
|
|
3700
3657
|
stopTimeUpdate.parent = entity;
|
|
3701
|
-
const subValues =
|
|
3658
|
+
const subValues = stopTimeUpdates.schema.map(
|
|
3702
3659
|
(column) => prepareRealtimeValue(stopTimeUpdate, column, task)
|
|
3703
3660
|
);
|
|
3704
3661
|
stopTimeUpdateArray.push(`(${subValues.join(", ")})`);
|
|
@@ -3706,31 +3663,36 @@ var updateRealtimeData = async (task) => {
|
|
|
3706
3663
|
}
|
|
3707
3664
|
try {
|
|
3708
3665
|
db.prepare(
|
|
3709
|
-
`REPLACE INTO ${
|
|
3666
|
+
`REPLACE INTO ${stopTimeUpdates.filenameBase} (${stopTimeUpdates.schema.map((column) => column.name).join(", ")}) VALUES ${stopTimeUpdateArray.join(", ")}`
|
|
3710
3667
|
).run();
|
|
3711
3668
|
} catch (error) {
|
|
3712
3669
|
task.logWarning("Import error: " + error.message);
|
|
3713
3670
|
}
|
|
3671
|
+
task.log(`Importing - ${totalLineCount++} entries imported\r`, true);
|
|
3714
3672
|
}
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3673
|
+
}
|
|
3674
|
+
}
|
|
3675
|
+
if (task.realtimeVehiclePositions?.url) {
|
|
3676
|
+
const gtfsRealtimeData = await downloadGtfsRealtimeData(
|
|
3677
|
+
task.realtimeVehiclePositions,
|
|
3678
|
+
task
|
|
3679
|
+
);
|
|
3680
|
+
if (gtfsRealtimeData?.entity) {
|
|
3681
|
+
task.log(`Download successful`);
|
|
3682
|
+
let totalLineCount = 0;
|
|
3683
|
+
for (const entity of gtfsRealtimeData.entity) {
|
|
3684
|
+
const fieldValues = tripUpdates.schema.map(
|
|
3685
|
+
(column) => prepareRealtimeValue(entity, column, task)
|
|
3686
|
+
);
|
|
3725
3687
|
try {
|
|
3726
3688
|
db.prepare(
|
|
3727
|
-
`REPLACE INTO ${
|
|
3689
|
+
`REPLACE INTO ${tripUpdates.filenameBase} (${tripUpdates.schema.map((column) => column.name).join(", ")}) VALUES (${fieldValues.join(", ")})`
|
|
3728
3690
|
).run();
|
|
3729
3691
|
} catch (error) {
|
|
3730
3692
|
task.logWarning("Import error: " + error.message);
|
|
3731
3693
|
}
|
|
3694
|
+
task.log(`Importing - ${totalLineCount++} entries imported\r`, true);
|
|
3732
3695
|
}
|
|
3733
|
-
task.log(`Importing - ${totalLineCount++} entries imported\r`, true);
|
|
3734
3696
|
}
|
|
3735
3697
|
}
|
|
3736
3698
|
task.log(`GTFS-Realtime data import complete`);
|
|
@@ -3789,11 +3751,11 @@ var readFiles = async (task) => {
|
|
|
3789
3751
|
}
|
|
3790
3752
|
};
|
|
3791
3753
|
var createTables = (db) => {
|
|
3792
|
-
for (const
|
|
3793
|
-
if (!
|
|
3754
|
+
for (const model of Object.values(models_exports)) {
|
|
3755
|
+
if (!model.schema) {
|
|
3794
3756
|
return;
|
|
3795
3757
|
}
|
|
3796
|
-
const columns =
|
|
3758
|
+
const columns = model.schema.map((column) => {
|
|
3797
3759
|
let check = "";
|
|
3798
3760
|
if (column.min !== void 0 && column.max) {
|
|
3799
3761
|
check = `CHECK( ${column.name} >= ${column.min} AND ${column.name} <= ${column.max} )`;
|
|
@@ -3807,34 +3769,34 @@ var createTables = (db) => {
|
|
|
3807
3769
|
const columnCollation = column.nocase ? "COLLATE NOCASE" : "";
|
|
3808
3770
|
return `${column.name} ${column.type} ${check} ${required} ${columnDefault} ${columnCollation}`;
|
|
3809
3771
|
});
|
|
3810
|
-
const primaryColumns =
|
|
3772
|
+
const primaryColumns = model.schema.filter((column) => column.primary);
|
|
3811
3773
|
if (primaryColumns.length > 0) {
|
|
3812
3774
|
columns.push(
|
|
3813
3775
|
`PRIMARY KEY (${primaryColumns.map((column) => column.name).join(", ")})`
|
|
3814
3776
|
);
|
|
3815
3777
|
}
|
|
3816
|
-
db.prepare(`DROP TABLE IF EXISTS ${
|
|
3778
|
+
db.prepare(`DROP TABLE IF EXISTS ${model.filenameBase};`).run();
|
|
3817
3779
|
db.prepare(
|
|
3818
|
-
`CREATE TABLE ${
|
|
3780
|
+
`CREATE TABLE ${model.filenameBase} (${columns.join(", ")});`
|
|
3819
3781
|
).run();
|
|
3820
|
-
for (const column of
|
|
3782
|
+
for (const column of model.schema.filter((column2) => column2.index)) {
|
|
3821
3783
|
db.prepare(
|
|
3822
|
-
`CREATE INDEX idx_${
|
|
3784
|
+
`CREATE INDEX idx_${model.filenameBase}_${column.name} ON ${model.filenameBase} (${column.name});`
|
|
3823
3785
|
).run();
|
|
3824
3786
|
}
|
|
3825
3787
|
}
|
|
3826
3788
|
};
|
|
3827
|
-
var formatLine = (line,
|
|
3789
|
+
var formatLine = (line, model, totalLineCount) => {
|
|
3828
3790
|
const lineNumber = totalLineCount + 1;
|
|
3829
3791
|
const formattedLine = {};
|
|
3830
|
-
for (const columnSchema of
|
|
3792
|
+
for (const columnSchema of model.schema) {
|
|
3831
3793
|
const lineValue = line[columnSchema.name];
|
|
3832
3794
|
if (columnSchema.type === "date") {
|
|
3833
3795
|
if (lineValue !== "" && lineValue !== void 0) {
|
|
3834
3796
|
const dateValue = lineValue.replace(/-/g, "");
|
|
3835
3797
|
if (dateValue.length !== 8) {
|
|
3836
3798
|
throw new Error(
|
|
3837
|
-
`Invalid date in ${
|
|
3799
|
+
`Invalid date in ${model.filenameBase}.${model.filenameExtension} for ${columnSchema.name} on line ${lineNumber}.`
|
|
3838
3800
|
);
|
|
3839
3801
|
}
|
|
3840
3802
|
formattedLine[columnSchema.name] = Number.parseInt(dateValue, 10);
|
|
@@ -3851,17 +3813,17 @@ var formatLine = (line, model56, totalLineCount) => {
|
|
|
3851
3813
|
}
|
|
3852
3814
|
if (columnSchema.required === true && formattedLine[columnSchema.name] === null) {
|
|
3853
3815
|
throw new Error(
|
|
3854
|
-
`Missing required value in ${
|
|
3816
|
+
`Missing required value in ${model.filenameBase}.${model.filenameExtension} for ${columnSchema.name} on line ${lineNumber}.`
|
|
3855
3817
|
);
|
|
3856
3818
|
}
|
|
3857
3819
|
if (columnSchema.min !== void 0 && formattedLine[columnSchema.name] < columnSchema.min) {
|
|
3858
3820
|
throw new Error(
|
|
3859
|
-
`Invalid value in ${
|
|
3821
|
+
`Invalid value in ${model.filenameBase}.${model.filenameExtension} for ${columnSchema.name} on line ${lineNumber}: below minimum value of ${columnSchema.min}.`
|
|
3860
3822
|
);
|
|
3861
3823
|
}
|
|
3862
3824
|
if (columnSchema.max !== void 0 && formattedLine[columnSchema.name] > columnSchema.max) {
|
|
3863
3825
|
throw new Error(
|
|
3864
|
-
`Invalid value in ${
|
|
3826
|
+
`Invalid value in ${model.filenameBase}.${model.filenameExtension} for ${columnSchema.name} on line ${lineNumber}: above maximum value of ${columnSchema.max}.`
|
|
3865
3827
|
);
|
|
3866
3828
|
}
|
|
3867
3829
|
}
|
|
@@ -3887,7 +3849,7 @@ var formatLine = (line, model56, totalLineCount) => {
|
|
|
3887
3849
|
}
|
|
3888
3850
|
return formattedLine;
|
|
3889
3851
|
};
|
|
3890
|
-
var importLines = (task, lines,
|
|
3852
|
+
var importLines = (task, lines, model, totalLineCount) => {
|
|
3891
3853
|
const db = openDb({
|
|
3892
3854
|
sqlitePath: task.sqlitePath
|
|
3893
3855
|
});
|
|
@@ -3895,7 +3857,7 @@ var importLines = (task, lines, model56, totalLineCount) => {
|
|
|
3895
3857
|
return;
|
|
3896
3858
|
}
|
|
3897
3859
|
const linesToImportCount = lines.length;
|
|
3898
|
-
const columns =
|
|
3860
|
+
const columns = model.schema.filter((column) => column.name !== "id");
|
|
3899
3861
|
const placeholders = [];
|
|
3900
3862
|
const values = [];
|
|
3901
3863
|
while (lines.length > 0) {
|
|
@@ -3915,59 +3877,59 @@ var importLines = (task, lines, model56, totalLineCount) => {
|
|
|
3915
3877
|
}
|
|
3916
3878
|
try {
|
|
3917
3879
|
db.prepare(
|
|
3918
|
-
`INSERT ${task.ignoreDuplicates ? "OR IGNORE" : ""} INTO ${
|
|
3880
|
+
`INSERT ${task.ignoreDuplicates ? "OR IGNORE" : ""} INTO ${model.filenameBase} (${columns.map((column) => column.name).join(", ")}) VALUES ${placeholders.join(",")}`
|
|
3919
3881
|
).run(...values);
|
|
3920
3882
|
} catch (error) {
|
|
3921
3883
|
if (error.code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
|
|
3922
|
-
const primaryColumns =
|
|
3884
|
+
const primaryColumns = model.schema.filter((column) => column.primary);
|
|
3923
3885
|
task.logWarning(
|
|
3924
|
-
`Duplicate values for primary key (${primaryColumns.map((column) => column.name).join(", ")}) found in ${
|
|
3886
|
+
`Duplicate values for primary key (${primaryColumns.map((column) => column.name).join(", ")}) found in ${model.filenameBase}.${model.filenameExtension}. Set the \`ignoreDuplicates\` option to true in config.json to ignore this error`
|
|
3925
3887
|
);
|
|
3926
3888
|
}
|
|
3927
3889
|
task.logWarning(
|
|
3928
|
-
`Check ${
|
|
3890
|
+
`Check ${model.filenameBase}.${model.filenameExtension} for invalid data between lines ${totalLineCount - linesToImportCount} and ${totalLineCount}.`
|
|
3929
3891
|
);
|
|
3930
3892
|
throw error;
|
|
3931
3893
|
}
|
|
3932
3894
|
task.log(
|
|
3933
|
-
`Importing - ${
|
|
3895
|
+
`Importing - ${model.filenameBase}.${model.filenameExtension} - ${totalLineCount} lines imported\r`,
|
|
3934
3896
|
true
|
|
3935
3897
|
);
|
|
3936
3898
|
};
|
|
3937
3899
|
var importFiles = (task) => mapSeries(
|
|
3938
|
-
|
|
3939
|
-
(
|
|
3900
|
+
Object.values(models_exports),
|
|
3901
|
+
(model) => new Promise((resolve, reject) => {
|
|
3940
3902
|
const lines = [];
|
|
3941
3903
|
let totalLineCount = 0;
|
|
3942
3904
|
const maxInsertVariables = 32e3;
|
|
3943
|
-
if (task.exclude && task.exclude.includes(
|
|
3905
|
+
if (task.exclude && task.exclude.includes(model.filenameBase)) {
|
|
3944
3906
|
task.log(
|
|
3945
|
-
`Skipping - ${
|
|
3907
|
+
`Skipping - ${model.filenameBase}.${model.filenameExtension}\r`
|
|
3946
3908
|
);
|
|
3947
3909
|
resolve();
|
|
3948
3910
|
return;
|
|
3949
3911
|
}
|
|
3950
|
-
if (
|
|
3912
|
+
if (model.extension === "gtfs-realtime") {
|
|
3951
3913
|
resolve();
|
|
3952
3914
|
return;
|
|
3953
3915
|
}
|
|
3954
3916
|
const filepath = path.join(
|
|
3955
3917
|
task.downloadDir,
|
|
3956
|
-
`${
|
|
3918
|
+
`${model.filenameBase}.${model.filenameExtension}`
|
|
3957
3919
|
);
|
|
3958
3920
|
if (!existsSync(filepath)) {
|
|
3959
|
-
if (!
|
|
3921
|
+
if (!model.nonstandard) {
|
|
3960
3922
|
task.log(
|
|
3961
|
-
`Importing - ${
|
|
3923
|
+
`Importing - ${model.filenameBase}.${model.filenameExtension} - No file found\r`
|
|
3962
3924
|
);
|
|
3963
3925
|
}
|
|
3964
3926
|
resolve();
|
|
3965
3927
|
return;
|
|
3966
3928
|
}
|
|
3967
3929
|
task.log(
|
|
3968
|
-
`Importing - ${
|
|
3930
|
+
`Importing - ${model.filenameBase}.${model.filenameExtension}\r`
|
|
3969
3931
|
);
|
|
3970
|
-
if (
|
|
3932
|
+
if (model.filenameExtension === "txt") {
|
|
3971
3933
|
const parser = parse({
|
|
3972
3934
|
columns: true,
|
|
3973
3935
|
relax_quotes: true,
|
|
@@ -3980,9 +3942,9 @@ var importFiles = (task) => mapSeries(
|
|
|
3980
3942
|
while (record = parser.read()) {
|
|
3981
3943
|
try {
|
|
3982
3944
|
totalLineCount += 1;
|
|
3983
|
-
lines.push(formatLine(record,
|
|
3984
|
-
if (lines.length >= maxInsertVariables /
|
|
3985
|
-
importLines(task, lines,
|
|
3945
|
+
lines.push(formatLine(record, model, totalLineCount));
|
|
3946
|
+
if (lines.length >= maxInsertVariables / model.schema.length) {
|
|
3947
|
+
importLines(task, lines, model, totalLineCount);
|
|
3986
3948
|
}
|
|
3987
3949
|
} catch (error) {
|
|
3988
3950
|
reject(error);
|
|
@@ -3991,7 +3953,7 @@ var importFiles = (task) => mapSeries(
|
|
|
3991
3953
|
});
|
|
3992
3954
|
parser.on("end", () => {
|
|
3993
3955
|
try {
|
|
3994
|
-
importLines(task, lines,
|
|
3956
|
+
importLines(task, lines, model, totalLineCount);
|
|
3995
3957
|
} catch (error) {
|
|
3996
3958
|
reject(error);
|
|
3997
3959
|
}
|
|
@@ -3999,22 +3961,22 @@ var importFiles = (task) => mapSeries(
|
|
|
3999
3961
|
});
|
|
4000
3962
|
parser.on("error", reject);
|
|
4001
3963
|
createReadStream(filepath).pipe(stripBomStream()).pipe(parser);
|
|
4002
|
-
} else if (
|
|
3964
|
+
} else if (model.filenameExtension === "geojson") {
|
|
4003
3965
|
readFile2(filepath, "utf8").then((data) => {
|
|
4004
3966
|
if (isValidJSON(data) === false) {
|
|
4005
3967
|
reject(
|
|
4006
3968
|
new Error(
|
|
4007
|
-
`Invalid JSON in ${
|
|
3969
|
+
`Invalid JSON in ${model.filenameBase}.${model.filenameExtension}`
|
|
4008
3970
|
)
|
|
4009
3971
|
);
|
|
4010
3972
|
}
|
|
4011
|
-
const line = formatLine({ geojson: data },
|
|
4012
|
-
importLines(task, [line],
|
|
3973
|
+
const line = formatLine({ geojson: data }, model, totalLineCount);
|
|
3974
|
+
importLines(task, [line], model, totalLineCount);
|
|
4013
3975
|
resolve();
|
|
4014
3976
|
}).catch(reject);
|
|
4015
3977
|
} else {
|
|
4016
3978
|
reject(
|
|
4017
|
-
new Error(`Unsupported file type: ${
|
|
3979
|
+
new Error(`Unsupported file type: ${model.filenameExtension}`)
|
|
4018
3980
|
);
|
|
4019
3981
|
}
|
|
4020
3982
|
})
|
|
@@ -4038,29 +4000,30 @@ async function importGtfs(initialConfig) {
|
|
|
4038
4000
|
createTables(db);
|
|
4039
4001
|
await mapSeries(
|
|
4040
4002
|
config.agencies,
|
|
4041
|
-
async (
|
|
4003
|
+
async (agency2) => {
|
|
4042
4004
|
const tempPath = temporaryDirectory();
|
|
4043
4005
|
const task = {
|
|
4044
|
-
exclude:
|
|
4045
|
-
|
|
4046
|
-
headers:
|
|
4047
|
-
|
|
4048
|
-
|
|
4006
|
+
exclude: agency2.exclude,
|
|
4007
|
+
url: agency2.url,
|
|
4008
|
+
headers: agency2.headers,
|
|
4009
|
+
realtimeAlerts: agency2.realtimeAlerts,
|
|
4010
|
+
realtimeTripUpdates: agency2.realtimeTripUpdates,
|
|
4011
|
+
realtimeVehiclePositions: agency2.realtimeVehiclePositions,
|
|
4049
4012
|
downloadDir: tempPath,
|
|
4050
4013
|
downloadTimeout: config.downloadTimeout,
|
|
4051
4014
|
gtfsRealtimeExpirationSeconds: config.gtfsRealtimeExpirationSeconds,
|
|
4052
|
-
path:
|
|
4015
|
+
path: agency2.path,
|
|
4053
4016
|
csvOptions: config.csvOptions || {},
|
|
4054
4017
|
ignoreDuplicates: config.ignoreDuplicates,
|
|
4055
4018
|
sqlitePath: config.sqlitePath,
|
|
4056
|
-
prefix:
|
|
4019
|
+
prefix: agency2.prefix,
|
|
4057
4020
|
currentTimestamp: Math.floor(Date.now() / 1e3),
|
|
4058
4021
|
log: log2,
|
|
4059
4022
|
logWarning: logWarning2,
|
|
4060
4023
|
logError: logError2
|
|
4061
4024
|
};
|
|
4062
4025
|
try {
|
|
4063
|
-
if (task.
|
|
4026
|
+
if (task.url) {
|
|
4064
4027
|
await downloadFiles(task);
|
|
4065
4028
|
}
|
|
4066
4029
|
await readFiles(task);
|
|
@@ -4107,13 +4070,11 @@ async function updateGtfsRealtime(initialConfig) {
|
|
|
4107
4070
|
);
|
|
4108
4071
|
deleteExpiredRealtimeData(config);
|
|
4109
4072
|
await Promise.all(
|
|
4110
|
-
config.agencies.map(async (
|
|
4111
|
-
if (agency.realtimeUrls === void 0) {
|
|
4112
|
-
return;
|
|
4113
|
-
}
|
|
4073
|
+
config.agencies.map(async (agency2) => {
|
|
4114
4074
|
const task = {
|
|
4115
|
-
|
|
4116
|
-
|
|
4075
|
+
realtimeAlerts: agency2.realtimeAlerts,
|
|
4076
|
+
realtimeTripUpdates: agency2.realtimeTripUpdates,
|
|
4077
|
+
realtimeVehiclePositions: agency2.realtimeVehiclePositions,
|
|
4117
4078
|
downloadTimeout: config.downloadTimeout,
|
|
4118
4079
|
gtfsRealtimeExpirationSeconds: config.gtfsRealtimeExpirationSeconds,
|
|
4119
4080
|
sqlitePath: config.sqlitePath,
|
|
@@ -4136,7 +4097,7 @@ async function updateGtfsRealtime(initialConfig) {
|
|
|
4136
4097
|
} catch (error) {
|
|
4137
4098
|
if (error?.code === "SQLITE_CANTOPEN") {
|
|
4138
4099
|
logError2(
|
|
4139
|
-
`
|
|
4100
|
+
`Unable to open sqlite database "${config.sqlitePath}" defined as \`sqlitePath\` config.json. Ensure the parent directory exists or remove \`sqlitePath\` from config.json.`
|
|
4140
4101
|
);
|
|
4141
4102
|
}
|
|
4142
4103
|
throw error;
|
|
@@ -4193,27 +4154,27 @@ var exportGtfs = async (initialConfig) => {
|
|
|
4193
4154
|
const defaultExportPath = path2.join(process.cwd(), "gtfs-export", folderName);
|
|
4194
4155
|
const exportPath = untildify4(config.exportPath || defaultExportPath);
|
|
4195
4156
|
await prepDirectory(exportPath);
|
|
4196
|
-
const modelsToExport =
|
|
4197
|
-
(
|
|
4157
|
+
const modelsToExport = Object.values(models_exports).filter(
|
|
4158
|
+
(model) => model.extension !== "gtfs-realtime"
|
|
4198
4159
|
);
|
|
4199
4160
|
const exportedFiles = await mapSeries2(
|
|
4200
4161
|
modelsToExport,
|
|
4201
|
-
async (
|
|
4162
|
+
async (model) => {
|
|
4202
4163
|
const filePath = path2.join(
|
|
4203
4164
|
exportPath,
|
|
4204
|
-
`${
|
|
4165
|
+
`${model.filenameBase}.${model.filenameExtension}`
|
|
4205
4166
|
);
|
|
4206
|
-
const tableName = sqlString3.escapeId(
|
|
4167
|
+
const tableName = sqlString3.escapeId(model.filenameBase);
|
|
4207
4168
|
const lines = db.prepare(`SELECT * FROM ${tableName};`).all();
|
|
4208
4169
|
if (!lines || lines.length === 0) {
|
|
4209
|
-
if (!
|
|
4170
|
+
if (!model.nonstandard) {
|
|
4210
4171
|
log2(
|
|
4211
|
-
`Skipping (no data) - ${
|
|
4172
|
+
`Skipping (no data) - ${model.filenameBase}.${model.filenameExtension}\r`
|
|
4212
4173
|
);
|
|
4213
4174
|
}
|
|
4214
4175
|
return;
|
|
4215
4176
|
}
|
|
4216
|
-
if (
|
|
4177
|
+
if (model.filenameExtension === "txt") {
|
|
4217
4178
|
const excludeColumns = [
|
|
4218
4179
|
"id",
|
|
4219
4180
|
"arrival_timestamp",
|
|
@@ -4227,7 +4188,7 @@ var exportGtfs = async (initialConfig) => {
|
|
|
4227
4188
|
"ridership_start_timestamp",
|
|
4228
4189
|
"ridership_end_timestamp"
|
|
4229
4190
|
];
|
|
4230
|
-
if (
|
|
4191
|
+
if (model.filenameBase === "routes") {
|
|
4231
4192
|
const routesWithAgencyId = db.prepare(
|
|
4232
4193
|
"SELECT agency_id FROM routes WHERE agency_id IS NOT NULL;"
|
|
4233
4194
|
).all();
|
|
@@ -4236,21 +4197,21 @@ var exportGtfs = async (initialConfig) => {
|
|
|
4236
4197
|
}
|
|
4237
4198
|
}
|
|
4238
4199
|
const columns = without(
|
|
4239
|
-
|
|
4200
|
+
model.schema.map((column) => column.name),
|
|
4240
4201
|
...excludeColumns
|
|
4241
4202
|
);
|
|
4242
4203
|
const fileText = await stringify(lines, { columns, header: true });
|
|
4243
4204
|
await writeFile2(filePath, fileText);
|
|
4244
|
-
} else if (
|
|
4205
|
+
} else if (model.filenameExtension === "geojson") {
|
|
4245
4206
|
const fileText = lines?.[0].geojson ?? "";
|
|
4246
4207
|
await writeFile2(filePath, fileText);
|
|
4247
4208
|
} else {
|
|
4248
4209
|
throw new Error(
|
|
4249
|
-
`Unexpected filename extension: ${
|
|
4210
|
+
`Unexpected filename extension: ${model.filenameExtension}`
|
|
4250
4211
|
);
|
|
4251
4212
|
}
|
|
4252
|
-
log2(`Exporting - ${
|
|
4253
|
-
return `${
|
|
4213
|
+
log2(`Exporting - ${model.filenameBase}.${model.filenameExtension}\r`);
|
|
4214
|
+
return `${model.filenameBase}.${model.filenameExtension}`;
|
|
4254
4215
|
}
|
|
4255
4216
|
);
|
|
4256
4217
|
if (compact(exportedFiles).length === 0) {
|
|
@@ -4285,10 +4246,9 @@ function advancedQuery(table, advancedQueryOptions) {
|
|
|
4285
4246
|
}
|
|
4286
4247
|
|
|
4287
4248
|
// src/lib/gtfs/agencies.ts
|
|
4288
|
-
import sqlString5 from "sqlstring-sqlite";
|
|
4289
4249
|
function getAgencies2(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4290
4250
|
const db = options.db ?? openDb();
|
|
4291
|
-
const tableName =
|
|
4251
|
+
const tableName = "agency";
|
|
4292
4252
|
const selectClause = formatSelectClause(fields);
|
|
4293
4253
|
const whereClause = formatWhereClauses(query);
|
|
4294
4254
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4298,10 +4258,9 @@ function getAgencies2(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4298
4258
|
}
|
|
4299
4259
|
|
|
4300
4260
|
// src/lib/gtfs/areas.ts
|
|
4301
|
-
import sqlString6 from "sqlstring-sqlite";
|
|
4302
4261
|
function getAreas(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4303
4262
|
const db = options.db ?? openDb();
|
|
4304
|
-
const tableName =
|
|
4263
|
+
const tableName = "areas";
|
|
4305
4264
|
const selectClause = formatSelectClause(fields);
|
|
4306
4265
|
const whereClause = formatWhereClauses(query);
|
|
4307
4266
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4311,10 +4270,9 @@ function getAreas(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4311
4270
|
}
|
|
4312
4271
|
|
|
4313
4272
|
// src/lib/gtfs/attributions.ts
|
|
4314
|
-
import sqlString7 from "sqlstring-sqlite";
|
|
4315
4273
|
function getAttributions(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4316
4274
|
const db = options.db ?? openDb();
|
|
4317
|
-
const tableName =
|
|
4275
|
+
const tableName = "attributions";
|
|
4318
4276
|
const selectClause = formatSelectClause(fields);
|
|
4319
4277
|
const whereClause = formatWhereClauses(query);
|
|
4320
4278
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4324,10 +4282,9 @@ function getAttributions(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4324
4282
|
}
|
|
4325
4283
|
|
|
4326
4284
|
// src/lib/gtfs/booking-rules.ts
|
|
4327
|
-
import sqlString8 from "sqlstring-sqlite";
|
|
4328
4285
|
function getBookingRules(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4329
4286
|
const db = options.db ?? openDb();
|
|
4330
|
-
const tableName =
|
|
4287
|
+
const tableName = "booking_rules";
|
|
4331
4288
|
const selectClause = formatSelectClause(fields);
|
|
4332
4289
|
const whereClause = formatWhereClauses(query);
|
|
4333
4290
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4337,10 +4294,9 @@ function getBookingRules(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4337
4294
|
}
|
|
4338
4295
|
|
|
4339
4296
|
// src/lib/gtfs/calendar-dates.ts
|
|
4340
|
-
import sqlString9 from "sqlstring-sqlite";
|
|
4341
4297
|
function getCalendarDates(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4342
4298
|
const db = options.db ?? openDb();
|
|
4343
|
-
const tableName =
|
|
4299
|
+
const tableName = "calendar_dates";
|
|
4344
4300
|
const selectClause = formatSelectClause(fields);
|
|
4345
4301
|
const whereClause = formatWhereClauses(query);
|
|
4346
4302
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4350,10 +4306,9 @@ function getCalendarDates(query = {}, fields = [], orderBy2 = [], options = {})
|
|
|
4350
4306
|
}
|
|
4351
4307
|
|
|
4352
4308
|
// src/lib/gtfs/calendars.ts
|
|
4353
|
-
import sqlString10 from "sqlstring-sqlite";
|
|
4354
4309
|
function getCalendars(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4355
4310
|
const db = options.db ?? openDb();
|
|
4356
|
-
const tableName =
|
|
4311
|
+
const tableName = "calendar";
|
|
4357
4312
|
const selectClause = formatSelectClause(fields);
|
|
4358
4313
|
const whereClause = formatWhereClauses(query);
|
|
4359
4314
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4363,10 +4318,9 @@ function getCalendars(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4363
4318
|
}
|
|
4364
4319
|
|
|
4365
4320
|
// src/lib/gtfs/fare-attributes.ts
|
|
4366
|
-
import sqlString11 from "sqlstring-sqlite";
|
|
4367
4321
|
function getFareAttributes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4368
4322
|
const db = options.db ?? openDb();
|
|
4369
|
-
const tableName =
|
|
4323
|
+
const tableName = "fare_attributes";
|
|
4370
4324
|
const selectClause = formatSelectClause(fields);
|
|
4371
4325
|
const whereClause = formatWhereClauses(query);
|
|
4372
4326
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4376,10 +4330,9 @@ function getFareAttributes(query = {}, fields = [], orderBy2 = [], options = {})
|
|
|
4376
4330
|
}
|
|
4377
4331
|
|
|
4378
4332
|
// src/lib/gtfs/fare-leg-rules.ts
|
|
4379
|
-
import sqlString12 from "sqlstring-sqlite";
|
|
4380
4333
|
function getFareLegRules(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4381
4334
|
const db = options.db ?? openDb();
|
|
4382
|
-
const tableName =
|
|
4335
|
+
const tableName = "fare_leg_rules";
|
|
4383
4336
|
const selectClause = formatSelectClause(fields);
|
|
4384
4337
|
const whereClause = formatWhereClauses(query);
|
|
4385
4338
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4389,10 +4342,9 @@ function getFareLegRules(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4389
4342
|
}
|
|
4390
4343
|
|
|
4391
4344
|
// src/lib/gtfs/fare-media.ts
|
|
4392
|
-
import sqlString13 from "sqlstring-sqlite";
|
|
4393
4345
|
function getFareMedia(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4394
4346
|
const db = options.db ?? openDb();
|
|
4395
|
-
const tableName =
|
|
4347
|
+
const tableName = "fare_media";
|
|
4396
4348
|
const selectClause = formatSelectClause(fields);
|
|
4397
4349
|
const whereClause = formatWhereClauses(query);
|
|
4398
4350
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4402,10 +4354,9 @@ function getFareMedia(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4402
4354
|
}
|
|
4403
4355
|
|
|
4404
4356
|
// src/lib/gtfs/fare-products.ts
|
|
4405
|
-
import sqlString14 from "sqlstring-sqlite";
|
|
4406
4357
|
function getFareProducts(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4407
4358
|
const db = options.db ?? openDb();
|
|
4408
|
-
const tableName =
|
|
4359
|
+
const tableName = "fare_products";
|
|
4409
4360
|
const selectClause = formatSelectClause(fields);
|
|
4410
4361
|
const whereClause = formatWhereClauses(query);
|
|
4411
4362
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4415,10 +4366,9 @@ function getFareProducts(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4415
4366
|
}
|
|
4416
4367
|
|
|
4417
4368
|
// src/lib/gtfs/fare-rules.ts
|
|
4418
|
-
import sqlString15 from "sqlstring-sqlite";
|
|
4419
4369
|
function getFareRules(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4420
4370
|
const db = options.db ?? openDb();
|
|
4421
|
-
const tableName =
|
|
4371
|
+
const tableName = "fare_rules";
|
|
4422
4372
|
const selectClause = formatSelectClause(fields);
|
|
4423
4373
|
const whereClause = formatWhereClauses(query);
|
|
4424
4374
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4428,10 +4378,9 @@ function getFareRules(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4428
4378
|
}
|
|
4429
4379
|
|
|
4430
4380
|
// src/lib/gtfs/fare-transfer-rules.ts
|
|
4431
|
-
import sqlString16 from "sqlstring-sqlite";
|
|
4432
4381
|
function getFareTransferRules(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4433
4382
|
const db = options.db ?? openDb();
|
|
4434
|
-
const tableName =
|
|
4383
|
+
const tableName = "fare_transfer_rules";
|
|
4435
4384
|
const selectClause = formatSelectClause(fields);
|
|
4436
4385
|
const whereClause = formatWhereClauses(query);
|
|
4437
4386
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4441,10 +4390,9 @@ function getFareTransferRules(query = {}, fields = [], orderBy2 = [], options =
|
|
|
4441
4390
|
}
|
|
4442
4391
|
|
|
4443
4392
|
// src/lib/gtfs/feed-info.ts
|
|
4444
|
-
import sqlString17 from "sqlstring-sqlite";
|
|
4445
4393
|
function getFeedInfo(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4446
4394
|
const db = options.db ?? openDb();
|
|
4447
|
-
const tableName =
|
|
4395
|
+
const tableName = "feed_info";
|
|
4448
4396
|
const selectClause = formatSelectClause(fields);
|
|
4449
4397
|
const whereClause = formatWhereClauses(query);
|
|
4450
4398
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4454,10 +4402,9 @@ function getFeedInfo(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4454
4402
|
}
|
|
4455
4403
|
|
|
4456
4404
|
// src/lib/gtfs/frequencies.ts
|
|
4457
|
-
import sqlString18 from "sqlstring-sqlite";
|
|
4458
4405
|
function getFrequencies(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4459
4406
|
const db = options.db ?? openDb();
|
|
4460
|
-
const tableName =
|
|
4407
|
+
const tableName = "frequencies";
|
|
4461
4408
|
const selectClause = formatSelectClause(fields);
|
|
4462
4409
|
const whereClause = formatWhereClauses(query);
|
|
4463
4410
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4467,10 +4414,9 @@ function getFrequencies(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4467
4414
|
}
|
|
4468
4415
|
|
|
4469
4416
|
// src/lib/gtfs/levels.ts
|
|
4470
|
-
import sqlString19 from "sqlstring-sqlite";
|
|
4471
4417
|
function getLevels(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4472
4418
|
const db = options.db ?? openDb();
|
|
4473
|
-
const tableName =
|
|
4419
|
+
const tableName = "levels";
|
|
4474
4420
|
const selectClause = formatSelectClause(fields);
|
|
4475
4421
|
const whereClause = formatWhereClauses(query);
|
|
4476
4422
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4480,10 +4426,9 @@ function getLevels(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4480
4426
|
}
|
|
4481
4427
|
|
|
4482
4428
|
// src/lib/gtfs/location-groups.ts
|
|
4483
|
-
import sqlString20 from "sqlstring-sqlite";
|
|
4484
4429
|
function getLocationGroups(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4485
4430
|
const db = options.db ?? openDb();
|
|
4486
|
-
const tableName =
|
|
4431
|
+
const tableName = "location_groups";
|
|
4487
4432
|
const selectClause = formatSelectClause(fields);
|
|
4488
4433
|
const whereClause = formatWhereClauses(query);
|
|
4489
4434
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4493,10 +4438,9 @@ function getLocationGroups(query = {}, fields = [], orderBy2 = [], options = {})
|
|
|
4493
4438
|
}
|
|
4494
4439
|
|
|
4495
4440
|
// src/lib/gtfs/location-group-stops.ts
|
|
4496
|
-
import sqlString21 from "sqlstring-sqlite";
|
|
4497
4441
|
function getLocationGroupStops(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4498
4442
|
const db = options.db ?? openDb();
|
|
4499
|
-
const tableName =
|
|
4443
|
+
const tableName = "location_group_stops";
|
|
4500
4444
|
const selectClause = formatSelectClause(fields);
|
|
4501
4445
|
const whereClause = formatWhereClauses(query);
|
|
4502
4446
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4506,10 +4450,9 @@ function getLocationGroupStops(query = {}, fields = [], orderBy2 = [], options =
|
|
|
4506
4450
|
}
|
|
4507
4451
|
|
|
4508
4452
|
// src/lib/gtfs/locations.ts
|
|
4509
|
-
import sqlString22 from "sqlstring-sqlite";
|
|
4510
4453
|
function getLocations(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4511
4454
|
const db = options.db ?? openDb();
|
|
4512
|
-
const tableName =
|
|
4455
|
+
const tableName = "locations";
|
|
4513
4456
|
const selectClause = formatSelectClause(fields);
|
|
4514
4457
|
const whereClause = formatWhereClauses(query);
|
|
4515
4458
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4519,10 +4462,9 @@ function getLocations(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4519
4462
|
}
|
|
4520
4463
|
|
|
4521
4464
|
// src/lib/gtfs/networks.ts
|
|
4522
|
-
import sqlString23 from "sqlstring-sqlite";
|
|
4523
4465
|
function getNetworks(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4524
4466
|
const db = options.db ?? openDb();
|
|
4525
|
-
const tableName =
|
|
4467
|
+
const tableName = "networks";
|
|
4526
4468
|
const selectClause = formatSelectClause(fields);
|
|
4527
4469
|
const whereClause = formatWhereClauses(query);
|
|
4528
4470
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4532,10 +4474,9 @@ function getNetworks(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4532
4474
|
}
|
|
4533
4475
|
|
|
4534
4476
|
// src/lib/gtfs/pathways.ts
|
|
4535
|
-
import sqlString24 from "sqlstring-sqlite";
|
|
4536
4477
|
function getPathways(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4537
4478
|
const db = options.db ?? openDb();
|
|
4538
|
-
const tableName =
|
|
4479
|
+
const tableName = "pathways";
|
|
4539
4480
|
const selectClause = formatSelectClause(fields);
|
|
4540
4481
|
const whereClause = formatWhereClauses(query);
|
|
4541
4482
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4545,10 +4486,9 @@ function getPathways(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4545
4486
|
}
|
|
4546
4487
|
|
|
4547
4488
|
// src/lib/gtfs/route-networks.ts
|
|
4548
|
-
import sqlString25 from "sqlstring-sqlite";
|
|
4549
4489
|
function getRouteNetworks(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4550
4490
|
const db = options.db ?? openDb();
|
|
4551
|
-
const tableName =
|
|
4491
|
+
const tableName = "route_networks";
|
|
4552
4492
|
const selectClause = formatSelectClause(fields);
|
|
4553
4493
|
const whereClause = formatWhereClauses(query);
|
|
4554
4494
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4559,7 +4499,6 @@ function getRouteNetworks(query = {}, fields = [], orderBy2 = [], options = {})
|
|
|
4559
4499
|
|
|
4560
4500
|
// src/lib/gtfs/routes.ts
|
|
4561
4501
|
import { omit as omit3, pick } from "lodash-es";
|
|
4562
|
-
import sqlString26 from "sqlstring-sqlite";
|
|
4563
4502
|
function buildStoptimeSubquery(query) {
|
|
4564
4503
|
const whereClause = formatWhereClauses(query);
|
|
4565
4504
|
return `SELECT DISTINCT trip_id FROM stop_times ${whereClause}`;
|
|
@@ -4581,7 +4520,7 @@ function buildTripSubquery(query) {
|
|
|
4581
4520
|
}
|
|
4582
4521
|
function getRoutes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4583
4522
|
const db = options.db ?? openDb();
|
|
4584
|
-
const tableName =
|
|
4523
|
+
const tableName = "routes";
|
|
4585
4524
|
const selectClause = formatSelectClause(fields);
|
|
4586
4525
|
let whereClause = "";
|
|
4587
4526
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4606,14 +4545,12 @@ function getRoutes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4606
4545
|
|
|
4607
4546
|
// src/lib/gtfs/shapes.ts
|
|
4608
4547
|
import { compact as compact2, omit as omit4, pick as pick2 } from "lodash-es";
|
|
4609
|
-
import sqlString28 from "sqlstring-sqlite";
|
|
4610
4548
|
import { featureCollection as featureCollection2 } from "@turf/helpers";
|
|
4611
4549
|
|
|
4612
4550
|
// src/lib/gtfs-plus/route-attributes.ts
|
|
4613
|
-
import sqlString27 from "sqlstring-sqlite";
|
|
4614
4551
|
function getRouteAttributes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4615
4552
|
const db = options.db ?? openDb();
|
|
4616
|
-
const tableName =
|
|
4553
|
+
const tableName = "route_attributes";
|
|
4617
4554
|
const selectClause = formatSelectClause(fields);
|
|
4618
4555
|
const whereClause = formatWhereClauses(query);
|
|
4619
4556
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4629,7 +4566,7 @@ function buildTripSubquery2(query) {
|
|
|
4629
4566
|
}
|
|
4630
4567
|
function getShapes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4631
4568
|
const db = options.db ?? openDb();
|
|
4632
|
-
const tableName =
|
|
4569
|
+
const tableName = "shapes";
|
|
4633
4570
|
const selectClause = formatSelectClause(fields);
|
|
4634
4571
|
let whereClause = "";
|
|
4635
4572
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4656,48 +4593,47 @@ function getShapes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4656
4593
|
function getShapesAsGeoJSON(query = {}, options = {}) {
|
|
4657
4594
|
const agencies = getAgencies2({}, [], [], options);
|
|
4658
4595
|
const routeQuery = pick2(query, ["route_id"]);
|
|
4659
|
-
const
|
|
4596
|
+
const routes2 = getRoutes(routeQuery, [], [], options);
|
|
4660
4597
|
const features = compact2(
|
|
4661
|
-
|
|
4598
|
+
routes2.map((route) => {
|
|
4662
4599
|
const shapeQuery = {
|
|
4663
4600
|
route_id: route.route_id,
|
|
4664
4601
|
...omit4(query, "route_id")
|
|
4665
4602
|
};
|
|
4666
|
-
const
|
|
4603
|
+
const shapes2 = getShapes(
|
|
4667
4604
|
shapeQuery,
|
|
4668
4605
|
["shape_id", "shape_pt_sequence", "shape_pt_lon", "shape_pt_lat"],
|
|
4669
4606
|
[],
|
|
4670
4607
|
options
|
|
4671
4608
|
);
|
|
4672
|
-
if (
|
|
4609
|
+
if (shapes2.length === 0) {
|
|
4673
4610
|
return;
|
|
4674
4611
|
}
|
|
4675
|
-
const
|
|
4612
|
+
const routeAttributes2 = getRouteAttributes(
|
|
4676
4613
|
{ route_id: route.route_id },
|
|
4677
4614
|
[],
|
|
4678
4615
|
[],
|
|
4679
4616
|
options
|
|
4680
4617
|
);
|
|
4681
|
-
const
|
|
4682
|
-
(
|
|
4618
|
+
const agency2 = agencies.find(
|
|
4619
|
+
(agency3) => agency3.agency_id === route.agency_id
|
|
4683
4620
|
);
|
|
4684
4621
|
const geojsonProperties = {
|
|
4685
|
-
agency_name:
|
|
4622
|
+
agency_name: agency2 ? agency2.agency_name : void 0,
|
|
4686
4623
|
shape_id: query.shape_id,
|
|
4687
4624
|
...route,
|
|
4688
|
-
...
|
|
4625
|
+
...routeAttributes2?.[0] || []
|
|
4689
4626
|
};
|
|
4690
|
-
return shapesToGeoJSONFeature(
|
|
4627
|
+
return shapesToGeoJSONFeature(shapes2, geojsonProperties);
|
|
4691
4628
|
})
|
|
4692
4629
|
);
|
|
4693
4630
|
return featureCollection2(features);
|
|
4694
4631
|
}
|
|
4695
4632
|
|
|
4696
4633
|
// src/lib/gtfs/stop-areas.ts
|
|
4697
|
-
import sqlString29 from "sqlstring-sqlite";
|
|
4698
4634
|
function getStopAreas(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4699
4635
|
const db = options.db ?? openDb();
|
|
4700
|
-
const tableName =
|
|
4636
|
+
const tableName = "stop_areas";
|
|
4701
4637
|
const selectClause = formatSelectClause(fields);
|
|
4702
4638
|
const whereClause = formatWhereClauses(query);
|
|
4703
4639
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4708,13 +4644,11 @@ function getStopAreas(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4708
4644
|
|
|
4709
4645
|
// src/lib/gtfs/stops.ts
|
|
4710
4646
|
import { omit as omit5, orderBy, pick as pick3 } from "lodash-es";
|
|
4711
|
-
import sqlString31 from "sqlstring-sqlite";
|
|
4712
4647
|
|
|
4713
4648
|
// src/lib/gtfs-plus/stop-attributes.ts
|
|
4714
|
-
import sqlString30 from "sqlstring-sqlite";
|
|
4715
4649
|
function getStopAttributes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4716
4650
|
const db = options.db ?? openDb();
|
|
4717
|
-
const tableName =
|
|
4651
|
+
const tableName = "stop_attributes";
|
|
4718
4652
|
const selectClause = formatSelectClause(fields);
|
|
4719
4653
|
const whereClause = formatWhereClauses(query);
|
|
4720
4654
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4735,7 +4669,7 @@ function buildStoptimeSubquery2(query) {
|
|
|
4735
4669
|
}
|
|
4736
4670
|
function getStops(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4737
4671
|
const db = options.db ?? openDb();
|
|
4738
|
-
const tableName =
|
|
4672
|
+
const tableName = "stops";
|
|
4739
4673
|
const selectClause = formatSelectClause(fields);
|
|
4740
4674
|
let whereClause = "";
|
|
4741
4675
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4781,20 +4715,20 @@ function getStops(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4781
4715
|
}
|
|
4782
4716
|
function getStopsAsGeoJSON(query = {}, options = {}) {
|
|
4783
4717
|
const db = options.db ?? openDb();
|
|
4784
|
-
const
|
|
4718
|
+
const stops2 = getStops(query, [], [], options);
|
|
4785
4719
|
const agencies = getAgencies2({}, [], [], options);
|
|
4786
|
-
const preparedStops =
|
|
4720
|
+
const preparedStops = stops2.map((stop) => {
|
|
4787
4721
|
const routeSubquery = "SELECT DISTINCT route_id FROM trips WHERE trip_id IN (SELECT DISTINCT trip_id FROM stop_times WHERE stop_id = ?)";
|
|
4788
|
-
const
|
|
4789
|
-
const
|
|
4722
|
+
const routes2 = db.prepare(`SELECT * FROM routes WHERE route_id IN (${routeSubquery})`).all(stop.stop_id);
|
|
4723
|
+
const stopAttributes2 = getStopAttributes({ stop_id: stop.stop_id });
|
|
4790
4724
|
stop.routes = orderBy(
|
|
4791
|
-
|
|
4725
|
+
routes2,
|
|
4792
4726
|
(route) => route?.route_short_name ? Number.parseInt(route.route_short_name, 10) : 0
|
|
4793
4727
|
);
|
|
4794
4728
|
stop.agency_name = agencies[0].agency_name;
|
|
4795
4729
|
return {
|
|
4796
4730
|
...stop,
|
|
4797
|
-
...
|
|
4731
|
+
...stopAttributes2?.[0] || []
|
|
4798
4732
|
};
|
|
4799
4733
|
});
|
|
4800
4734
|
const filteredStops = preparedStops.filter((stop) => stop.routes.length > 0);
|
|
@@ -4802,10 +4736,9 @@ function getStopsAsGeoJSON(query = {}, options = {}) {
|
|
|
4802
4736
|
}
|
|
4803
4737
|
|
|
4804
4738
|
// src/lib/gtfs/stop-times.ts
|
|
4805
|
-
import sqlString32 from "sqlstring-sqlite";
|
|
4806
4739
|
function getStoptimes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4807
4740
|
const db = options.db ?? openDb();
|
|
4808
|
-
const tableName =
|
|
4741
|
+
const tableName = "stop_times";
|
|
4809
4742
|
const selectClause = formatSelectClause(fields);
|
|
4810
4743
|
const whereClause = formatWhereClauses(query);
|
|
4811
4744
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4815,10 +4748,9 @@ function getStoptimes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4815
4748
|
}
|
|
4816
4749
|
|
|
4817
4750
|
// src/lib/gtfs/timeframes.ts
|
|
4818
|
-
import sqlString33 from "sqlstring-sqlite";
|
|
4819
4751
|
function getTimeframes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4820
4752
|
const db = options.db ?? openDb();
|
|
4821
|
-
const tableName =
|
|
4753
|
+
const tableName = "timeframes";
|
|
4822
4754
|
const selectClause = formatSelectClause(fields);
|
|
4823
4755
|
const whereClause = formatWhereClauses(query);
|
|
4824
4756
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4828,10 +4760,9 @@ function getTimeframes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4828
4760
|
}
|
|
4829
4761
|
|
|
4830
4762
|
// src/lib/gtfs/transfers.ts
|
|
4831
|
-
import sqlString34 from "sqlstring-sqlite";
|
|
4832
4763
|
function getTransfers(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4833
4764
|
const db = options.db ?? openDb();
|
|
4834
|
-
const tableName =
|
|
4765
|
+
const tableName = "transfers";
|
|
4835
4766
|
const selectClause = formatSelectClause(fields);
|
|
4836
4767
|
const whereClause = formatWhereClauses(query);
|
|
4837
4768
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4841,10 +4772,9 @@ function getTransfers(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4841
4772
|
}
|
|
4842
4773
|
|
|
4843
4774
|
// src/lib/gtfs/translations.ts
|
|
4844
|
-
import sqlString35 from "sqlstring-sqlite";
|
|
4845
4775
|
function getTranslations(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4846
4776
|
const db = options.db ?? openDb();
|
|
4847
|
-
const tableName =
|
|
4777
|
+
const tableName = "translations";
|
|
4848
4778
|
const selectClause = formatSelectClause(fields);
|
|
4849
4779
|
const whereClause = formatWhereClauses(query);
|
|
4850
4780
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4854,10 +4784,9 @@ function getTranslations(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4854
4784
|
}
|
|
4855
4785
|
|
|
4856
4786
|
// src/lib/gtfs/trips.ts
|
|
4857
|
-
import sqlString36 from "sqlstring-sqlite";
|
|
4858
4787
|
function getTrips(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4859
4788
|
const db = options.db ?? openDb();
|
|
4860
|
-
const tableName =
|
|
4789
|
+
const tableName = "trips";
|
|
4861
4790
|
const selectClause = formatSelectClause(fields);
|
|
4862
4791
|
const whereClause = formatWhereClauses(query);
|
|
4863
4792
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4867,10 +4796,9 @@ function getTrips(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4867
4796
|
}
|
|
4868
4797
|
|
|
4869
4798
|
// src/lib/gtfs-plus/calendar-attributes.ts
|
|
4870
|
-
import sqlString37 from "sqlstring-sqlite";
|
|
4871
4799
|
function getCalendarAttributes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4872
4800
|
const db = options.db ?? openDb();
|
|
4873
|
-
const tableName =
|
|
4801
|
+
const tableName = "calendar_attributes";
|
|
4874
4802
|
const selectClause = formatSelectClause(fields);
|
|
4875
4803
|
const whereClause = formatWhereClauses(query);
|
|
4876
4804
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4880,10 +4808,9 @@ function getCalendarAttributes(query = {}, fields = [], orderBy2 = [], options =
|
|
|
4880
4808
|
}
|
|
4881
4809
|
|
|
4882
4810
|
// src/lib/gtfs-plus/directions.ts
|
|
4883
|
-
import sqlString38 from "sqlstring-sqlite";
|
|
4884
4811
|
function getDirections(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4885
4812
|
const db = options.db ?? openDb();
|
|
4886
|
-
const tableName =
|
|
4813
|
+
const tableName = "directions";
|
|
4887
4814
|
const selectClause = formatSelectClause(fields);
|
|
4888
4815
|
const whereClause = formatWhereClauses(query);
|
|
4889
4816
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4893,10 +4820,9 @@ function getDirections(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4893
4820
|
}
|
|
4894
4821
|
|
|
4895
4822
|
// src/lib/non-standard/timetables.ts
|
|
4896
|
-
import sqlString39 from "sqlstring-sqlite";
|
|
4897
4823
|
function getTimetables(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4898
4824
|
const db = options.db ?? openDb();
|
|
4899
|
-
const tableName =
|
|
4825
|
+
const tableName = "timetables";
|
|
4900
4826
|
const selectClause = formatSelectClause(fields);
|
|
4901
4827
|
const whereClause = formatWhereClauses(query);
|
|
4902
4828
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4906,10 +4832,9 @@ function getTimetables(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4906
4832
|
}
|
|
4907
4833
|
|
|
4908
4834
|
// src/lib/non-standard/timetable-stop-order.ts
|
|
4909
|
-
import sqlString40 from "sqlstring-sqlite";
|
|
4910
4835
|
function getTimetableStopOrders(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4911
4836
|
const db = options.db ?? openDb();
|
|
4912
|
-
const tableName =
|
|
4837
|
+
const tableName = "timetable_stop_order";
|
|
4913
4838
|
const selectClause = formatSelectClause(fields);
|
|
4914
4839
|
const whereClause = formatWhereClauses(query);
|
|
4915
4840
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4919,10 +4844,9 @@ function getTimetableStopOrders(query = {}, fields = [], orderBy2 = [], options
|
|
|
4919
4844
|
}
|
|
4920
4845
|
|
|
4921
4846
|
// src/lib/non-standard/timetable-pages.ts
|
|
4922
|
-
import sqlString41 from "sqlstring-sqlite";
|
|
4923
4847
|
function getTimetablePages(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4924
4848
|
const db = options.db ?? openDb();
|
|
4925
|
-
const tableName =
|
|
4849
|
+
const tableName = "timetable_pages";
|
|
4926
4850
|
const selectClause = formatSelectClause(fields);
|
|
4927
4851
|
const whereClause = formatWhereClauses(query);
|
|
4928
4852
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4932,10 +4856,9 @@ function getTimetablePages(query = {}, fields = [], orderBy2 = [], options = {})
|
|
|
4932
4856
|
}
|
|
4933
4857
|
|
|
4934
4858
|
// src/lib/non-standard/timetable-notes.ts
|
|
4935
|
-
import sqlString42 from "sqlstring-sqlite";
|
|
4936
4859
|
function getTimetableNotes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4937
4860
|
const db = options.db ?? openDb();
|
|
4938
|
-
const tableName =
|
|
4861
|
+
const tableName = "timetable_notes";
|
|
4939
4862
|
const selectClause = formatSelectClause(fields);
|
|
4940
4863
|
const whereClause = formatWhereClauses(query);
|
|
4941
4864
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4945,10 +4868,9 @@ function getTimetableNotes(query = {}, fields = [], orderBy2 = [], options = {})
|
|
|
4945
4868
|
}
|
|
4946
4869
|
|
|
4947
4870
|
// src/lib/non-standard/timetable-notes-references.ts
|
|
4948
|
-
import sqlString43 from "sqlstring-sqlite";
|
|
4949
4871
|
function getTimetableNotesReferences(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4950
4872
|
const db = options.db ?? openDb();
|
|
4951
|
-
const tableName =
|
|
4873
|
+
const tableName = "timetable_notes_references";
|
|
4952
4874
|
const selectClause = formatSelectClause(fields);
|
|
4953
4875
|
const whereClause = formatWhereClauses(query);
|
|
4954
4876
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4958,10 +4880,9 @@ function getTimetableNotesReferences(query = {}, fields = [], orderBy2 = [], opt
|
|
|
4958
4880
|
}
|
|
4959
4881
|
|
|
4960
4882
|
// src/lib/non-standard/trips-dated-vehicle-journey.ts
|
|
4961
|
-
import sqlString44 from "sqlstring-sqlite";
|
|
4962
4883
|
function getTripsDatedVehicleJourneys(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4963
4884
|
const db = options.db ?? openDb();
|
|
4964
|
-
const tableName =
|
|
4885
|
+
const tableName = "trips_dated_vehicle_journey";
|
|
4965
4886
|
const selectClause = formatSelectClause(fields);
|
|
4966
4887
|
const whereClause = formatWhereClauses(query);
|
|
4967
4888
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4971,10 +4892,9 @@ function getTripsDatedVehicleJourneys(query = {}, fields = [], orderBy2 = [], op
|
|
|
4971
4892
|
}
|
|
4972
4893
|
|
|
4973
4894
|
// src/lib/gtfs-ride/board-alights.ts
|
|
4974
|
-
import sqlString45 from "sqlstring-sqlite";
|
|
4975
4895
|
function getBoardAlights(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4976
4896
|
const db = options.db ?? openDb();
|
|
4977
|
-
const tableName =
|
|
4897
|
+
const tableName = "board_alight";
|
|
4978
4898
|
const selectClause = formatSelectClause(fields);
|
|
4979
4899
|
const whereClause = formatWhereClauses(query);
|
|
4980
4900
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4983,11 +4903,10 @@ function getBoardAlights(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4983
4903
|
).all();
|
|
4984
4904
|
}
|
|
4985
4905
|
|
|
4986
|
-
// src/lib/gtfs-ride/ride-feed-
|
|
4987
|
-
|
|
4988
|
-
function getRideFeedInfos(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4906
|
+
// src/lib/gtfs-ride/ride-feed-info.ts
|
|
4907
|
+
function getRideFeedInfo(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4989
4908
|
const db = options.db ?? openDb();
|
|
4990
|
-
const tableName =
|
|
4909
|
+
const tableName = "ride_feed_info";
|
|
4991
4910
|
const selectClause = formatSelectClause(fields);
|
|
4992
4911
|
const whereClause = formatWhereClauses(query);
|
|
4993
4912
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4997,10 +4916,9 @@ function getRideFeedInfos(query = {}, fields = [], orderBy2 = [], options = {})
|
|
|
4997
4916
|
}
|
|
4998
4917
|
|
|
4999
4918
|
// src/lib/gtfs-ride/rider-trips.ts
|
|
5000
|
-
import sqlString47 from "sqlstring-sqlite";
|
|
5001
4919
|
function getRiderTrips(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5002
4920
|
const db = options.db ?? openDb();
|
|
5003
|
-
const tableName =
|
|
4921
|
+
const tableName = "rider_trip";
|
|
5004
4922
|
const selectClause = formatSelectClause(fields);
|
|
5005
4923
|
const whereClause = formatWhereClauses(query);
|
|
5006
4924
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5009,11 +4927,10 @@ function getRiderTrips(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
5009
4927
|
).all();
|
|
5010
4928
|
}
|
|
5011
4929
|
|
|
5012
|
-
// src/lib/gtfs-ride/
|
|
5013
|
-
|
|
5014
|
-
function getRiderships(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4930
|
+
// src/lib/gtfs-ride/ridership.ts
|
|
4931
|
+
function getRidership(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5015
4932
|
const db = options.db ?? openDb();
|
|
5016
|
-
const tableName =
|
|
4933
|
+
const tableName = "ridership";
|
|
5017
4934
|
const selectClause = formatSelectClause(fields);
|
|
5018
4935
|
const whereClause = formatWhereClauses(query);
|
|
5019
4936
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5023,10 +4940,9 @@ function getRiderships(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
5023
4940
|
}
|
|
5024
4941
|
|
|
5025
4942
|
// src/lib/gtfs-ride/trip-capacities.ts
|
|
5026
|
-
import sqlString49 from "sqlstring-sqlite";
|
|
5027
4943
|
function getTripCapacities(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5028
4944
|
const db = options.db ?? openDb();
|
|
5029
|
-
const tableName =
|
|
4945
|
+
const tableName = "trip_capacity";
|
|
5030
4946
|
const selectClause = formatSelectClause(fields);
|
|
5031
4947
|
const whereClause = formatWhereClauses(query);
|
|
5032
4948
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5036,10 +4952,9 @@ function getTripCapacities(query = {}, fields = [], orderBy2 = [], options = {})
|
|
|
5036
4952
|
}
|
|
5037
4953
|
|
|
5038
4954
|
// src/lib/gtfs-realtime/stop-time-updates.ts
|
|
5039
|
-
import sqlString50 from "sqlstring-sqlite";
|
|
5040
4955
|
function getStopTimeUpdates(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5041
4956
|
const db = options.db ?? openDb();
|
|
5042
|
-
const tableName =
|
|
4957
|
+
const tableName = "stop_time_updates";
|
|
5043
4958
|
const selectClause = formatSelectClause(fields);
|
|
5044
4959
|
const whereClause = formatWhereClauses(query);
|
|
5045
4960
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5049,10 +4964,9 @@ function getStopTimeUpdates(query = {}, fields = [], orderBy2 = [], options = {}
|
|
|
5049
4964
|
}
|
|
5050
4965
|
|
|
5051
4966
|
// src/lib/gtfs-realtime/trip-updates.ts
|
|
5052
|
-
import sqlString51 from "sqlstring-sqlite";
|
|
5053
4967
|
function getTripUpdates(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5054
4968
|
const db = options.db ?? openDb();
|
|
5055
|
-
const tableName =
|
|
4969
|
+
const tableName = "trip_updates";
|
|
5056
4970
|
const selectClause = formatSelectClause(fields);
|
|
5057
4971
|
const whereClause = formatWhereClauses(query);
|
|
5058
4972
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5062,10 +4976,9 @@ function getTripUpdates(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
5062
4976
|
}
|
|
5063
4977
|
|
|
5064
4978
|
// src/lib/gtfs-realtime/vehicle-positions.ts
|
|
5065
|
-
import sqlString52 from "sqlstring-sqlite";
|
|
5066
4979
|
function getVehiclePositions(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5067
4980
|
const db = options.db ?? openDb();
|
|
5068
|
-
const tableName =
|
|
4981
|
+
const tableName = "vehicle_positions";
|
|
5069
4982
|
const selectClause = formatSelectClause(fields);
|
|
5070
4983
|
const whereClause = formatWhereClauses(query);
|
|
5071
4984
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5075,24 +4988,22 @@ function getVehiclePositions(query = {}, fields = [], orderBy2 = [], options = {
|
|
|
5075
4988
|
}
|
|
5076
4989
|
|
|
5077
4990
|
// src/lib/gtfs-realtime/service-alerts.ts
|
|
5078
|
-
import sqlString53 from "sqlstring-sqlite";
|
|
5079
4991
|
function getServiceAlerts(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5080
4992
|
const db = options.db ?? openDb();
|
|
5081
|
-
const tableName =
|
|
5082
|
-
const
|
|
4993
|
+
const tableName = "service_alerts";
|
|
4994
|
+
const joinTableName = "service_alert_targets";
|
|
5083
4995
|
const selectClause = formatSelectClause(fields);
|
|
5084
4996
|
const whereClause = formatWhereClauses(query);
|
|
5085
4997
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
5086
4998
|
return db.prepare(
|
|
5087
|
-
`${selectClause} FROM ${tableName} INNER JOIN ${
|
|
4999
|
+
`${selectClause} FROM ${tableName} INNER JOIN ${joinTableName} ON ${tableName}.id=${joinTableName}.alert_id ${whereClause} ${orderByClause};`
|
|
5088
5000
|
).all();
|
|
5089
5001
|
}
|
|
5090
5002
|
|
|
5091
5003
|
// src/lib/ods/deadheads.ts
|
|
5092
|
-
import sqlString54 from "sqlstring-sqlite";
|
|
5093
5004
|
function getDeadheads(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5094
5005
|
const db = options.db ?? openDb();
|
|
5095
|
-
const tableName =
|
|
5006
|
+
const tableName = "deadheads";
|
|
5096
5007
|
const selectClause = formatSelectClause(fields);
|
|
5097
5008
|
const whereClause = formatWhereClauses(query);
|
|
5098
5009
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5102,10 +5013,9 @@ function getDeadheads(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
5102
5013
|
}
|
|
5103
5014
|
|
|
5104
5015
|
// src/lib/ods/deadhead-times.ts
|
|
5105
|
-
import sqlString55 from "sqlstring-sqlite";
|
|
5106
5016
|
function getDeadheadTimes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5107
5017
|
const db = options.db ?? openDb();
|
|
5108
|
-
const tableName =
|
|
5018
|
+
const tableName = "deadhead_times";
|
|
5109
5019
|
const selectClause = formatSelectClause(fields);
|
|
5110
5020
|
const whereClause = formatWhereClauses(query);
|
|
5111
5021
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5115,10 +5025,9 @@ function getDeadheadTimes(query = {}, fields = [], orderBy2 = [], options = {})
|
|
|
5115
5025
|
}
|
|
5116
5026
|
|
|
5117
5027
|
// src/lib/ods/ops-locations.ts
|
|
5118
|
-
import sqlString56 from "sqlstring-sqlite";
|
|
5119
5028
|
function getOpsLocations(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5120
5029
|
const db = options.db ?? openDb();
|
|
5121
|
-
const tableName =
|
|
5030
|
+
const tableName = "ops_locations";
|
|
5122
5031
|
const selectClause = formatSelectClause(fields);
|
|
5123
5032
|
const whereClause = formatWhereClauses(query);
|
|
5124
5033
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5128,10 +5037,9 @@ function getOpsLocations(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
5128
5037
|
}
|
|
5129
5038
|
|
|
5130
5039
|
// src/lib/ods/run-events.ts
|
|
5131
|
-
import sqlString57 from "sqlstring-sqlite";
|
|
5132
5040
|
function getRunEvents(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5133
5041
|
const db = options.db ?? openDb();
|
|
5134
|
-
const tableName =
|
|
5042
|
+
const tableName = "run_events";
|
|
5135
5043
|
const selectClause = formatSelectClause(fields);
|
|
5136
5044
|
const whereClause = formatWhereClauses(query);
|
|
5137
5045
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5141,10 +5049,9 @@ function getRunEvents(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
5141
5049
|
}
|
|
5142
5050
|
|
|
5143
5051
|
// src/lib/ods/runs-pieces.ts
|
|
5144
|
-
import sqlString58 from "sqlstring-sqlite";
|
|
5145
5052
|
function getRunsPieces(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5146
5053
|
const db = options.db ?? openDb();
|
|
5147
|
-
const tableName =
|
|
5054
|
+
const tableName = "runs_pieces";
|
|
5148
5055
|
const selectClause = formatSelectClause(fields);
|
|
5149
5056
|
const whereClause = formatWhereClauses(query);
|
|
5150
5057
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5183,9 +5090,9 @@ export {
|
|
|
5183
5090
|
getNetworks,
|
|
5184
5091
|
getOpsLocations,
|
|
5185
5092
|
getPathways,
|
|
5186
|
-
|
|
5093
|
+
getRideFeedInfo,
|
|
5187
5094
|
getRiderTrips,
|
|
5188
|
-
|
|
5095
|
+
getRidership,
|
|
5189
5096
|
getRouteAttributes,
|
|
5190
5097
|
getRouteNetworks,
|
|
5191
5098
|
getRoutes,
|