gtfs-to-html 2.3.1 → 2.3.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/CHANGELOG.md CHANGED
@@ -5,7 +5,27 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [unreleased]
8
+ ## [2.3.4] - 2022-04-09
9
+
10
+ ### Updated
11
+
12
+ - Remove route info from map geojson
13
+ - Dependency updates
14
+
15
+ ## [2.3.3] - 2022-01-21
16
+
17
+ ### Updated
18
+
19
+ - Dependency updates
20
+
21
+ ## [2.3.2] - 2021-12-28
22
+
23
+ ### Updated
24
+
25
+ - Dependency updates
26
+ - Updated docs info on multi-route timetables
27
+
28
+ ## [2.3.1] - 2021-11-26
9
29
 
10
30
  ### Updated
11
31
 
package/app/index.js CHANGED
@@ -87,6 +87,7 @@ router.get('/', async (request, response, next) => {
87
87
  const html = await generateOverviewHTML(timetablePages, config);
88
88
  response.send(html);
89
89
  } catch (error) {
90
+ console.error(error);
90
91
  next(error);
91
92
  }
92
93
  });
package/lib/log-utils.js CHANGED
@@ -205,12 +205,12 @@ export function progressBar(formatString, barTotal, config) {
205
205
  config.log(renderProgressString(), true);
206
206
 
207
207
  return {
208
- interrupt: (text) => {
208
+ interrupt(text) {
209
209
  // Log two lines to avoid overwrite by progress bar
210
210
  config.logWarning(text);
211
211
  config.logWarning('');
212
212
  },
213
- increment: () => {
213
+ increment() {
214
214
  barProgress += 1;
215
215
  config.log(renderProgressString(), true);
216
216
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gtfs-to-html",
3
- "version": "2.3.1",
3
+ "version": "2.3.4",
4
4
  "private": false,
5
5
  "description": "Build human readable transit timetables as HTML, PDF or CSV from GTFS",
6
6
  "keywords": [
@@ -38,33 +38,33 @@
38
38
  "@turf/helpers": "^6.5.0",
39
39
  "@turf/simplify": "^6.5.0",
40
40
  "archiver": "^5.3.0",
41
- "chalk": "^5.0.0",
42
- "cli-table": "^0.3.9",
41
+ "chalk": "^5.0.1",
42
+ "cli-table": "^0.3.11",
43
43
  "copy-dir": "^1.3.0",
44
- "csv-stringify": "^6.0.4",
45
- "express": "^4.17.1",
46
- "gtfs": "^3.2.1",
47
- "js-beautify": "^1.14.0",
44
+ "csv-stringify": "^6.0.5",
45
+ "express": "^4.17.3",
46
+ "gtfs": "^3.2.5",
47
+ "js-beautify": "^1.14.3",
48
48
  "lodash-es": "^4.17.21",
49
- "moment": "^2.29.1",
49
+ "moment": "^2.29.2",
50
50
  "morgan": "^1.10.0",
51
51
  "pretty-error": "^4.0.0",
52
52
  "pug": "^3.0.2",
53
- "puppeteer": "^11.0.0",
53
+ "puppeteer": "^13.5.2",
54
54
  "sanitize-filename": "^1.6.3",
55
- "sqlstring": "^2.3.2",
55
+ "sqlstring": "^2.3.3",
56
56
  "timer-machine": "^1.1.0",
57
57
  "toposort": "^2.0.2",
58
58
  "untildify": "^4.0.0",
59
- "yargs": "^17.2.1"
59
+ "yargs": "^17.4.1"
60
60
  },
61
61
  "devDependencies": {
62
- "eslint": "^8.3.0",
63
- "eslint-config-prettier": "^8.3.0",
64
- "eslint-config-xo": "^0.39.0",
62
+ "eslint": "^8.13.0",
63
+ "eslint-config-prettier": "^8.5.0",
64
+ "eslint-config-xo": "^0.40.0",
65
65
  "husky": "^7.0.4",
66
- "prettier": "^2.5.0",
67
- "pretty-quick": "^3.1.2"
66
+ "prettier": "^2.6.2",
67
+ "pretty-quick": "^3.1.3"
68
68
  },
69
69
  "engines": {
70
70
  "node": ">= 12.14.0"
@@ -24,8 +24,8 @@ function formatRoute(route) {
24
24
  return html.prop('outerHTML');
25
25
  }
26
26
 
27
- function formatStopPopup(feature) {
28
- const routes = JSON.parse(feature.properties.routes);
27
+ function formatStopPopup(feature, routes) {
28
+ const routeIds = JSON.parse(feature.properties.routes);
29
29
  const html = $('<div>');
30
30
 
31
31
  $('<div>')
@@ -41,7 +41,7 @@ function formatStopPopup(feature) {
41
41
 
42
42
  $('<div>').text('Routes Served:').appendTo(html);
43
43
 
44
- $(html).append(routes.map((route) => formatRoute(route)));
44
+ $(html).append(routeIds.map((routeId) => formatRoute(routes[routeId])));
45
45
 
46
46
  return html.prop('outerHTML');
47
47
  }
@@ -61,7 +61,7 @@ function getBounds(geojson) {
61
61
  return bounds;
62
62
  }
63
63
 
64
- function createMap(id, geojson) {
64
+ function createMap(id, geojson, routes) {
65
65
  const defaultRouteColor = '#FF4728';
66
66
 
67
67
  if (!geojson || geojson.features.length === 0) {
@@ -228,7 +228,7 @@ function createMap(id, geojson) {
228
228
 
229
229
  new mapboxgl.Popup()
230
230
  .setLngLat(feature.geometry.coordinates)
231
- .setHTML(formatStopPopup(feature))
231
+ .setHTML(formatStopPopup(feature, routes))
232
232
  .addTo(map);
233
233
  });
234
234
 
@@ -65,3 +65,34 @@
65
65
  };
66
66
  }), timetableGroup => timetableGroup.agency.agency_name.toLowerCase());
67
67
  }
68
+
69
+ function prepareMapData(timetable) {
70
+ const routes = {}
71
+ const minifiedGeojson = {
72
+ type: 'FeatureCollection',
73
+ features: []
74
+ }
75
+
76
+ for (const feature of timetable.geojson.features) {
77
+ if (feature.geometry.type === 'LineString') {
78
+ feature.properties = {
79
+ route_color: feature.properties.route_color
80
+ }
81
+ minifiedGeojson.features.push(feature)
82
+ } else if (feature.geometry.type === 'Point') {
83
+ for (const route of feature.properties.routes) {
84
+ routes[route.route_id] = route
85
+ }
86
+
87
+ feature.properties.routes = feature.properties.routes.map(route => route.route_id)
88
+
89
+ minifiedGeojson.features.push(feature)
90
+ }
91
+ }
92
+
93
+ return {
94
+ id: `timetable_id_${formatHtmlId(timetable.timetable_id)}`,
95
+ routes,
96
+ geojson: minifiedGeojson
97
+ }
98
+ }
@@ -24,13 +24,10 @@ include formatting_functions.pug
24
24
 
25
25
  if config.showMap
26
26
  .map(id=`map_timetable_id_${formatHtmlId(timetable.timetable_id)}`)
27
-
28
- //- Use #{variable} format to inject values from pug to client side js
29
27
  script.
30
28
  (function() {
31
- const id = 'timetable_id_#{formatHtmlId(timetable.timetable_id)}';
32
- const geojson = !{JSON.stringify(timetable.geojson)};
33
- createMap(id, geojson);
29
+ const { id, geojson, routes } = !{JSON.stringify(prepareMapData(timetable))};
30
+ createMap(id, geojson, routes);
34
31
  })();
35
32
 
36
33
  if timetable.orientation === 'horizontal'
@@ -3,35 +3,34 @@ id: timetables
3
3
  title: timetables.txt
4
4
  ---
5
5
 
6
-
7
6
  This is an optional, non-standard file called `timetables.txt` which can be included in an agency's GTFS. This file specifies to GTFS-to-HTML which HTML timetables should be built. Often, this is the only additional file you need to create to use GTFS-to-HTML.
8
7
 
9
8
  ### Column Definitions
10
9
 
11
- | column name | description |
12
- | ----------- | ----------- |
13
- | `timetable_id` | A unique ID for the timetable |
14
- | `route_id` | The ID of the route the timetable is for from `routes.txt`. |
15
- | `direction_id` | The `direction_id` from `trips.txt` for the timetable. This can be blank. |
16
- | `start_date` | The start date for this timetable in `YYYY-MM-DD` format. |
17
- | `end_date` | The end date for this timetable in `YYYY-MM-DD` format. |
18
- | `monday` | A binary value that indicates whether this timetable should include service on Mondays. Valid options are `0` and `1`. |
19
- | `tuesday` | A binary value that indicates whether this timetable should include service on Tuesdays. Valid options are `0` and `1`. |
20
- | `wednesday` | A binary value that indicates whether this timetable should include service on Wednesdays. Valid options are `0` and `1`. |
21
- | `thursday` | A binary value that indicates whether this timetable should include service on Thursdays. Valid options are `0` and `1`. |
22
- | `friday` | A binary value that indicates whether this timetable should include service on Fridays. Valid options are `0` and `1`. |
23
- | `saturday` | A binary value that indicates whether this timetable should include service on Saturdays. Valid options are `0` and `1`. |
24
- | `sunday` | A binary value that indicates whether this timetable should include service on Sundays. Valid options are `0` and `1`. |
25
- | `start_time` | A time in HH:MM:SS format used exclude all trips that start before this time. Optional, default is to use all trips throughout the day. |
26
- | `end_time` | A time in HH:MM:SS format used exclude all trips that start on or after this time. Optional, default is to use all trips throughout the day. |
27
- | `include_exceptions` | A binary value that indicates whether or not to include exceptions of type `1` from `calendar_dates.txt`, such as holiday service on a weekday. Valid options are `0` and `1`. Optional, defaults to `0` (exceptions are not included by default). |
28
- | `timetable_label` | A short text label describing the timetable, for instance "Route 4 Northbound Mon-Fri". Optional, defaults to route name and first and last stops. Optional. |
29
- | `service_notes` | Text shown on the timetable about the service represented. Optional. |
30
- | `orientation` | Determines if the top row should be a list of trips or stops. Valid options are `vertical`, `horizontal` or `hourly`. `vertical` shows stops across the top row with each row being a list of stop times for each trip. `horizontal` shows trips across the top row with each row being stop times for a specific stop. `hourly` is for routes that run the same time each hour and will print a simplified schedule showing minutes after the hour for each stop. `horizontal` orientation is best for routes with lots of stops and fewer trips while `vertical` orientation is best for routes with lots of trips and a smaller number of stops. Optional, default is `vertical`. |
31
- | `timetable_page_id` | The timetable page that should include this timetable. Optional. |
32
- | `timetable_sequence` | The order that this timetable should appear on the timetable page. Optional. |
33
- | `direction_name` | The human readable name of the direction of the timetable, such as "Southbound". Optional. |
34
- | `show_trip_continuation` | A binary value that indicates whether this timetable should show an additional column(s) or row(s) indicating which trips continue from a different route or continue on as a different route. This is calculated by trips that share the same `block_id` in `trips.txt`. Valid options are `0` and `1`. Optional, defaults to `0`. |
10
+ | column name | description |
11
+ | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
12
+ | `timetable_id` | A unique ID for the timetable |
13
+ | `route_id` | The ID of the route the timetable is for from `routes.txt`. For timetables that should include more than one route, see [Multi-route timetables](#multi-route-timetables) |
14
+ | `direction_id` | The `direction_id` from `trips.txt` for the timetable. This can be blank. |
15
+ | `start_date` | The start date for this timetable in `YYYY-MM-DD` format. |
16
+ | `end_date` | The end date for this timetable in `YYYY-MM-DD` format. |
17
+ | `monday` | A binary value that indicates whether this timetable should include service on Mondays. Valid options are `0` and `1`. |
18
+ | `tuesday` | A binary value that indicates whether this timetable should include service on Tuesdays. Valid options are `0` and `1`. |
19
+ | `wednesday` | A binary value that indicates whether this timetable should include service on Wednesdays. Valid options are `0` and `1`. |
20
+ | `thursday` | A binary value that indicates whether this timetable should include service on Thursdays. Valid options are `0` and `1`. |
21
+ | `friday` | A binary value that indicates whether this timetable should include service on Fridays. Valid options are `0` and `1`. |
22
+ | `saturday` | A binary value that indicates whether this timetable should include service on Saturdays. Valid options are `0` and `1`. |
23
+ | `sunday` | A binary value that indicates whether this timetable should include service on Sundays. Valid options are `0` and `1`. |
24
+ | `start_time` | A time in HH:MM:SS format used exclude all trips that start before this time. Optional, default is to use all trips throughout the day. |
25
+ | `end_time` | A time in HH:MM:SS format used exclude all trips that start on or after this time. Optional, default is to use all trips throughout the day. |
26
+ | `include_exceptions` | A binary value that indicates whether or not to include exceptions of type `1` from `calendar_dates.txt`, such as holiday service on a weekday. Valid options are `0` and `1`. Optional, defaults to `0` (exceptions are not included by default). |
27
+ | `timetable_label` | A short text label describing the timetable, for instance "Route 4 Northbound Mon-Fri". Optional, defaults to route name and first and last stops. Optional. |
28
+ | `service_notes` | Text shown on the timetable about the service represented. Optional. |
29
+ | `orientation` | Determines if the top row should be a list of trips or stops. Valid options are `vertical`, `horizontal` or `hourly`. `vertical` shows stops across the top row with each row being a list of stop times for each trip. `horizontal` shows trips across the top row with each row being stop times for a specific stop. `hourly` is for routes that run the same time each hour and will print a simplified schedule showing minutes after the hour for each stop. `horizontal` orientation is best for routes with lots of stops and fewer trips while `vertical` orientation is best for routes with lots of trips and a smaller number of stops. Optional, default is `vertical`. |
30
+ | `timetable_page_id` | The timetable page that should include this timetable. Optional. |
31
+ | `timetable_sequence` | The order that this timetable should appear on the timetable page. Optional. |
32
+ | `direction_name` | The human readable name of the direction of the timetable, such as "Southbound". Optional. |
33
+ | `show_trip_continuation` | A binary value that indicates whether this timetable should show an additional column(s) or row(s) indicating which trips continue from a different route or continue on as a different route. This is calculated by trips that share the same `block_id` in `trips.txt`. Valid options are `0` and `1`. Optional, defaults to `0`. |
35
34
 
36
35
  ### Example
37
36
 
@@ -47,10 +46,19 @@ timetable_id,route_id,direction_id,start_date,end_date,monday,tuesday,wednesday,
47
46
  7,2037,0,20150101,20151122,1,1,1,1,1,0,0,,,0,103 Westbound,Mon-Fri,horizontal,1,0,Westbound,0
48
47
  ```
49
48
 
50
- An example of this file is located in [examples/timetables.txt](https://github.com/BlinkTagInc/gtfs-to-html/blob/master/examples/timetables.txt).
51
-
49
+ An example of this file is located in [examples/timetables.txt](https://github.com/BlinkTagInc/gtfs-to-html/blob/master/examples/timetables.txt).
52
50
 
53
51
  ## Multi-route Timetables
54
52
 
55
53
  To allow creating a single timetable for multiple routes that overlap, you can have multiple entries in `timetables.txt` for the same `timetable_id`. All fields should be the same for each row in `timetables.txt` for a combined route timetable except `route_id`.
56
54
 
55
+ ### Multi-route example
56
+
57
+ In this example, only one timetable will be generated that will include trips from route_ids `2034`, `2035` and `2036`.
58
+
59
+ ```csv
60
+ timetable_id,route_id,direction_id,start_date,end_date,monday,tuesday,wednesday,thursday,friday,saturday,sunday,start_time,end_time,include_exceptions,timetable_label,service_notes,orientation,timetable_page_id,timetable_sequence,direction_name,show_trip_continuation
61
+ 0,2034,0,20150101,20151122,1,1,1,1,1,1,0,,,0,101 Northbound,Mon-Sat AM,horizontal,1,0,Northbound,0
62
+ 0,2035,0,20150101,20151122,1,1,1,1,1,1,0,,,0,101 Northbound,Mon-Sat AM,horizontal,1,0,Northbound,0
63
+ 0,2036,0,20150101,20151122,1,1,1,1,1,1,0,,,0,101 Northbound,Mon-Sat AM,horizontal,1,0,Northbound,0
64
+ ```
package/www/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  "deploy": "docusaurus deploy"
10
10
  },
11
11
  "dependencies": {
12
- "@docusaurus/core": "^2.0.0-beta.9",
13
- "@docusaurus/preset-classic": "^2.0.0-beta.9",
12
+ "@docusaurus/core": "^2.0.0-beta.16",
13
+ "@docusaurus/preset-classic": "^2.0.0-beta.16",
14
14
  "clsx": "^1.1.1",
15
15
  "react": "^17.0.2",
16
16
  "react-dom": "^17.0.2"