gtfs 4.13.3 → 4.13.4
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 +7 -7
- package/dist/bin/gtfs-export.js +135 -341
- package/dist/bin/gtfs-export.js.map +1 -1
- package/dist/bin/gtfs-import.js +182 -407
- package/dist/bin/gtfs-import.js.map +1 -1
- package/dist/bin/gtfsrealtime-update.js +22 -2929
- package/dist/bin/gtfsrealtime-update.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +285 -407
- 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 +11 -1
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
|
);
|
|
@@ -3640,25 +3591,6 @@ var updateRealtimeData = async (task) => {
|
|
|
3640
3591
|
const db = openDb({
|
|
3641
3592
|
sqlitePath: task.sqlitePath
|
|
3642
3593
|
});
|
|
3643
|
-
const vehiclePositionsModel = models_default.find(
|
|
3644
|
-
(x) => x.filenameBase === "vehicle_positions"
|
|
3645
|
-
);
|
|
3646
|
-
const tripUpdatesModel = models_default.find(
|
|
3647
|
-
(x) => x.filenameBase === "trip_updates"
|
|
3648
|
-
);
|
|
3649
|
-
const stoptimeUpdatesModel = models_default.find(
|
|
3650
|
-
(x) => x.filenameBase === "stop_time_updates"
|
|
3651
|
-
);
|
|
3652
|
-
const serviceAlertsModel = models_default.find(
|
|
3653
|
-
(x) => x.filenameBase === "service_alerts"
|
|
3654
|
-
);
|
|
3655
|
-
const serviceAlertTargetsModel = models_default.find(
|
|
3656
|
-
(x) => x.filenameBase === "service_alert_targets"
|
|
3657
|
-
);
|
|
3658
|
-
if (!vehiclePositionsModel || !tripUpdatesModel || !stoptimeUpdatesModel || !serviceAlertsModel || !serviceAlertTargetsModel) {
|
|
3659
|
-
task.logError("GTFS-Realtime models definitions not found");
|
|
3660
|
-
return;
|
|
3661
|
-
}
|
|
3662
3594
|
task.log(
|
|
3663
3595
|
`Starting GTFS-Realtime import from ${task.realtime_urls.length} urls`
|
|
3664
3596
|
);
|
|
@@ -3671,25 +3603,25 @@ var updateRealtimeData = async (task) => {
|
|
|
3671
3603
|
task.log(`Download successful`);
|
|
3672
3604
|
let totalLineCount = 0;
|
|
3673
3605
|
for (const entity of gtfsRealtimeData.entity) {
|
|
3674
|
-
let
|
|
3606
|
+
let model;
|
|
3675
3607
|
if (entity.vehicle) {
|
|
3676
|
-
|
|
3608
|
+
model = vehiclePositions;
|
|
3677
3609
|
}
|
|
3678
3610
|
if (entity.tripUpdate) {
|
|
3679
|
-
|
|
3611
|
+
model = tripUpdates;
|
|
3680
3612
|
}
|
|
3681
3613
|
if (entity.alert) {
|
|
3682
|
-
|
|
3614
|
+
model = serviceAlerts;
|
|
3683
3615
|
}
|
|
3684
|
-
if (!
|
|
3616
|
+
if (!model) {
|
|
3685
3617
|
break;
|
|
3686
3618
|
}
|
|
3687
|
-
const fieldValues =
|
|
3619
|
+
const fieldValues = model.schema.map(
|
|
3688
3620
|
(column) => prepareRealtimeValue(entity, column, task)
|
|
3689
3621
|
);
|
|
3690
3622
|
try {
|
|
3691
3623
|
db.prepare(
|
|
3692
|
-
`REPLACE INTO ${
|
|
3624
|
+
`REPLACE INTO ${model.filenameBase} (${model.schema.map((column) => column.name).join(", ")}) VALUES (${fieldValues.join(", ")})`
|
|
3693
3625
|
).run();
|
|
3694
3626
|
} catch (error) {
|
|
3695
3627
|
task.logWarning("Import error: " + error.message);
|
|
@@ -3698,7 +3630,7 @@ var updateRealtimeData = async (task) => {
|
|
|
3698
3630
|
const stopTimeUpdateArray = [];
|
|
3699
3631
|
for (const stopTimeUpdate of entity.tripUpdate.stopTimeUpdate) {
|
|
3700
3632
|
stopTimeUpdate.parent = entity;
|
|
3701
|
-
const subValues =
|
|
3633
|
+
const subValues = stopTimeUpdates.schema.map(
|
|
3702
3634
|
(column) => prepareRealtimeValue(stopTimeUpdate, column, task)
|
|
3703
3635
|
);
|
|
3704
3636
|
stopTimeUpdateArray.push(`(${subValues.join(", ")})`);
|
|
@@ -3706,7 +3638,7 @@ var updateRealtimeData = async (task) => {
|
|
|
3706
3638
|
}
|
|
3707
3639
|
try {
|
|
3708
3640
|
db.prepare(
|
|
3709
|
-
`REPLACE INTO ${
|
|
3641
|
+
`REPLACE INTO ${stopTimeUpdates.filenameBase} (${stopTimeUpdates.schema.map((column) => column.name).join(", ")}) VALUES ${stopTimeUpdateArray.join(", ")}`
|
|
3710
3642
|
).run();
|
|
3711
3643
|
} catch (error) {
|
|
3712
3644
|
task.logWarning("Import error: " + error.message);
|
|
@@ -3716,7 +3648,7 @@ var updateRealtimeData = async (task) => {
|
|
|
3716
3648
|
const alertTargetArray = [];
|
|
3717
3649
|
for (const informedEntity of entity.alert.informedEntity) {
|
|
3718
3650
|
informedEntity.parent = entity;
|
|
3719
|
-
const subValues =
|
|
3651
|
+
const subValues = serviceAlertTargets.schema.map(
|
|
3720
3652
|
(column) => prepareRealtimeValue(informedEntity, column, task)
|
|
3721
3653
|
);
|
|
3722
3654
|
alertTargetArray.push(`(${subValues.join(", ")})`);
|
|
@@ -3724,7 +3656,7 @@ var updateRealtimeData = async (task) => {
|
|
|
3724
3656
|
}
|
|
3725
3657
|
try {
|
|
3726
3658
|
db.prepare(
|
|
3727
|
-
`REPLACE INTO ${
|
|
3659
|
+
`REPLACE INTO ${serviceAlertTargets.filenameBase} (${serviceAlertTargets.schema.map((column) => column.name).join(", ")}) VALUES ${alertTargetArray.join(", ")}`
|
|
3728
3660
|
).run();
|
|
3729
3661
|
} catch (error) {
|
|
3730
3662
|
task.logWarning("Import error: " + error.message);
|
|
@@ -3789,11 +3721,11 @@ var readFiles = async (task) => {
|
|
|
3789
3721
|
}
|
|
3790
3722
|
};
|
|
3791
3723
|
var createTables = (db) => {
|
|
3792
|
-
for (const
|
|
3793
|
-
if (!
|
|
3724
|
+
for (const model of Object.values(models_exports)) {
|
|
3725
|
+
if (!model.schema) {
|
|
3794
3726
|
return;
|
|
3795
3727
|
}
|
|
3796
|
-
const columns =
|
|
3728
|
+
const columns = model.schema.map((column) => {
|
|
3797
3729
|
let check = "";
|
|
3798
3730
|
if (column.min !== void 0 && column.max) {
|
|
3799
3731
|
check = `CHECK( ${column.name} >= ${column.min} AND ${column.name} <= ${column.max} )`;
|
|
@@ -3807,34 +3739,34 @@ var createTables = (db) => {
|
|
|
3807
3739
|
const columnCollation = column.nocase ? "COLLATE NOCASE" : "";
|
|
3808
3740
|
return `${column.name} ${column.type} ${check} ${required} ${columnDefault} ${columnCollation}`;
|
|
3809
3741
|
});
|
|
3810
|
-
const primaryColumns =
|
|
3742
|
+
const primaryColumns = model.schema.filter((column) => column.primary);
|
|
3811
3743
|
if (primaryColumns.length > 0) {
|
|
3812
3744
|
columns.push(
|
|
3813
3745
|
`PRIMARY KEY (${primaryColumns.map((column) => column.name).join(", ")})`
|
|
3814
3746
|
);
|
|
3815
3747
|
}
|
|
3816
|
-
db.prepare(`DROP TABLE IF EXISTS ${
|
|
3748
|
+
db.prepare(`DROP TABLE IF EXISTS ${model.filenameBase};`).run();
|
|
3817
3749
|
db.prepare(
|
|
3818
|
-
`CREATE TABLE ${
|
|
3750
|
+
`CREATE TABLE ${model.filenameBase} (${columns.join(", ")});`
|
|
3819
3751
|
).run();
|
|
3820
|
-
for (const column of
|
|
3752
|
+
for (const column of model.schema.filter((column2) => column2.index)) {
|
|
3821
3753
|
db.prepare(
|
|
3822
|
-
`CREATE INDEX idx_${
|
|
3754
|
+
`CREATE INDEX idx_${model.filenameBase}_${column.name} ON ${model.filenameBase} (${column.name});`
|
|
3823
3755
|
).run();
|
|
3824
3756
|
}
|
|
3825
3757
|
}
|
|
3826
3758
|
};
|
|
3827
|
-
var formatLine = (line,
|
|
3759
|
+
var formatLine = (line, model, totalLineCount) => {
|
|
3828
3760
|
const lineNumber = totalLineCount + 1;
|
|
3829
3761
|
const formattedLine = {};
|
|
3830
|
-
for (const columnSchema of
|
|
3762
|
+
for (const columnSchema of model.schema) {
|
|
3831
3763
|
const lineValue = line[columnSchema.name];
|
|
3832
3764
|
if (columnSchema.type === "date") {
|
|
3833
3765
|
if (lineValue !== "" && lineValue !== void 0) {
|
|
3834
3766
|
const dateValue = lineValue.replace(/-/g, "");
|
|
3835
3767
|
if (dateValue.length !== 8) {
|
|
3836
3768
|
throw new Error(
|
|
3837
|
-
`Invalid date in ${
|
|
3769
|
+
`Invalid date in ${model.filenameBase}.${model.filenameExtension} for ${columnSchema.name} on line ${lineNumber}.`
|
|
3838
3770
|
);
|
|
3839
3771
|
}
|
|
3840
3772
|
formattedLine[columnSchema.name] = Number.parseInt(dateValue, 10);
|
|
@@ -3851,17 +3783,17 @@ var formatLine = (line, model56, totalLineCount) => {
|
|
|
3851
3783
|
}
|
|
3852
3784
|
if (columnSchema.required === true && formattedLine[columnSchema.name] === null) {
|
|
3853
3785
|
throw new Error(
|
|
3854
|
-
`Missing required value in ${
|
|
3786
|
+
`Missing required value in ${model.filenameBase}.${model.filenameExtension} for ${columnSchema.name} on line ${lineNumber}.`
|
|
3855
3787
|
);
|
|
3856
3788
|
}
|
|
3857
3789
|
if (columnSchema.min !== void 0 && formattedLine[columnSchema.name] < columnSchema.min) {
|
|
3858
3790
|
throw new Error(
|
|
3859
|
-
`Invalid value in ${
|
|
3791
|
+
`Invalid value in ${model.filenameBase}.${model.filenameExtension} for ${columnSchema.name} on line ${lineNumber}: below minimum value of ${columnSchema.min}.`
|
|
3860
3792
|
);
|
|
3861
3793
|
}
|
|
3862
3794
|
if (columnSchema.max !== void 0 && formattedLine[columnSchema.name] > columnSchema.max) {
|
|
3863
3795
|
throw new Error(
|
|
3864
|
-
`Invalid value in ${
|
|
3796
|
+
`Invalid value in ${model.filenameBase}.${model.filenameExtension} for ${columnSchema.name} on line ${lineNumber}: above maximum value of ${columnSchema.max}.`
|
|
3865
3797
|
);
|
|
3866
3798
|
}
|
|
3867
3799
|
}
|
|
@@ -3887,7 +3819,7 @@ var formatLine = (line, model56, totalLineCount) => {
|
|
|
3887
3819
|
}
|
|
3888
3820
|
return formattedLine;
|
|
3889
3821
|
};
|
|
3890
|
-
var importLines = (task, lines,
|
|
3822
|
+
var importLines = (task, lines, model, totalLineCount) => {
|
|
3891
3823
|
const db = openDb({
|
|
3892
3824
|
sqlitePath: task.sqlitePath
|
|
3893
3825
|
});
|
|
@@ -3895,7 +3827,7 @@ var importLines = (task, lines, model56, totalLineCount) => {
|
|
|
3895
3827
|
return;
|
|
3896
3828
|
}
|
|
3897
3829
|
const linesToImportCount = lines.length;
|
|
3898
|
-
const columns =
|
|
3830
|
+
const columns = model.schema.filter((column) => column.name !== "id");
|
|
3899
3831
|
const placeholders = [];
|
|
3900
3832
|
const values = [];
|
|
3901
3833
|
while (lines.length > 0) {
|
|
@@ -3915,59 +3847,59 @@ var importLines = (task, lines, model56, totalLineCount) => {
|
|
|
3915
3847
|
}
|
|
3916
3848
|
try {
|
|
3917
3849
|
db.prepare(
|
|
3918
|
-
`INSERT ${task.ignoreDuplicates ? "OR IGNORE" : ""} INTO ${
|
|
3850
|
+
`INSERT ${task.ignoreDuplicates ? "OR IGNORE" : ""} INTO ${model.filenameBase} (${columns.map((column) => column.name).join(", ")}) VALUES ${placeholders.join(",")}`
|
|
3919
3851
|
).run(...values);
|
|
3920
3852
|
} catch (error) {
|
|
3921
3853
|
if (error.code === "SQLITE_CONSTRAINT_PRIMARYKEY") {
|
|
3922
|
-
const primaryColumns =
|
|
3854
|
+
const primaryColumns = model.schema.filter((column) => column.primary);
|
|
3923
3855
|
task.logWarning(
|
|
3924
|
-
`Duplicate values for primary key (${primaryColumns.map((column) => column.name).join(", ")}) found in ${
|
|
3856
|
+
`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
3857
|
);
|
|
3926
3858
|
}
|
|
3927
3859
|
task.logWarning(
|
|
3928
|
-
`Check ${
|
|
3860
|
+
`Check ${model.filenameBase}.${model.filenameExtension} for invalid data between lines ${totalLineCount - linesToImportCount} and ${totalLineCount}.`
|
|
3929
3861
|
);
|
|
3930
3862
|
throw error;
|
|
3931
3863
|
}
|
|
3932
3864
|
task.log(
|
|
3933
|
-
`Importing - ${
|
|
3865
|
+
`Importing - ${model.filenameBase}.${model.filenameExtension} - ${totalLineCount} lines imported\r`,
|
|
3934
3866
|
true
|
|
3935
3867
|
);
|
|
3936
3868
|
};
|
|
3937
3869
|
var importFiles = (task) => mapSeries(
|
|
3938
|
-
|
|
3939
|
-
(
|
|
3870
|
+
Object.values(models_exports),
|
|
3871
|
+
(model) => new Promise((resolve, reject) => {
|
|
3940
3872
|
const lines = [];
|
|
3941
3873
|
let totalLineCount = 0;
|
|
3942
3874
|
const maxInsertVariables = 32e3;
|
|
3943
|
-
if (task.exclude && task.exclude.includes(
|
|
3875
|
+
if (task.exclude && task.exclude.includes(model.filenameBase)) {
|
|
3944
3876
|
task.log(
|
|
3945
|
-
`Skipping - ${
|
|
3877
|
+
`Skipping - ${model.filenameBase}.${model.filenameExtension}\r`
|
|
3946
3878
|
);
|
|
3947
3879
|
resolve();
|
|
3948
3880
|
return;
|
|
3949
3881
|
}
|
|
3950
|
-
if (
|
|
3882
|
+
if (model.extension === "gtfs-realtime") {
|
|
3951
3883
|
resolve();
|
|
3952
3884
|
return;
|
|
3953
3885
|
}
|
|
3954
3886
|
const filepath = path.join(
|
|
3955
3887
|
task.downloadDir,
|
|
3956
|
-
`${
|
|
3888
|
+
`${model.filenameBase}.${model.filenameExtension}`
|
|
3957
3889
|
);
|
|
3958
3890
|
if (!existsSync(filepath)) {
|
|
3959
|
-
if (!
|
|
3891
|
+
if (!model.nonstandard) {
|
|
3960
3892
|
task.log(
|
|
3961
|
-
`Importing - ${
|
|
3893
|
+
`Importing - ${model.filenameBase}.${model.filenameExtension} - No file found\r`
|
|
3962
3894
|
);
|
|
3963
3895
|
}
|
|
3964
3896
|
resolve();
|
|
3965
3897
|
return;
|
|
3966
3898
|
}
|
|
3967
3899
|
task.log(
|
|
3968
|
-
`Importing - ${
|
|
3900
|
+
`Importing - ${model.filenameBase}.${model.filenameExtension}\r`
|
|
3969
3901
|
);
|
|
3970
|
-
if (
|
|
3902
|
+
if (model.filenameExtension === "txt") {
|
|
3971
3903
|
const parser = parse({
|
|
3972
3904
|
columns: true,
|
|
3973
3905
|
relax_quotes: true,
|
|
@@ -3980,9 +3912,9 @@ var importFiles = (task) => mapSeries(
|
|
|
3980
3912
|
while (record = parser.read()) {
|
|
3981
3913
|
try {
|
|
3982
3914
|
totalLineCount += 1;
|
|
3983
|
-
lines.push(formatLine(record,
|
|
3984
|
-
if (lines.length >= maxInsertVariables /
|
|
3985
|
-
importLines(task, lines,
|
|
3915
|
+
lines.push(formatLine(record, model, totalLineCount));
|
|
3916
|
+
if (lines.length >= maxInsertVariables / model.schema.length) {
|
|
3917
|
+
importLines(task, lines, model, totalLineCount);
|
|
3986
3918
|
}
|
|
3987
3919
|
} catch (error) {
|
|
3988
3920
|
reject(error);
|
|
@@ -3991,7 +3923,7 @@ var importFiles = (task) => mapSeries(
|
|
|
3991
3923
|
});
|
|
3992
3924
|
parser.on("end", () => {
|
|
3993
3925
|
try {
|
|
3994
|
-
importLines(task, lines,
|
|
3926
|
+
importLines(task, lines, model, totalLineCount);
|
|
3995
3927
|
} catch (error) {
|
|
3996
3928
|
reject(error);
|
|
3997
3929
|
}
|
|
@@ -3999,22 +3931,22 @@ var importFiles = (task) => mapSeries(
|
|
|
3999
3931
|
});
|
|
4000
3932
|
parser.on("error", reject);
|
|
4001
3933
|
createReadStream(filepath).pipe(stripBomStream()).pipe(parser);
|
|
4002
|
-
} else if (
|
|
3934
|
+
} else if (model.filenameExtension === "geojson") {
|
|
4003
3935
|
readFile2(filepath, "utf8").then((data) => {
|
|
4004
3936
|
if (isValidJSON(data) === false) {
|
|
4005
3937
|
reject(
|
|
4006
3938
|
new Error(
|
|
4007
|
-
`Invalid JSON in ${
|
|
3939
|
+
`Invalid JSON in ${model.filenameBase}.${model.filenameExtension}`
|
|
4008
3940
|
)
|
|
4009
3941
|
);
|
|
4010
3942
|
}
|
|
4011
|
-
const line = formatLine({ geojson: data },
|
|
4012
|
-
importLines(task, [line],
|
|
3943
|
+
const line = formatLine({ geojson: data }, model, totalLineCount);
|
|
3944
|
+
importLines(task, [line], model, totalLineCount);
|
|
4013
3945
|
resolve();
|
|
4014
3946
|
}).catch(reject);
|
|
4015
3947
|
} else {
|
|
4016
3948
|
reject(
|
|
4017
|
-
new Error(`Unsupported file type: ${
|
|
3949
|
+
new Error(`Unsupported file type: ${model.filenameExtension}`)
|
|
4018
3950
|
);
|
|
4019
3951
|
}
|
|
4020
3952
|
})
|
|
@@ -4038,22 +3970,22 @@ async function importGtfs(initialConfig) {
|
|
|
4038
3970
|
createTables(db);
|
|
4039
3971
|
await mapSeries(
|
|
4040
3972
|
config.agencies,
|
|
4041
|
-
async (
|
|
3973
|
+
async (agency2) => {
|
|
4042
3974
|
const tempPath = temporaryDirectory();
|
|
4043
3975
|
const task = {
|
|
4044
|
-
exclude:
|
|
4045
|
-
agency_url:
|
|
4046
|
-
headers:
|
|
4047
|
-
realtime_headers:
|
|
4048
|
-
realtime_urls:
|
|
3976
|
+
exclude: agency2.exclude,
|
|
3977
|
+
agency_url: agency2.url,
|
|
3978
|
+
headers: agency2.headers,
|
|
3979
|
+
realtime_headers: agency2.realtimeHeaders,
|
|
3980
|
+
realtime_urls: agency2.realtimeUrls,
|
|
4049
3981
|
downloadDir: tempPath,
|
|
4050
3982
|
downloadTimeout: config.downloadTimeout,
|
|
4051
3983
|
gtfsRealtimeExpirationSeconds: config.gtfsRealtimeExpirationSeconds,
|
|
4052
|
-
path:
|
|
3984
|
+
path: agency2.path,
|
|
4053
3985
|
csvOptions: config.csvOptions || {},
|
|
4054
3986
|
ignoreDuplicates: config.ignoreDuplicates,
|
|
4055
3987
|
sqlitePath: config.sqlitePath,
|
|
4056
|
-
prefix:
|
|
3988
|
+
prefix: agency2.prefix,
|
|
4057
3989
|
currentTimestamp: Math.floor(Date.now() / 1e3),
|
|
4058
3990
|
log: log2,
|
|
4059
3991
|
logWarning: logWarning2,
|
|
@@ -4107,13 +4039,13 @@ async function updateGtfsRealtime(initialConfig) {
|
|
|
4107
4039
|
);
|
|
4108
4040
|
deleteExpiredRealtimeData(config);
|
|
4109
4041
|
await Promise.all(
|
|
4110
|
-
config.agencies.map(async (
|
|
4111
|
-
if (
|
|
4042
|
+
config.agencies.map(async (agency2) => {
|
|
4043
|
+
if (agency2.realtimeUrls === void 0) {
|
|
4112
4044
|
return;
|
|
4113
4045
|
}
|
|
4114
4046
|
const task = {
|
|
4115
|
-
realtime_headers:
|
|
4116
|
-
realtime_urls:
|
|
4047
|
+
realtime_headers: agency2.realtimeHeaders,
|
|
4048
|
+
realtime_urls: agency2.realtimeUrls,
|
|
4117
4049
|
downloadTimeout: config.downloadTimeout,
|
|
4118
4050
|
gtfsRealtimeExpirationSeconds: config.gtfsRealtimeExpirationSeconds,
|
|
4119
4051
|
sqlitePath: config.sqlitePath,
|
|
@@ -4193,27 +4125,27 @@ var exportGtfs = async (initialConfig) => {
|
|
|
4193
4125
|
const defaultExportPath = path2.join(process.cwd(), "gtfs-export", folderName);
|
|
4194
4126
|
const exportPath = untildify4(config.exportPath || defaultExportPath);
|
|
4195
4127
|
await prepDirectory(exportPath);
|
|
4196
|
-
const modelsToExport =
|
|
4197
|
-
(
|
|
4128
|
+
const modelsToExport = Object.values(models_exports).filter(
|
|
4129
|
+
(model) => model.extension !== "gtfs-realtime"
|
|
4198
4130
|
);
|
|
4199
4131
|
const exportedFiles = await mapSeries2(
|
|
4200
4132
|
modelsToExport,
|
|
4201
|
-
async (
|
|
4133
|
+
async (model) => {
|
|
4202
4134
|
const filePath = path2.join(
|
|
4203
4135
|
exportPath,
|
|
4204
|
-
`${
|
|
4136
|
+
`${model.filenameBase}.${model.filenameExtension}`
|
|
4205
4137
|
);
|
|
4206
|
-
const tableName = sqlString3.escapeId(
|
|
4138
|
+
const tableName = sqlString3.escapeId(model.filenameBase);
|
|
4207
4139
|
const lines = db.prepare(`SELECT * FROM ${tableName};`).all();
|
|
4208
4140
|
if (!lines || lines.length === 0) {
|
|
4209
|
-
if (!
|
|
4141
|
+
if (!model.nonstandard) {
|
|
4210
4142
|
log2(
|
|
4211
|
-
`Skipping (no data) - ${
|
|
4143
|
+
`Skipping (no data) - ${model.filenameBase}.${model.filenameExtension}\r`
|
|
4212
4144
|
);
|
|
4213
4145
|
}
|
|
4214
4146
|
return;
|
|
4215
4147
|
}
|
|
4216
|
-
if (
|
|
4148
|
+
if (model.filenameExtension === "txt") {
|
|
4217
4149
|
const excludeColumns = [
|
|
4218
4150
|
"id",
|
|
4219
4151
|
"arrival_timestamp",
|
|
@@ -4227,7 +4159,7 @@ var exportGtfs = async (initialConfig) => {
|
|
|
4227
4159
|
"ridership_start_timestamp",
|
|
4228
4160
|
"ridership_end_timestamp"
|
|
4229
4161
|
];
|
|
4230
|
-
if (
|
|
4162
|
+
if (model.filenameBase === "routes") {
|
|
4231
4163
|
const routesWithAgencyId = db.prepare(
|
|
4232
4164
|
"SELECT agency_id FROM routes WHERE agency_id IS NOT NULL;"
|
|
4233
4165
|
).all();
|
|
@@ -4236,21 +4168,21 @@ var exportGtfs = async (initialConfig) => {
|
|
|
4236
4168
|
}
|
|
4237
4169
|
}
|
|
4238
4170
|
const columns = without(
|
|
4239
|
-
|
|
4171
|
+
model.schema.map((column) => column.name),
|
|
4240
4172
|
...excludeColumns
|
|
4241
4173
|
);
|
|
4242
4174
|
const fileText = await stringify(lines, { columns, header: true });
|
|
4243
4175
|
await writeFile2(filePath, fileText);
|
|
4244
|
-
} else if (
|
|
4176
|
+
} else if (model.filenameExtension === "geojson") {
|
|
4245
4177
|
const fileText = lines?.[0].geojson ?? "";
|
|
4246
4178
|
await writeFile2(filePath, fileText);
|
|
4247
4179
|
} else {
|
|
4248
4180
|
throw new Error(
|
|
4249
|
-
`Unexpected filename extension: ${
|
|
4181
|
+
`Unexpected filename extension: ${model.filenameExtension}`
|
|
4250
4182
|
);
|
|
4251
4183
|
}
|
|
4252
|
-
log2(`Exporting - ${
|
|
4253
|
-
return `${
|
|
4184
|
+
log2(`Exporting - ${model.filenameBase}.${model.filenameExtension}\r`);
|
|
4185
|
+
return `${model.filenameBase}.${model.filenameExtension}`;
|
|
4254
4186
|
}
|
|
4255
4187
|
);
|
|
4256
4188
|
if (compact(exportedFiles).length === 0) {
|
|
@@ -4285,10 +4217,9 @@ function advancedQuery(table, advancedQueryOptions) {
|
|
|
4285
4217
|
}
|
|
4286
4218
|
|
|
4287
4219
|
// src/lib/gtfs/agencies.ts
|
|
4288
|
-
import sqlString5 from "sqlstring-sqlite";
|
|
4289
4220
|
function getAgencies2(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4290
4221
|
const db = options.db ?? openDb();
|
|
4291
|
-
const tableName =
|
|
4222
|
+
const tableName = "agency";
|
|
4292
4223
|
const selectClause = formatSelectClause(fields);
|
|
4293
4224
|
const whereClause = formatWhereClauses(query);
|
|
4294
4225
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4298,10 +4229,9 @@ function getAgencies2(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4298
4229
|
}
|
|
4299
4230
|
|
|
4300
4231
|
// src/lib/gtfs/areas.ts
|
|
4301
|
-
import sqlString6 from "sqlstring-sqlite";
|
|
4302
4232
|
function getAreas(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4303
4233
|
const db = options.db ?? openDb();
|
|
4304
|
-
const tableName =
|
|
4234
|
+
const tableName = "areas";
|
|
4305
4235
|
const selectClause = formatSelectClause(fields);
|
|
4306
4236
|
const whereClause = formatWhereClauses(query);
|
|
4307
4237
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4311,10 +4241,9 @@ function getAreas(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4311
4241
|
}
|
|
4312
4242
|
|
|
4313
4243
|
// src/lib/gtfs/attributions.ts
|
|
4314
|
-
import sqlString7 from "sqlstring-sqlite";
|
|
4315
4244
|
function getAttributions(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4316
4245
|
const db = options.db ?? openDb();
|
|
4317
|
-
const tableName =
|
|
4246
|
+
const tableName = "attributions";
|
|
4318
4247
|
const selectClause = formatSelectClause(fields);
|
|
4319
4248
|
const whereClause = formatWhereClauses(query);
|
|
4320
4249
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4324,10 +4253,9 @@ function getAttributions(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4324
4253
|
}
|
|
4325
4254
|
|
|
4326
4255
|
// src/lib/gtfs/booking-rules.ts
|
|
4327
|
-
import sqlString8 from "sqlstring-sqlite";
|
|
4328
4256
|
function getBookingRules(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4329
4257
|
const db = options.db ?? openDb();
|
|
4330
|
-
const tableName =
|
|
4258
|
+
const tableName = "booking_rules";
|
|
4331
4259
|
const selectClause = formatSelectClause(fields);
|
|
4332
4260
|
const whereClause = formatWhereClauses(query);
|
|
4333
4261
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4337,10 +4265,9 @@ function getBookingRules(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4337
4265
|
}
|
|
4338
4266
|
|
|
4339
4267
|
// src/lib/gtfs/calendar-dates.ts
|
|
4340
|
-
import sqlString9 from "sqlstring-sqlite";
|
|
4341
4268
|
function getCalendarDates(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4342
4269
|
const db = options.db ?? openDb();
|
|
4343
|
-
const tableName =
|
|
4270
|
+
const tableName = "calendar_dates";
|
|
4344
4271
|
const selectClause = formatSelectClause(fields);
|
|
4345
4272
|
const whereClause = formatWhereClauses(query);
|
|
4346
4273
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4350,10 +4277,9 @@ function getCalendarDates(query = {}, fields = [], orderBy2 = [], options = {})
|
|
|
4350
4277
|
}
|
|
4351
4278
|
|
|
4352
4279
|
// src/lib/gtfs/calendars.ts
|
|
4353
|
-
import sqlString10 from "sqlstring-sqlite";
|
|
4354
4280
|
function getCalendars(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4355
4281
|
const db = options.db ?? openDb();
|
|
4356
|
-
const tableName =
|
|
4282
|
+
const tableName = "calendar";
|
|
4357
4283
|
const selectClause = formatSelectClause(fields);
|
|
4358
4284
|
const whereClause = formatWhereClauses(query);
|
|
4359
4285
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4363,10 +4289,9 @@ function getCalendars(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4363
4289
|
}
|
|
4364
4290
|
|
|
4365
4291
|
// src/lib/gtfs/fare-attributes.ts
|
|
4366
|
-
import sqlString11 from "sqlstring-sqlite";
|
|
4367
4292
|
function getFareAttributes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4368
4293
|
const db = options.db ?? openDb();
|
|
4369
|
-
const tableName =
|
|
4294
|
+
const tableName = "fare_attributes";
|
|
4370
4295
|
const selectClause = formatSelectClause(fields);
|
|
4371
4296
|
const whereClause = formatWhereClauses(query);
|
|
4372
4297
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4376,10 +4301,9 @@ function getFareAttributes(query = {}, fields = [], orderBy2 = [], options = {})
|
|
|
4376
4301
|
}
|
|
4377
4302
|
|
|
4378
4303
|
// src/lib/gtfs/fare-leg-rules.ts
|
|
4379
|
-
import sqlString12 from "sqlstring-sqlite";
|
|
4380
4304
|
function getFareLegRules(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4381
4305
|
const db = options.db ?? openDb();
|
|
4382
|
-
const tableName =
|
|
4306
|
+
const tableName = "fare_leg_rules";
|
|
4383
4307
|
const selectClause = formatSelectClause(fields);
|
|
4384
4308
|
const whereClause = formatWhereClauses(query);
|
|
4385
4309
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4389,10 +4313,9 @@ function getFareLegRules(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4389
4313
|
}
|
|
4390
4314
|
|
|
4391
4315
|
// src/lib/gtfs/fare-media.ts
|
|
4392
|
-
import sqlString13 from "sqlstring-sqlite";
|
|
4393
4316
|
function getFareMedia(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4394
4317
|
const db = options.db ?? openDb();
|
|
4395
|
-
const tableName =
|
|
4318
|
+
const tableName = "fare_media";
|
|
4396
4319
|
const selectClause = formatSelectClause(fields);
|
|
4397
4320
|
const whereClause = formatWhereClauses(query);
|
|
4398
4321
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4402,10 +4325,9 @@ function getFareMedia(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4402
4325
|
}
|
|
4403
4326
|
|
|
4404
4327
|
// src/lib/gtfs/fare-products.ts
|
|
4405
|
-
import sqlString14 from "sqlstring-sqlite";
|
|
4406
4328
|
function getFareProducts(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4407
4329
|
const db = options.db ?? openDb();
|
|
4408
|
-
const tableName =
|
|
4330
|
+
const tableName = "fare_products";
|
|
4409
4331
|
const selectClause = formatSelectClause(fields);
|
|
4410
4332
|
const whereClause = formatWhereClauses(query);
|
|
4411
4333
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4415,10 +4337,9 @@ function getFareProducts(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4415
4337
|
}
|
|
4416
4338
|
|
|
4417
4339
|
// src/lib/gtfs/fare-rules.ts
|
|
4418
|
-
import sqlString15 from "sqlstring-sqlite";
|
|
4419
4340
|
function getFareRules(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4420
4341
|
const db = options.db ?? openDb();
|
|
4421
|
-
const tableName =
|
|
4342
|
+
const tableName = "fare_rules";
|
|
4422
4343
|
const selectClause = formatSelectClause(fields);
|
|
4423
4344
|
const whereClause = formatWhereClauses(query);
|
|
4424
4345
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4428,10 +4349,9 @@ function getFareRules(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4428
4349
|
}
|
|
4429
4350
|
|
|
4430
4351
|
// src/lib/gtfs/fare-transfer-rules.ts
|
|
4431
|
-
import sqlString16 from "sqlstring-sqlite";
|
|
4432
4352
|
function getFareTransferRules(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4433
4353
|
const db = options.db ?? openDb();
|
|
4434
|
-
const tableName =
|
|
4354
|
+
const tableName = "fare_transfer_rules";
|
|
4435
4355
|
const selectClause = formatSelectClause(fields);
|
|
4436
4356
|
const whereClause = formatWhereClauses(query);
|
|
4437
4357
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4441,10 +4361,9 @@ function getFareTransferRules(query = {}, fields = [], orderBy2 = [], options =
|
|
|
4441
4361
|
}
|
|
4442
4362
|
|
|
4443
4363
|
// src/lib/gtfs/feed-info.ts
|
|
4444
|
-
import sqlString17 from "sqlstring-sqlite";
|
|
4445
4364
|
function getFeedInfo(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4446
4365
|
const db = options.db ?? openDb();
|
|
4447
|
-
const tableName =
|
|
4366
|
+
const tableName = "feed_info";
|
|
4448
4367
|
const selectClause = formatSelectClause(fields);
|
|
4449
4368
|
const whereClause = formatWhereClauses(query);
|
|
4450
4369
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4454,10 +4373,9 @@ function getFeedInfo(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4454
4373
|
}
|
|
4455
4374
|
|
|
4456
4375
|
// src/lib/gtfs/frequencies.ts
|
|
4457
|
-
import sqlString18 from "sqlstring-sqlite";
|
|
4458
4376
|
function getFrequencies(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4459
4377
|
const db = options.db ?? openDb();
|
|
4460
|
-
const tableName =
|
|
4378
|
+
const tableName = "frequencies";
|
|
4461
4379
|
const selectClause = formatSelectClause(fields);
|
|
4462
4380
|
const whereClause = formatWhereClauses(query);
|
|
4463
4381
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4467,10 +4385,9 @@ function getFrequencies(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4467
4385
|
}
|
|
4468
4386
|
|
|
4469
4387
|
// src/lib/gtfs/levels.ts
|
|
4470
|
-
import sqlString19 from "sqlstring-sqlite";
|
|
4471
4388
|
function getLevels(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4472
4389
|
const db = options.db ?? openDb();
|
|
4473
|
-
const tableName =
|
|
4390
|
+
const tableName = "levels";
|
|
4474
4391
|
const selectClause = formatSelectClause(fields);
|
|
4475
4392
|
const whereClause = formatWhereClauses(query);
|
|
4476
4393
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4480,10 +4397,9 @@ function getLevels(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4480
4397
|
}
|
|
4481
4398
|
|
|
4482
4399
|
// src/lib/gtfs/location-groups.ts
|
|
4483
|
-
import sqlString20 from "sqlstring-sqlite";
|
|
4484
4400
|
function getLocationGroups(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4485
4401
|
const db = options.db ?? openDb();
|
|
4486
|
-
const tableName =
|
|
4402
|
+
const tableName = "location_groups";
|
|
4487
4403
|
const selectClause = formatSelectClause(fields);
|
|
4488
4404
|
const whereClause = formatWhereClauses(query);
|
|
4489
4405
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4493,10 +4409,9 @@ function getLocationGroups(query = {}, fields = [], orderBy2 = [], options = {})
|
|
|
4493
4409
|
}
|
|
4494
4410
|
|
|
4495
4411
|
// src/lib/gtfs/location-group-stops.ts
|
|
4496
|
-
import sqlString21 from "sqlstring-sqlite";
|
|
4497
4412
|
function getLocationGroupStops(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4498
4413
|
const db = options.db ?? openDb();
|
|
4499
|
-
const tableName =
|
|
4414
|
+
const tableName = "location_group_stops";
|
|
4500
4415
|
const selectClause = formatSelectClause(fields);
|
|
4501
4416
|
const whereClause = formatWhereClauses(query);
|
|
4502
4417
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4506,10 +4421,9 @@ function getLocationGroupStops(query = {}, fields = [], orderBy2 = [], options =
|
|
|
4506
4421
|
}
|
|
4507
4422
|
|
|
4508
4423
|
// src/lib/gtfs/locations.ts
|
|
4509
|
-
import sqlString22 from "sqlstring-sqlite";
|
|
4510
4424
|
function getLocations(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4511
4425
|
const db = options.db ?? openDb();
|
|
4512
|
-
const tableName =
|
|
4426
|
+
const tableName = "locations";
|
|
4513
4427
|
const selectClause = formatSelectClause(fields);
|
|
4514
4428
|
const whereClause = formatWhereClauses(query);
|
|
4515
4429
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4519,10 +4433,9 @@ function getLocations(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4519
4433
|
}
|
|
4520
4434
|
|
|
4521
4435
|
// src/lib/gtfs/networks.ts
|
|
4522
|
-
import sqlString23 from "sqlstring-sqlite";
|
|
4523
4436
|
function getNetworks(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4524
4437
|
const db = options.db ?? openDb();
|
|
4525
|
-
const tableName =
|
|
4438
|
+
const tableName = "networks";
|
|
4526
4439
|
const selectClause = formatSelectClause(fields);
|
|
4527
4440
|
const whereClause = formatWhereClauses(query);
|
|
4528
4441
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4532,10 +4445,9 @@ function getNetworks(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4532
4445
|
}
|
|
4533
4446
|
|
|
4534
4447
|
// src/lib/gtfs/pathways.ts
|
|
4535
|
-
import sqlString24 from "sqlstring-sqlite";
|
|
4536
4448
|
function getPathways(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4537
4449
|
const db = options.db ?? openDb();
|
|
4538
|
-
const tableName =
|
|
4450
|
+
const tableName = "pathways";
|
|
4539
4451
|
const selectClause = formatSelectClause(fields);
|
|
4540
4452
|
const whereClause = formatWhereClauses(query);
|
|
4541
4453
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4545,10 +4457,9 @@ function getPathways(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4545
4457
|
}
|
|
4546
4458
|
|
|
4547
4459
|
// src/lib/gtfs/route-networks.ts
|
|
4548
|
-
import sqlString25 from "sqlstring-sqlite";
|
|
4549
4460
|
function getRouteNetworks(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4550
4461
|
const db = options.db ?? openDb();
|
|
4551
|
-
const tableName =
|
|
4462
|
+
const tableName = "route_networks";
|
|
4552
4463
|
const selectClause = formatSelectClause(fields);
|
|
4553
4464
|
const whereClause = formatWhereClauses(query);
|
|
4554
4465
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4559,7 +4470,6 @@ function getRouteNetworks(query = {}, fields = [], orderBy2 = [], options = {})
|
|
|
4559
4470
|
|
|
4560
4471
|
// src/lib/gtfs/routes.ts
|
|
4561
4472
|
import { omit as omit3, pick } from "lodash-es";
|
|
4562
|
-
import sqlString26 from "sqlstring-sqlite";
|
|
4563
4473
|
function buildStoptimeSubquery(query) {
|
|
4564
4474
|
const whereClause = formatWhereClauses(query);
|
|
4565
4475
|
return `SELECT DISTINCT trip_id FROM stop_times ${whereClause}`;
|
|
@@ -4581,7 +4491,7 @@ function buildTripSubquery(query) {
|
|
|
4581
4491
|
}
|
|
4582
4492
|
function getRoutes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4583
4493
|
const db = options.db ?? openDb();
|
|
4584
|
-
const tableName =
|
|
4494
|
+
const tableName = "routes";
|
|
4585
4495
|
const selectClause = formatSelectClause(fields);
|
|
4586
4496
|
let whereClause = "";
|
|
4587
4497
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4606,14 +4516,12 @@ function getRoutes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4606
4516
|
|
|
4607
4517
|
// src/lib/gtfs/shapes.ts
|
|
4608
4518
|
import { compact as compact2, omit as omit4, pick as pick2 } from "lodash-es";
|
|
4609
|
-
import sqlString28 from "sqlstring-sqlite";
|
|
4610
4519
|
import { featureCollection as featureCollection2 } from "@turf/helpers";
|
|
4611
4520
|
|
|
4612
4521
|
// src/lib/gtfs-plus/route-attributes.ts
|
|
4613
|
-
import sqlString27 from "sqlstring-sqlite";
|
|
4614
4522
|
function getRouteAttributes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4615
4523
|
const db = options.db ?? openDb();
|
|
4616
|
-
const tableName =
|
|
4524
|
+
const tableName = "route_attributes";
|
|
4617
4525
|
const selectClause = formatSelectClause(fields);
|
|
4618
4526
|
const whereClause = formatWhereClauses(query);
|
|
4619
4527
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4629,7 +4537,7 @@ function buildTripSubquery2(query) {
|
|
|
4629
4537
|
}
|
|
4630
4538
|
function getShapes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4631
4539
|
const db = options.db ?? openDb();
|
|
4632
|
-
const tableName =
|
|
4540
|
+
const tableName = "shapes";
|
|
4633
4541
|
const selectClause = formatSelectClause(fields);
|
|
4634
4542
|
let whereClause = "";
|
|
4635
4543
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4656,48 +4564,47 @@ function getShapes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4656
4564
|
function getShapesAsGeoJSON(query = {}, options = {}) {
|
|
4657
4565
|
const agencies = getAgencies2({}, [], [], options);
|
|
4658
4566
|
const routeQuery = pick2(query, ["route_id"]);
|
|
4659
|
-
const
|
|
4567
|
+
const routes2 = getRoutes(routeQuery, [], [], options);
|
|
4660
4568
|
const features = compact2(
|
|
4661
|
-
|
|
4569
|
+
routes2.map((route) => {
|
|
4662
4570
|
const shapeQuery = {
|
|
4663
4571
|
route_id: route.route_id,
|
|
4664
4572
|
...omit4(query, "route_id")
|
|
4665
4573
|
};
|
|
4666
|
-
const
|
|
4574
|
+
const shapes2 = getShapes(
|
|
4667
4575
|
shapeQuery,
|
|
4668
4576
|
["shape_id", "shape_pt_sequence", "shape_pt_lon", "shape_pt_lat"],
|
|
4669
4577
|
[],
|
|
4670
4578
|
options
|
|
4671
4579
|
);
|
|
4672
|
-
if (
|
|
4580
|
+
if (shapes2.length === 0) {
|
|
4673
4581
|
return;
|
|
4674
4582
|
}
|
|
4675
|
-
const
|
|
4583
|
+
const routeAttributes2 = getRouteAttributes(
|
|
4676
4584
|
{ route_id: route.route_id },
|
|
4677
4585
|
[],
|
|
4678
4586
|
[],
|
|
4679
4587
|
options
|
|
4680
4588
|
);
|
|
4681
|
-
const
|
|
4682
|
-
(
|
|
4589
|
+
const agency2 = agencies.find(
|
|
4590
|
+
(agency3) => agency3.agency_id === route.agency_id
|
|
4683
4591
|
);
|
|
4684
4592
|
const geojsonProperties = {
|
|
4685
|
-
agency_name:
|
|
4593
|
+
agency_name: agency2 ? agency2.agency_name : void 0,
|
|
4686
4594
|
shape_id: query.shape_id,
|
|
4687
4595
|
...route,
|
|
4688
|
-
...
|
|
4596
|
+
...routeAttributes2?.[0] || []
|
|
4689
4597
|
};
|
|
4690
|
-
return shapesToGeoJSONFeature(
|
|
4598
|
+
return shapesToGeoJSONFeature(shapes2, geojsonProperties);
|
|
4691
4599
|
})
|
|
4692
4600
|
);
|
|
4693
4601
|
return featureCollection2(features);
|
|
4694
4602
|
}
|
|
4695
4603
|
|
|
4696
4604
|
// src/lib/gtfs/stop-areas.ts
|
|
4697
|
-
import sqlString29 from "sqlstring-sqlite";
|
|
4698
4605
|
function getStopAreas(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4699
4606
|
const db = options.db ?? openDb();
|
|
4700
|
-
const tableName =
|
|
4607
|
+
const tableName = "stop_areas";
|
|
4701
4608
|
const selectClause = formatSelectClause(fields);
|
|
4702
4609
|
const whereClause = formatWhereClauses(query);
|
|
4703
4610
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4708,13 +4615,11 @@ function getStopAreas(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4708
4615
|
|
|
4709
4616
|
// src/lib/gtfs/stops.ts
|
|
4710
4617
|
import { omit as omit5, orderBy, pick as pick3 } from "lodash-es";
|
|
4711
|
-
import sqlString31 from "sqlstring-sqlite";
|
|
4712
4618
|
|
|
4713
4619
|
// src/lib/gtfs-plus/stop-attributes.ts
|
|
4714
|
-
import sqlString30 from "sqlstring-sqlite";
|
|
4715
4620
|
function getStopAttributes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4716
4621
|
const db = options.db ?? openDb();
|
|
4717
|
-
const tableName =
|
|
4622
|
+
const tableName = "stop_attributes";
|
|
4718
4623
|
const selectClause = formatSelectClause(fields);
|
|
4719
4624
|
const whereClause = formatWhereClauses(query);
|
|
4720
4625
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4735,7 +4640,7 @@ function buildStoptimeSubquery2(query) {
|
|
|
4735
4640
|
}
|
|
4736
4641
|
function getStops(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4737
4642
|
const db = options.db ?? openDb();
|
|
4738
|
-
const tableName =
|
|
4643
|
+
const tableName = "stops";
|
|
4739
4644
|
const selectClause = formatSelectClause(fields);
|
|
4740
4645
|
let whereClause = "";
|
|
4741
4646
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4781,20 +4686,20 @@ function getStops(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4781
4686
|
}
|
|
4782
4687
|
function getStopsAsGeoJSON(query = {}, options = {}) {
|
|
4783
4688
|
const db = options.db ?? openDb();
|
|
4784
|
-
const
|
|
4689
|
+
const stops2 = getStops(query, [], [], options);
|
|
4785
4690
|
const agencies = getAgencies2({}, [], [], options);
|
|
4786
|
-
const preparedStops =
|
|
4691
|
+
const preparedStops = stops2.map((stop) => {
|
|
4787
4692
|
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
|
|
4693
|
+
const routes2 = db.prepare(`SELECT * FROM routes WHERE route_id IN (${routeSubquery})`).all(stop.stop_id);
|
|
4694
|
+
const stopAttributes2 = getStopAttributes({ stop_id: stop.stop_id });
|
|
4790
4695
|
stop.routes = orderBy(
|
|
4791
|
-
|
|
4696
|
+
routes2,
|
|
4792
4697
|
(route) => route?.route_short_name ? Number.parseInt(route.route_short_name, 10) : 0
|
|
4793
4698
|
);
|
|
4794
4699
|
stop.agency_name = agencies[0].agency_name;
|
|
4795
4700
|
return {
|
|
4796
4701
|
...stop,
|
|
4797
|
-
...
|
|
4702
|
+
...stopAttributes2?.[0] || []
|
|
4798
4703
|
};
|
|
4799
4704
|
});
|
|
4800
4705
|
const filteredStops = preparedStops.filter((stop) => stop.routes.length > 0);
|
|
@@ -4802,10 +4707,9 @@ function getStopsAsGeoJSON(query = {}, options = {}) {
|
|
|
4802
4707
|
}
|
|
4803
4708
|
|
|
4804
4709
|
// src/lib/gtfs/stop-times.ts
|
|
4805
|
-
import sqlString32 from "sqlstring-sqlite";
|
|
4806
4710
|
function getStoptimes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4807
4711
|
const db = options.db ?? openDb();
|
|
4808
|
-
const tableName =
|
|
4712
|
+
const tableName = "stop_times";
|
|
4809
4713
|
const selectClause = formatSelectClause(fields);
|
|
4810
4714
|
const whereClause = formatWhereClauses(query);
|
|
4811
4715
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4815,10 +4719,9 @@ function getStoptimes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4815
4719
|
}
|
|
4816
4720
|
|
|
4817
4721
|
// src/lib/gtfs/timeframes.ts
|
|
4818
|
-
import sqlString33 from "sqlstring-sqlite";
|
|
4819
4722
|
function getTimeframes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4820
4723
|
const db = options.db ?? openDb();
|
|
4821
|
-
const tableName =
|
|
4724
|
+
const tableName = "timeframes";
|
|
4822
4725
|
const selectClause = formatSelectClause(fields);
|
|
4823
4726
|
const whereClause = formatWhereClauses(query);
|
|
4824
4727
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4828,10 +4731,9 @@ function getTimeframes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4828
4731
|
}
|
|
4829
4732
|
|
|
4830
4733
|
// src/lib/gtfs/transfers.ts
|
|
4831
|
-
import sqlString34 from "sqlstring-sqlite";
|
|
4832
4734
|
function getTransfers(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4833
4735
|
const db = options.db ?? openDb();
|
|
4834
|
-
const tableName =
|
|
4736
|
+
const tableName = "transfers";
|
|
4835
4737
|
const selectClause = formatSelectClause(fields);
|
|
4836
4738
|
const whereClause = formatWhereClauses(query);
|
|
4837
4739
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4841,10 +4743,9 @@ function getTransfers(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4841
4743
|
}
|
|
4842
4744
|
|
|
4843
4745
|
// src/lib/gtfs/translations.ts
|
|
4844
|
-
import sqlString35 from "sqlstring-sqlite";
|
|
4845
4746
|
function getTranslations(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4846
4747
|
const db = options.db ?? openDb();
|
|
4847
|
-
const tableName =
|
|
4748
|
+
const tableName = "translations";
|
|
4848
4749
|
const selectClause = formatSelectClause(fields);
|
|
4849
4750
|
const whereClause = formatWhereClauses(query);
|
|
4850
4751
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4854,10 +4755,9 @@ function getTranslations(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4854
4755
|
}
|
|
4855
4756
|
|
|
4856
4757
|
// src/lib/gtfs/trips.ts
|
|
4857
|
-
import sqlString36 from "sqlstring-sqlite";
|
|
4858
4758
|
function getTrips(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4859
4759
|
const db = options.db ?? openDb();
|
|
4860
|
-
const tableName =
|
|
4760
|
+
const tableName = "trips";
|
|
4861
4761
|
const selectClause = formatSelectClause(fields);
|
|
4862
4762
|
const whereClause = formatWhereClauses(query);
|
|
4863
4763
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4867,10 +4767,9 @@ function getTrips(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4867
4767
|
}
|
|
4868
4768
|
|
|
4869
4769
|
// src/lib/gtfs-plus/calendar-attributes.ts
|
|
4870
|
-
import sqlString37 from "sqlstring-sqlite";
|
|
4871
4770
|
function getCalendarAttributes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4872
4771
|
const db = options.db ?? openDb();
|
|
4873
|
-
const tableName =
|
|
4772
|
+
const tableName = "calendar_attributes";
|
|
4874
4773
|
const selectClause = formatSelectClause(fields);
|
|
4875
4774
|
const whereClause = formatWhereClauses(query);
|
|
4876
4775
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4880,10 +4779,9 @@ function getCalendarAttributes(query = {}, fields = [], orderBy2 = [], options =
|
|
|
4880
4779
|
}
|
|
4881
4780
|
|
|
4882
4781
|
// src/lib/gtfs-plus/directions.ts
|
|
4883
|
-
import sqlString38 from "sqlstring-sqlite";
|
|
4884
4782
|
function getDirections(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4885
4783
|
const db = options.db ?? openDb();
|
|
4886
|
-
const tableName =
|
|
4784
|
+
const tableName = "directions";
|
|
4887
4785
|
const selectClause = formatSelectClause(fields);
|
|
4888
4786
|
const whereClause = formatWhereClauses(query);
|
|
4889
4787
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4893,10 +4791,9 @@ function getDirections(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4893
4791
|
}
|
|
4894
4792
|
|
|
4895
4793
|
// src/lib/non-standard/timetables.ts
|
|
4896
|
-
import sqlString39 from "sqlstring-sqlite";
|
|
4897
4794
|
function getTimetables(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4898
4795
|
const db = options.db ?? openDb();
|
|
4899
|
-
const tableName =
|
|
4796
|
+
const tableName = "timetables";
|
|
4900
4797
|
const selectClause = formatSelectClause(fields);
|
|
4901
4798
|
const whereClause = formatWhereClauses(query);
|
|
4902
4799
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4906,10 +4803,9 @@ function getTimetables(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4906
4803
|
}
|
|
4907
4804
|
|
|
4908
4805
|
// src/lib/non-standard/timetable-stop-order.ts
|
|
4909
|
-
import sqlString40 from "sqlstring-sqlite";
|
|
4910
4806
|
function getTimetableStopOrders(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4911
4807
|
const db = options.db ?? openDb();
|
|
4912
|
-
const tableName =
|
|
4808
|
+
const tableName = "timetable_stop_order";
|
|
4913
4809
|
const selectClause = formatSelectClause(fields);
|
|
4914
4810
|
const whereClause = formatWhereClauses(query);
|
|
4915
4811
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4919,10 +4815,9 @@ function getTimetableStopOrders(query = {}, fields = [], orderBy2 = [], options
|
|
|
4919
4815
|
}
|
|
4920
4816
|
|
|
4921
4817
|
// src/lib/non-standard/timetable-pages.ts
|
|
4922
|
-
import sqlString41 from "sqlstring-sqlite";
|
|
4923
4818
|
function getTimetablePages(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4924
4819
|
const db = options.db ?? openDb();
|
|
4925
|
-
const tableName =
|
|
4820
|
+
const tableName = "timetable_pages";
|
|
4926
4821
|
const selectClause = formatSelectClause(fields);
|
|
4927
4822
|
const whereClause = formatWhereClauses(query);
|
|
4928
4823
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4932,10 +4827,9 @@ function getTimetablePages(query = {}, fields = [], orderBy2 = [], options = {})
|
|
|
4932
4827
|
}
|
|
4933
4828
|
|
|
4934
4829
|
// src/lib/non-standard/timetable-notes.ts
|
|
4935
|
-
import sqlString42 from "sqlstring-sqlite";
|
|
4936
4830
|
function getTimetableNotes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4937
4831
|
const db = options.db ?? openDb();
|
|
4938
|
-
const tableName =
|
|
4832
|
+
const tableName = "timetable_notes";
|
|
4939
4833
|
const selectClause = formatSelectClause(fields);
|
|
4940
4834
|
const whereClause = formatWhereClauses(query);
|
|
4941
4835
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4945,10 +4839,9 @@ function getTimetableNotes(query = {}, fields = [], orderBy2 = [], options = {})
|
|
|
4945
4839
|
}
|
|
4946
4840
|
|
|
4947
4841
|
// src/lib/non-standard/timetable-notes-references.ts
|
|
4948
|
-
import sqlString43 from "sqlstring-sqlite";
|
|
4949
4842
|
function getTimetableNotesReferences(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4950
4843
|
const db = options.db ?? openDb();
|
|
4951
|
-
const tableName =
|
|
4844
|
+
const tableName = "timetable_notes_references";
|
|
4952
4845
|
const selectClause = formatSelectClause(fields);
|
|
4953
4846
|
const whereClause = formatWhereClauses(query);
|
|
4954
4847
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4958,10 +4851,9 @@ function getTimetableNotesReferences(query = {}, fields = [], orderBy2 = [], opt
|
|
|
4958
4851
|
}
|
|
4959
4852
|
|
|
4960
4853
|
// src/lib/non-standard/trips-dated-vehicle-journey.ts
|
|
4961
|
-
import sqlString44 from "sqlstring-sqlite";
|
|
4962
4854
|
function getTripsDatedVehicleJourneys(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4963
4855
|
const db = options.db ?? openDb();
|
|
4964
|
-
const tableName =
|
|
4856
|
+
const tableName = "trips_dated_vehicle_journey";
|
|
4965
4857
|
const selectClause = formatSelectClause(fields);
|
|
4966
4858
|
const whereClause = formatWhereClauses(query);
|
|
4967
4859
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4971,10 +4863,9 @@ function getTripsDatedVehicleJourneys(query = {}, fields = [], orderBy2 = [], op
|
|
|
4971
4863
|
}
|
|
4972
4864
|
|
|
4973
4865
|
// src/lib/gtfs-ride/board-alights.ts
|
|
4974
|
-
import sqlString45 from "sqlstring-sqlite";
|
|
4975
4866
|
function getBoardAlights(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4976
4867
|
const db = options.db ?? openDb();
|
|
4977
|
-
const tableName =
|
|
4868
|
+
const tableName = "board_alight";
|
|
4978
4869
|
const selectClause = formatSelectClause(fields);
|
|
4979
4870
|
const whereClause = formatWhereClauses(query);
|
|
4980
4871
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4983,11 +4874,10 @@ function getBoardAlights(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
4983
4874
|
).all();
|
|
4984
4875
|
}
|
|
4985
4876
|
|
|
4986
|
-
// src/lib/gtfs-ride/ride-feed-
|
|
4987
|
-
|
|
4988
|
-
function getRideFeedInfos(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4877
|
+
// src/lib/gtfs-ride/ride-feed-info.ts
|
|
4878
|
+
function getRideFeedInfo(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4989
4879
|
const db = options.db ?? openDb();
|
|
4990
|
-
const tableName =
|
|
4880
|
+
const tableName = "ride_feed_info";
|
|
4991
4881
|
const selectClause = formatSelectClause(fields);
|
|
4992
4882
|
const whereClause = formatWhereClauses(query);
|
|
4993
4883
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -4997,10 +4887,9 @@ function getRideFeedInfos(query = {}, fields = [], orderBy2 = [], options = {})
|
|
|
4997
4887
|
}
|
|
4998
4888
|
|
|
4999
4889
|
// src/lib/gtfs-ride/rider-trips.ts
|
|
5000
|
-
import sqlString47 from "sqlstring-sqlite";
|
|
5001
4890
|
function getRiderTrips(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5002
4891
|
const db = options.db ?? openDb();
|
|
5003
|
-
const tableName =
|
|
4892
|
+
const tableName = "rider_trip";
|
|
5004
4893
|
const selectClause = formatSelectClause(fields);
|
|
5005
4894
|
const whereClause = formatWhereClauses(query);
|
|
5006
4895
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5009,11 +4898,10 @@ function getRiderTrips(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
5009
4898
|
).all();
|
|
5010
4899
|
}
|
|
5011
4900
|
|
|
5012
|
-
// src/lib/gtfs-ride/
|
|
5013
|
-
|
|
5014
|
-
function getRiderships(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
4901
|
+
// src/lib/gtfs-ride/ridership.ts
|
|
4902
|
+
function getRidership(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5015
4903
|
const db = options.db ?? openDb();
|
|
5016
|
-
const tableName =
|
|
4904
|
+
const tableName = "ridership";
|
|
5017
4905
|
const selectClause = formatSelectClause(fields);
|
|
5018
4906
|
const whereClause = formatWhereClauses(query);
|
|
5019
4907
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5023,10 +4911,9 @@ function getRiderships(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
5023
4911
|
}
|
|
5024
4912
|
|
|
5025
4913
|
// src/lib/gtfs-ride/trip-capacities.ts
|
|
5026
|
-
import sqlString49 from "sqlstring-sqlite";
|
|
5027
4914
|
function getTripCapacities(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5028
4915
|
const db = options.db ?? openDb();
|
|
5029
|
-
const tableName =
|
|
4916
|
+
const tableName = "trip_capacity";
|
|
5030
4917
|
const selectClause = formatSelectClause(fields);
|
|
5031
4918
|
const whereClause = formatWhereClauses(query);
|
|
5032
4919
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5036,10 +4923,9 @@ function getTripCapacities(query = {}, fields = [], orderBy2 = [], options = {})
|
|
|
5036
4923
|
}
|
|
5037
4924
|
|
|
5038
4925
|
// src/lib/gtfs-realtime/stop-time-updates.ts
|
|
5039
|
-
import sqlString50 from "sqlstring-sqlite";
|
|
5040
4926
|
function getStopTimeUpdates(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5041
4927
|
const db = options.db ?? openDb();
|
|
5042
|
-
const tableName =
|
|
4928
|
+
const tableName = "stop_time_updates";
|
|
5043
4929
|
const selectClause = formatSelectClause(fields);
|
|
5044
4930
|
const whereClause = formatWhereClauses(query);
|
|
5045
4931
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5049,10 +4935,9 @@ function getStopTimeUpdates(query = {}, fields = [], orderBy2 = [], options = {}
|
|
|
5049
4935
|
}
|
|
5050
4936
|
|
|
5051
4937
|
// src/lib/gtfs-realtime/trip-updates.ts
|
|
5052
|
-
import sqlString51 from "sqlstring-sqlite";
|
|
5053
4938
|
function getTripUpdates(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5054
4939
|
const db = options.db ?? openDb();
|
|
5055
|
-
const tableName =
|
|
4940
|
+
const tableName = "trip_updates";
|
|
5056
4941
|
const selectClause = formatSelectClause(fields);
|
|
5057
4942
|
const whereClause = formatWhereClauses(query);
|
|
5058
4943
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5062,10 +4947,9 @@ function getTripUpdates(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
5062
4947
|
}
|
|
5063
4948
|
|
|
5064
4949
|
// src/lib/gtfs-realtime/vehicle-positions.ts
|
|
5065
|
-
import sqlString52 from "sqlstring-sqlite";
|
|
5066
4950
|
function getVehiclePositions(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5067
4951
|
const db = options.db ?? openDb();
|
|
5068
|
-
const tableName =
|
|
4952
|
+
const tableName = "vehicle_positions";
|
|
5069
4953
|
const selectClause = formatSelectClause(fields);
|
|
5070
4954
|
const whereClause = formatWhereClauses(query);
|
|
5071
4955
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5075,24 +4959,22 @@ function getVehiclePositions(query = {}, fields = [], orderBy2 = [], options = {
|
|
|
5075
4959
|
}
|
|
5076
4960
|
|
|
5077
4961
|
// src/lib/gtfs-realtime/service-alerts.ts
|
|
5078
|
-
import sqlString53 from "sqlstring-sqlite";
|
|
5079
4962
|
function getServiceAlerts(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5080
4963
|
const db = options.db ?? openDb();
|
|
5081
|
-
const tableName =
|
|
5082
|
-
const
|
|
4964
|
+
const tableName = "service_alerts";
|
|
4965
|
+
const joinTableName = "service_alert_targets";
|
|
5083
4966
|
const selectClause = formatSelectClause(fields);
|
|
5084
4967
|
const whereClause = formatWhereClauses(query);
|
|
5085
4968
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
5086
4969
|
return db.prepare(
|
|
5087
|
-
`${selectClause} FROM ${tableName} INNER JOIN ${
|
|
4970
|
+
`${selectClause} FROM ${tableName} INNER JOIN ${joinTableName} ON ${tableName}.id=${joinTableName}.alert_id ${whereClause} ${orderByClause};`
|
|
5088
4971
|
).all();
|
|
5089
4972
|
}
|
|
5090
4973
|
|
|
5091
4974
|
// src/lib/ods/deadheads.ts
|
|
5092
|
-
import sqlString54 from "sqlstring-sqlite";
|
|
5093
4975
|
function getDeadheads(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5094
4976
|
const db = options.db ?? openDb();
|
|
5095
|
-
const tableName =
|
|
4977
|
+
const tableName = "deadheads";
|
|
5096
4978
|
const selectClause = formatSelectClause(fields);
|
|
5097
4979
|
const whereClause = formatWhereClauses(query);
|
|
5098
4980
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5102,10 +4984,9 @@ function getDeadheads(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
5102
4984
|
}
|
|
5103
4985
|
|
|
5104
4986
|
// src/lib/ods/deadhead-times.ts
|
|
5105
|
-
import sqlString55 from "sqlstring-sqlite";
|
|
5106
4987
|
function getDeadheadTimes(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5107
4988
|
const db = options.db ?? openDb();
|
|
5108
|
-
const tableName =
|
|
4989
|
+
const tableName = "deadhead_times";
|
|
5109
4990
|
const selectClause = formatSelectClause(fields);
|
|
5110
4991
|
const whereClause = formatWhereClauses(query);
|
|
5111
4992
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5115,10 +4996,9 @@ function getDeadheadTimes(query = {}, fields = [], orderBy2 = [], options = {})
|
|
|
5115
4996
|
}
|
|
5116
4997
|
|
|
5117
4998
|
// src/lib/ods/ops-locations.ts
|
|
5118
|
-
import sqlString56 from "sqlstring-sqlite";
|
|
5119
4999
|
function getOpsLocations(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5120
5000
|
const db = options.db ?? openDb();
|
|
5121
|
-
const tableName =
|
|
5001
|
+
const tableName = "ops_locations";
|
|
5122
5002
|
const selectClause = formatSelectClause(fields);
|
|
5123
5003
|
const whereClause = formatWhereClauses(query);
|
|
5124
5004
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5128,10 +5008,9 @@ function getOpsLocations(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
5128
5008
|
}
|
|
5129
5009
|
|
|
5130
5010
|
// src/lib/ods/run-events.ts
|
|
5131
|
-
import sqlString57 from "sqlstring-sqlite";
|
|
5132
5011
|
function getRunEvents(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5133
5012
|
const db = options.db ?? openDb();
|
|
5134
|
-
const tableName =
|
|
5013
|
+
const tableName = "run_events";
|
|
5135
5014
|
const selectClause = formatSelectClause(fields);
|
|
5136
5015
|
const whereClause = formatWhereClauses(query);
|
|
5137
5016
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5141,10 +5020,9 @@ function getRunEvents(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
|
5141
5020
|
}
|
|
5142
5021
|
|
|
5143
5022
|
// src/lib/ods/runs-pieces.ts
|
|
5144
|
-
import sqlString58 from "sqlstring-sqlite";
|
|
5145
5023
|
function getRunsPieces(query = {}, fields = [], orderBy2 = [], options = {}) {
|
|
5146
5024
|
const db = options.db ?? openDb();
|
|
5147
|
-
const tableName =
|
|
5025
|
+
const tableName = "runs_pieces";
|
|
5148
5026
|
const selectClause = formatSelectClause(fields);
|
|
5149
5027
|
const whereClause = formatWhereClauses(query);
|
|
5150
5028
|
const orderByClause = formatOrderByClause(orderBy2);
|
|
@@ -5183,9 +5061,9 @@ export {
|
|
|
5183
5061
|
getNetworks,
|
|
5184
5062
|
getOpsLocations,
|
|
5185
5063
|
getPathways,
|
|
5186
|
-
|
|
5064
|
+
getRideFeedInfo,
|
|
5187
5065
|
getRiderTrips,
|
|
5188
|
-
|
|
5066
|
+
getRidership,
|
|
5189
5067
|
getRouteAttributes,
|
|
5190
5068
|
getRouteNetworks,
|
|
5191
5069
|
getRoutes,
|