-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into db-tickets-without-ticket-url
- Loading branch information
Showing
258 changed files
with
19,628 additions
and
11,120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,5 @@ node_modules | |
npm-debug.log | ||
|
||
package-lock.json | ||
|
||
/.tap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,27 @@ | ||
import {formatLocationIdentifier} from './location-identifier.js' | ||
import {formatCoord} from './coord.js' | ||
import {formatLocationIdentifier} from './location-identifier.js'; | ||
import {formatCoord} from './coord.js'; | ||
|
||
const formatAddress = (a) => { | ||
if (a.type !== 'location' || !a.latitude || !a.longitude || !a.address) { | ||
throw new TypeError('invalid address') | ||
throw new TypeError('invalid address'); | ||
} | ||
|
||
const data = { | ||
A: '2', // address? | ||
O: a.address, | ||
X: formatCoord(a.longitude), | ||
Y: formatCoord(a.latitude) | ||
Y: formatCoord(a.latitude), | ||
}; | ||
if (a.id) { | ||
data.L = a.id; | ||
} | ||
if (a.id) data.L = a.id | ||
return { | ||
type: 'A', // address | ||
name: a.address, | ||
lid: formatLocationIdentifier(data) | ||
} | ||
} | ||
lid: formatLocationIdentifier(data), | ||
}; | ||
}; | ||
|
||
export { | ||
formatAddress, | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
const formatCoord = x => Math.round(x * 1000000) | ||
const formatCoord = x => Math.round(x * 1000000); | ||
|
||
export { | ||
formatCoord, | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,24 @@ | ||
import {DateTime, IANAZone} from 'luxon' | ||
import {luxonIANAZonesByProfile as timezones} from '../lib/luxon-timezones.js' | ||
import {DateTime, IANAZone} from 'luxon'; | ||
import {luxonIANAZonesByProfile as timezones} from '../lib/luxon-timezones.js'; | ||
|
||
// todo: change to `(profile) => (when) => {}` | ||
const formatDate = (profile, when) => { | ||
let timezone | ||
if (timezones.has(profile)) timezone = timezones.get(profile) | ||
else { | ||
timezone = new IANAZone(profile.timezone) | ||
timezones.set(profile, timezone) | ||
let timezone; | ||
if (timezones.has(profile)) { | ||
timezone = timezones.get(profile); | ||
} else { | ||
timezone = new IANAZone(profile.timezone); | ||
timezones.set(profile, timezone); | ||
} | ||
|
||
return DateTime.fromMillis(+when, { | ||
locale: profile.locale, | ||
zone: timezone | ||
}).toFormat('yyyyMMdd') | ||
} | ||
return DateTime | ||
.fromMillis(Number(when), { | ||
locale: profile.locale, | ||
zone: timezone, | ||
}) | ||
.toFormat('yyyyMMdd'); | ||
}; | ||
|
||
export { | ||
formatDate, | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
const bike = {type: 'BC', mode: 'INC'} | ||
const bike = {type: 'BC', mode: 'INC'}; | ||
|
||
const accessibility = { | ||
none: {type: 'META', mode: 'INC', meta: 'notBarrierfree'}, | ||
partial: {type: 'META', mode: 'INC', meta: 'limitedBarrierfree'}, | ||
complete: {type: 'META', mode: 'INC', meta: 'completeBarrierfree'} | ||
} | ||
complete: {type: 'META', mode: 'INC', meta: 'completeBarrierfree'}, | ||
}; | ||
|
||
export { | ||
bike, | ||
accessibility, | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
const formatLocationFilter = (stops, addresses, poi) => { | ||
if (stops && addresses && poi) return 'ALL' | ||
return (stops ? 'S' : '') + (addresses ? 'A' : '') + (poi ? 'P' : '') | ||
} | ||
if (stops && addresses && poi) { | ||
return 'ALL'; | ||
} | ||
return ( | ||
(stops ? 'S' : '') | ||
+ (addresses ? 'A' : '') | ||
+ (poi ? 'P' : '') | ||
); | ||
}; | ||
|
||
export { | ||
formatLocationFilter, | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
const sep = '@' | ||
const sep = '@'; | ||
|
||
const formatLocationIdentifier = (data) => { | ||
let str = '' | ||
let str = ''; | ||
for (let key in data) { | ||
if (!Object.prototype.hasOwnProperty.call(data, key)) continue | ||
if (!Object.prototype.hasOwnProperty.call(data, key)) { | ||
continue; | ||
} | ||
|
||
str += key + '=' + data[key] + sep // todo: escape, but how? | ||
str += key + '=' + data[key] + sep; // todo: escape, but how? | ||
} | ||
|
||
return str | ||
} | ||
return str; | ||
}; | ||
|
||
export { | ||
formatLocationIdentifier, | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,25 @@ | ||
const formatLocation = (profile, l, name = 'location') => { | ||
if ('string' === typeof l) return profile.formatStation(l) | ||
if ('string' === typeof l) { | ||
return profile.formatStation(l); | ||
} | ||
if ('object' === typeof l && !Array.isArray(l)) { | ||
if (l.type === 'station' || l.type === 'stop') { | ||
return profile.formatStation(l.id) | ||
return profile.formatStation(l.id); | ||
} | ||
if (l.poi) { | ||
return profile.formatPoi(l); | ||
} | ||
if ('string' === typeof l.address) { | ||
return profile.formatAddress(l); | ||
} | ||
if (!l.type) { | ||
throw new TypeError(`missing ${name}.type`); | ||
} | ||
if (l.poi) return profile.formatPoi(l) | ||
if ('string' === typeof l.address) return profile.formatAddress(l) | ||
if (!l.type) throw new TypeError(`missing ${name}.type`) | ||
throw new TypeError(`invalid ${name}.type: ${l.type}`) | ||
throw new TypeError(`invalid ${name}.type: ${l.type}`); | ||
} | ||
throw new TypeError(name + ': valid station, address or poi required.') | ||
} | ||
throw new TypeError(name + ': valid station, address or poi required.'); | ||
}; | ||
|
||
export { | ||
formatLocation, | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
const formatLocationsReq = (ctx, query) => { | ||
const {profile, opt} = ctx | ||
const {profile, opt} = ctx; | ||
|
||
return { | ||
cfg: {polyEnc: 'GPA'}, | ||
meth: 'LocMatch', | ||
req: {input: { | ||
loc: { | ||
type: profile.formatLocationFilter(opt.stops, opt.addresses, opt.poi), | ||
name: opt.fuzzy ? query + '?' : query | ||
name: opt.fuzzy | ||
? query + '?' | ||
: query, | ||
}, | ||
maxLoc: opt.results, | ||
field: 'S' // todo: what is this? | ||
}} | ||
} | ||
} | ||
field: 'S', // todo: what is this? | ||
}}, | ||
}; | ||
}; | ||
|
||
export { | ||
formatLocationsReq, | ||
} | ||
}; |
Oops, something went wrong.