本文整理汇总了C#中IRoute.ToArray方法的典型用法代码示例。如果您正苦于以下问题:C# IRoute.ToArray方法的具体用法?C# IRoute.ToArray怎么用?C# IRoute.ToArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRoute
的用法示例。
在下文中一共展示了IRoute.ToArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BuildRoute
/// <summary>
/// Builds a route along all the given point in the order given by the tsp solution.
/// </summary>
/// <param name="vehicle"></param>
/// <param name="resolved"></param>
/// <param name="coordinates"></param>
/// <param name="tspSolution"></param>
/// <param name="isRound"></param>
/// <returns></returns>
public Route BuildRoute(Vehicle vehicle, RouterPoint[] resolved, GeoCoordinate[] coordinates, IRoute tspSolution, bool isRound)
{
// sort resolved and coordinates.
var solution = tspSolution.ToArray();
var size = isRound ? solution.Length + 1 : solution.Length;
var sortedResolved = new RouterPoint[size];
var sortedCoordinates = new GeoCoordinate[size];
for (int idx = 0; idx < solution.Length; idx++)
{
sortedResolved[idx] = resolved[solution[idx]];
sortedCoordinates[idx] = coordinates[solution[idx]];
}
// make round if needed.
if (isRound)
{
sortedResolved[size - 1] = sortedResolved[0];
sortedCoordinates[size - 1] = sortedCoordinates[0];
}
// build the route.
return this.BuildRoute(vehicle, sortedResolved, sortedCoordinates);
}