Replaced 'in' and 'out' at the flatbuffers 'instersection' object
with 'in_bearing' and 'out_bearing' to get flatbuffers schema javascript friendly. Added a cucumber test for flatbuffers support.
This commit is contained in:
@@ -111,3 +111,28 @@ Feature: Locating Nearest node on a Way - basic projection onto way
|
||||
| 7 | b |
|
||||
| 8 | a |
|
||||
| 9 | b |
|
||||
|
||||
Scenario: Nearest - easy-west way with flatbuffers
|
||||
Given the node map
|
||||
"""
|
||||
0 1 2 3 4
|
||||
a x b
|
||||
5 6 7 8 9
|
||||
"""
|
||||
|
||||
And the ways
|
||||
| nodes |
|
||||
| ab |
|
||||
|
||||
When I request nearest with flatbuffers I should get
|
||||
| in | out |
|
||||
| 0 | a |
|
||||
| 1 | a |
|
||||
| 2 | x |
|
||||
| 3 | b |
|
||||
| 4 | b |
|
||||
| 5 | a |
|
||||
| 6 | a |
|
||||
| 7 | x |
|
||||
| 8 | b |
|
||||
| 9 | b |
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
var util = require('util');
|
||||
|
||||
var flatbuffers = require('../support/flatbuffers').flatbuffers;
|
||||
var FBResult = require('../support/fbresult_generated').osrm.engine.api.fbresult.FBResult;
|
||||
|
||||
module.exports = function () {
|
||||
this.When(/^I request nearest I should get$/, (table, callback) => {
|
||||
this.reprocessAndLoadData((e) => {
|
||||
@@ -43,4 +46,55 @@ module.exports = function () {
|
||||
this.processRowsAndDiff(table, testRow, callback);
|
||||
});
|
||||
});
|
||||
|
||||
this.When(/^I request nearest with flatbuffers I should get$/, (table, callback) => {
|
||||
this.reprocessAndLoadData((e) => {
|
||||
if (e) return callback(e);
|
||||
var testRow = (row, ri, cb) => {
|
||||
var inNode = this.findNodeByName(row.in);
|
||||
if (!inNode) throw new Error(util.format('*** unknown in-node "%s"', row.in));
|
||||
|
||||
var outNode = this.findNodeByName(row.out);
|
||||
if (!outNode) throw new Error(util.format('*** unknown out-node "%s"', row.out));
|
||||
|
||||
this.queryParams.output = 'flatbuffers';
|
||||
this.requestNearest(inNode, this.queryParams, (err, response) => {
|
||||
if (err) return cb(err);
|
||||
var coord;
|
||||
|
||||
if (response.statusCode === 200 && response.body.length) {
|
||||
var body = response.body;
|
||||
var bytes = new Uint8Array(body.length);
|
||||
for (var indx = 0; indx < body.length; ++indx) {
|
||||
bytes[indx] = body.charCodeAt(indx);
|
||||
}
|
||||
var buf = new flatbuffers.ByteBuffer(bytes);
|
||||
var fb = FBResult.getRootAsFBResult(buf);
|
||||
var location = fb.waypoints(0).location();
|
||||
|
||||
coord = [location.longitute(), location.latitude()];
|
||||
|
||||
var got = { in: row.in, out: row.out };
|
||||
|
||||
Object.keys(row).forEach((key) => {
|
||||
if (key === 'out') {
|
||||
if (this.FuzzyMatch.matchLocation(coord, outNode)) {
|
||||
got[key] = row[key];
|
||||
} else {
|
||||
row[key] = util.format('%s [%d,%d]', row[key], outNode.lat, outNode.lon);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cb(null, got);
|
||||
}
|
||||
else {
|
||||
cb();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.processRowsAndDiff(table, testRow, callback);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user