gtfs-to-html 2.12.1 → 2.12.3
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/README.md +1 -0
- package/dist/app/index.js +102 -32
- package/dist/app/index.js.map +1 -1
- package/dist/bin/gtfs-to-html.js +113 -69
- package/dist/bin/gtfs-to-html.js.map +1 -1
- package/dist/frontend_libraries/anchorme.min.js +1 -0
- package/dist/frontend_libraries/gtfs-realtime.browser.proto.js +0 -0
- package/dist/frontend_libraries/maplibre-gl-geocoder.css +284 -0
- package/dist/frontend_libraries/maplibre-gl-geocoder.js +2790 -0
- package/dist/frontend_libraries/maplibre-gl.css +1 -0
- package/dist/frontend_libraries/maplibre-gl.js +59 -0
- package/dist/frontend_libraries/pbf.js +1 -0
- package/dist/index.js +113 -69
- package/dist/index.js.map +1 -1
- package/package.json +14 -11
- package/scripts/postinstall.js +115 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(t="undefined"!=typeof globalThis?globalThis:t||self).Pbf=i()}(this,(function(){"use strict";const t=4294967296,i=1/t,e="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");function s(t,i,e){return e?4294967296*i+(t>>>0):4294967296*(i>>>0)+(t>>>0)}function r(t,i,e){const s=i<=16383?1:i<=2097151?2:i<=268435455?3:Math.floor(Math.log(i)/(7*Math.LN2));e.realloc(s);for(let i=e.pos-1;i>=t;i--)e.buf[i+s]=e.buf[i]}function o(t,i){for(let e=0;e<t.length;e++)i.writeVarint(t[e])}function h(t,i){for(let e=0;e<t.length;e++)i.writeSVarint(t[e])}function n(t,i){for(let e=0;e<t.length;e++)i.writeFloat(t[e])}function a(t,i){for(let e=0;e<t.length;e++)i.writeDouble(t[e])}function d(t,i){for(let e=0;e<t.length;e++)i.writeBoolean(t[e])}function l(t,i){for(let e=0;e<t.length;e++)i.writeFixed32(t[e])}function u(t,i){for(let e=0;e<t.length;e++)i.writeSFixed32(t[e])}function f(t,i){for(let e=0;e<t.length;e++)i.writeFixed64(t[e])}function p(t,i){for(let e=0;e<t.length;e++)i.writeSFixed64(t[e])}return class{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(t,i,e=this.length){for(;this.pos<e;){const e=this.readVarint(),s=e>>3,r=this.pos;this.type=7&e,t(s,i,this),this.pos===r&&this.skip(e)}return i}readMessage(t,i){return this.readFields(t,i,this.readVarint()+this.pos)}readFixed32(){const t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){const t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){const i=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*t;return this.pos+=8,i}readSFixed64(){const i=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*t;return this.pos+=8,i}readFloat(){const t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){const t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){const i=this.buf;let e,r;return r=i[this.pos++],e=127&r,r<128?e:(r=i[this.pos++],e|=(127&r)<<7,r<128?e:(r=i[this.pos++],e|=(127&r)<<14,r<128?e:(r=i[this.pos++],e|=(127&r)<<21,r<128?e:(r=i[this.pos],e|=(15&r)<<28,function(t,i,e){const r=e.buf;let o,h;if(h=r[e.pos++],o=(112&h)>>4,h<128)return s(t,o,i);if(h=r[e.pos++],o|=(127&h)<<3,h<128)return s(t,o,i);if(h=r[e.pos++],o|=(127&h)<<10,h<128)return s(t,o,i);if(h=r[e.pos++],o|=(127&h)<<17,h<128)return s(t,o,i);if(h=r[e.pos++],o|=(127&h)<<24,h<128)return s(t,o,i);if(h=r[e.pos++],o|=(1&h)<<31,h<128)return s(t,o,i);throw new Error("Expected varint not more than 10 bytes")}(e,t,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){const t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return Boolean(this.readVarint())}readString(){const t=this.readVarint()+this.pos,i=this.pos;return this.pos=t,t-i>=12&&e?e.decode(this.buf.subarray(i,t)):function(t,i,e){let s="",r=i;for(;r<e;){const i=t[r];let o,h,n,a=null,d=i>239?4:i>223?3:i>191?2:1;if(r+d>e)break;1===d?i<128&&(a=i):2===d?(o=t[r+1],128==(192&o)&&(a=(31&i)<<6|63&o,a<=127&&(a=null))):3===d?(o=t[r+1],h=t[r+2],128==(192&o)&&128==(192&h)&&(a=(15&i)<<12|(63&o)<<6|63&h,(a<=2047||a>=55296&&a<=57343)&&(a=null))):4===d&&(o=t[r+1],h=t[r+2],n=t[r+3],128==(192&o)&&128==(192&h)&&128==(192&n)&&(a=(15&i)<<18|(63&o)<<12|(63&h)<<6|63&n,(a<=65535||a>=1114112)&&(a=null))),null===a?(a=65533,d=1):a>65535&&(a-=65536,s+=String.fromCharCode(a>>>10&1023|55296),a=56320|1023&a),s+=String.fromCharCode(a),r+=d}return s}(this.buf,i,t)}readBytes(){const t=this.readVarint()+this.pos,i=this.buf.subarray(this.pos,t);return this.pos=t,i}readPackedVarint(t=[],i){const e=this.readPackedEnd();for(;this.pos<e;)t.push(this.readVarint(i));return t}readPackedSVarint(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readSVarint());return t}readPackedBoolean(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readBoolean());return t}readPackedFloat(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readFloat());return t}readPackedDouble(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readDouble());return t}readPackedFixed32(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readFixed32());return t}readPackedSFixed32(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readSFixed32());return t}readPackedFixed64(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readFixed64());return t}readPackedSFixed64(t=[]){const i=this.readPackedEnd();for(;this.pos<i;)t.push(this.readSFixed64());return t}readPackedEnd(){return 2===this.type?this.readVarint()+this.pos:this.pos+1}skip(t){const i=7&t;if(0===i)for(;this.buf[this.pos++]>127;);else if(2===i)this.pos=this.readVarint()+this.pos;else if(5===i)this.pos+=4;else{if(1!==i)throw new Error(`Unimplemented type: ${i}`);this.pos+=8}}writeTag(t,i){this.writeVarint(t<<3|i)}realloc(t){let i=this.length||16;for(;i<this.pos+t;)i*=2;if(i!==this.length){const t=new Uint8Array(i);t.set(this.buf),this.buf=t,this.dataView=new DataView(t.buffer),this.length=i}}finish(){return this.length=this.pos,this.pos=0,this.buf.subarray(0,this.length)}writeFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeSFixed32(t){this.realloc(4),this.dataView.setInt32(this.pos,t,!0),this.pos+=4}writeFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*i),!0),this.pos+=8}writeSFixed64(t){this.realloc(8),this.dataView.setInt32(this.pos,-1&t,!0),this.dataView.setInt32(this.pos+4,Math.floor(t*i),!0),this.pos+=8}writeVarint(t){(t=+t||0)>268435455||t<0?function(t,i){let e,s;t>=0?(e=t%4294967296|0,s=t/4294967296|0):(e=~(-t%4294967296),s=~(-t/4294967296),4294967295^e?e=e+1|0:(e=0,s=s+1|0));if(t>=0x10000000000000000||t<-0x10000000000000000)throw new Error("Given varint doesn't fit into 10 bytes");i.realloc(10),function(t,i,e){e.buf[e.pos++]=127&t|128,t>>>=7,e.buf[e.pos++]=127&t|128,t>>>=7,e.buf[e.pos++]=127&t|128,t>>>=7,e.buf[e.pos++]=127&t|128,t>>>=7,e.buf[e.pos]=127&t}(e,0,i),function(t,i){const e=(7&t)<<4;if(i.buf[i.pos++]|=e|((t>>>=3)?128:0),!t)return;if(i.buf[i.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(i.buf[i.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(i.buf[i.pos++]=127&t|((t>>>=7)?128:0),!t)return;if(i.buf[i.pos++]=127&t|((t>>>=7)?128:0),!t)return;i.buf[i.pos++]=127&t}(s,i)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=127&(t>>>=7)|(t>127?128:0),t<=127||(this.buf[this.pos++]=t>>>7&127))))}writeSVarint(t){this.writeVarint(t<0?2*-t-1:2*t)}writeBoolean(t){this.writeVarint(+t)}writeString(t){t=String(t),this.realloc(4*t.length),this.pos++;const i=this.pos;this.pos=function(t,i,e){for(let s,r,o=0;o<i.length;o++){if(s=i.charCodeAt(o),s>55295&&s<57344){if(!r){s>56319||o+1===i.length?(t[e++]=239,t[e++]=191,t[e++]=189):r=s;continue}if(s<56320){t[e++]=239,t[e++]=191,t[e++]=189,r=s;continue}s=r-55296<<10|s-56320|65536,r=null}else r&&(t[e++]=239,t[e++]=191,t[e++]=189,r=null);s<128?t[e++]=s:(s<2048?t[e++]=s>>6|192:(s<65536?t[e++]=s>>12|224:(t[e++]=s>>18|240,t[e++]=s>>12&63|128),t[e++]=s>>6&63|128),t[e++]=63&s|128)}return e}(this.buf,t,this.pos);const e=this.pos-i;e>=128&&r(i,e,this),this.pos=i-1,this.writeVarint(e),this.pos+=e}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(t){const i=t.length;this.writeVarint(i),this.realloc(i);for(let e=0;e<i;e++)this.buf[this.pos++]=t[e]}writeRawMessage(t,i){this.pos++;const e=this.pos;t(i,this);const s=this.pos-e;s>=128&&r(e,s,this),this.pos=e-1,this.writeVarint(s),this.pos+=s}writeMessage(t,i,e){this.writeTag(t,2),this.writeRawMessage(i,e)}writePackedVarint(t,i){i.length&&this.writeMessage(t,o,i)}writePackedSVarint(t,i){i.length&&this.writeMessage(t,h,i)}writePackedBoolean(t,i){i.length&&this.writeMessage(t,d,i)}writePackedFloat(t,i){i.length&&this.writeMessage(t,n,i)}writePackedDouble(t,i){i.length&&this.writeMessage(t,a,i)}writePackedFixed32(t,i){i.length&&this.writeMessage(t,l,i)}writePackedSFixed32(t,i){i.length&&this.writeMessage(t,u,i)}writePackedFixed64(t,i){i.length&&this.writeMessage(t,f,i)}writePackedSFixed64(t,i){i.length&&this.writeMessage(t,p,i)}writeBytesField(t,i){this.writeTag(t,2),this.writeBytes(i)}writeFixed32Field(t,i){this.writeTag(t,5),this.writeFixed32(i)}writeSFixed32Field(t,i){this.writeTag(t,5),this.writeSFixed32(i)}writeFixed64Field(t,i){this.writeTag(t,1),this.writeFixed64(i)}writeSFixed64Field(t,i){this.writeTag(t,1),this.writeSFixed64(i)}writeVarintField(t,i){this.writeTag(t,0),this.writeVarint(i)}writeSVarintField(t,i){this.writeTag(t,0),this.writeSVarint(i)}writeStringField(t,i){this.writeTag(t,2),this.writeString(i)}writeFloatField(t,i){this.writeTag(t,5),this.writeFloat(i)}writeDoubleField(t,i){this.writeTag(t,1),this.writeDouble(i)}writeBooleanField(t,i){this.writeVarintField(t,+i)}}}));
|
package/dist/index.js
CHANGED
|
@@ -25,7 +25,6 @@ import {
|
|
|
25
25
|
rm
|
|
26
26
|
} from "fs/promises";
|
|
27
27
|
import { homedir } from "os";
|
|
28
|
-
import { findPackageJSON } from "module";
|
|
29
28
|
import * as _ from "lodash-es";
|
|
30
29
|
import { uniqBy as uniqBy2 } from "lodash-es";
|
|
31
30
|
import archiver from "archiver";
|
|
@@ -62,11 +61,11 @@ function fromGTFSTime(timeString) {
|
|
|
62
61
|
function toGTFSTime(time) {
|
|
63
62
|
return time.format("HH:mm:ss");
|
|
64
63
|
}
|
|
65
|
-
function calendarToCalendarCode(
|
|
66
|
-
if (Object.values(
|
|
64
|
+
function calendarToCalendarCode(calendar) {
|
|
65
|
+
if (Object.values(calendar).every((value) => value === null)) {
|
|
67
66
|
return "";
|
|
68
67
|
}
|
|
69
|
-
return `${
|
|
68
|
+
return `${calendar.monday ?? "0"}${calendar.tuesday ?? "0"}${calendar.wednesday ?? "0"}${calendar.thursday ?? "0"}${calendar.friday ?? "0"}${calendar.saturday ?? "0"}${calendar.sunday ?? "0"}`;
|
|
70
69
|
}
|
|
71
70
|
function calendarCodeToCalendar(code) {
|
|
72
71
|
const days2 = [
|
|
@@ -84,6 +83,35 @@ function calendarCodeToCalendar(code) {
|
|
|
84
83
|
}
|
|
85
84
|
return calendar;
|
|
86
85
|
}
|
|
86
|
+
function calendarToDateList(calendar, startDate, endDate) {
|
|
87
|
+
if (!startDate || !endDate) {
|
|
88
|
+
return [];
|
|
89
|
+
}
|
|
90
|
+
const activeWeekdays = [
|
|
91
|
+
calendar.monday === 1 ? 1 : null,
|
|
92
|
+
calendar.tuesday === 1 ? 2 : null,
|
|
93
|
+
calendar.wednesday === 1 ? 3 : null,
|
|
94
|
+
calendar.thursday === 1 ? 4 : null,
|
|
95
|
+
calendar.friday === 1 ? 5 : null,
|
|
96
|
+
calendar.saturday === 1 ? 6 : null,
|
|
97
|
+
calendar.sunday === 1 ? 7 : null
|
|
98
|
+
].filter((weekday) => weekday !== null);
|
|
99
|
+
if (activeWeekdays.length === 0) {
|
|
100
|
+
return [];
|
|
101
|
+
}
|
|
102
|
+
const activeWeekdaySet = new Set(activeWeekdays);
|
|
103
|
+
const dates = /* @__PURE__ */ new Set();
|
|
104
|
+
const date = moment(startDate.toString(), "YYYYMMDD");
|
|
105
|
+
const endDateMoment = moment(endDate.toString(), "YYYYMMDD");
|
|
106
|
+
while (date.isSameOrBefore(endDateMoment)) {
|
|
107
|
+
const isoWeekday = date.isoWeekday();
|
|
108
|
+
if (activeWeekdaySet.has(isoWeekday)) {
|
|
109
|
+
dates.add(parseInt(date.format("YYYYMMDD"), 10));
|
|
110
|
+
}
|
|
111
|
+
date.add(1, "day");
|
|
112
|
+
}
|
|
113
|
+
return Array.from(dates);
|
|
114
|
+
}
|
|
87
115
|
function secondsAfterMidnight(timeString) {
|
|
88
116
|
return moment.duration(timeString).asSeconds();
|
|
89
117
|
}
|
|
@@ -494,7 +522,7 @@ function formatTripNameForCSV(trip, timetable) {
|
|
|
494
522
|
// package.json
|
|
495
523
|
var package_default = {
|
|
496
524
|
name: "gtfs-to-html",
|
|
497
|
-
version: "2.12.
|
|
525
|
+
version: "2.12.3",
|
|
498
526
|
private: false,
|
|
499
527
|
description: "Build human readable transit timetables as HTML, PDF or CSV from GTFS",
|
|
500
528
|
keywords: [
|
|
@@ -529,6 +557,7 @@ var package_default = {
|
|
|
529
557
|
"dist",
|
|
530
558
|
"docker",
|
|
531
559
|
"examples",
|
|
560
|
+
"scripts",
|
|
532
561
|
"views/default",
|
|
533
562
|
"config-sample.json"
|
|
534
563
|
],
|
|
@@ -537,30 +566,32 @@ var package_default = {
|
|
|
537
566
|
},
|
|
538
567
|
scripts: {
|
|
539
568
|
build: "tsup",
|
|
569
|
+
postbuild: "node scripts/postinstall.js",
|
|
540
570
|
start: "node ./dist/app",
|
|
541
|
-
prepare: "husky"
|
|
571
|
+
prepare: "husky && npm run build",
|
|
572
|
+
postinstall: "node scripts/postinstall.js"
|
|
542
573
|
},
|
|
543
574
|
dependencies: {
|
|
544
575
|
"@maplibre/maplibre-gl-geocoder": "^1.9.1",
|
|
545
|
-
"@turf/helpers": "^7.3.
|
|
546
|
-
"@turf/simplify": "^7.3.
|
|
576
|
+
"@turf/helpers": "^7.3.1",
|
|
577
|
+
"@turf/simplify": "^7.3.1",
|
|
547
578
|
anchorme: "^3.0.8",
|
|
548
579
|
archiver: "^7.0.1",
|
|
549
580
|
"cli-table": "^0.3.11",
|
|
550
581
|
"css.escape": "^1.5.1",
|
|
551
582
|
"csv-stringify": "^6.6.0",
|
|
552
|
-
express: "^5.1
|
|
553
|
-
gtfs: "^4.18.
|
|
583
|
+
express: "^5.2.1",
|
|
584
|
+
gtfs: "^4.18.2",
|
|
554
585
|
"gtfs-realtime-pbf-js-module": "^1.0.0",
|
|
555
586
|
"js-beautify": "^1.15.4",
|
|
556
587
|
"lodash-es": "^4.17.21",
|
|
557
|
-
"maplibre-gl": "^5.
|
|
558
|
-
marked: "^17.0.
|
|
588
|
+
"maplibre-gl": "^5.14.0",
|
|
589
|
+
marked: "^17.0.1",
|
|
559
590
|
moment: "^2.30.1",
|
|
560
591
|
pbf: "^4.0.1",
|
|
561
592
|
"pretty-error": "^4.0.0",
|
|
562
593
|
pug: "^3.0.3",
|
|
563
|
-
puppeteer: "^24.
|
|
594
|
+
puppeteer: "^24.32.0",
|
|
564
595
|
"sanitize-filename": "^1.6.3",
|
|
565
596
|
"sanitize-html": "^2.17.0",
|
|
566
597
|
sqlstring: "^2.3.3",
|
|
@@ -571,7 +602,7 @@ var package_default = {
|
|
|
571
602
|
devDependencies: {
|
|
572
603
|
"@types/archiver": "^7.0.0",
|
|
573
604
|
"@types/cli-table": "^0.3.4",
|
|
574
|
-
"@types/express": "^5.0.
|
|
605
|
+
"@types/express": "^5.0.6",
|
|
575
606
|
"@types/insane": "^1.0.0",
|
|
576
607
|
"@types/js-beautify": "^1.14.3",
|
|
577
608
|
"@types/lodash-es": "^4.17.12",
|
|
@@ -584,7 +615,7 @@ var package_default = {
|
|
|
584
615
|
"@types/yargs": "^17.0.35",
|
|
585
616
|
husky: "^9.1.7",
|
|
586
617
|
"lint-staged": "^16.2.7",
|
|
587
|
-
prettier: "^3.
|
|
618
|
+
prettier: "^3.7.4",
|
|
588
619
|
tsup: "^8.5.1",
|
|
589
620
|
typescript: "^5.9.3"
|
|
590
621
|
},
|
|
@@ -1249,9 +1280,9 @@ var getCalendarsFromTimetable = (timetable) => {
|
|
|
1249
1280
|
}
|
|
1250
1281
|
return db.prepare(`SELECT * FROM calendar ${whereClause}`).all();
|
|
1251
1282
|
};
|
|
1252
|
-
var
|
|
1283
|
+
var getCalendarDatesForDateRange = (startDate, endDate) => {
|
|
1253
1284
|
const db = openDb();
|
|
1254
|
-
const whereClauses = [
|
|
1285
|
+
const whereClauses = [];
|
|
1255
1286
|
if (endDate) {
|
|
1256
1287
|
whereClauses.push(`date <= ${sqlString.escape(endDate)}`);
|
|
1257
1288
|
}
|
|
@@ -1259,11 +1290,11 @@ var getCalendarDatesServiceIds = (startDate, endDate) => {
|
|
|
1259
1290
|
whereClauses.push(`date >= ${sqlString.escape(startDate)}`);
|
|
1260
1291
|
}
|
|
1261
1292
|
const calendarDates = db.prepare(
|
|
1262
|
-
`SELECT
|
|
1293
|
+
`SELECT service_id, date, exception_type FROM calendar_dates WHERE ${whereClauses.join(
|
|
1263
1294
|
" AND "
|
|
1264
1295
|
)}`
|
|
1265
1296
|
).all();
|
|
1266
|
-
return calendarDates
|
|
1297
|
+
return calendarDates;
|
|
1267
1298
|
};
|
|
1268
1299
|
var getAllStationStopIds = (stopId) => {
|
|
1269
1300
|
const stops = getStops({
|
|
@@ -1474,13 +1505,49 @@ var formatTimetables = (timetables, config) => {
|
|
|
1474
1505
|
timetable.warnings = [];
|
|
1475
1506
|
const dayList = formatDays(timetable, config);
|
|
1476
1507
|
const calendars = getCalendarsFromTimetable(timetable);
|
|
1477
|
-
|
|
1508
|
+
const serviceIds = /* @__PURE__ */ new Set();
|
|
1509
|
+
for (const calendar of calendars) {
|
|
1510
|
+
serviceIds.add(calendar.service_id);
|
|
1511
|
+
}
|
|
1478
1512
|
if (timetable.include_exceptions === 1) {
|
|
1479
|
-
const
|
|
1513
|
+
const calendarDates = getCalendarDatesForDateRange(
|
|
1480
1514
|
timetable.start_date,
|
|
1481
1515
|
timetable.end_date
|
|
1482
1516
|
);
|
|
1483
|
-
|
|
1517
|
+
const calendarDateGroups = groupBy(calendarDates, "service_id");
|
|
1518
|
+
for (const [serviceId, calendarDateGroup] of Object.entries(
|
|
1519
|
+
calendarDateGroups
|
|
1520
|
+
)) {
|
|
1521
|
+
const calendar = calendars.find(
|
|
1522
|
+
(c) => c.service_id === serviceId
|
|
1523
|
+
);
|
|
1524
|
+
if (calendarDateGroup.some(
|
|
1525
|
+
(calendarDate) => calendarDate.exception_type === 1
|
|
1526
|
+
)) {
|
|
1527
|
+
serviceIds.add(serviceId);
|
|
1528
|
+
}
|
|
1529
|
+
const calendarDateGroupExceptionType2 = calendarDateGroup.filter(
|
|
1530
|
+
(calendarDate) => calendarDate.exception_type === 2
|
|
1531
|
+
);
|
|
1532
|
+
if (timetable.start_date && timetable.end_date && calendar && calendarDateGroupExceptionType2.length > 0) {
|
|
1533
|
+
const datesDuringDateRange = calendarToDateList(
|
|
1534
|
+
calendar,
|
|
1535
|
+
timetable.start_date,
|
|
1536
|
+
timetable.end_date
|
|
1537
|
+
);
|
|
1538
|
+
if (datesDuringDateRange.length === 0) {
|
|
1539
|
+
serviceIds.delete(serviceId);
|
|
1540
|
+
}
|
|
1541
|
+
const everyDateIsExcluded = datesDuringDateRange.every(
|
|
1542
|
+
(dateDuringDateRange) => calendarDateGroupExceptionType2.some(
|
|
1543
|
+
(calendarDate) => calendarDate.date === dateDuringDateRange
|
|
1544
|
+
)
|
|
1545
|
+
);
|
|
1546
|
+
if (everyDateIsExcluded) {
|
|
1547
|
+
serviceIds.delete(serviceId);
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
}
|
|
1484
1551
|
}
|
|
1485
1552
|
Object.assign(timetable, {
|
|
1486
1553
|
noServiceSymbolUsed: false,
|
|
@@ -1498,7 +1565,7 @@ var formatTimetables = (timetables, config) => {
|
|
|
1498
1565
|
noPickupSymbol: config.noPickupSymbol,
|
|
1499
1566
|
interpolatedStopSymbol: config.interpolatedStopSymbol,
|
|
1500
1567
|
orientation: timetable.orientation || config.defaultOrientation,
|
|
1501
|
-
service_ids: serviceIds,
|
|
1568
|
+
service_ids: Array.from(serviceIds),
|
|
1502
1569
|
dayList,
|
|
1503
1570
|
dayListLong: formatDaysLong(dayList, config)
|
|
1504
1571
|
});
|
|
@@ -2294,20 +2361,23 @@ function mergeTimetablesWithSameId(timetables) {
|
|
|
2294
2361
|
|
|
2295
2362
|
// src/lib/file-utils.ts
|
|
2296
2363
|
var homeDirectory = homedir();
|
|
2297
|
-
function
|
|
2298
|
-
if (config.templatePath) {
|
|
2299
|
-
return untildify(config.templatePath);
|
|
2300
|
-
}
|
|
2364
|
+
function getPathToThisModuleFolder() {
|
|
2301
2365
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
2302
|
-
let
|
|
2366
|
+
let distFolderPath;
|
|
2303
2367
|
if (__dirname.endsWith("/dist/bin") || __dirname.endsWith("/dist/app")) {
|
|
2304
|
-
|
|
2368
|
+
distFolderPath = resolve(__dirname, "../../");
|
|
2305
2369
|
} else if (__dirname.endsWith("/dist")) {
|
|
2306
|
-
|
|
2370
|
+
distFolderPath = resolve(__dirname, "../");
|
|
2307
2371
|
} else {
|
|
2308
|
-
|
|
2372
|
+
distFolderPath = resolve(__dirname, "../../");
|
|
2309
2373
|
}
|
|
2310
|
-
return
|
|
2374
|
+
return distFolderPath;
|
|
2375
|
+
}
|
|
2376
|
+
function getPathToViewsFolder(config) {
|
|
2377
|
+
if (config.templatePath) {
|
|
2378
|
+
return untildify(config.templatePath);
|
|
2379
|
+
}
|
|
2380
|
+
return join(getPathToThisModuleFolder(), "views/default");
|
|
2311
2381
|
}
|
|
2312
2382
|
function getPathToTemplateFile(templateFileName, config) {
|
|
2313
2383
|
const fullTemplateFileName = config.noHead !== true ? `${templateFileName}_full.pug` : `${templateFileName}.pug`;
|
|
@@ -2340,6 +2410,7 @@ async function prepDirectory(outputPath, config) {
|
|
|
2340
2410
|
}
|
|
2341
2411
|
async function copyStaticAssets(config, outputPath) {
|
|
2342
2412
|
const viewsFolderPath = getPathToViewsFolder(config);
|
|
2413
|
+
const thisModuleFolderPath = getPathToThisModuleFolder();
|
|
2343
2414
|
const foldersToCopy = ["css", "js", "img"];
|
|
2344
2415
|
for (const folder of foldersToCopy) {
|
|
2345
2416
|
if (await access(join(viewsFolderPath, folder)).then(() => true).catch(() => false)) {
|
|
@@ -2350,70 +2421,43 @@ async function copyStaticAssets(config, outputPath) {
|
|
|
2350
2421
|
}
|
|
2351
2422
|
if (config.hasGtfsRealtimeVehiclePositions || config.hasGtfsRealtimeTripUpdates || config.hasGtfsRealtimeAlerts) {
|
|
2352
2423
|
await copyFile(
|
|
2353
|
-
join(
|
|
2354
|
-
dirname(findPackageJSON("pbf", import.meta.url)),
|
|
2355
|
-
"dist/pbf.js"
|
|
2356
|
-
),
|
|
2424
|
+
join(thisModuleFolderPath, "dist/frontend_libraries/pbf.js"),
|
|
2357
2425
|
join(outputPath, "js/pbf.js")
|
|
2358
2426
|
);
|
|
2359
2427
|
await copyFile(
|
|
2360
2428
|
join(
|
|
2361
|
-
|
|
2362
|
-
|
|
2363
|
-
"gtfs-realtime-pbf-js-module",
|
|
2364
|
-
import.meta.url
|
|
2365
|
-
)
|
|
2366
|
-
),
|
|
2367
|
-
"gtfs-realtime.browser.proto.js"
|
|
2429
|
+
thisModuleFolderPath,
|
|
2430
|
+
"dist/frontend_libraries/gtfs-realtime.browser.proto.js"
|
|
2368
2431
|
),
|
|
2369
2432
|
join(outputPath, "js/gtfs-realtime.browser.proto.js")
|
|
2370
2433
|
);
|
|
2371
2434
|
}
|
|
2372
2435
|
if (config.hasGtfsRealtimeAlerts) {
|
|
2373
2436
|
await copyFile(
|
|
2374
|
-
join(
|
|
2375
|
-
dirname(findPackageJSON("anchorme", import.meta.url)),
|
|
2376
|
-
"dist/browser/anchorme.min.js"
|
|
2377
|
-
),
|
|
2437
|
+
join(thisModuleFolderPath, "dist/frontend_libraries/anchorme.min.js"),
|
|
2378
2438
|
join(outputPath, "js/anchorme.min.js")
|
|
2379
2439
|
);
|
|
2380
2440
|
}
|
|
2381
2441
|
if (config.showMap) {
|
|
2382
2442
|
await copyFile(
|
|
2383
|
-
join(
|
|
2384
|
-
dirname(findPackageJSON("maplibre-gl", import.meta.url)),
|
|
2385
|
-
"dist/maplibre-gl.js"
|
|
2386
|
-
),
|
|
2443
|
+
join(thisModuleFolderPath, "dist/frontend_libraries/maplibre-gl.js"),
|
|
2387
2444
|
join(outputPath, "js/maplibre-gl.js")
|
|
2388
2445
|
);
|
|
2389
2446
|
await copyFile(
|
|
2390
|
-
join(
|
|
2391
|
-
dirname(findPackageJSON("maplibre-gl", import.meta.url)),
|
|
2392
|
-
"dist/maplibre-gl.css"
|
|
2393
|
-
),
|
|
2447
|
+
join(thisModuleFolderPath, "dist/frontend_libraries/maplibre-gl.css"),
|
|
2394
2448
|
join(outputPath, "css/maplibre-gl.css")
|
|
2395
2449
|
);
|
|
2396
2450
|
await copyFile(
|
|
2397
2451
|
join(
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
"@maplibre/maplibre-gl-geocoder",
|
|
2401
|
-
import.meta.url
|
|
2402
|
-
)
|
|
2403
|
-
),
|
|
2404
|
-
"dist/maplibre-gl-geocoder.js"
|
|
2452
|
+
thisModuleFolderPath,
|
|
2453
|
+
"dist/frontend_libraries/maplibre-gl-geocoder.js"
|
|
2405
2454
|
),
|
|
2406
2455
|
join(outputPath, "js/maplibre-gl-geocoder.js")
|
|
2407
2456
|
);
|
|
2408
2457
|
await copyFile(
|
|
2409
2458
|
join(
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
"@maplibre/maplibre-gl-geocoder",
|
|
2413
|
-
import.meta.url
|
|
2414
|
-
)
|
|
2415
|
-
),
|
|
2416
|
-
"dist/maplibre-gl-geocoder.css"
|
|
2459
|
+
thisModuleFolderPath,
|
|
2460
|
+
"dist/frontend_libraries/maplibre-gl-geocoder.css"
|
|
2417
2461
|
),
|
|
2418
2462
|
join(outputPath, "css/maplibre-gl-geocoder.css")
|
|
2419
2463
|
);
|