Routing API Developer's Guide

Optimizing Matrix Calculation by Limiting a Search Range

In cases where only destinations in a specific range are relevant, the matrix calculation may be optimized by limiting the search range. To limit the search range include a searchrange parameter with a desired value in the calculatematrix request. Calculation of routes to destinations which are beyond the specified range will be interrupted at certain point and the corresponding MatrixEntry elements in the response will include the Status field with a rangeExceeded value instead of Summary.

The following example demonstrates a request of a matrix of routes between two start points and two destinations with a search range limited to 5 kilometers. Both destinations are beyond the first start point range. Note that the corresponding matrix entries in the response include the Status field with a rangeExceeded value.

https://matrix.route.cit.api.here.com/routing/7.2/calculatematrix.json
?app_id={YOUR_APP_ID}
&app_code={YOUR_APP_CODE}
&start0=52.43,13.4
&start1=52.5,13.4
&destination0=52.5,13.43
&destination1=52.5,13.46
&mode=fastest;car;traffic:disabled
&searchrange=5000

Response:

{
  response: {
  metaInfo: { /*content omitted*/ },
  matrixEntry: [
    {
    startIndex: 0,
    destinationIndex: 0,
    status: "rangeExceeded"
    },
    {
    startIndex: 0,
    destinationIndex: 1,
    status: "rangeExceeded"
    },
    {
    startIndex: 1,
    destinationIndex: 0,
    summary: { costFactor: 1020 }
    },
    {
    startIndex: 1,
    destinationIndex: 1,
    summary: { costFactor: 1314 }
    }
  ]
  }
}