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,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, getFrequencies } from '../../index.js';
7
-
8
- describe('getFrequencies():', () => {
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 frequencies', () => {
20
- const tripId = 'not_real';
21
-
22
- const results = getFrequencies({
23
- trip_id: tripId,
24
- });
25
- should.exists(results);
26
- results.should.have.length(0);
27
- });
28
- });
@@ -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, getLevels } from '../../index.js';
7
-
8
- describe('getLevels():', () => {
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 levels', () => {
20
- const levelId = 'not_real';
21
-
22
- const results = getLevels({
23
- level_id: levelId,
24
- });
25
- should.exists(results);
26
- results.should.have.length(0);
27
- });
28
- });
@@ -1,33 +0,0 @@
1
- /* eslint-env mocha */
2
-
3
- import should from 'should';
4
-
5
- import config from '../test-config.js';
6
- import {
7
- openDb,
8
- closeDb,
9
- importGtfs,
10
- getLocationGroupStops,
11
- } from '../../index.js';
12
-
13
- describe('getLocationGroupStops():', () => {
14
- before(async () => {
15
- openDb(config);
16
- await importGtfs(config);
17
- });
18
-
19
- after(() => {
20
- const db = openDb(config);
21
- closeDb(db);
22
- });
23
-
24
- it('should return empty array if no location group stops', () => {
25
- const locationGroupId = 'not_real';
26
-
27
- const results = getLocationGroupStops({
28
- location_group_id: locationGroupId,
29
- });
30
- should.exists(results);
31
- results.should.have.length(0);
32
- });
33
- });
@@ -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, getLocationGroups } from '../../index.js';
7
-
8
- describe('getLocationGroups():', () => {
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 location groups', () => {
20
- const locationGroupId = 'not_real';
21
-
22
- const results = getLocationGroups({
23
- location_group_id: locationGroupId,
24
- });
25
- should.exists(results);
26
- results.should.have.length(0);
27
- });
28
- });
@@ -1,69 +0,0 @@
1
- /* eslint-env mocha */
2
-
3
- import should from 'should';
4
- import path from 'node:path';
5
- import { writeFile } from 'node:fs/promises';
6
-
7
- import config from '../test-config.js';
8
- import { openDb, closeDb, importGtfs, getLocations } from '../../index.js';
9
- import { unzip, prepDirectory } from '../../lib/file-utils.js';
10
-
11
- const temporaryDir = path.join(import.meta.dirname, '../fixture/tmp2/');
12
-
13
- const locationsConfig = {
14
- agencies: [
15
- {
16
- path: temporaryDir,
17
- },
18
- ],
19
- verbose: false,
20
- };
21
-
22
- describe('getLocations():', () => {
23
- before(async () => {
24
- openDb(locationsConfig);
25
-
26
- // Add locations.geojson to test GTFS dataset
27
- await prepDirectory(temporaryDir);
28
- await unzip(config.agencies[0].path, temporaryDir);
29
-
30
- const filePath = path.join(temporaryDir, 'locations.geojson');
31
- const fileText = JSON.stringify({
32
- type: 'FeatureCollection',
33
- features: [
34
- {
35
- id: '1',
36
- type: 'Feature',
37
- properties: {
38
- stop_desc: 'This is a stop for testing',
39
- stop_name: 'Test Stop 1',
40
- },
41
- geometry: {
42
- type: 'Point',
43
- coordinates: [
44
- [
45
- [-94.7805702, 44.4560958],
46
- [-94.7805608, 44.4559928],
47
- [-94.7805218, 44.4559649],
48
- ],
49
- ],
50
- },
51
- },
52
- ],
53
- });
54
- await writeFile(filePath, fileText);
55
-
56
- await importGtfs(locationsConfig);
57
- });
58
-
59
- after(() => {
60
- const db = openDb(locationsConfig);
61
- closeDb(db);
62
- });
63
-
64
- it('should return a single location', () => {
65
- const results = getLocations({});
66
- should.exists(results);
67
- results.should.have.length(1);
68
- });
69
- });
@@ -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, getNetworks } from '../../index.js';
7
-
8
- describe('getNetworks():', () => {
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 networks', () => {
20
- const networkId = 'not_real';
21
-
22
- const results = getNetworks({
23
- network_id: networkId,
24
- });
25
- should.exists(results);
26
- results.should.have.length(0);
27
- });
28
- });
@@ -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, getPathways } from '../../index.js';
7
-
8
- describe('getPathways():', () => {
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 pathways', () => {
20
- const pathwayId = 'not_real';
21
-
22
- const results = getPathways({
23
- pathway_id: pathwayId,
24
- });
25
- should.exists(results);
26
- results.should.have.length(0);
27
- });
28
- });
@@ -1,24 +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, getRideFeedInfos } from '../../index.js';
7
-
8
- describe('getRideFeedInfos():', () => {
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 ride-feed-infos (GTFS-ride)', () => {
20
- const results = getRideFeedInfos({});
21
- should.exists(results);
22
- results.should.have.length(0);
23
- });
24
- });
@@ -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, getRiderTrips } from '../../index.js';
7
-
8
- describe('getRiderTrips():', () => {
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 rider trips (GTFS-ride)', () => {
20
- const tripId = 'fake-trip-id';
21
-
22
- const results = getRiderTrips({
23
- trip_id: tripId,
24
- });
25
- should.exists(results);
26
- results.should.have.length(0);
27
- });
28
- });
@@ -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, getRiderships } from '../../index.js';
7
-
8
- describe('getRiderships():', () => {
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 riderships (GTFS-ride)', () => {
20
- const routeId = 'fake-route-id';
21
-
22
- const results = getRiderships({
23
- route_id: routeId,
24
- });
25
- should.exists(results);
26
- results.should.have.length(0);
27
- });
28
- });
@@ -1,33 +0,0 @@
1
- /* eslint-env mocha */
2
-
3
- import should from 'should';
4
-
5
- import config from '../test-config.js';
6
- import {
7
- openDb,
8
- closeDb,
9
- importGtfs,
10
- getRouteAttributes,
11
- } from '../../index.js';
12
-
13
- describe('getRouteAttributes():', () => {
14
- before(async () => {
15
- openDb(config);
16
- await importGtfs(config);
17
- });
18
-
19
- after(() => {
20
- const db = openDb(config);
21
- closeDb(db);
22
- });
23
-
24
- it('should return empty array if no route attributes', () => {
25
- const routeId = 'fake-route-id';
26
-
27
- const results = getRouteAttributes({
28
- route_id: routeId,
29
- });
30
- should.exists(results);
31
- results.should.have.length(0);
32
- });
33
- });
@@ -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, getRouteNetworks } from '../../index.js';
7
-
8
- describe('getRouteNetworks():', () => {
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 route_networks', () => {
20
- const networkId = 'not_real';
21
-
22
- const results = getRouteNetworks({
23
- network_id: networkId,
24
- });
25
- should.exists(results);
26
- results.should.have.length(0);
27
- });
28
- });
@@ -1,143 +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, getRoutes } from '../../index.js';
7
-
8
- describe('getRoutes():', () => {
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 routes for given agency exist', () => {
20
- const routeId = 'fake-route-id';
21
-
22
- const results = getRoutes({
23
- route_id: routeId,
24
- });
25
- should.exists(results);
26
- results.should.have.length(0);
27
- });
28
-
29
- it('should return expected routes', () => {
30
- const results = getRoutes({}, [], [['route_long_name', 'ASC']]);
31
-
32
- const expectedResults = [
33
- {
34
- route_id: 'Bu-16APR',
35
- agency_id: null,
36
- route_short_name: null,
37
- route_long_name: 'Baby Bullet',
38
- route_desc: null,
39
- route_type: 2,
40
- route_url: null,
41
- route_color: 'E31837',
42
- route_text_color: null,
43
- route_sort_order: null,
44
- continuous_pickup: null,
45
- continuous_drop_off: null,
46
- network_id: null,
47
- },
48
- {
49
- route_id: 'Li-16APR',
50
- agency_id: null,
51
- route_short_name: null,
52
- route_long_name: 'Limited',
53
- route_desc: null,
54
- route_type: 2,
55
- route_url: null,
56
- route_color: 'FEF0B5',
57
- route_text_color: null,
58
- route_sort_order: null,
59
- continuous_pickup: null,
60
- continuous_drop_off: null,
61
- network_id: null,
62
- },
63
- {
64
- route_id: 'Lo-16APR',
65
- agency_id: null,
66
- route_short_name: null,
67
- route_long_name: 'Local',
68
- route_desc: null,
69
- route_type: 2,
70
- route_url: null,
71
- route_color: 'FFFFFF',
72
- route_text_color: null,
73
- route_sort_order: null,
74
- continuous_pickup: null,
75
- continuous_drop_off: null,
76
- network_id: null,
77
- },
78
- {
79
- route_id: 'TaSj-16APR',
80
- agency_id: null,
81
- route_short_name: null,
82
- route_long_name: 'Tamien / San Jose Diridon Caltrain Shuttle',
83
- route_desc: null,
84
- route_type: 3,
85
- route_url: null,
86
- route_color: '41AD49',
87
- route_text_color: null,
88
- route_sort_order: null,
89
- continuous_pickup: null,
90
- continuous_drop_off: null,
91
- network_id: null,
92
- },
93
- ];
94
-
95
- should.exist(results);
96
- results.should.have.length(4);
97
- expectedResults.should.match(results);
98
- });
99
-
100
- it('should return expected routes for a specific stop_id', () => {
101
- const results = getRoutes(
102
- { stop_id: '70321' },
103
- [],
104
- [['route_long_name', 'ASC']],
105
- );
106
-
107
- const expectedResults = [
108
- {
109
- route_id: 'Li-16APR',
110
- agency_id: null,
111
- route_short_name: null,
112
- route_long_name: 'Limited',
113
- route_desc: null,
114
- route_type: 2,
115
- route_url: null,
116
- route_color: 'FEF0B5',
117
- route_text_color: null,
118
- route_sort_order: null,
119
- continuous_pickup: null,
120
- continuous_drop_off: null,
121
- network_id: null,
122
- },
123
- ];
124
-
125
- should.exist(results);
126
- results.should.have.length(1);
127
- expectedResults.should.match(results);
128
- });
129
-
130
- it('should return no routes for a invalid stop_id', () => {
131
- const results = getRoutes(
132
- { stop_id: 'not-valid' },
133
- [],
134
- [['route_long_name', 'ASC']],
135
- );
136
-
137
- const expectedResults = [];
138
-
139
- should.exist(results);
140
- results.should.have.length(0);
141
- expectedResults.should.match(results);
142
- });
143
- });
@@ -1,92 +0,0 @@
1
- /* eslint-env mocha */
2
-
3
- import should from 'should';
4
-
5
- import config from '../test-config.js';
6
- import {
7
- openDb,
8
- closeDb,
9
- importGtfs,
10
- getShapesAsGeoJSON,
11
- } from '../../index.js';
12
-
13
- describe('getShapesAsGeoJSON():', () => {
14
- before(async () => {
15
- openDb(config);
16
- await importGtfs(config);
17
- });
18
-
19
- after(() => {
20
- const db = openDb(config);
21
- closeDb(db);
22
- });
23
-
24
- it('should return geojson with an empty features array if no shapes exist', () => {
25
- const shapeId = 'fake-shape-id';
26
- const geojson = getShapesAsGeoJSON({
27
- shape_id: shapeId,
28
- });
29
-
30
- should.exist(geojson);
31
- geojson.type.should.equal('FeatureCollection');
32
- geojson.features.should.have.length(0);
33
- });
34
-
35
- it('should return geojson with shapes if they exist', () => {
36
- const geojson = getShapesAsGeoJSON();
37
-
38
- should.exist(geojson);
39
- geojson.type.should.equal('FeatureCollection');
40
- geojson.features.length.should.be.above(1);
41
- should.exist(geojson.features[0].geometry.coordinates);
42
- geojson.features[0].geometry.coordinates[0].length.should.equal(2);
43
- geojson.features[0].properties.route_color.should.startWith('#');
44
- });
45
-
46
- it('should return geojson with shapes for a specific routeId', () => {
47
- const routeId = 'Lo-16APR';
48
-
49
- const geojson = getShapesAsGeoJSON({
50
- route_id: routeId,
51
- });
52
-
53
- should.exist(geojson);
54
- geojson.type.should.equal('FeatureCollection');
55
- geojson.features.length.should.equal(2);
56
- should.exist(geojson.features[0].geometry.coordinates);
57
- geojson.features[0].geometry.coordinates[0].length.should.equal(2);
58
- geojson.features[0].properties.route_color.should.startWith('#');
59
- });
60
-
61
- it('should return geojson with shapes for a specific routeId and directionId', () => {
62
- const routeId = 'Lo-16APR';
63
- const directionId = 0;
64
-
65
- const geojson = getShapesAsGeoJSON({
66
- route_id: routeId,
67
- direction_id: directionId,
68
- });
69
-
70
- should.exist(geojson);
71
- geojson.type.should.equal('FeatureCollection');
72
- geojson.features.length.should.equal(2);
73
- should.exist(geojson.features[0].geometry.coordinates);
74
- geojson.features[0].geometry.coordinates[0].length.should.equal(2);
75
- geojson.features[0].properties.route_color.should.startWith('#');
76
- });
77
-
78
- it('should return geojson with shapes for a specific shapeId', () => {
79
- const shapeId = 'cal_sf_tam';
80
-
81
- const geojson = getShapesAsGeoJSON({
82
- shape_id: shapeId,
83
- });
84
-
85
- should.exist(geojson);
86
- geojson.type.should.equal('FeatureCollection');
87
- geojson.features.length.should.equal(3);
88
- should.exist(geojson.features[0].geometry.coordinates);
89
- geojson.features[0].geometry.coordinates[0].length.should.equal(2);
90
- geojson.features[0].properties.route_color.should.startWith('#');
91
- });
92
- });