diff --git a/features/support/http.js b/features/support/http.js
index 9e3704f0b..41ec126ec 100644
--- a/features/support/http.js
+++ b/features/support/http.js
@@ -1,5 +1,6 @@
var Timeout = require('node-timeout');
var request = require('request');
+var fs = require('fs');
module.exports = function () {
this.paramsToString = (params) => {
@@ -22,14 +23,17 @@ module.exports = function () {
// FIXME this needs to be simplified!
// - remove usage of node-timeout
// - replace with node's native timout mechanism
- this.sendRequest = (baseUri, parameters, type, callback) => {
+ this.sendRequest = (baseUri, parameters, type, logfile, callback) => {
var limit = Timeout(this.TIMEOUT, { err: { statusCode: 408 } });
var runRequest = (cb) => {
if (type === 'GET') {
+
var params = this.paramsToString(parameters);
this.query = baseUri + (params.length ? '/' + params : '');
+
+ if (logfile && typeof logfile !== 'function') fs.writeFileSync(logfile, `GET ${this.query}`);
request(this.query, (err, res, body) => {
if (err && err.code === 'ECONNREFUSED') {
return cb(new Error('*** osrm-routed is not running.'));
@@ -41,6 +45,7 @@ module.exports = function () {
});
} else {
this.query = baseUri;
+ if (logfile && typeof logfile !== 'function') fs.writeFileSync(logfile, `POST ${this.query}\n\n${JSON.stringify(parameters)}`);
request.post(this.query, {body: JSON.stringify(parameters)}, (err, res, body) => {
if (err && err.code === 'ECONNREFUSED') {
return cb(new Error('*** osrm-routed is not running.'));
diff --git a/features/support/route.js b/features/support/route.js
index 6f59d315b..712b55a1a 100644
--- a/features/support/route.js
+++ b/features/support/route.js
@@ -5,7 +5,7 @@ const request = require('request');
const ensureDecimal = require('../lib/utils').ensureDecimal;
module.exports = function () {
- this.requestPath = (service, params, callback) => {
+ this.requestPath = (service, params, logfile, callback) => {
var uri;
if (service == 'timestamp' || this.osrmLoader.method === 'valhalla') {
uri = [this.HOST, service].join('/');
@@ -13,7 +13,7 @@ module.exports = function () {
uri = [this.HOST, service, 'v1', this.profile].join('/');
}
- return this.sendRequest(uri, params, this.osrmLoader.method === 'valhalla' ? 'POST' : 'GET', callback);
+ return this.sendRequest(uri, params, this.osrmLoader.method === 'valhalla' ? 'POST' : 'GET', logfile, callback);
};
this.requestUrl = (path, callback) => {
@@ -46,7 +46,7 @@ module.exports = function () {
return waypoints.map(w => [w.lon, w.lat].map(ensureDecimal).join(','));
};
- this.requestRoute = (waypoints, bearings, approaches, userParams, callback) => {
+ this.requestRoute = (waypoints, bearings, approaches, userParams, logfile, callback) => {
if (bearings.length && bearings.length !== waypoints.length) throw new Error('*** number of bearings does not equal the number of waypoints');
if (approaches.length && approaches.length !== waypoints.length) throw new Error('*** number of approaches does not equal the number of waypoints');
@@ -82,7 +82,7 @@ module.exports = function () {
}
- return this.requestPath('route', params, callback);
+ return this.requestPath('route', params, logfile, callback);
};
this.requestNearest = (node, userParams, callback) => {
@@ -316,14 +316,19 @@ var typemap = {
25: {type: 'merge', modifier: null },
- 26: {type: 'roundabout', modifier: null },
- 27: {type: 'roundabout-exit', modifier: null },
+ 26: {type: 'roundabout-exit', modifier: null },
+ 27: {type: 'exit roundabout', modifier: null },
+
+ 28: {type: 'enter ferry', modifier: null },
+ 29: {type: 'exit ferry', modifier: null }
}
return instructions.legs.reduce((m, v) => m.concat(v.maneuvers), [])
.map(v => {
if (v.type in typemap) {
- if (typemap[v.type].modifier) {
+ if (v.type === 26) { // special construction for roundabout instructions
+ return `${typemap[v.type].type}-${v.roundabout_exit_count}`;
+ } else if (typemap[v.type].modifier) {
return `${typemap[v.type].type} ${typemap[v.type].modifier}`;
} else {
return `${typemap[v.type].type}`;
diff --git a/features/support/shared_steps.js b/features/support/shared_steps.js
index 2682cbb42..253be94fd 100644
--- a/features/support/shared_steps.js
+++ b/features/support/shared_steps.js
@@ -95,6 +95,7 @@ module.exports = function () {
}
}
fs.writeFileSync(`${this.scenarioCacheFile}_${rowIndex}_results.json`,JSON.stringify(resultdata));
+ fs.writeFileSync(`${this.scenarioCacheFile}_${rowIndex}_response.json`,body);
var geojson = {
type: 'FeatureCollection',
@@ -324,7 +325,9 @@ module.exports = function () {
got.from = row.from;
got.to = row.to;
- this.requestRoute(waypoints, bearings, approaches, params, afterRequest);
+
+ this.currentRowIndex = rowIndex;
+ this.requestRoute(waypoints, bearings, approaches, params, `${this.scenarioCacheFile}_${rowIndex}_request.txt`, afterRequest);
} else if (row.waypoints) {
row.waypoints.split(',').forEach((n) => {
var node = this.findNodeByName(n.trim());
@@ -332,7 +335,7 @@ module.exports = function () {
waypoints.push(node);
});
got.waypoints = row.waypoints;
- this.requestRoute(waypoints, bearings, approaches, params, afterRequest);
+ this.requestRoute(waypoints, bearings, approaches, params, `${this.scenarioCacheFile}_${rowIndex}_request.txt`, afterRequest);
} else {
return cb(new Error('*** no waypoints'));
}
diff --git a/scripts/tests2doc.js b/scripts/tests2doc.js
index 291bb4142..6cfb6d027 100644
--- a/scripts/tests2doc.js
+++ b/scripts/tests2doc.js
@@ -32,61 +32,61 @@ var stylesheet = `