🤖 Merge PR #47389 @types/osrm: Expose annotations and distances matrix by @alistairwoodcock

* Annotations to specify what matrices are returned is available in OSRM but was not exposed via the types

* Updated supported version number

* Removed patch version to match CI requirement MAJOR.MINOR
This commit is contained in:
Alistair Woodcock 2020-09-22 06:52:30 +10:00 committed by GitHub
parent fc8039e9b5
commit b1099059f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -1,4 +1,4 @@
// Type definitions for osrm 5.12
// Type definitions for osrm 5.22
// Project: https://github.com/Project-OSRM/osrm-backend
// Definitions by: Denis Carriere <https://github.com/DenisCarriere>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@ -50,6 +50,7 @@ declare namespace OSRM {
type Radius = number;
type Hint = string;
type Duration = number;
type Distance = number;
type Tile = [number, number, number];
type StepManeuverTypes = 'turn' | 'new name' | 'depart' | 'arrive' | 'merge' |
'ramp' | 'on ramp' | 'off ramp' | 'fork' | 'end of road' |
@ -466,6 +467,10 @@ declare namespace OSRM {
* to use location with given index as destination. Default is to use all.
*/
destinations?: number[];
/**
* specify which table results to return.
*/
annotations?: Array<('duration' | 'distance')>;
}
/**
@ -570,6 +575,7 @@ declare namespace OSRM {
interface TableResults {
durations: Duration[][];
distances?: Distance[][];
sources: Waypoint[];
destinations: Waypoint[];
}

View File

@ -35,6 +35,21 @@ osrm.table({coordinates}, (err, response) => {
console.log(response.destinations); // array of Waypoint objects
});
// Table Distances
osrm.table({coordinates, annotations: ['distance']}, (err, response) => {
console.log(response.distances); // array of arrays, matrix in row-major order
console.log(response.sources); // array of Waypoint objects
console.log(response.destinations); // array of Waypoint objects
});
// Table Durations and Distances
osrm.table({coordinates, annotations: ['distance', 'duration']}, (err, response) => {
console.log(response.durations); // array of arrays, matrix in row-major order
console.log(response.distances); // array of arrays, matrix in row-major order
console.log(response.sources); // array of Waypoint objects
console.log(response.destinations); // array of Waypoint objects
});
// Tile
osrm.tile([0, 0, 0], (err, response) => {
if (err) throw err;