gtfs-to-html 2.3.3 → 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,6 +5,13 @@ 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
+ ## [2.3.4] - 2022-04-09
9
+
10
+ ### Updated
11
+
12
+ - Remove route info from map geojson
13
+ - Dependency updates
14
+
8
15
  ## [2.3.3] - 2022-01-21
9
16
 
10
17
  ### Updated
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.3",
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,32 +38,32 @@
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",
41
+ "chalk": "^5.0.1",
42
42
  "cli-table": "^0.3.11",
43
43
  "copy-dir": "^1.3.0",
44
44
  "csv-stringify": "^6.0.5",
45
- "express": "^4.17.2",
46
- "gtfs": "^3.2.4",
47
- "js-beautify": "^1.14.0",
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": "^13.1.1",
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.3.1"
59
+ "yargs": "^17.4.1"
60
60
  },
61
61
  "devDependencies": {
62
- "eslint": "^8.7.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.1",
66
+ "prettier": "^2.6.2",
67
67
  "pretty-quick": "^3.1.3"
68
68
  },
69
69
  "engines": {
@@ -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'
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.14",
13
- "@docusaurus/preset-classic": "^2.0.0-beta.14",
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"