# Time and Distance Matrix

**URL:** <https://community.thinkgeo.com/t/time-and-distance-matrix/7531>\
**Category:** Routing\
**Created:** [June 8, 2010, 2:20pm UTC](https://community.thinkgeo.com/t/time-and-distance-matrix/7531 "2010-06-08T14:20:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian3](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/b/9e8a1a/32.png) [@Brian3](https://community.thinkgeo.com/u/Brian3)\
**Post date:** [June 8, 2010, 2:20pm UTC](https://community.thinkgeo.com/t/time-and-distance-matrix/7531/1 "2010-06-08T14:20:47Z")

</div>

Does&nbsp;the&nbsp;routing&nbsp;extention&nbsp;support&nbsp;generating&nbsp;Time&nbsp;and&nbsp;Distance&nbsp;matrix&nbsp;for&nbsp;a&nbsp;set&nbsp;of&nbsp;points?&nbsp;  
  
  
  
Example:&nbsp;&nbsp;Pass&nbsp;in&nbsp;150&nbsp;Points&nbsp;and&nbsp;the&nbsp;returned&nbsp;matrix&nbsp;would&nbsp;be&nbsp;22500&nbsp;records&nbsp;and&nbsp;would&nbsp;give&nbsp;me&nbsp;the&nbsp;time&nbsp;and&nbsp;distance&nbsp;from&nbsp;and&nbsp;to&nbsp;every&nbsp;point&nbsp;passed&nbsp;in.

&nbsp;

&nbsp;

---

<div class="post-metadata">

**Author:** ![Johnny](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/johnny/32/19044_2.png) [@Johnny](https://community.thinkgeo.com/u/Johnny)\
**Post date:** [June 9, 2010, 8:12am UTC](https://community.thinkgeo.com/t/time-and-distance-matrix/7531/2 "2010-06-09T08:12:46Z")

</div>

&nbsp;

Brian,  
&nbsp;  
Welcome&nbsp;to&nbsp;MapSuite&nbsp;discussion&nbsp;forum.  
&nbsp;  
Sure!&nbsp;The&nbsp;routing&nbsp;extension&nbsp;can&nbsp;generates&nbsp;the&nbsp;Time&nbsp;and&nbsp;distance&nbsp;matrix&nbsp;for&nbsp;a&nbsp;set&nbsp;of&nbsp;points,&nbsp;but&nbsp;there&nbsp;is&nbsp;no&nbsp;built-in&nbsp;function&nbsp;and&nbsp;some&nbsp;custom&nbsp;codes&nbsp;are&nbsp;needed.  
&nbsp;  
Here&nbsp;is&nbsp;a&nbsp;simple&nbsp;sample&nbsp;about&nbsp;how&nbsp;to&nbsp;generate&nbsp;RoutingResult&nbsp;matrix&nbsp;which&nbsp;contains&nbsp;the&nbsp;distance&nbsp;information:  
&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  
` // 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;                }            }`  
&nbsp;  
Thanks,  
Johnny&nbsp;  
&nbsp;
