Implement NodeJS based server fully replicating osrm-routed
This commit is contained in:
parent
4dfae26be7
commit
ddde7e1ea6
@ -88,7 +88,6 @@ inline void ParseResult(const osrm::Status &result_status, osrm::json::Object &r
|
||||
throw std::logic_error(code_iter->second.get<osrm::json::String>().value.c_str());
|
||||
}
|
||||
|
||||
result.values.erase(code_iter);
|
||||
const auto message_iter = result.values.find("message");
|
||||
if (message_iter != end_iter)
|
||||
{
|
||||
|
@ -15,19 +15,19 @@ class OSRMWrapper {
|
||||
return util_1.default.promisify(this.osrm.tile.bind(this.osrm))(zxy);
|
||||
}
|
||||
async route(options) {
|
||||
return util_1.default.promisify(this.osrm.route.bind(this.osrm))(options);
|
||||
return util_1.default.promisify(this.osrm.route.bind(this.osrm))(options, { format: 'buffer' });
|
||||
}
|
||||
async nearest(options) {
|
||||
return util_1.default.promisify(this.osrm.nearest.bind(this.osrm))(options);
|
||||
return util_1.default.promisify(this.osrm.nearest.bind(this.osrm))(options, { format: 'buffer' });
|
||||
}
|
||||
async table(options) {
|
||||
return util_1.default.promisify(this.osrm.table.bind(this.osrm))(options);
|
||||
return util_1.default.promisify(this.osrm.table.bind(this.osrm))(options, { format: 'buffer' });
|
||||
}
|
||||
async trip(options) {
|
||||
return util_1.default.promisify(this.osrm.trip.bind(this.osrm))(options);
|
||||
return util_1.default.promisify(this.osrm.trip.bind(this.osrm))(options, { format: 'buffer' });
|
||||
}
|
||||
async match(options) {
|
||||
return util_1.default.promisify(this.osrm.match.bind(this.osrm))(options);
|
||||
return util_1.default.promisify(this.osrm.match.bind(this.osrm))(options, { format: 'buffer' });
|
||||
}
|
||||
}
|
||||
exports.OSRMWrapper = OSRMWrapper;
|
||||
|
@ -15,22 +15,22 @@ export class OSRMWrapper {
|
||||
}
|
||||
|
||||
async route(options: any): Promise<any> {
|
||||
return util.promisify(this.osrm.route.bind(this.osrm))(options);
|
||||
return util.promisify(this.osrm.route.bind(this.osrm))(options, {format: 'buffer'});
|
||||
}
|
||||
|
||||
async nearest(options: any): Promise<any> {
|
||||
return util.promisify(this.osrm.nearest.bind(this.osrm))(options);
|
||||
return util.promisify(this.osrm.nearest.bind(this.osrm))(options, {format: 'buffer'});
|
||||
}
|
||||
|
||||
async table(options: any): Promise<any> {
|
||||
return util.promisify(this.osrm.table.bind(this.osrm))(options);
|
||||
return util.promisify(this.osrm.table.bind(this.osrm))(options, {format: 'buffer'});
|
||||
}
|
||||
|
||||
async trip(options: any): Promise<any> {
|
||||
return util.promisify(this.osrm.trip.bind(this.osrm))(options);
|
||||
return util.promisify(this.osrm.trip.bind(this.osrm))(options, {format: 'buffer'});
|
||||
}
|
||||
|
||||
async match(options: any): Promise<any> {
|
||||
return util.promisify(this.osrm.match.bind(this.osrm))(options);
|
||||
return util.promisify(this.osrm.match.bind(this.osrm))(options, {format: 'buffer'});
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ class RouteServiceHandler extends ServiceHandler_1.ServiceHandler {
|
||||
if (query.waypoints) {
|
||||
options.waypoints = query.waypoints;
|
||||
}
|
||||
// throw Error(JSON.stringify(options));
|
||||
return options;
|
||||
}
|
||||
async callOSRM(options) {
|
||||
|
@ -10,11 +10,9 @@ export class RouteServiceHandler extends ServiceHandler {
|
||||
if (query.approaches) {
|
||||
options.approaches = query.approaches;
|
||||
}
|
||||
|
||||
if (query.waypoints) {
|
||||
options.waypoints = query.waypoints;
|
||||
}
|
||||
// throw Error(JSON.stringify(options));
|
||||
return options;
|
||||
}
|
||||
|
||||
|
@ -107,7 +107,7 @@ async function main() {
|
||||
break;
|
||||
}
|
||||
const result = await handler.handle(coordinates, query, format);
|
||||
result['code'] = 'Ok';
|
||||
// result['code'] = 'Ok';
|
||||
return result;
|
||||
}
|
||||
catch (e) {
|
||||
|
@ -92,9 +92,7 @@ async function main() {
|
||||
break;
|
||||
}
|
||||
|
||||
const result = await handler.handle(coordinates, query, format);
|
||||
result['code'] = 'Ok';
|
||||
return result;
|
||||
return handler.handle(coordinates, query, format);
|
||||
} catch (e: any) {
|
||||
reply.code(400);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user