mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
🤖 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:
parent
fc8039e9b5
commit
b1099059f5
8
types/osrm/index.d.ts
vendored
8
types/osrm/index.d.ts
vendored
@ -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[];
|
||||
}
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user