gtfs 3.4.0 → 3.6.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/CHANGELOG.md +28 -0
- package/README.md +183 -147
- package/lib/db.js +2 -1
- package/lib/gtfs/areas.js +30 -0
- package/lib/gtfs/fare-leg-rules.js +30 -0
- package/lib/gtfs/fare-products.js +30 -0
- package/lib/gtfs/fare-transfer-rules.js +30 -0
- package/lib/gtfs/stop-areas.js +30 -0
- package/lib/gtfs.js +20 -0
- package/lib/log-utils.js +8 -7
- package/models/gtfs/areas.js +17 -0
- package/models/gtfs/attributions.js +1 -5
- package/models/gtfs/fare-leg-rules.js +28 -0
- package/models/gtfs/fare-products.js +27 -0
- package/models/gtfs/fare-rules.js +0 -2
- package/models/gtfs/fare-transfer-rules.js +45 -0
- package/models/gtfs/levels.js +1 -0
- package/models/gtfs/pathways.js +2 -0
- package/models/gtfs/routes.js +5 -0
- package/models/gtfs/stop-areas.js +17 -0
- package/models/gtfs/stops.js +1 -0
- package/models/gtfs/transfers.js +18 -3
- package/models/gtfs/trips.js +6 -5
- package/models/models.js +10 -0
- package/package.json +10 -10
- package/test/mocha/get-routes.js +5 -0
package/README.md
CHANGED
|
@@ -62,17 +62,16 @@ or
|
|
|
62
62
|
```js
|
|
63
63
|
import { importGtfs } from 'gtfs';
|
|
64
64
|
import { readFile } from 'fs/promises';
|
|
65
|
+
|
|
65
66
|
const config = JSON.parse(
|
|
66
67
|
await readFile(new URL('./config.json', import.meta.url))
|
|
67
68
|
);
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
console.error(err);
|
|
75
|
-
});
|
|
70
|
+
try {
|
|
71
|
+
await importGtfs(config);
|
|
72
|
+
} catch (error) {
|
|
73
|
+
console.error(error);
|
|
74
|
+
}
|
|
76
75
|
```
|
|
77
76
|
|
|
78
77
|
### Example Applications
|
|
@@ -312,7 +311,7 @@ const config = {
|
|
|
312
311
|
},
|
|
313
312
|
};
|
|
314
313
|
|
|
315
|
-
importGtfs(config);
|
|
314
|
+
await importGtfs(config);
|
|
316
315
|
```
|
|
317
316
|
|
|
318
317
|
## `gtfs-import` Script
|
|
@@ -339,13 +338,7 @@ const config = JSON.parse(
|
|
|
339
338
|
await readFile(new URL('./config.json', import.meta.url))
|
|
340
339
|
);
|
|
341
340
|
|
|
342
|
-
importGtfs(config)
|
|
343
|
-
.then(() => {
|
|
344
|
-
console.log('Import Successful');
|
|
345
|
-
})
|
|
346
|
-
.catch((err) => {
|
|
347
|
-
console.error(err);
|
|
348
|
-
});
|
|
341
|
+
await importGtfs(config);
|
|
349
342
|
```
|
|
350
343
|
|
|
351
344
|
Configuration can be a JSON object in your code
|
|
@@ -363,13 +356,7 @@ const config = {
|
|
|
363
356
|
],
|
|
364
357
|
};
|
|
365
358
|
|
|
366
|
-
importGtfs(config)
|
|
367
|
-
.then(() => {
|
|
368
|
-
console.log('Import Successful');
|
|
369
|
-
})
|
|
370
|
-
.catch((err) => {
|
|
371
|
-
console.error(err);
|
|
372
|
-
});
|
|
359
|
+
await importGtfs(config);
|
|
373
360
|
```
|
|
374
361
|
|
|
375
362
|
## `gtfsrealtime-update` Script
|
|
@@ -396,13 +383,7 @@ const config = JSON.parse(
|
|
|
396
383
|
await readFile(new URL('./config.json', import.meta.url))
|
|
397
384
|
);
|
|
398
385
|
|
|
399
|
-
updateGtfsRealtime(config)
|
|
400
|
-
.then(() => {
|
|
401
|
-
console.log('Update Successful');
|
|
402
|
-
})
|
|
403
|
-
.catch((err) => {
|
|
404
|
-
console.error(err);
|
|
405
|
-
});
|
|
386
|
+
await updateGtfsRealtime(config);
|
|
406
387
|
```
|
|
407
388
|
|
|
408
389
|
## `gtfs-export` Script
|
|
@@ -454,13 +435,7 @@ const config = {
|
|
|
454
435
|
],
|
|
455
436
|
};
|
|
456
437
|
|
|
457
|
-
exportGtfs(config)
|
|
458
|
-
.then(() => {
|
|
459
|
-
console.log('Export Successful');
|
|
460
|
-
})
|
|
461
|
-
.catch((err) => {
|
|
462
|
-
console.error(err);
|
|
463
|
-
});
|
|
438
|
+
await exportGtfs(config);
|
|
464
439
|
```
|
|
465
440
|
|
|
466
441
|
## Query Methods
|
|
@@ -549,14 +524,30 @@ Queries agencies and returns a promise. The result of the promise is an array of
|
|
|
549
524
|
import { getAgencies } from 'gtfs';
|
|
550
525
|
|
|
551
526
|
// Get all agencies
|
|
552
|
-
getAgencies();
|
|
527
|
+
const agencies = await getAgencies();
|
|
553
528
|
|
|
554
529
|
// Get a specific agency
|
|
555
|
-
getAgencies({
|
|
530
|
+
const agencies = await getAgencies({
|
|
556
531
|
agency_id: 'caltrain',
|
|
557
532
|
});
|
|
558
533
|
```
|
|
559
534
|
|
|
535
|
+
### getAreas(query, fields, sortBy)
|
|
536
|
+
|
|
537
|
+
Queries areas and returns a promise. The result of the promise is an array of areas.
|
|
538
|
+
|
|
539
|
+
```js
|
|
540
|
+
import { getAreas } from 'gtfs';
|
|
541
|
+
|
|
542
|
+
// Get all areas
|
|
543
|
+
const areas = await getAreas();
|
|
544
|
+
|
|
545
|
+
// Get a specific area
|
|
546
|
+
const areas = await getAreas({
|
|
547
|
+
area_id: 'area1',
|
|
548
|
+
});
|
|
549
|
+
```
|
|
550
|
+
|
|
560
551
|
### getAttributions(query, fields, sortBy)
|
|
561
552
|
|
|
562
553
|
Queries attributions and returns a promise. The result of the promise is an array of attributions.
|
|
@@ -565,10 +556,10 @@ Queries attributions and returns a promise. The result of the promise is an arra
|
|
|
565
556
|
import { getAttributions } from 'gtfs';
|
|
566
557
|
|
|
567
558
|
// Get all attributions
|
|
568
|
-
getAttributions();
|
|
559
|
+
const attributions = await getAttributions();
|
|
569
560
|
|
|
570
561
|
// Get a specific attribution
|
|
571
|
-
getAttributions({
|
|
562
|
+
const attributions = await getAttributions({
|
|
572
563
|
attribution_id: '123',
|
|
573
564
|
});
|
|
574
565
|
```
|
|
@@ -581,10 +572,10 @@ Queries routes and returns a promise. The result of the promise is an array of r
|
|
|
581
572
|
import { getRoutes } from 'gtfs';
|
|
582
573
|
|
|
583
574
|
// Get all routes, sorted by route_short_name
|
|
584
|
-
getRoutes({}, [], [['route_short_name', 'ASC']]);
|
|
575
|
+
const routes = await getRoutes({}, [], [['route_short_name', 'ASC']]);
|
|
585
576
|
|
|
586
577
|
// Get a specific route
|
|
587
|
-
getRoutes({
|
|
578
|
+
const routes = await getRoutes({
|
|
588
579
|
route_id: 'Lo-16APR',
|
|
589
580
|
});
|
|
590
581
|
```
|
|
@@ -595,7 +586,7 @@ getRoutes({
|
|
|
595
586
|
import { getRoutes } from 'gtfs';
|
|
596
587
|
|
|
597
588
|
// Get routes that serve a specific stop, sorted by `stop_name`.
|
|
598
|
-
getRoutes(
|
|
589
|
+
const routes = await getRoutes(
|
|
599
590
|
{
|
|
600
591
|
stop_id: '70011',
|
|
601
592
|
},
|
|
@@ -612,43 +603,34 @@ Queries stops and returns a promise. The result of the promise is an array of st
|
|
|
612
603
|
import { getStops } from 'gtfs';
|
|
613
604
|
|
|
614
605
|
// Get all stops
|
|
615
|
-
getStops();
|
|
606
|
+
const stops = await getStops();
|
|
616
607
|
|
|
617
608
|
// Get a specific stop by stop_id
|
|
618
|
-
getStops({
|
|
609
|
+
const stops = await getStops({
|
|
619
610
|
stop_id: '70011',
|
|
620
611
|
});
|
|
621
|
-
```
|
|
622
612
|
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
// Get all stops for a specific route
|
|
629
|
-
getStops({
|
|
613
|
+
/*
|
|
614
|
+
* `getStops` allows passing a `route_id` in the query and it will
|
|
615
|
+
* query trips and stoptimes to find all stops served by that `route_id`.
|
|
616
|
+
*/
|
|
617
|
+
const stops = await getStops({
|
|
630
618
|
route_id: 'Lo-16APR',
|
|
631
619
|
});
|
|
632
|
-
```
|
|
633
|
-
|
|
634
|
-
`getStops` allows passing a `trip_id` in the query and it will query stoptimes to find all stops on that `trip_id`.
|
|
635
620
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
getStops({
|
|
621
|
+
/*
|
|
622
|
+
* `getStops` allows passing a `trip_id` in the query and it will query
|
|
623
|
+
* stoptimes to find all stops on that `trip_id`.
|
|
624
|
+
*/
|
|
625
|
+
const stops = await getStops({
|
|
641
626
|
trip_id: '37a',
|
|
642
627
|
});
|
|
643
|
-
```
|
|
644
|
-
|
|
645
|
-
`getStops` allows passing a `shape_id` in the query and it will query trips and stoptimes to find all stops that use that `shape_id`.
|
|
646
628
|
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
getStops({
|
|
629
|
+
/*
|
|
630
|
+
* `getStops` allows passing a `shape_id` in the query and it will query
|
|
631
|
+
* trips and stoptimes to find all stops that use that `shape_id`.
|
|
632
|
+
*/
|
|
633
|
+
const stops = await getStops({
|
|
652
634
|
shape_id: 'cal_sf_tam',
|
|
653
635
|
});
|
|
654
636
|
```
|
|
@@ -661,10 +643,10 @@ Queries stops and returns a promise. The result of the promise is an geoJSON obj
|
|
|
661
643
|
import { getStopsAsGeoJSON } from 'gtfs';
|
|
662
644
|
|
|
663
645
|
// Get all stops for an agency as geoJSON
|
|
664
|
-
getStopsAsGeoJSON();
|
|
646
|
+
const stopsGeojson = await getStopsAsGeoJSON();
|
|
665
647
|
|
|
666
648
|
// Get all stops for a specific route as geoJSON
|
|
667
|
-
getStopsAsGeoJSON({
|
|
649
|
+
const stopsGeojson = await getStopsAsGeoJSON({
|
|
668
650
|
route_id: 'Lo-16APR',
|
|
669
651
|
});
|
|
670
652
|
```
|
|
@@ -677,15 +659,15 @@ Queries `stop_times` and returns a promise. The result of the promise is an arra
|
|
|
677
659
|
import { getStoptimes } from 'gtfs';
|
|
678
660
|
|
|
679
661
|
// Get all stoptimes
|
|
680
|
-
getStoptimes();
|
|
662
|
+
const stoptimes = await getStoptimes();
|
|
681
663
|
|
|
682
664
|
// Get all stoptimes for a specific stop
|
|
683
|
-
getStoptimes({
|
|
665
|
+
const stoptimes = await getStoptimes({
|
|
684
666
|
stop_id: '70011',
|
|
685
667
|
});
|
|
686
668
|
|
|
687
669
|
// Get all stoptimes for a specific trip, sorted by stop_sequence
|
|
688
|
-
getStoptimes(
|
|
670
|
+
const stoptimes = await getStoptimes(
|
|
689
671
|
{
|
|
690
672
|
trip_id: '37a',
|
|
691
673
|
},
|
|
@@ -694,7 +676,7 @@ getStoptimes(
|
|
|
694
676
|
);
|
|
695
677
|
|
|
696
678
|
// Get all stoptimes for a specific stop and service_id
|
|
697
|
-
getStoptimes({
|
|
679
|
+
const stoptimes = await getStoptimes({
|
|
698
680
|
stop_id: '70011',
|
|
699
681
|
service_id: 'CT-16APR-Caltrain-Weekday-01',
|
|
700
682
|
});
|
|
@@ -708,22 +690,22 @@ Queries trips and returns a promise. The result of the promise is an array of tr
|
|
|
708
690
|
import { getTrips } from 'gtfs';
|
|
709
691
|
|
|
710
692
|
// Get all trips
|
|
711
|
-
getTrips();
|
|
693
|
+
const trips = await getTrips();
|
|
712
694
|
|
|
713
695
|
// Get trips for a specific route and direction
|
|
714
|
-
getTrips({
|
|
696
|
+
const trips = await getTrips({
|
|
715
697
|
route_id: 'Lo-16APR',
|
|
716
698
|
direction_id: 0
|
|
717
699
|
});
|
|
718
700
|
|
|
719
701
|
// Get trips for direction '' or null
|
|
720
|
-
getTrips({
|
|
702
|
+
const trips = await getTrips({
|
|
721
703
|
route_id: 'Lo-16APR',
|
|
722
704
|
direction_id: null
|
|
723
705
|
});
|
|
724
706
|
|
|
725
707
|
// Get trips for a specific route and direction limited by a service_id
|
|
726
|
-
getTrips({
|
|
708
|
+
const trips = await getTrips({
|
|
727
709
|
route_id: 'Lo-16APR',
|
|
728
710
|
direction_id: 0,
|
|
729
711
|
service_id: '
|
|
@@ -738,7 +720,7 @@ Queries shapes and returns a promise. The result of the promise is an array of s
|
|
|
738
720
|
import { getShapes } from 'gtfs';
|
|
739
721
|
|
|
740
722
|
// Get all shapes for an agency
|
|
741
|
-
getShapes();
|
|
723
|
+
const shapes = await getShapes();
|
|
742
724
|
```
|
|
743
725
|
|
|
744
726
|
`getShapes` allows passing a `route_id` in the query and it will query trips to find all shapes served by that `route_id`.
|
|
@@ -747,30 +729,24 @@ getShapes();
|
|
|
747
729
|
import { getShapes } from 'gtfs';
|
|
748
730
|
|
|
749
731
|
// Get all shapes for a specific route and direction
|
|
750
|
-
getShapes({
|
|
732
|
+
const shapes = await getShapes({
|
|
751
733
|
route_id: 'Lo-16APR',
|
|
752
734
|
});
|
|
753
|
-
```
|
|
754
735
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
// Get all shapes for a specific trip_id
|
|
761
|
-
getShapes({
|
|
736
|
+
/*
|
|
737
|
+
* `getShapes` allows passing a `trip_id` in the query and it will query
|
|
738
|
+
* trips to find all shapes served by that `trip_id`.
|
|
739
|
+
*/
|
|
740
|
+
const shapes = await getShapes({
|
|
762
741
|
trip_id: '37a',
|
|
763
742
|
});
|
|
764
|
-
```
|
|
765
|
-
|
|
766
|
-
`getShapes` allows passing a `service_id` in the query and it will query trips to find all shapes served by that `service_id`.
|
|
767
|
-
|
|
768
|
-
```js
|
|
769
|
-
import { getShapes } from 'gtfs';
|
|
770
743
|
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
744
|
+
/*
|
|
745
|
+
* `getShapes` allows passing a `service_id` in the query and it will query
|
|
746
|
+
* trips to find all shapes served by that `service_id`.
|
|
747
|
+
*/
|
|
748
|
+
const shapes = await getShapes({
|
|
749
|
+
service_id: 'CT-16APR-Caltrain-Sunday-02',
|
|
774
750
|
});
|
|
775
751
|
```
|
|
776
752
|
|
|
@@ -778,31 +754,29 @@ import { getShapes } from 'gtfs';
|
|
|
778
754
|
|
|
779
755
|
Queries shapes and returns a promise. The result of the promise is an geoJSON object of shapes. All valid queries for `getShapes()` work for `getShapesAsGeoJSON()`.
|
|
780
756
|
|
|
781
|
-
Returns geoJSON of shapes.
|
|
782
|
-
|
|
783
757
|
```js
|
|
784
758
|
import { getShapesAsGeoJSON } from 'gtfs';
|
|
785
759
|
|
|
786
760
|
// Get geoJSON of all routes in an agency
|
|
787
|
-
getShapesAsGeoJSON();
|
|
761
|
+
const shapesGeojson = await getShapesAsGeoJSON();
|
|
788
762
|
|
|
789
763
|
// Get geoJSON of shapes for a specific route
|
|
790
|
-
getShapesAsGeoJSON({
|
|
764
|
+
const shapesGeojson = await getShapesAsGeoJSON({
|
|
791
765
|
route_id: 'Lo-16APR',
|
|
792
766
|
});
|
|
793
767
|
|
|
794
768
|
// Get geoJSON of shapes for a specific trip
|
|
795
|
-
getShapesAsGeoJSON({
|
|
769
|
+
const shapesGeojson = await getShapesAsGeoJSON({
|
|
796
770
|
trip_id: '37a',
|
|
797
771
|
});
|
|
798
772
|
|
|
799
773
|
// Get geoJSON of shapes for a specific `service_id`
|
|
800
|
-
getShapesAsGeoJSON({
|
|
774
|
+
const shapesGeojson = await getShapesAsGeoJSON({
|
|
801
775
|
service_id: 'CT-16APR-Caltrain-Sunday-02',
|
|
802
776
|
});
|
|
803
777
|
|
|
804
778
|
// Get geoJSON of shapes for a specific `shape_id`
|
|
805
|
-
getShapesAsGeoJSON({
|
|
779
|
+
const shapesGeojson = await getShapesAsGeoJSON({
|
|
806
780
|
shape_id: 'cal_sf_tam',
|
|
807
781
|
});
|
|
808
782
|
```
|
|
@@ -815,10 +789,10 @@ Queries calendars and returns a promise. The result of the promise is an array o
|
|
|
815
789
|
import { getCalendars } from 'gtfs';
|
|
816
790
|
|
|
817
791
|
// Get all calendars for an agency
|
|
818
|
-
getCalendars();
|
|
792
|
+
const calendars = await getCalendars();
|
|
819
793
|
|
|
820
794
|
// Get calendars for a specific `service_id`
|
|
821
|
-
getCalendars({
|
|
795
|
+
const calendars = await getCalendars({
|
|
822
796
|
service_id: 'CT-16APR-Caltrain-Sunday-02',
|
|
823
797
|
});
|
|
824
798
|
```
|
|
@@ -831,10 +805,10 @@ Queries calendar_dates and returns a promise. The result of the promise is an ar
|
|
|
831
805
|
import { getCalendarDates } from 'gtfs';
|
|
832
806
|
|
|
833
807
|
// Get all calendar_dates for an agency
|
|
834
|
-
getCalendarDates();
|
|
808
|
+
const calendarDates = await getCalendarDates();
|
|
835
809
|
|
|
836
810
|
// Get calendar_dates for a specific `service_id`
|
|
837
|
-
getCalendarDates({
|
|
811
|
+
const calendarDates = await getCalendarDates({
|
|
838
812
|
service_id: 'CT-16APR-Caltrain-Sunday-02',
|
|
839
813
|
});
|
|
840
814
|
```
|
|
@@ -847,14 +821,46 @@ Queries fare_attributes and returns a promise. The result of the promise is an a
|
|
|
847
821
|
import { getFareAttributes } from 'gtfs';
|
|
848
822
|
|
|
849
823
|
// Get all `fare_attributes` for an agency
|
|
850
|
-
getFareAttributes();
|
|
824
|
+
const fareAttributes = await getFareAttributes();
|
|
851
825
|
|
|
852
826
|
// Get `fare_attributes` for a specific `fare_id`
|
|
853
|
-
getFareAttributes({
|
|
827
|
+
const fareAttributes = await getFareAttributes({
|
|
854
828
|
fare_id: '123',
|
|
855
829
|
});
|
|
856
830
|
```
|
|
857
831
|
|
|
832
|
+
### getFareLegRules(query, fields, sortBy)
|
|
833
|
+
|
|
834
|
+
Queries fare leg rules and returns a promise. The result of the promise is an array of fare leg rules.
|
|
835
|
+
|
|
836
|
+
```js
|
|
837
|
+
import { getFareLegRules } from 'gtfs';
|
|
838
|
+
|
|
839
|
+
// Get all fare leg rules
|
|
840
|
+
const fareLegRules = await getFareLegRules();
|
|
841
|
+
|
|
842
|
+
// Get fare leg rules for a specific fare product
|
|
843
|
+
const fareLegRules = await getFareLegRules({
|
|
844
|
+
fare_product_id: 'product1',
|
|
845
|
+
});
|
|
846
|
+
```
|
|
847
|
+
|
|
848
|
+
### getFareProducts(query, fields, sortBy)
|
|
849
|
+
|
|
850
|
+
Queries fare products and returns a promise. The result of the promise is an array of fare products.
|
|
851
|
+
|
|
852
|
+
```js
|
|
853
|
+
import { getFareProducts } from 'gtfs';
|
|
854
|
+
|
|
855
|
+
// Get all fare products
|
|
856
|
+
const fareProducts = await getFareProducts();
|
|
857
|
+
|
|
858
|
+
// Get a specific fare product
|
|
859
|
+
const fareProducts = await getFareProducts({
|
|
860
|
+
fare_product_id: 'product1',
|
|
861
|
+
});
|
|
862
|
+
```
|
|
863
|
+
|
|
858
864
|
### getFareRules(query, fields, sortBy)
|
|
859
865
|
|
|
860
866
|
Queries fare_rules and returns a promise. The result of the promise is an array of fare_rules.
|
|
@@ -863,14 +869,30 @@ Queries fare_rules and returns a promise. The result of the promise is an array
|
|
|
863
869
|
import { getFareRules } from 'gtfs';
|
|
864
870
|
|
|
865
871
|
// Get all `fare_rules` for an agency
|
|
866
|
-
getFareRules();
|
|
872
|
+
const fareRules = await getFareRules();
|
|
867
873
|
|
|
868
874
|
// Get fare_rules for a specific route
|
|
869
|
-
getFareRules({
|
|
875
|
+
const fareRules = await getFareRules({
|
|
870
876
|
route_id: 'Lo-16APR',
|
|
871
877
|
});
|
|
872
878
|
```
|
|
873
879
|
|
|
880
|
+
### getFareTransferRules(query, fields, sortBy)
|
|
881
|
+
|
|
882
|
+
Queries fare transfer rules and returns a promise. The result of the promise is an array of fare transfer rules.
|
|
883
|
+
|
|
884
|
+
```js
|
|
885
|
+
import { getFareTransferRules } from 'gtfs';
|
|
886
|
+
|
|
887
|
+
// Get all fare transfer rules
|
|
888
|
+
const fareTransferRules = await getFareTransferRules();
|
|
889
|
+
|
|
890
|
+
// Get a all fare transfer rules for a specific fare product
|
|
891
|
+
const fareTransferRules = await getFareTransferRules({
|
|
892
|
+
fare_product_id: 'product1',
|
|
893
|
+
});
|
|
894
|
+
```
|
|
895
|
+
|
|
874
896
|
### getFeedInfo(query, fields, sortBy)
|
|
875
897
|
|
|
876
898
|
Queries feed_info and returns a promise. The result of the promise is an array of feed_infos.
|
|
@@ -879,7 +901,7 @@ Queries feed_info and returns a promise. The result of the promise is an array o
|
|
|
879
901
|
import { getFeedInfo } from 'gtfs';
|
|
880
902
|
|
|
881
903
|
// Get feed_info
|
|
882
|
-
getFeedInfo();
|
|
904
|
+
const feedInfo = await getFeedInfo();
|
|
883
905
|
```
|
|
884
906
|
|
|
885
907
|
### getFrequencies(query, fields, sortBy)
|
|
@@ -890,10 +912,10 @@ Queries frequencies and returns a promise. The result of the promise is an array
|
|
|
890
912
|
import { getFrequencies } from 'gtfs';
|
|
891
913
|
|
|
892
914
|
// Get all frequencies
|
|
893
|
-
getFrequencies();
|
|
915
|
+
const frequencies = await getFrequencies();
|
|
894
916
|
|
|
895
917
|
// Get frequencies for a specific trip
|
|
896
|
-
getFrequencies({
|
|
918
|
+
const frequencies = await getFrequencies({
|
|
897
919
|
trip_id: '1234',
|
|
898
920
|
});
|
|
899
921
|
```
|
|
@@ -905,8 +927,8 @@ Queries levels and returns a promise. The result of the promise is an array of l
|
|
|
905
927
|
```js
|
|
906
928
|
import { getLevels } from 'gtfs';
|
|
907
929
|
|
|
908
|
-
// Get levels
|
|
909
|
-
getLevels();
|
|
930
|
+
// Get all levels
|
|
931
|
+
const levels = await getLevels();
|
|
910
932
|
```
|
|
911
933
|
|
|
912
934
|
### getPathways(query, fields, sortBy)
|
|
@@ -916,8 +938,8 @@ Queries pathways and returns a promise. The result of the promise is an array of
|
|
|
916
938
|
```js
|
|
917
939
|
import { getPathways } from 'gtfs';
|
|
918
940
|
|
|
919
|
-
// Get pathways
|
|
920
|
-
getPathways();
|
|
941
|
+
// Get all pathways
|
|
942
|
+
const pathways = await getPathways();
|
|
921
943
|
```
|
|
922
944
|
|
|
923
945
|
### getTransfers(query, fields, sortBy)
|
|
@@ -928,10 +950,10 @@ Queries transfers and returns a promise. The result of the promise is an array o
|
|
|
928
950
|
import { getTransfers } from 'gtfs';
|
|
929
951
|
|
|
930
952
|
// Get all transfers
|
|
931
|
-
getTransfers();
|
|
953
|
+
const transfers = await getTransfers();
|
|
932
954
|
|
|
933
955
|
// Get transfers for a specific stop
|
|
934
|
-
getTransfers({
|
|
956
|
+
const transfers = await getTransfers({
|
|
935
957
|
from_stop_id: '1234',
|
|
936
958
|
});
|
|
937
959
|
```
|
|
@@ -943,8 +965,8 @@ Queries translations and returns a promise. The result of the promise is an arra
|
|
|
943
965
|
```js
|
|
944
966
|
import { getTranslations } from 'gtfs';
|
|
945
967
|
|
|
946
|
-
// Get translations
|
|
947
|
-
getTranslations();
|
|
968
|
+
// Get all translations
|
|
969
|
+
const translations = await getTranslations();
|
|
948
970
|
```
|
|
949
971
|
|
|
950
972
|
### getDirections(query, fields, sortBy)
|
|
@@ -955,20 +977,31 @@ Queries directions and returns a promise. The result of the promise is an array
|
|
|
955
977
|
import { getDirections } from 'gtfs';
|
|
956
978
|
|
|
957
979
|
// Get all directions
|
|
958
|
-
getDirections();
|
|
980
|
+
const directions = await getDirections();
|
|
959
981
|
|
|
960
982
|
// Get directions for a specific route
|
|
961
|
-
getDirections({
|
|
983
|
+
const directions = await getDirections({
|
|
962
984
|
route_id: '1234',
|
|
963
985
|
});
|
|
964
986
|
|
|
965
987
|
// Get directions for a specific route and direction
|
|
966
|
-
getDirections({
|
|
988
|
+
const directions = await getDirections({
|
|
967
989
|
route_id: '1234',
|
|
968
990
|
direction_id: 1,
|
|
969
991
|
});
|
|
970
992
|
```
|
|
971
993
|
|
|
994
|
+
### getStopAreas(query, fields, sortBy)
|
|
995
|
+
|
|
996
|
+
Queries stop areas and returns a promise. The result of the promise is an array of stop areas.
|
|
997
|
+
|
|
998
|
+
```js
|
|
999
|
+
import { getStopAreas } from 'gtfs';
|
|
1000
|
+
|
|
1001
|
+
// Get all stop areas
|
|
1002
|
+
const stopAreas = await getStopAreas();
|
|
1003
|
+
```
|
|
1004
|
+
|
|
972
1005
|
### getStopAttributes(query, fields, sortBy)
|
|
973
1006
|
|
|
974
1007
|
Queries stop_attributes and returns a promise. The result of the promise is an array of stop_attributes. These are from the non-standard `stop_attributes.txt` file. See [documentation and examples of this file](https://gtfstohtml.com/docs/stop-attributes).
|
|
@@ -977,10 +1010,10 @@ Queries stop_attributes and returns a promise. The result of the promise is an a
|
|
|
977
1010
|
import { getStopAttributes } from 'gtfs';
|
|
978
1011
|
|
|
979
1012
|
// Get all stop attributes
|
|
980
|
-
getStopAttributes();
|
|
1013
|
+
const stopAttributes = await getStopAttributes();
|
|
981
1014
|
|
|
982
1015
|
// Get stop attributes for specific stop
|
|
983
|
-
getStopAttributes({
|
|
1016
|
+
const stopAttributes = await getStopAttributes({
|
|
984
1017
|
stop_id: '1234',
|
|
985
1018
|
});
|
|
986
1019
|
```
|
|
@@ -993,10 +1026,10 @@ Queries timetables and returns a promise. The result of the promise is an array
|
|
|
993
1026
|
import { getTimetables } from 'gtfs';
|
|
994
1027
|
|
|
995
1028
|
// Get all timetables for an agency
|
|
996
|
-
getTimetables();
|
|
1029
|
+
const timetables = await getTimetables();
|
|
997
1030
|
|
|
998
1031
|
// Get a specific timetable
|
|
999
|
-
getTimetables({
|
|
1032
|
+
const timetables = await getTimetables({
|
|
1000
1033
|
timetable_id: '1',
|
|
1001
1034
|
});
|
|
1002
1035
|
```
|
|
@@ -1009,10 +1042,10 @@ Queries timetable_stop_orders and returns a promise. The result of the promise i
|
|
|
1009
1042
|
import { getTimetableStopOrders } from 'gtfs';
|
|
1010
1043
|
|
|
1011
1044
|
// Get all timetable_stop_orders
|
|
1012
|
-
getTimetableStopOrders();
|
|
1045
|
+
const timetableStopOrders = await getTimetableStopOrders();
|
|
1013
1046
|
|
|
1014
1047
|
// Get timetable_stop_orders for a specific timetable
|
|
1015
|
-
getTimetableStopOrders({
|
|
1048
|
+
const timetableStopOrders = await getTimetableStopOrders({
|
|
1016
1049
|
timetable_id: '1',
|
|
1017
1050
|
});
|
|
1018
1051
|
```
|
|
@@ -1025,10 +1058,10 @@ Queries timetable_pages and returns a promise. The result of the promise is an a
|
|
|
1025
1058
|
import { getTimetablePages } from 'gtfs';
|
|
1026
1059
|
|
|
1027
1060
|
// Get all timetable_pages for an agency
|
|
1028
|
-
getTimetablePages();
|
|
1061
|
+
const timetablePages = await getTimetablePages();
|
|
1029
1062
|
|
|
1030
1063
|
// Get a specific timetable_page
|
|
1031
|
-
getTimetablePages({
|
|
1064
|
+
const timetablePages = await getTimetablePages({
|
|
1032
1065
|
timetable_page_id: '2',
|
|
1033
1066
|
});
|
|
1034
1067
|
```
|
|
@@ -1041,10 +1074,10 @@ Queries timetable_notes and returns a promise. The result of the promise is an a
|
|
|
1041
1074
|
import { getTimetableNotes } from 'gtfs';
|
|
1042
1075
|
|
|
1043
1076
|
// Get all timetable_notes for an agency
|
|
1044
|
-
getTimetableNotes();
|
|
1077
|
+
const timetableNotes = await getTimetableNotes();
|
|
1045
1078
|
|
|
1046
1079
|
// Get a specific timetable_note
|
|
1047
|
-
getTimetableNotes({
|
|
1080
|
+
const timetableNotes = await getTimetableNotes({
|
|
1048
1081
|
note_id: '1',
|
|
1049
1082
|
});
|
|
1050
1083
|
```
|
|
@@ -1057,10 +1090,10 @@ Queries timetable_notes_references and returns a promise. The result of the prom
|
|
|
1057
1090
|
import { getTimetableNotesReferences } from 'gtfs';
|
|
1058
1091
|
|
|
1059
1092
|
// Get all timetable_notes_references for an agency
|
|
1060
|
-
getTimetableNotesReferences();
|
|
1093
|
+
const timetableNotesReferences = await getTimetableNotesReferences();
|
|
1061
1094
|
|
|
1062
1095
|
// Get all timetable_notes_references for a specific timetable
|
|
1063
|
-
getTimetableNotesReferences({
|
|
1096
|
+
const timetableNotesReferences = await getTimetableNotesReferences({
|
|
1064
1097
|
timetable_id: '4',
|
|
1065
1098
|
});
|
|
1066
1099
|
```
|
|
@@ -1073,7 +1106,7 @@ Queries trips_dated_vehicle_journey and returns a promise. The result of the pro
|
|
|
1073
1106
|
import { getTripsDatedVehicleJourneys } from 'gtfs';
|
|
1074
1107
|
|
|
1075
1108
|
// Get all timetable_stop_orders
|
|
1076
|
-
getTripsDatedVehicleJourneys();
|
|
1109
|
+
const tripsDatedVehicleJourneys = await getTripsDatedVehicleJourneys();
|
|
1077
1110
|
```
|
|
1078
1111
|
|
|
1079
1112
|
### getServiceAlerts(query, fields, sortBy)
|
|
@@ -1085,7 +1118,7 @@ These are only valid if you use GTFS-Realtime and have imported Service Alert da
|
|
|
1085
1118
|
import { getServiceAlerts } from 'gtfs';
|
|
1086
1119
|
|
|
1087
1120
|
// Get service alerts
|
|
1088
|
-
getServiceAlerts();
|
|
1121
|
+
const serviceAlerts = await getServiceAlerts();
|
|
1089
1122
|
```
|
|
1090
1123
|
|
|
1091
1124
|
### getTripUpdates(query, fields, sortBy)
|
|
@@ -1097,7 +1130,7 @@ These are only valid if you use GTFS-Realtime and have imported Trip Update data
|
|
|
1097
1130
|
import { getTripUpdates } from 'gtfs';
|
|
1098
1131
|
|
|
1099
1132
|
// Get all trip updates
|
|
1100
|
-
getTripUpdates();
|
|
1133
|
+
const tripUpdates = await getTripUpdates();
|
|
1101
1134
|
```
|
|
1102
1135
|
|
|
1103
1136
|
### getStopTimesUpdates(query, fields, sortBy)
|
|
@@ -1109,7 +1142,7 @@ These are only valid if you use GTFS-Realtime and have imported Trip Update data
|
|
|
1109
1142
|
import { getStopTimesUpdates } from 'gtfs';
|
|
1110
1143
|
|
|
1111
1144
|
// Get all stop times updates
|
|
1112
|
-
getStopTimesUpdates();
|
|
1145
|
+
const stopTimesUpdates = await getStopTimesUpdates();
|
|
1113
1146
|
```
|
|
1114
1147
|
|
|
1115
1148
|
### getVehiclePositions(query, fields, sortBy)
|
|
@@ -1121,7 +1154,7 @@ These are only valid if you use GTFS-Realtime and have imported Vehicle Position
|
|
|
1121
1154
|
import { getVehiclePositions } from 'gtfs';
|
|
1122
1155
|
|
|
1123
1156
|
// Get all vehicle position data
|
|
1124
|
-
getVehiclePositions();
|
|
1157
|
+
const vehiclePositions = await getVehiclePositions();
|
|
1125
1158
|
```
|
|
1126
1159
|
|
|
1127
1160
|
### advancedQuery(table, advancedQueryOptions)
|
|
@@ -1146,8 +1179,9 @@ const advancedQueryOptions = {
|
|
|
1146
1179
|
},
|
|
1147
1180
|
],
|
|
1148
1181
|
};
|
|
1182
|
+
|
|
1149
1183
|
// Perform a custom query
|
|
1150
|
-
advancedQuery('stop_times', advancedQueryOptions);
|
|
1184
|
+
const stoptimes = await advancedQuery('stop_times', advancedQueryOptions);
|
|
1151
1185
|
```
|
|
1152
1186
|
|
|
1153
1187
|
### runRawQuery(query)
|
|
@@ -1159,7 +1193,9 @@ The result of the promise is an array the selected data.
|
|
|
1159
1193
|
import { runRawQuery } from 'gtfs';
|
|
1160
1194
|
|
|
1161
1195
|
// Perform a raw query
|
|
1162
|
-
|
|
1196
|
+
const stoptimes = await runRawQuery(
|
|
1197
|
+
'SELECT * FROM stop_times WHERE stop_sequence="1"'
|
|
1198
|
+
);
|
|
1163
1199
|
```
|
|
1164
1200
|
|
|
1165
1201
|
### execRawQuery(query)
|
|
@@ -1170,7 +1206,7 @@ Executes a statement. Returns a promise containing the result of the execute.
|
|
|
1170
1206
|
import { execRawQuery } from 'gtfs';
|
|
1171
1207
|
|
|
1172
1208
|
// Purge trips table
|
|
1173
|
-
execRawQuery('DELETE FROM trips');
|
|
1209
|
+
await execRawQuery('DELETE FROM trips');
|
|
1174
1210
|
```
|
|
1175
1211
|
|
|
1176
1212
|
## Contributing
|