mirror of
https://github.com/public-transport/db-vendo-client.git
synced 2025-05-02 20:49:58 +03:00
rename stringify -> format
This commit is contained in:
parent
e6982753cd
commit
5b96c89b5b
14 changed files with 52 additions and 52 deletions
17
format/address.js
Normal file
17
format/address.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const formatCoord = require('./coord')
|
||||||
|
|
||||||
|
const formatAddress = (latitude, longitude, name) => {
|
||||||
|
if (!latitude || !longitude || !name) throw new Error('invalid address.')
|
||||||
|
return {
|
||||||
|
type: 'A',
|
||||||
|
name,
|
||||||
|
crd: {
|
||||||
|
x: formatCoord(longitude),
|
||||||
|
y: formatCoord(latitude)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = formatAddress
|
5
format/coord.js
Normal file
5
format/coord.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const formatCoord = x => Math.round(x * 1000000)
|
||||||
|
|
||||||
|
module.exports = formatCoord
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
const moment = require('moment-timezone')
|
const moment = require('moment-timezone')
|
||||||
|
|
||||||
const stringifyDate = (tz, when) => {
|
const formatDate = (tz, when) => {
|
||||||
moment(when).tz(tz).format('YYYYMMDD')
|
moment(when).tz(tz).format('YYYYMMDD')
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = stringifyDate
|
module.exports = formatDate
|
|
@ -1,8 +1,8 @@
|
||||||
'use strict'
|
'use strict'
|
||||||
|
|
||||||
const stringifyLocationFilter = (stations, addresses, poi) => {
|
const formatLocationFilter = (stations, addresses, poi) => {
|
||||||
if (stations && addresses && poi) return 'ALL'
|
if (stations && addresses && poi) return 'ALL'
|
||||||
return (stations ? 'S' : '') + (addresses ? 'A' : '') + (poi ? 'P' : '')
|
return (stations ? 'S' : '') + (addresses ? 'A' : '') + (poi ? 'P' : '')
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = stringifyLocationFilter
|
module.exports = formatLocationFilter
|
18
format/poi.js
Normal file
18
format/poi.js
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const formatCoord = require('./coord')
|
||||||
|
|
||||||
|
const formatPoi = (latitude, longitude, id, name) => {
|
||||||
|
if (!latitude || !longitude || !id || !name) throw new Error('invalid poi.')
|
||||||
|
return {
|
||||||
|
type: 'P',
|
||||||
|
name,
|
||||||
|
lid: 'L=' + id,
|
||||||
|
crd: {
|
||||||
|
x: formatCoord(longitude),
|
||||||
|
y: formatCoord(latitude)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = formatPoi
|
5
format/station.js
Normal file
5
format/station.js
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
const formatStation = id => ({type: 'S', lid: 'L=' + id})
|
||||||
|
|
||||||
|
module.exports = formatStation
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
const moment = require('moment-timezone')
|
const moment = require('moment-timezone')
|
||||||
|
|
||||||
const stringifyTime = (tz, when) => {
|
const formatTime = (tz, when) => {
|
||||||
return moment(when).tz(tz).format('HHmmss')
|
return moment(when).tz(tz).format('HHmmss')
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = stringifyTime
|
module.exports = formatTime
|
|
@ -7,7 +7,7 @@
|
||||||
"index.js",
|
"index.js",
|
||||||
"lib",
|
"lib",
|
||||||
"parse",
|
"parse",
|
||||||
"stringify"
|
"format"
|
||||||
],
|
],
|
||||||
"author": "Jannis R <mail@jannisr.de>",
|
"author": "Jannis R <mail@jannisr.de>",
|
||||||
"homepage": "https://github.com/derhuerst/hafas-client",
|
"homepage": "https://github.com/derhuerst/hafas-client",
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
const stringifyCoord = require('./coord')
|
|
||||||
|
|
||||||
const stringifyAddress = (latitude, longitude, name) => {
|
|
||||||
if (!latitude || !longitude || !name) throw new Error('invalid address.')
|
|
||||||
return {
|
|
||||||
type: 'A',
|
|
||||||
name,
|
|
||||||
crd: {
|
|
||||||
x: stringifyCoord(longitude),
|
|
||||||
y: stringifyCoord(latitude)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = stringifyAddress
|
|
|
@ -1,5 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
const stringifyCoord = x => Math.round(x * 1000000)
|
|
||||||
|
|
||||||
module.exports = stringifyCoord
|
|
|
@ -1,18 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
const stringifyCoord = require('./coord')
|
|
||||||
|
|
||||||
const stringifyPoi = (latitude, longitude, id, name) => {
|
|
||||||
if (!latitude || !longitude || !id || !name) throw new Error('invalid poi.')
|
|
||||||
return {
|
|
||||||
type: 'P',
|
|
||||||
name,
|
|
||||||
lid: 'L=' + id,
|
|
||||||
crd: {
|
|
||||||
x: stringifyCoord(longitude),
|
|
||||||
y: stringifyCoord(latitude)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = stringifyPoi
|
|
|
@ -1,5 +0,0 @@
|
||||||
'use strict'
|
|
||||||
|
|
||||||
const stringifyStation = id => ({type: 'S', lid: 'L=' + id})
|
|
||||||
|
|
||||||
module.exports = stringifyStation
|
|
Loading…
Add table
Reference in a new issue