GetRouteCostMatrix
Description
GetRouteCostMatrix calculates the travel time and distances between an array of start and end locations and returns the route that is either the fastest or the shortest. The result determines the total time and distance of the individual routes (the route costs). For example if you input four start points and four end points, a total of 16 routes will be calculated.
The GetRouteCostMatrix operation also supports transient updates, that allow you to perform per-request based road network updates for your calculations. For more information on transient updates, see Adding Transient Updates to GetRouteCostMatrix
Service URL Formats
The URL endpoint for the Routing SOAP service has the following general form:
http://<server>:<port>/soap/RoutingService
The URL for the Routing WSDL has the following general form:
http://<server>:<port>/soap/RoutingService?wsdl
Messages
The following table lists the request and response messages for the GetRouteCostMatrix operation.
Click on a message name to get more information about the message.
Message | Description |
---|---|
RouteCostMatrixRequest | The request message for the GetRouteCostMatrix operation. |
RouteCostMatrixResponse | The response message for the GetRouteCostMatrix operation. |
Single Start and End Point Example
Request for a cost matrix with a single start and end point.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v1="http://www.mapinfo.com/routing/service/v1" xmlns:v11="http://www.mapinfo.com/midev/service/geometries/v1">
<soapenv:Header />
<soapenv:Body>
<v1:RouteCostMatrixRequest id="?" locale="?">
<v1:DatasetResourceName>US_NE</v1:DatasetResourceName>
<v1:StartPoints srsName="epsg:4326">
<v11:Point srsName="epsg:4326">
<v11:Pos>
<v11:X>-74.150620</v11:X>
<v11:Y>41.057343</v11:Y>
</v11:Pos>
</v11:Point>
</v1:StartPoints>
<v1:EndPoints srsName="epsg:4326">
<v11:Point srsName="epsg:4326">
<v11:Pos>
<v11:X>-74.946153</v11:X>
<v11:Y>42.010112</v11:Y>
</v11:Pos>
</v11:Point>
</v1:EndPoints>
<v1:DistanceUnit>km</v1:DistanceUnit>
<v1:TimeUnit>Second</v1:TimeUnit>
<v1:ReturnOptimalRoutesOnly>true</v1:ReturnOptimalRoutesOnly>
<v1:OptimizeBy>time</v1:OptimizeBy>
<v1:MajorRoads>true</v1:MajorRoads>
<v1:ReturnDistance>true</v1:ReturnDistance>
<v1:ReturnTime>true</v1:ReturnTime>
<v1:DestinationSrs>epsg:4326</v1:DestinationSrs>
<v1:HistoricTrafficTimeBucket>none</v1:HistoricTrafficTimeBucket>
<v1:RoadTypePreferences>
<v12:RoadTypesPrefEntry xmlns:v12="http://www.mapinfo.com/routing/service/common/v1">
<v12:RoadTypes>limited access dense urban</v12:RoadTypes>
<v12:RoadTypesPref>None</v12:RoadTypesPref>
</v12:RoadTypesPrefEntry>
</v1:RoadTypePreferences>
</v1:RouteCostMatrixRequest>
</soapenv:Body>
</soapenv:Envelope>
Response for a cost matrix with a single start and end point.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<RouteCostMatrixResponse xmlns="http://www.mapinfo.com/routing/service/v1" xmlns:ns2="http://www.mapinfo.com/midev/service/geometries/v1" xmlns:ns3="http://www.mapinfo.com/routing/service/common/v1" xmlns:ns4="http://www.mapinfo.com/midev/service/common/v1" xmlns:ns5="http://www.mapinfo.com/midev/service/units/v1">
<Matrix>
<Time uom="Second">5704.0</Time>
<Distance uom="km">164.479</Distance>
<StartPoint srsName="epsg:4326">
<ns2:Pos>
<ns2:X>-74.15062</ns2:X>
<ns2:Y>41.057343</ns2:Y>
</ns2:Pos>
</StartPoint>
<EndPoint srsName="epsg:4326">
<ns2:Pos>
<ns2:X>-74.946153</ns2:X>
<ns2:Y>42.010112</ns2:Y>
</ns2:Pos>
</EndPoint>
</Matrix>
</RouteCostMatrixResponse>
</soap:Body>
</soap:Envelope>
Multiple Start and End Point Example
Request for a cost matrix with two start and end point.
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v1="http://www.mapinfo.com/routing/service/v1" xmlns:v11="http://www.mapinfo.com/midev/service/geometries/v1">
<soapenv:Header />
<soapenv:Body>
<v1:RouteCostMatrixRequest id="?" locale="?">
<v1:DatasetResourceName>US_NE</v1:DatasetResourceName>
<v1:StartPoints srsName="epsg:4326">
<v11:Point srsName="epsg:4326">
<v11:Pos>
<v11:X>-74.150620</v11:X>
<v11:Y>41.057343</v11:Y>
</v11:Pos>
</v11:Point>
<v11:Point srsName="epsg:4326">
<v11:Pos>
<v11:X>-74.250620</v11:X>
<v11:Y>41.357343</v11:Y>
</v11:Pos>
</v11:Point>
</v1:StartPoints>
<v1:EndPoints srsName="epsg:4326">
<v11:Point srsName="epsg:4326">
<v11:Pos>
<v11:X>-74.946153</v11:X>
<v11:Y>42.010112</v11:Y>
</v11:Pos>
</v11:Point>
<v11:Point srsName="epsg:4326">
<v11:Pos>
<v11:X>-74.946153</v11:X>
<v11:Y>42.010112</v11:Y>
</v11:Pos>
</v11:Point>
</v1:EndPoints>
<v1:DistanceUnit>km</v1:DistanceUnit>
<v1:TimeUnit>Second</v1:TimeUnit>
<v1:ReturnOptimalRoutesOnly>true</v1:ReturnOptimalRoutesOnly>
<v1:OptimizeBy>time</v1:OptimizeBy>
<v1:MajorRoads>true</v1:MajorRoads>
<v1:ReturnDistance>true</v1:ReturnDistance>
<v1:ReturnTime>true</v1:ReturnTime>
<v1:DestinationSrs>epsg:4326</v1:DestinationSrs>
<v1:HistoricTrafficTimeBucket>none</v1:HistoricTrafficTimeBucket>
<v1:RoadTypePreferences>
<v11:RoadTypesPrefEntry>
<v11:RoadTypes>limited access dense urban</v11:RoadTypes>
<v11:RoadTypesPref>None</v11:RoadTypesPref>
</v11:RoadTypesPrefEntry>
</v1:RoadTypePreferences>
</v1:RouteCostMatrixRequest>
</soapenv:Body>
</soapenv:Envelope>
Response for a Travel boundary with multiple costs.
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<RouteCostMatrixResponse xmlns="http://www.mapinfo.com/routing/service/v1"
xmlns:ns2="http://www.mapinfo.com/midev/service/geometries/v1"
xmlns:ns3="http://www.mapinfo.com/routing/service/common/v1"
xmlns:ns4="http://www.mapinfo.com/midev/service/common/v1" xmlns:ns5="http://www.mapinfo.com/midev/service/units/v1">
<Matrix>
<Time uom="Second">5704.0</Time>
<Distance uom="km">164.479</Distance>
<StartPoint srsName="epsg:4326">
<ns2:Pos>
<ns2:X>-74.15062</ns2:X>
<ns2:Y>41.057343</ns2:Y>
</ns2:Pos>
</StartPoint>
<EndPoint srsName="epsg:4326">
<ns2:Pos>
<ns2:X>-74.946153</ns2:X>
<ns2:Y>42.010112</ns2:Y>
</ns2:Pos>
</EndPoint>
</Matrix>
<Matrix>
<Time uom="Second">4087.0</Time>
<Distance uom="km">119.585</Distance>
<StartPoint srsName="epsg:4326">
<ns2:Pos>
<ns2:X>-74.25062</ns2:X>
<ns2:Y>41.357343</ns2:Y>
</ns2:Pos>
</StartPoint>
<EndPoint srsName="epsg:4326">
<ns2:Pos>
<ns2:X>-74.946153</ns2:X>
<ns2:Y>42.010112</ns2:Y>
</ns2:Pos>
</EndPoint>
</Matrix>
</RouteCostMatrixResponse>
</soap:Body>
</soap:Envelope>