我有一个从 Bing 地图返回 XML 的代码,我在其中解析行程点。有趣的是,当我在视觉上显示时,我看到 Bing 的行为很奇怪。因此,它有时会在没有十字路口的笔直道路上给我积分。这对我的应用程序来说是个问题,因为我收到的分数比我应该得到的要多。
问题:我想消除标记:ManouverType是 keepStraight 或 continueRoute 的点。
XML 看起来像这样
<ItineraryItem>
<TravelMode>Driving</TravelMode>
<TravelDistance>0.586</TravelDistance>
<TravelDuration>66</TravelDuration>
<ManeuverPoint>
<Latitude>46.086102</Latitude>
<Longitude>19.679518</Longitude>
</ManeuverPoint>
<Instruction maneuverType="EnterThenExitRoundabout">At roundabout, take 1st exit onto Ulica Bajnatska</Instruction>
<CompassDirection>west</CompassDirection>
<Detail>
<ManeuverType>EnterRoundabout</ManeuverType>
<StartPathIndex>2</StartPathIndex>
<EndPathIndex>4</EndPathIndex>
<CompassDegrees>208</CompassDegrees>
<Mode>Driving</Mode>
<PreviousEntityId>0</PreviousEntityId>
<NextEntityId>0</NextEntityId>
<RoadType>Arterial</RoadType>
</Detail>
<Detail>
<ManeuverType>ExitRoundabout</ManeuverType>
<StartPathIndex>4</StartPathIndex>
<EndPathIndex>8</EndPathIndex>
<Name>Ulica Bajnatska</Name>
<CompassDegrees>250</CompassDegrees>
<Mode>Driving</Mode>
<PreviousEntityId>0</PreviousEntityId>
<NextEntityId>0</NextEntityId>
<RoadType>Arterial</RoadType>
</Detail>
...
我的代码看起来像这样
public List<CGeoPoint> GetItin(CGeoPair latlongpair)
{
string RequestText = CreateRequest(latlongpair.GeoPoint1, latlongpair.GeoPoint2);
XmlDocument locationsResponse = MakeRequest(RequestText);
List<CGeoPoint> itin = new List<CGeoPoint>();
XmlNodeList nList = locationsResponse.GetElementsByTagName("ManeuverPoint");
foreach (XmlNode node in nList)
{
decimal d1 = decimal.Parse(node.ChildNodes[0].InnerText);
decimal d2 = decimal.Parse(node.ChildNodes[1].InnerText);
CGeoPoint ll = new CGeoPoint(d1, d2);
itin.Add(ll);
}
return itin;
}
此代码为每个 ItineraryItem 返回了纬度和经度