request polyline with precision of 5 or 6 positions (#3220)

This commit is contained in:
Kajari Ghosh
2016-11-07 15:11:21 -05:00
committed by GitHub
parent 1b03b8df6d
commit f33180f092
13 changed files with 247 additions and 66 deletions
+7 -4
View File
@@ -90,7 +90,7 @@ module.exports = function () {
if (headers.has('geometry')) {
if (json.matchings.length != 1) throw new Error('*** Checking geometry only supported for matchings with one subtrace');
geometry = json.matchings[0].geometry.coordinates;
geometry = json.matchings[0].geometry;
}
if (headers.has('OSM IDs')) {
@@ -116,10 +116,13 @@ module.exports = function () {
}
if (headers.has('geometry')) {
if (this.queryParams['geometries'] === 'polyline')
if (this.queryParams['geometries'] === 'polyline') {
got.geometry = polyline.decode(geometry).toString();
else
got.geometry = geometry;
} else if (this.queryParams['geometries'] === 'polyline6') {
got.geometry = polyline.decode(geometry,6).toString();
} else {
got.geometry = geometry.coordinates;
}
}
if (headers.has('OSM IDs')) {
+11
View File
@@ -1,4 +1,5 @@
var util = require('util');
var polyline = require('polyline');
module.exports = function () {
function add(a, b) {
@@ -41,6 +42,16 @@ module.exports = function () {
got.message = json.status_message;
}
if (headers.has('geometry')) {
if (this.queryParams['geometries'] === 'polyline') {
got.geometry = polyline.decode(json.trips[0].geometry).toString();
} else if (this.queryParams['geometries'] === 'polyline6') {
got.geometry = polyline.decode(json.trips[0].geometry, 6).toString();
} else {
got.geometry = json.trips[0].geometry.coordinates;
}
}
if (headers.has('#')) {
// comment column
got['#'] = row['#'];