Skip to content

Incorrect Radar Matrix response type #220

@Guysnacho

Description

@Guysnacho

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.

Image

Radar_Matrix_Response.json

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions