gtfs 4.11.3 → 4.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (199) hide show
  1. package/README.md +27 -5
  2. package/dist/bin/gtfs-export.d.ts +1 -0
  3. package/dist/bin/gtfs-export.js +3646 -0
  4. package/dist/bin/gtfs-export.js.map +1 -0
  5. package/dist/bin/gtfs-import.d.ts +1 -0
  6. package/dist/bin/gtfs-import.js +4146 -0
  7. package/dist/bin/gtfs-import.js.map +1 -0
  8. package/dist/bin/gtfsrealtime-update.d.ts +1 -0
  9. package/dist/bin/gtfsrealtime-update.js +3802 -0
  10. package/dist/bin/gtfsrealtime-update.js.map +1 -0
  11. package/dist/index.d.ts +169 -0
  12. package/dist/index.js +5205 -0
  13. package/dist/index.js.map +1 -0
  14. package/package.json +27 -13
  15. package/.eslintrc.json +0 -28
  16. package/.github/workflows/nodejs.yml +0 -21
  17. package/.husky/pre-commit +0 -4
  18. package/@types/index.d.ts +0 -606
  19. package/@types/tests.ts +0 -31
  20. package/@types/tsconfig.json +0 -17
  21. package/CHANGELOG.md +0 -895
  22. package/bin/gtfs-export.js +0 -42
  23. package/bin/gtfs-import.js +0 -52
  24. package/bin/gtfsrealtime-update.js +0 -35
  25. package/config-sample-full.json +0 -20
  26. package/config-sample-rtupdates.json +0 -16
  27. package/config-sample.json +0 -8
  28. package/docs/images/node-gtfs-logo.svg +0 -18
  29. package/index.js +0 -1
  30. package/lib/advancedQuery.js +0 -36
  31. package/lib/db.js +0 -92
  32. package/lib/export.js +0 -141
  33. package/lib/file-utils.js +0 -103
  34. package/lib/geojson-utils.js +0 -138
  35. package/lib/gtfs/agencies.js +0 -32
  36. package/lib/gtfs/areas.js +0 -27
  37. package/lib/gtfs/attributions.js +0 -32
  38. package/lib/gtfs/booking-rules.js +0 -32
  39. package/lib/gtfs/calendar-dates.js +0 -32
  40. package/lib/gtfs/calendars.js +0 -32
  41. package/lib/gtfs/fare-attributes.js +0 -32
  42. package/lib/gtfs/fare-leg-rules.js +0 -32
  43. package/lib/gtfs/fare-media.js +0 -32
  44. package/lib/gtfs/fare-products.js +0 -32
  45. package/lib/gtfs/fare-rules.js +0 -32
  46. package/lib/gtfs/fare-transfer-rules.js +0 -32
  47. package/lib/gtfs/feed-info.js +0 -32
  48. package/lib/gtfs/frequencies.js +0 -32
  49. package/lib/gtfs/levels.js +0 -27
  50. package/lib/gtfs/location-group-stops.js +0 -32
  51. package/lib/gtfs/location-groups.js +0 -32
  52. package/lib/gtfs/locations.js +0 -32
  53. package/lib/gtfs/networks.js +0 -32
  54. package/lib/gtfs/pathways.js +0 -32
  55. package/lib/gtfs/route-networks.js +0 -32
  56. package/lib/gtfs/routes.js +0 -56
  57. package/lib/gtfs/shapes.js +0 -119
  58. package/lib/gtfs/stop-areas.js +0 -32
  59. package/lib/gtfs/stop-times.js +0 -32
  60. package/lib/gtfs/stops.js +0 -136
  61. package/lib/gtfs/timeframes.js +0 -32
  62. package/lib/gtfs/transfers.js +0 -32
  63. package/lib/gtfs/translations.js +0 -32
  64. package/lib/gtfs/trips.js +0 -27
  65. package/lib/gtfs-plus/calendar-attributes.js +0 -32
  66. package/lib/gtfs-plus/directions.js +0 -32
  67. package/lib/gtfs-plus/route-attributes.js +0 -32
  68. package/lib/gtfs-plus/stop-attributes.js +0 -32
  69. package/lib/gtfs-realtime/service-alerts.js +0 -34
  70. package/lib/gtfs-realtime/stop-time-updates.js +0 -32
  71. package/lib/gtfs-realtime/trip-updates.js +0 -32
  72. package/lib/gtfs-realtime/vehicle-positions.js +0 -32
  73. package/lib/gtfs-ride/board-alights.js +0 -32
  74. package/lib/gtfs-ride/ride-feed-infos.js +0 -32
  75. package/lib/gtfs-ride/rider-trips.js +0 -32
  76. package/lib/gtfs-ride/riderships.js +0 -32
  77. package/lib/gtfs-ride/trip-capacities.js +0 -32
  78. package/lib/gtfs.js +0 -261
  79. package/lib/import.js +0 -803
  80. package/lib/log-utils.js +0 -73
  81. package/lib/non-standard/timetable-notes-references.js +0 -32
  82. package/lib/non-standard/timetable-notes.js +0 -32
  83. package/lib/non-standard/timetable-pages.js +0 -32
  84. package/lib/non-standard/timetable-stop-order.js +0 -32
  85. package/lib/non-standard/timetables.js +0 -32
  86. package/lib/non-standard/trips-dated-vehicle-journey.js +0 -32
  87. package/lib/ods/deadhead-times.js +0 -32
  88. package/lib/ods/deadheads.js +0 -32
  89. package/lib/ods/ops-locations.js +0 -32
  90. package/lib/ods/run-events.js +0 -32
  91. package/lib/ods/runs-pieces.js +0 -32
  92. package/lib/utils.js +0 -178
  93. package/models/gtfs/agency.js +0 -49
  94. package/models/gtfs/areas.js +0 -19
  95. package/models/gtfs/attributions.js +0 -68
  96. package/models/gtfs/booking-rules.js +0 -92
  97. package/models/gtfs/calendar-dates.js +0 -34
  98. package/models/gtfs/calendar.js +0 -76
  99. package/models/gtfs/fare-attributes.js +0 -48
  100. package/models/gtfs/fare-leg-rules.js +0 -55
  101. package/models/gtfs/fare-media.js +0 -26
  102. package/models/gtfs/fare-products.js +0 -35
  103. package/models/gtfs/fare-rules.js +0 -34
  104. package/models/gtfs/fare-transfer-rules.js +0 -56
  105. package/models/gtfs/feed-info.js +0 -50
  106. package/models/gtfs/frequencies.js +0 -46
  107. package/models/gtfs/levels.js +0 -25
  108. package/models/gtfs/location-group-stops.js +0 -22
  109. package/models/gtfs/location-groups.js +0 -19
  110. package/models/gtfs/locations.js +0 -12
  111. package/models/gtfs/networks.js +0 -20
  112. package/models/gtfs/pathways.js +0 -74
  113. package/models/gtfs/route-networks.js +0 -21
  114. package/models/gtfs/routes.js +0 -79
  115. package/models/gtfs/shapes.js +0 -41
  116. package/models/gtfs/stop-areas.js +0 -20
  117. package/models/gtfs/stop-times.js +0 -120
  118. package/models/gtfs/stops.js +0 -85
  119. package/models/gtfs/timeframes.js +0 -29
  120. package/models/gtfs/transfers.js +0 -56
  121. package/models/gtfs/translations.js +0 -48
  122. package/models/gtfs/trips.js +0 -70
  123. package/models/gtfs-plus/calendar-attributes.js +0 -22
  124. package/models/gtfs-plus/directions.js +0 -29
  125. package/models/gtfs-plus/route-attributes.js +0 -34
  126. package/models/gtfs-plus/stop-attributes.js +0 -35
  127. package/models/gtfs-realtime/service-alert-targets.js +0 -37
  128. package/models/gtfs-realtime/service-alerts.js +0 -60
  129. package/models/gtfs-realtime/stop-time-updates.js +0 -85
  130. package/models/gtfs-realtime/trip-updates.js +0 -75
  131. package/models/gtfs-realtime/vehicle-positions.js +0 -135
  132. package/models/gtfs-ride/board-alight.js +0 -132
  133. package/models/gtfs-ride/ride-feed-info.js +0 -40
  134. package/models/gtfs-ride/rider-trip.js +0 -113
  135. package/models/gtfs-ride/ridership.js +0 -127
  136. package/models/gtfs-ride/trip-capacity.js +0 -51
  137. package/models/models.js +0 -120
  138. package/models/non-standard/timetable-notes-references.js +0 -50
  139. package/models/non-standard/timetable-notes.js +0 -24
  140. package/models/non-standard/timetable-pages.js +0 -23
  141. package/models/non-standard/timetable-stop-order.js +0 -32
  142. package/models/non-standard/timetables.js +0 -144
  143. package/models/non-standard/trips-dated-vehicle-journey.js +0 -34
  144. package/models/ods/deadhead-times.js +0 -65
  145. package/models/ods/deadheads.js +0 -60
  146. package/models/ods/ops-locations.js +0 -46
  147. package/models/ods/run-events.js +0 -70
  148. package/models/ods/runs-pieces.js +0 -59
  149. package/test/fixture/caltrain_20160406.zip +0 -0
  150. package/test/mocha/advanced-query.js +0 -74
  151. package/test/mocha/delete-db.js +0 -62
  152. package/test/mocha/export-gtfs.js +0 -147
  153. package/test/mocha/fare-transfer-rules.js +0 -32
  154. package/test/mocha/get-agencies.js +0 -90
  155. package/test/mocha/get-areas.js +0 -27
  156. package/test/mocha/get-attributions.js +0 -27
  157. package/test/mocha/get-board-alights.js +0 -28
  158. package/test/mocha/get-booking-rules.js +0 -28
  159. package/test/mocha/get-calendar-attributes.js +0 -33
  160. package/test/mocha/get-calendar-dates.js +0 -107
  161. package/test/mocha/get-calendars.js +0 -94
  162. package/test/mocha/get-directions.js +0 -28
  163. package/test/mocha/get-fare-attributes.js +0 -51
  164. package/test/mocha/get-fare-leg-rules.js +0 -27
  165. package/test/mocha/get-fare-media.js +0 -27
  166. package/test/mocha/get-fare-products.js +0 -27
  167. package/test/mocha/get-fare-rules.js +0 -50
  168. package/test/mocha/get-feed-info.js +0 -28
  169. package/test/mocha/get-frequencies.js +0 -28
  170. package/test/mocha/get-levels.js +0 -28
  171. package/test/mocha/get-location-group-stops.js +0 -33
  172. package/test/mocha/get-location-groups.js +0 -28
  173. package/test/mocha/get-locations.js +0 -69
  174. package/test/mocha/get-networks.js +0 -28
  175. package/test/mocha/get-pathways.js +0 -28
  176. package/test/mocha/get-ride-feed-infos.js +0 -24
  177. package/test/mocha/get-rider-trips.js +0 -28
  178. package/test/mocha/get-riderships.js +0 -28
  179. package/test/mocha/get-route-attributes.js +0 -33
  180. package/test/mocha/get-route-networks.js +0 -28
  181. package/test/mocha/get-routes.js +0 -143
  182. package/test/mocha/get-shapes-as-geojson.js +0 -92
  183. package/test/mocha/get-shapes.js +0 -240
  184. package/test/mocha/get-stop-attributes.js +0 -28
  185. package/test/mocha/get-stops-as-geojson.js +0 -87
  186. package/test/mocha/get-stops.js +0 -343
  187. package/test/mocha/get-stoptimes.js +0 -67
  188. package/test/mocha/get-timeframes.js +0 -28
  189. package/test/mocha/get-timetable-pages.js +0 -28
  190. package/test/mocha/get-timetable-stop-orders.js +0 -33
  191. package/test/mocha/get-timetables.js +0 -28
  192. package/test/mocha/get-transfers.js +0 -28
  193. package/test/mocha/get-translations.js +0 -28
  194. package/test/mocha/get-trip-capacities.js +0 -28
  195. package/test/mocha/get-trips.js +0 -53
  196. package/test/mocha/import-gtfs.js +0 -173
  197. package/test/mocha/open-db.js +0 -149
  198. package/test/mocha/raw-query.js +0 -34
  199. package/test/test-config.js +0 -12
@@ -1,240 +0,0 @@
1
- /* eslint-env mocha */
2
-
3
- import should from 'should';
4
-
5
- import config from '../test-config.js';
6
- import { openDb, closeDb, importGtfs, getShapes } from '../../index.js';
7
-
8
- describe('getShapes():', () => {
9
- before(async () => {
10
- openDb(config);
11
- await importGtfs(config);
12
- });
13
-
14
- after(() => {
15
- const db = openDb(config);
16
- closeDb(db);
17
- });
18
-
19
- it('should return an empty array if no shapes exist', () => {
20
- const shapeId = 'fake-shape-id';
21
-
22
- const results = getShapes({
23
- shape_id: shapeId,
24
- });
25
- should.exists(results);
26
- results.should.have.length(0);
27
- });
28
-
29
- it('should return an empty array if no matching trips exist', () => {
30
- const routeId = 'TaSj-16APR';
31
- const serviceId = 'fake-service-id';
32
-
33
- const results = getShapes({
34
- route_id: routeId,
35
- service_id: serviceId,
36
- });
37
- should.exists(results);
38
- results.should.have.length(0);
39
- });
40
-
41
- it('should return array of shapes', () => {
42
- const results = getShapes({}, [
43
- 'shape_id',
44
- 'shape_pt_lat',
45
- 'shape_pt_lon',
46
- 'shape_pt_sequence',
47
- 'shape_dist_traveled',
48
- ]);
49
-
50
- const expectedResult = {
51
- shape_id: 'cal_tam_sf',
52
- shape_pt_lat: 37.607_687_113_495_64,
53
- shape_pt_lon: -122.394_679_784_774_78,
54
- shape_pt_sequence: 244,
55
- shape_dist_traveled: null,
56
- };
57
-
58
- should.exist(results);
59
- results.length.should.equal(3008);
60
- results.should.containEql(expectedResult);
61
- });
62
-
63
- it('should return array of shapes by route', () => {
64
- const routeId = 'TaSj-16APR';
65
- const results = getShapes(
66
- {
67
- route_id: routeId,
68
- },
69
- [
70
- 'shape_id',
71
- 'shape_pt_lat',
72
- 'shape_pt_lon',
73
- 'shape_pt_sequence',
74
- 'shape_dist_traveled',
75
- ],
76
- );
77
-
78
- const expectedResult = {
79
- shape_id: 'cal_tam_sj',
80
- shape_pt_lat: 37.323558,
81
- shape_pt_lon: -121.8919,
82
- shape_pt_sequence: 10051,
83
- shape_dist_traveled: null,
84
- };
85
-
86
- should.exist(results);
87
- results.length.should.equal(331);
88
- results.should.containEql(expectedResult);
89
- });
90
-
91
- it('should return array of shapes for multiple routes', () => {
92
- const results = getShapes(
93
- {
94
- route_id: ['Lo-16APR', 'Li-16APR'],
95
- },
96
- [
97
- 'shape_id',
98
- 'shape_pt_lat',
99
- 'shape_pt_lon',
100
- 'shape_pt_sequence',
101
- 'shape_dist_traveled',
102
- ],
103
- );
104
-
105
- const expectedResult = {
106
- shape_id: 'cal_sj_sf',
107
- shape_pt_lat: 37.694_407_548_683_614,
108
- shape_pt_lon: -122.401_739_358_901_98,
109
- shape_pt_sequence: 306,
110
- shape_dist_traveled: null,
111
- };
112
-
113
- should.exist(results);
114
- results.length.should.equal(2677);
115
- results.should.containEql(expectedResult);
116
- });
117
-
118
- it('should return empty array of for invalid route', () => {
119
- const results = getShapes({
120
- route_id: 'not-valid',
121
- });
122
-
123
- should.exist(results);
124
- results.length.should.equal(0);
125
- });
126
-
127
- it('should return array of shapes by route and direction', () => {
128
- const routeId = 'TaSj-16APR';
129
- const directionId = 0;
130
- const results = getShapes(
131
- {
132
- route_id: routeId,
133
- direction_id: directionId,
134
- },
135
- [
136
- 'shape_id',
137
- 'shape_pt_lat',
138
- 'shape_pt_lon',
139
- 'shape_pt_sequence',
140
- 'shape_dist_traveled',
141
- ],
142
- );
143
-
144
- const expectedResult = {
145
- shape_id: 'cal_tam_sj',
146
- shape_pt_lat: 37.323558,
147
- shape_pt_lon: -121.8919,
148
- shape_pt_sequence: 10051,
149
- shape_dist_traveled: null,
150
- };
151
-
152
- should.exist(results);
153
- results.length.should.equal(114);
154
- results.should.containEql(expectedResult);
155
- });
156
-
157
- it('should return array of shapes for specific trip_id', () => {
158
- const tripId = '329';
159
- const results = getShapes(
160
- {
161
- trip_id: tripId,
162
- },
163
- [
164
- 'shape_id',
165
- 'shape_pt_lat',
166
- 'shape_pt_lon',
167
- 'shape_pt_sequence',
168
- 'shape_dist_traveled',
169
- ],
170
- );
171
-
172
- const expectedResult = {
173
- shape_id: 'cal_tam_sf',
174
- shape_pt_lat: 37.337_664_044_379_544,
175
- shape_pt_lon: -121.908_105_611_801_15,
176
- shape_pt_sequence: 25,
177
- shape_dist_traveled: null,
178
- };
179
-
180
- should.exist(results);
181
- results.length.should.equal(401);
182
- results.should.containEql(expectedResult);
183
- });
184
-
185
- it('should return array of shapes for specific service_id', () => {
186
- const serviceId = 'CT-16APR-Caltrain-Sunday-02';
187
- const results = getShapes(
188
- {
189
- service_id: serviceId,
190
- },
191
- [
192
- 'shape_id',
193
- 'shape_pt_lat',
194
- 'shape_pt_lon',
195
- 'shape_pt_sequence',
196
- 'shape_dist_traveled',
197
- ],
198
- );
199
-
200
- const expectedResult = {
201
- shape_id: 'cal_sj_tam',
202
- shape_pt_lat: 37.294079,
203
- shape_pt_lon: -121.874108,
204
- shape_pt_sequence: 10154,
205
- shape_dist_traveled: null,
206
- };
207
-
208
- should.exist(results);
209
- results.length.should.equal(713);
210
- results.should.containEql(expectedResult);
211
- });
212
-
213
- it('should return array of shapes for specific shape_id', () => {
214
- const shapeId = 'cal_sf_tam';
215
- const results = getShapes(
216
- {
217
- shape_id: shapeId,
218
- },
219
- [
220
- 'shape_id',
221
- 'shape_pt_lat',
222
- 'shape_pt_lon',
223
- 'shape_pt_sequence',
224
- 'shape_dist_traveled',
225
- ],
226
- );
227
-
228
- const expectedResult = {
229
- shape_id: 'cal_sf_tam',
230
- shape_pt_lat: 37.682971245836484,
231
- shape_pt_lon: -122.39507675170898,
232
- shape_pt_sequence: 88,
233
- shape_dist_traveled: null,
234
- };
235
-
236
- should.exist(results);
237
- results.length.should.equal(401);
238
- results.should.containEql(expectedResult);
239
- });
240
- });
@@ -1,28 +0,0 @@
1
- /* eslint-env mocha */
2
-
3
- import should from 'should';
4
-
5
- import config from '../test-config.js';
6
- import { openDb, closeDb, importGtfs, getStopAttributes } from '../../index.js';
7
-
8
- describe('getStopAttributes():', () => {
9
- before(async () => {
10
- openDb(config);
11
- await importGtfs(config);
12
- });
13
-
14
- after(() => {
15
- const db = openDb(config);
16
- closeDb(db);
17
- });
18
-
19
- it('should return empty array if no stop attributes', () => {
20
- const stopId = 'fake-stop-id';
21
-
22
- const results = getStopAttributes({
23
- stop_id: stopId,
24
- });
25
- should.exists(results);
26
- results.should.have.length(0);
27
- });
28
- });
@@ -1,87 +0,0 @@
1
- /* eslint-env mocha */
2
-
3
- import should from 'should';
4
-
5
- import config from '../test-config.js';
6
- import { openDb, closeDb, importGtfs, getStopsAsGeoJSON } from '../../index.js';
7
-
8
- describe('getStopsAsGeoJSON(): ', () => {
9
- before(async () => {
10
- openDb(config);
11
- await importGtfs(config);
12
- });
13
-
14
- after(() => {
15
- const db = openDb(config);
16
- closeDb(db);
17
- });
18
-
19
- it('should return geojson with an empty features array if no stops exist', () => {
20
- const stopId = 'fake-stop-id';
21
- const geojson = getStopsAsGeoJSON({
22
- stop_id: stopId,
23
- });
24
-
25
- should.exist(geojson);
26
- geojson.type.should.equal('FeatureCollection');
27
- geojson.features.should.have.length(0);
28
- });
29
-
30
- it('should return geojson with stops if they exist', () => {
31
- const geojson = getStopsAsGeoJSON();
32
-
33
- should.exist(geojson);
34
- geojson.type.should.equal('FeatureCollection');
35
- geojson.features.length.should.be.above(1);
36
- should.exist(geojson.features[0].geometry.coordinates);
37
- geojson.features[0].geometry.coordinates.length.should.equal(2);
38
- });
39
-
40
- it('should return geojson with stops if they exist for a specific stopId', () => {
41
- const stopId = '70031';
42
-
43
- const geojson = getStopsAsGeoJSON({
44
- stop_id: stopId,
45
- });
46
-
47
- should.exist(geojson);
48
- geojson.type.should.equal('FeatureCollection');
49
- geojson.features.length.should.equal(1);
50
- should.exist(geojson.features[0].geometry.coordinates);
51
- geojson.features[0].geometry.coordinates.length.should.equal(2);
52
- });
53
-
54
- it('should return geojson with stops if they exist for a specific shapeId', () => {
55
- const shapeId = 'cal_sf_tam';
56
-
57
- const geojson = getStopsAsGeoJSON({
58
- shape_id: shapeId,
59
- });
60
-
61
- should.exist(geojson);
62
- geojson.type.should.equal('FeatureCollection');
63
- geojson.features.length.should.equal(25);
64
- should.exist(geojson.features[0].geometry.coordinates);
65
- geojson.features[0].geometry.coordinates.length.should.equal(2);
66
- });
67
-
68
- it('should return geojson with specific stops for bounding box query', () => {
69
- const distance = 100;
70
- const stopLatitude = 37.709538;
71
- const stopLongitude = -122.401586;
72
-
73
- const geojson = getStopsAsGeoJSON(
74
- {
75
- stop_lat: stopLatitude,
76
- stop_lon: stopLongitude,
77
- },
78
- { bounding_box_side_m: distance },
79
- );
80
-
81
- should.exist(geojson);
82
- geojson.type.should.equal('FeatureCollection');
83
- geojson.features.length.should.equal(2);
84
- should.exist(geojson.features[0].geometry.coordinates);
85
- geojson.features[0].geometry.coordinates.length.should.equal(2);
86
- });
87
- });
@@ -1,343 +0,0 @@
1
- /* eslint-env mocha */
2
-
3
- import should from 'should';
4
-
5
- import config from '../test-config.js';
6
- import { openDb, closeDb, importGtfs, getStops } from '../../index.js';
7
-
8
- describe('getStops():', () => {
9
- before(async () => {
10
- openDb(config);
11
- await importGtfs(config);
12
- });
13
-
14
- after(() => {
15
- const db = openDb(config);
16
- closeDb(db);
17
- });
18
-
19
- it('should return an empty array if no stops exist', () => {
20
- const stopId = 'fake-stop-id';
21
-
22
- const results = getStops({
23
- stop_id: stopId,
24
- });
25
- should.exists(results);
26
- results.should.have.length(0);
27
- });
28
-
29
- it('should return array of stops', () => {
30
- const results = getStops();
31
-
32
- const expectedResult = {
33
- stop_id: 'ctbu',
34
- stop_code: null,
35
- stop_name: 'Burlingame Caltrain',
36
- tts_stop_name: null,
37
- stop_desc: null,
38
- stop_lat: 37.579719,
39
- stop_lon: -122.345266,
40
- zone_id: null,
41
- stop_url: 'http://www.caltrain.com/stations/burlingamestation.html',
42
- location_type: 1,
43
- parent_station: null,
44
- stop_timezone: null,
45
- wheelchair_boarding: 1,
46
- level_id: null,
47
- platform_code: null,
48
- };
49
-
50
- should.exist(results);
51
- results.length.should.equal(95);
52
- results.should.containEql(expectedResult);
53
- });
54
-
55
- it('should return array of stops for a specific stopId', () => {
56
- const stopId = '70031';
57
-
58
- const results = getStops({
59
- stop_id: stopId,
60
- });
61
-
62
- const expectedResult = [
63
- {
64
- stop_id: '70031',
65
- stop_code: '70031',
66
- stop_name: 'Bayshore Caltrain',
67
- tts_stop_name: null,
68
- stop_desc: null,
69
- stop_lat: 37.709537,
70
- stop_lon: -122.401586,
71
- zone_id: '1',
72
- stop_url: 'http://www.caltrain.com/stations/bayshorestation.html',
73
- location_type: 0,
74
- parent_station: 'ctba',
75
- stop_timezone: null,
76
- wheelchair_boarding: 1,
77
- level_id: null,
78
- platform_code: 'NB',
79
- },
80
- ];
81
-
82
- should.exist(results);
83
- results.length.should.equal(1);
84
- results.should.match(expectedResult);
85
- });
86
-
87
- it('should return array of stops if it exists for a specific route_id', () => {
88
- const routeId = 'Bu-16APR';
89
-
90
- const results = getStops(
91
- {
92
- route_id: routeId,
93
- },
94
- [],
95
- [['stop_id', 'ASC']],
96
- );
97
-
98
- const expectedStopIds = [
99
- '70011',
100
- '70012',
101
- '70021',
102
- '70022',
103
- '70061',
104
- '70062',
105
- '70091',
106
- '70092',
107
- '70111',
108
- '70112',
109
- '70141',
110
- '70142',
111
- '70161',
112
- '70162',
113
- '70171',
114
- '70172',
115
- '70211',
116
- '70212',
117
- '70221',
118
- '70222',
119
- '70261',
120
- '70262',
121
- '70271',
122
- '70272',
123
- ];
124
-
125
- should.exist(results);
126
- results.length.should.equal(24);
127
- for (const [idx, stop] of results.entries()) {
128
- expectedStopIds[idx].should.equal(
129
- stop.stop_id,
130
- 'The order of stops are expected to be the same',
131
- );
132
- }
133
- });
134
-
135
- it('should return array of stops if it exists for a specific route_id and direction_id', () => {
136
- const routeId = 'Bu-16APR';
137
- const directionId = 1;
138
-
139
- const results = getStops(
140
- {
141
- route_id: routeId,
142
- direction_id: directionId,
143
- },
144
- [],
145
- [['stop_id', 'ASC']],
146
- );
147
-
148
- const expectedStopIds = [
149
- '70012',
150
- '70022',
151
- '70062',
152
- '70092',
153
- '70112',
154
- '70142',
155
- '70162',
156
- '70172',
157
- '70212',
158
- '70222',
159
- '70262',
160
- '70272',
161
- ];
162
-
163
- should.exist(results);
164
- results.length.should.equal(12);
165
- for (const [idx, stop] of results.entries()) {
166
- expectedStopIds[idx].should.equal(
167
- stop.stop_id,
168
- 'The order of stops are expected to be the same',
169
- );
170
- }
171
- });
172
-
173
- it('should return array of stops for a specific trip_id', () => {
174
- const tripId = '427a';
175
-
176
- const results = getStops(
177
- {
178
- trip_id: tripId,
179
- },
180
- [],
181
- [['stop_id', 'ASC']],
182
- );
183
-
184
- const expectedStopIds = [
185
- '70011',
186
- '70021',
187
- '70031',
188
- '70041',
189
- '70051',
190
- '70061',
191
- '70071',
192
- '70081',
193
- '70091',
194
- '70101',
195
- '70111',
196
- '70121',
197
- '70131',
198
- '70141',
199
- '70151',
200
- '70161',
201
- '70171',
202
- '70191',
203
- '70201',
204
- '70211',
205
- '70221',
206
- '70231',
207
- '70241',
208
- '70261',
209
- ];
210
-
211
- should.exist(results);
212
- results.length.should.equal(24);
213
- for (const [idx, stop] of results.entries()) {
214
- expectedStopIds[idx].should.equal(
215
- stop.stop_id,
216
- 'The order of stops are expected to be the same',
217
- );
218
- }
219
- });
220
-
221
- it('should return array of stops if it exists for a specific shape_id', () => {
222
- const shapeId = 'cal_sf_tam';
223
-
224
- const results = getStops(
225
- {
226
- shape_id: shapeId,
227
- },
228
- [],
229
- [['stop_id', 'ASC']],
230
- );
231
-
232
- const expectedStopIds = [
233
- '70012',
234
- '70021',
235
- '70022',
236
- '70032',
237
- '70042',
238
- '70052',
239
- '70062',
240
- '70082',
241
- '70092',
242
- '70102',
243
- '70112',
244
- '70122',
245
- '70132',
246
- '70142',
247
- '70162',
248
- '70172',
249
- '70192',
250
- '70202',
251
- '70212',
252
- '70222',
253
- '70232',
254
- '70242',
255
- '70252',
256
- '70262',
257
- '70272',
258
- ];
259
-
260
- should.exist(results);
261
- results.length.should.equal(25);
262
- for (const [idx, stop] of results.entries()) {
263
- expectedStopIds[idx].should.equal(
264
- stop.stop_id,
265
- 'The order of stops are expected to be the same',
266
- );
267
- }
268
- });
269
-
270
- it('should return array of stops for bounding box query', () => {
271
- const distance = 100;
272
- const stopLatitude = 37.709538;
273
- const stopLongitude = -122.401586;
274
-
275
- const results = getStops(
276
- {
277
- stop_lat: stopLatitude,
278
- stop_lon: stopLongitude,
279
- },
280
- [],
281
- [],
282
- { bounding_box_side_m: distance },
283
- );
284
-
285
- const expectedResult = [
286
- {
287
- stop_id: 'ctba',
288
- stop_code: null,
289
- stop_name: 'Bayshore Caltrain',
290
- tts_stop_name: null,
291
- stop_desc: null,
292
- stop_lat: 37.709544,
293
- stop_lon: -122.401318,
294
- zone_id: null,
295
- stop_url: 'http://www.caltrain.com/stations/bayshorestation.html',
296
- location_type: 1,
297
- parent_station: null,
298
- stop_timezone: null,
299
- wheelchair_boarding: 1,
300
- level_id: null,
301
- platform_code: null,
302
- },
303
- {
304
- stop_id: '70032',
305
- stop_code: '70032',
306
- stop_name: 'Bayshore Caltrain',
307
- tts_stop_name: null,
308
- stop_desc: null,
309
- stop_lat: 37.709544,
310
- stop_lon: -122.40198,
311
- zone_id: '1',
312
- stop_url: 'http://www.caltrain.com/stations/bayshorestation.html',
313
- location_type: 0,
314
- parent_station: 'ctba',
315
- stop_timezone: null,
316
- wheelchair_boarding: 1,
317
- level_id: null,
318
- platform_code: 'SB',
319
- },
320
- {
321
- stop_id: '70031',
322
- stop_code: '70031',
323
- stop_name: 'Bayshore Caltrain',
324
- tts_stop_name: null,
325
- stop_desc: null,
326
- stop_lat: 37.709537,
327
- stop_lon: -122.401586,
328
- zone_id: '1',
329
- stop_url: 'http://www.caltrain.com/stations/bayshorestation.html',
330
- location_type: 0,
331
- parent_station: 'ctba',
332
- stop_timezone: null,
333
- wheelchair_boarding: 1,
334
- level_id: null,
335
- platform_code: 'NB',
336
- },
337
- ];
338
-
339
- should.exist(results);
340
- results.length.should.equal(3);
341
- results.should.match(expectedResult);
342
- });
343
- });