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['#'];
+43 -3
View File
@@ -177,7 +177,7 @@ Feature: Basic Map Matching
| trace | matchings | geometry |
| efbc | efbc | 1,0.99964,1.000359,0.99964,1.000359,1,1.000718,1 |
Scenario: Testbot - Geometry details
Scenario: Testbot - Geometry details using geojson
Given the query options
| overview | full |
| geometries | geojson |
@@ -197,7 +197,47 @@ Feature: Basic Map Matching
| trace | matchings | geometry |
| abd | abd | 1,1,1.000089,1,1.000089,1,1.000089,0.99991 |
Scenario: Testbot - Speed greater than speed threshhold, should split -- returns trace as abcd but should be split into ab,cd
Scenario: Testbot - Geometry details using polyline
Given the query options
| overview | full |
| geometries | polyline |
Given the node map
"""
a b c
d
"""
And the ways
| nodes | oneway |
| abc | no |
| bd | no |
When I match I should get
| trace | matchings | geometry |
| abd | abd | 1,1,1,1.00009,1,1.00009,0.99991,1.00009 |
Scenario: Testbot - Geometry details using polyline6
Given the query options
| overview | full |
| geometries | polyline6 |
Given the node map
"""
a b c
d
"""
And the ways
| nodes | oneway |
| abc | no |
| bd | no |
When I match I should get
| trace | matchings | geometry |
| abd | abd | 1,1,1,1.000089,1,1.000089,0.99991,1.000089 |
Scenario: Testbot - Speed greater than speed threshhold
Given a grid size of 10 meters
Given the query options
| geometries | geojson |
@@ -218,7 +258,7 @@ Feature: Basic Map Matching
| trace | timestamps | matchings |
| abcd | 0 1 2 3 | ab,cd |
Scenario: Testbot - Speed less than speed threshhold, should not split
Scenario: Testbot - Speed less than speed threshhold
Given a grid size of 10 meters
Given the query options
| geometries | geojson |
+66
View File
@@ -122,3 +122,69 @@ Feature: Basic trip planning
| waypoints | trips |
| a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a,a | |
Scenario: Testbot - Trip with geometry details of geojson
Given the query options
| geometries | geojson |
Given the node map
"""
a b
c d
"""
And the ways
| nodes |
| ab |
| bc |
| cb |
| da |
When I plan a trip I should get
| waypoints | trips | durations | geometry |
| a,b,c,d | abcda | 7.6 | 1,1,1.000089,1,1,0.99991,1.000089,1,1,1,1.000089,0.99991,1,1 |
| d,b,c,a | dbcad | 7.6 | 1.000089,0.99991,1,1,1.000089,1,1,0.99991,1.000089,1,1,1,1.000089,0.99991 |
Scenario: Testbot - Trip with geometry details of polyline
Given the query options
| geometries | polyline |
Given the node map
"""
a b
c d
"""
And the ways
| nodes |
| ab |
| bc |
| cb |
| da |
When I plan a trip I should get
| waypoints | trips | durations | geometry |
| a,b,c,d | abcda | 7.6 | 1,1,1,1.00009,0.99991,1,1,1.00009,1,1,0.99991,1.00009,1,1 |
| d,b,c,a | dbcad | 7.6 | 0.99991,1.00009,1,1,1,1.00009,0.99991,1,1,1.00009,1,1,0.99991,1.00009 |
Scenario: Testbot - Trip with geometry details of polyline6
Given the query options
| geometries | polyline6 |
Given the node map
"""
a b
c d
"""
And the ways
| nodes |
| ab |
| bc |
| cb |
| da |
When I plan a trip I should get
| waypoints | trips | durations | geometry |
| a,b,c,d | abcda | 7.6 | 1,1,1,1.000089,0.99991,1,1,1.000089,1,1,0.99991,1.000089,1,1 |
| d,b,c,a | dbcad | 7.6 | 0.99991,1.000089,1,1,1,1.000089,0.99991,1,1,1.000089,1,1,0.99991,1.000089 |