-
-
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.
- Loading branch information
1 parent
9949953
commit 22441fd
Showing
246 changed files
with
5,677 additions
and
5,677 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +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), | ||
} | ||
}; | ||
if (a.id) { | ||
data.L = a.id | ||
data.L = a.id; | ||
} | ||
return { | ||
type: 'A', // address | ||
name: a.address, | ||
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,23 +1,23 @@ | ||
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 | ||
let timezone; | ||
if (timezones.has(profile)) { | ||
timezone = timezones.get(profile) | ||
timezone = timezones.get(profile); | ||
} else { | ||
timezone = new IANAZone(profile.timezone) | ||
timezones.set(profile, timezone) | ||
timezone = new IANAZone(profile.timezone); | ||
timezones.set(profile, timezone); | ||
} | ||
|
||
return DateTime.fromMillis(Number(when), { | ||
locale: profile.locale, | ||
zone: timezone, | ||
}) | ||
.toFormat('yyyyMMdd') | ||
} | ||
.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'}, | ||
} | ||
}; | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,9 +4,9 @@ const formatLinesReq = (ctx, query) => { | |
req: { | ||
input: query, | ||
}, | ||
} | ||
} | ||
}; | ||
}; | ||
|
||
export { | ||
formatLinesReq, | ||
} | ||
}; |
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,16 @@ | ||
const formatLocationFilter = (stops, addresses, poi) => { | ||
if (stops && addresses && poi) { | ||
return 'ALL' | ||
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,18 +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 | ||
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,25 +1,25 @@ | ||
const formatLocation = (profile, l, name = 'location') => { | ||
if ('string' === typeof l) { | ||
return profile.formatStation(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) | ||
return profile.formatPoi(l); | ||
} | ||
if ('string' === typeof l.address) { | ||
return profile.formatAddress(l) | ||
return profile.formatAddress(l); | ||
} | ||
if (!l.type) { | ||
throw new TypeError(`missing ${name}.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
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,45 +1,45 @@ | ||
import isObj from 'lodash/isObject.js' | ||
import isObj from 'lodash/isObject.js'; | ||
|
||
const hasProp = (o, k) => Object.prototype.hasOwnProperty.call(o, k) | ||
const hasProp = (o, k) => Object.prototype.hasOwnProperty.call(o, k); | ||
|
||
const formatProductsFilter = (ctx, filter) => { | ||
if (!isObj(filter)) { | ||
throw new TypeError('products filter must be an object') | ||
throw new TypeError('products filter must be an object'); | ||
} | ||
const {profile} = ctx | ||
const {profile} = ctx; | ||
|
||
const byProduct = {} | ||
const defaultProducts = {} | ||
const byProduct = {}; | ||
const defaultProducts = {}; | ||
for (let product of profile.products) { | ||
byProduct[product.id] = product | ||
defaultProducts[product.id] = product.default | ||
byProduct[product.id] = product; | ||
defaultProducts[product.id] = product.default; | ||
} | ||
filter = Object.assign({}, defaultProducts, filter) | ||
filter = Object.assign({}, defaultProducts, filter); | ||
|
||
let res = 0, products = 0 | ||
let res = 0, products = 0; | ||
for (let product in filter) { | ||
if (!hasProp(filter, product) || filter[product] !== true) { | ||
continue | ||
continue; | ||
} | ||
if (!byProduct[product]) { | ||
throw new TypeError('unknown product ' + product) | ||
throw new TypeError('unknown product ' + product); | ||
} | ||
products++ | ||
products++; | ||
for (let bitmask of byProduct[product].bitmasks) { | ||
res = res | bitmask | ||
res = res | bitmask; | ||
} | ||
} | ||
if (products === 0) { | ||
throw new Error('no products used') | ||
throw new Error('no products used'); | ||
} | ||
|
||
return { | ||
type: 'PROD', | ||
mode: 'INC', | ||
value: String(res), | ||
} | ||
} | ||
}; | ||
}; | ||
|
||
export { | ||
formatProductsFilter, | ||
} | ||
}; |
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
Oops, something went wrong.