Implement NodeJS based server fully replicating osrm-routed
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -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) {
|
||||
|
||||
+1
-3
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user