@mapbox/polyline -> google-polyline

This commit is contained in:
Jannis R 2020-01-31 18:07:16 +01:00
parent f771e9fb5d
commit db9287f7fd
No known key found for this signature in database
GPG key ID: 0FE83946296A88A5
2 changed files with 6 additions and 6 deletions

View file

@ -34,10 +34,10 @@
}, },
"dependencies": { "dependencies": {
"@derhuerst/br2nl": "^1.0.0", "@derhuerst/br2nl": "^1.0.0",
"@mapbox/polyline": "^1.0.0",
"capture-stack-trace": "^1.0.0", "capture-stack-trace": "^1.0.0",
"create-hash": "^1.2.0", "create-hash": "^1.2.0",
"fetch-ponyfill": "^6.0.0", "fetch-ponyfill": "^6.0.0",
"google-polyline": "^1.0.3",
"gps-distance": "0.0.4", "gps-distance": "0.0.4",
"lodash": "^4.17.5", "lodash": "^4.17.5",
"luxon": "^1.3.0", "luxon": "^1.3.0",

View file

@ -1,6 +1,6 @@
'use strict' 'use strict'
const {toGeoJSON} = require('@mapbox/polyline') const {decode} = require('google-polyline')
const distance = require('gps-distance') const distance = require('gps-distance')
// todo: what is p.delta? // todo: what is p.delta?
@ -8,15 +8,15 @@ const distance = require('gps-distance')
// todo: what is p.crdEncS? // todo: what is p.crdEncS?
// todo: what is p.crdEncF? // todo: what is p.crdEncF?
const parsePolyline = (ctx, p) => { // p = raw polyline const parsePolyline = (ctx, p) => { // p = raw polyline
const shape = toGeoJSON(p.crdEncYX) const points = decode(p.crdEncYX)
if (shape.coordinates.length === 0) return null if (points.length === 0) return null
const res = shape.coordinates.map(crd => ({ const res = points.map(([lat, lon]) => ({
type: 'Feature', type: 'Feature',
properties: {}, properties: {},
geometry: { geometry: {
type: 'Point', type: 'Point',
coordinates: crd coordinates: [lon, lat]
} }
})) }))