Does the routing extention support generating Time and Distance matrix for a set of points?
Example: Pass in 150 Points and the returned matrix would be 22500 records and would give me the time and distance from and to every point passed in.
Does the routing extention support generating Time and Distance matrix for a set of points?
Example: Pass in 150 Points and the returned matrix would be 22500 records and would give me the time and distance from and to every point passed in.
Brian,
Welcome to MapSuite discussion forum.
Sure! The routing extension can generates the Time and distance matrix for a set of points, but there is no built-in function and some custom codes are needed.
Here is a simple sample about how to generate RoutingResult matrix which contains the distance information:
// Init Route Matrix
RoutingResult[,] routeMatrix = new RoutingResult[points.Count, points.Count];
for (int i = 0; i < points.Count; i++)
{
for (int j = i + 1; j < points.Count; j++)
{
RoutingResult result = GetRoute(points[i], points[j]);
if (result.RouteSegments.Count <= 0)
{
result.Distance = double.MaxValue;
}
routeMatrix[i, j] = result;
// Reverse the result
RoutingResult reverseResult = new RoutingResult();
for (int k = result.Features.Count - 1; k >= 0; k--)
{
reverseResult.Features.Add(result.Features[k]);
reverseResult.Route.Lines.Add(result.Route.Lines[k]);
reverseResult.RouteSegments.Add(result.RouteSegments[k]);
}
reverseResult.Distance = result.Distance;
routeMatrix[j, i] = reverseResult;
}
}
Thanks,
Johnny