more fixes for 3811b45 🐛

This commit is contained in:
Jannis R 2017-12-12 23:40:12 +01:00
parent 0b37e62e09
commit e6f7a09505
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
3 changed files with 6 additions and 6 deletions

View file

@ -3,13 +3,13 @@
const formatCoord = require('./coord')
const formatAddress = (a) => {
if (!a.type !== 'location' || !a.latitude || !a.longitude || !a.address) {
if (a.type !== 'location' || !a.latitude || !a.longitude || !a.address) {
throw new Error('invalid address')
}
return {
type: 'A',
name: a.name,
name: a.address,
crd: {
x: formatCoord(a.longitude),
y: formatCoord(a.latitude)

View file

@ -2,10 +2,10 @@
const formatLocation = (profile, l) => {
if ('string' === typeof l) return profile.formatStation(l)
if ('object' === typeof l) {
if ('object' === typeof l && !Array.isArray(l)) {
if (l.type === 'station') return profile.formatStation(l.id)
if (l.type === 'poi') return profile.formatPoi(l)
if (l.type === 'address') return profile.formatAddress(l)
if ('string' === typeof l.id) return profile.formatPoi(l)
if ('string' === typeof l.address) return profile.formatAddress(l)
throw new Error('invalid location type: ' + l.type)
}
throw new Error('valid station, address or poi required.')

View file

@ -3,7 +3,7 @@
const formatCoord = require('./coord')
const formatPoi = (p) => {
if (!p.type !== 'location' || !p.latitude || !p.longitude || !p.id || !p.name) {
if (p.type !== 'location' || !p.latitude || !p.longitude || !p.id || !p.name) {
throw new Error('invalid POI')
}