-
Notifications
You must be signed in to change notification settings - Fork 1
/
line.js
27 lines (25 loc) · 859 Bytes
/
line.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import {versionedId} from './lib/versioned-id.js'
const createGetStableLineIds = (namespace, normalizeName) => (s) => {
return [
s.wikidataId ? [s.wikidataId, 10] : null,
s.osmId ? [s.osmId, 10] : null,
s.id ? [namespace + ':' + s.id, 20] : null,
// todo [breaking]: use operator IDs
s.operator && s.operator.id && s.name
? [s.operator.id + ':' + normalizeName(s.name, s), 30]
: null,
s.product && s.name
? [s.product + ':' + normalizeName(s.name, s), 31]
: null,
s.mode && s.name
? [s.mode + ':' + normalizeName(s.name, s), 32]
: null,
// todo: Onestop ID?
// https://github.com/transitland/transitland-datastore/blob/ce4ad9468882dc22a4c6fbe8b84a69da6c4cef90/app/models/route.rb#L234-L244
]
.filter(id => id !== null)
.map(([id, specificity]) => [versionedId(id), specificity])
}
export {
createGetStableLineIds,
}