我想要实现的是将字符串拆分为多个地址,例如“NL,VENLO,5928PN”,getLocation 将返回“POINT(xy)”字符串值。
这行得通。接下来我需要为每个位置创建一个 WayPointDesc 对象。并且这些对象中的每一个都必须被推入 WayPointDesc[]。我尝试了各种方法,但到目前为止我找不到可行的选择。我最后的手段是硬编码最大数量的航路点,但我宁愿避免这样的事情。
不幸的是,使用列表不是一种选择......我认为。
这是功能:
/* tour()
* Input: string route
* Output: string[] [0] DISTANCE [1] TIME [2] MAP
* Edited 21/12/12 - Davide Nguyen
*/
public string[] tour(string route)
{
// EXAMPLE INPUT FROM QUERY
route = "NL,HELMOND,5709EM+NL,BREDA,8249EN+NL,VENLO,5928PN";
string[] waypoints = route.Split('+');
// Do something completly incomprehensible
foreach (string point in waypoints)
{
xRoute.WaypointDesc wpdStart = new xRoute.WaypointDesc();
wpdStart.wrappedCoords = new xRoute.Point[] { new xRoute.Point() };
wpdStart.wrappedCoords[0].wkt = getLocation(point);
}
// Put the strange result in here somehow
xRoute.WaypointDesc[] waypointDesc = new xRoute.WaypointDesc[] { wpdStart };
// Calculate the route information
xRoute.Route route = calculateRoute(waypointDesc);
// Generate the map, travel distance and travel time using the route information
string[] result = createMap(route);
// Return the result
return result;
//WEEKEND?
}