gpt4 book ai didi

c# - 如何将多个航路点发送到虚拟地球路由 Web 服务

转载 作者:太空宇宙 更新时间:2023-11-03 14:36:10 24 4
gpt4 key购买 nike

我正在尝试使用虚拟地球网络服务:

http://staging.dev.virtualearth.net/webservices/v1/routeservice/routeservice.svc?wsdl

返回停在多个点的车辆的总行程距离。

我的代码适用于具有 4 个航路点的旅程,但除此之外我会收到以下错误:

The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element.

粗略的代码是:(C#控制台应用程序)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using System.Text;
using System.Configuration;
using System.Threading;
using System.Text.RegularExpressions;
using altRouteFinder.VEStagingToken;
using altRouteFinder.VERoutingService;

namespace altRouteFinder
{
class Program
{
static void Main(string[] args)
{
waypointString = "53.450356,-2.873335;53.399184,-2.980577;53.440535,-2.864101;53.449368,-2.885361;53.454417,-2.930646;53.450356,-2.873335";

string[] points = waypointString.Split(';');
Waypoint[] waypoints = new Waypoint[points.Length];
double dayDistance = 0;
int pointIndex = -1;
foreach (string point in points)
{
pointIndex++;
waypoints[pointIndex] = new Waypoint();
string[] digits = point.Split(',');
waypoints[pointIndex].Location = new VERoutingService.Location();
waypoints[pointIndex].Location.Latitude = double.Parse(digits[0].Trim());
waypoints[pointIndex].Location.Longitude = double.Parse(digits[1].Trim());

if (pointIndex == 0)
waypoints[pointIndex].Description = "Start";
else if (pointIndex == points.Length)
waypoints[pointIndex].Description = "End";
else
waypoints[pointIndex].Description = string.Format("Stop #{0}", pointIndex);
}

routeRequest.Waypoints = waypoints;

RouteOptions myRouteOptions = new RouteOptions();
//Set travel mode - Driving or Walking
myRouteOptions.Mode = TravelMode.Driving;
//Set the optimization type - MinimizeDistance or MinimizeTime
myRouteOptions.Optimization = RouteOptimization.MinimizeTime;
//Set the use of traffic conditions - TrafficBasedRouteAndTime, TrafficBasedTime, or None
myRouteOptions.TrafficUsage = TrafficUsage.TrafficBasedTime;
//Pass the Route Options to the Route Object
routeRequest.Options = myRouteOptions;

// Make the calculate route request
RouteServiceClient routeService = new RouteServiceClient();

RouteResponse routeResponse = routeService.CalculateRoute(routeRequest);

// Iterate through each itinerary item to get the route directions
StringBuilder directions = new StringBuilder("");

if (routeResponse.Result.Legs.Length > 0)
{
int instructionCount = 0;
int legCount = 0;

foreach (RouteLeg leg in routeResponse.Result.Legs)
{
legCount++;
directions.Append(string.Format("Leg #{0}\n", legCount));

foreach (ItineraryItem item in leg.Itinerary)
{
instructionCount++;
directions.Append(string.Format("{0}. {1} {2}\n",
instructionCount, item.Summary.Distance, item.Text));
dayDistance += item.Summary.Distance;
}
}
//Remove all Bing Maps tags around keywords.
//If you wanted to format the results, you could use the tags
Regex regex = new Regex("<[/a-zA-Z:]*>",
RegexOptions.IgnoreCase | RegexOptions.Multiline);
results = regex.Replace(directions.ToString(), string.Empty);
}
else
results = "No Route found";

Console.WriteLine(results);
Console.WriteLine(dayDistance);
}

}

我不知道在哪里设置 MaxReceivedMessageSize 而且我读到它只适用于 Vista?!

帮助任何人?

最佳答案

我在这里找到了解决方案: link text

maxReceivedMessgeSize 在应用程序的 .config 文件中,即 web.config 或 app.config 等。

关于c# - 如何将多个航路点发送到虚拟地球路由 Web 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/956972/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com