-
Notifications
You must be signed in to change notification settings - Fork 17
Description
So the response for a matrix request is incorrectly typed.
This is the object that's returned from the Javascript SDK -
export interface RadarMatrixResponse extends RadarResponse {
origins: Location[];
destinations: Location[];
matrix: RadarMatrixRoute[];
}
export interface RadarMatrixRoute {
distance?: RadarRouteDistance;
duration?: RadarRouteDuration;
originIndex: number;
destinationIndex: number;
}Its almost right but during testing, I found that I was getting undefined values while trying to sum up the durations and distances for a specific combination of routes.
Turns out each of the values in the RadarMatrixResponse is an array of arrays (a matrix) but its typed as an array of objects. Attached is an actual response printed from the SDK and below is my current work around. I'll try to send a PR out when I have some time to pull the project down.
P.S. Context on the og[index][index].duration.value situation
If I'm providing a list of origins and destinations for a single trip (point a -> point b -> point c) I only really care about the distance/duration between origin 0 to destination 0, origin 1 to destination 1, and origin 2 to destination 2. Hence og[index][index], for my personal use case the rest is sort of fluff.