의 배열로 푸시하는 객체 만들기 getLocation이 "POINT (xy)"문자열 값을 반환하는 "NL, VENLO, 5928PN"과 같은 여러 주소로 문자열을 분할하는 것입니다. .foreach 내에서 C#
이것은 작동합니다. 다음으로 각 위치에 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?
}
당신이 목록을 사용하고 완료되면 다음에 ToArray를 호출 할 수 없습니다 이유는 무엇입니까? – mletterle
은 wpdStart가 현재 구현 된 방식대로 범위를 벗어나지 않으십니까? –
@mletterle 감사합니다. 나는 방금 그렇게했습니다. – Perfection