diff --git a/package.json b/package.json index 84747870..fa7da4f8 100644 --- a/package.json +++ b/package.json @@ -34,10 +34,10 @@ }, "dependencies": { "@derhuerst/br2nl": "^1.0.0", - "@mapbox/polyline": "^1.0.0", "capture-stack-trace": "^1.0.0", "create-hash": "^1.2.0", "fetch-ponyfill": "^6.0.0", + "google-polyline": "^1.0.3", "gps-distance": "0.0.4", "lodash": "^4.17.5", "luxon": "^1.3.0", diff --git a/parse/polyline.js b/parse/polyline.js index 593934d2..e2aaafef 100644 --- a/parse/polyline.js +++ b/parse/polyline.js @@ -1,6 +1,6 @@ 'use strict' -const {toGeoJSON} = require('@mapbox/polyline') +const {decode} = require('google-polyline') const distance = require('gps-distance') // todo: what is p.delta? @@ -8,15 +8,15 @@ const distance = require('gps-distance') // todo: what is p.crdEncS? // todo: what is p.crdEncF? const parsePolyline = (ctx, p) => { // p = raw polyline - const shape = toGeoJSON(p.crdEncYX) - if (shape.coordinates.length === 0) return null + const points = decode(p.crdEncYX) + if (points.length === 0) return null - const res = shape.coordinates.map(crd => ({ + const res = points.map(([lat, lon]) => ({ type: 'Feature', properties: {}, geometry: { type: 'Point', - coordinates: crd + coordinates: [lon, lat] } }))