Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 考虑manouvertype从Bing地图解析XML_C#_Xml_Xml Parsing_Bing Maps - Fatal编程技术网

C# 考虑manouvertype从Bing地图解析XML

C# 考虑manouvertype从Bing地图解析XML,c#,xml,xml-parsing,bing-maps,C#,Xml,Xml Parsing,Bing Maps,我有一个从Bing地图中检索XML的代码,在那里我解析ITinerry点。有趣的是,当我在视觉上展示时,我看到Bing的行为异常。因此,它有时会在没有十字路口的直道上给我打分。这是我的应用程序的一个问题,因为我收到的分数超过了我应该得到的分数 问题:我想消除标记:ManouverType为keepStraight或continueRoute的点 XML如下所示 <ItineraryItem> <TravelMode>Driving</TravelMode> &

我有一个从Bing地图中检索XML的代码,在那里我解析ITinerry点。有趣的是,当我在视觉上展示时,我看到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;
    }  

驱动
0.586
66
46.086102
19.679518
在环岛,从第一个出口进入Ulica Bajnatska
西
环形交叉路口
2.
4.
208
驱动
0
0
动脉的
存在
4.
8.
乌里卡·巴伊纳茨卡
250
驱动
0
0
动脉的
...
我的代码如下所示

<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;
    }  
public List GetItin(CGeoPair latlongpair)
{
string RequestText=CreateRequest(latlongpair.GeoPoint1,latlongpair.GeoPoint2);
XmlDocument locationsResponse=MakeRequest(RequestText);
List itin=新列表();
XmlNodeList nList=locationsResponse.GetElementsByTagName(“机动点”);
foreach(nList中的XmlNode节点)
{
decimal d1=decimal.Parse(node.ChildNodes[0].InnerText);
decimal d2=decimal.Parse(node.ChildNodes[1].InnerText);
CGeoPoint ll=新CGeoPoint(d1,d2);
加上(ll);
}
返回itin;
}  

这段代码返回了每个行程项目的纬度和经度。好的,我用以下方法解决了这个问题:

public List<CGeoPoint> GetItin(CGeoPair latlongpair)
    {
        string RequestText = CreateRequest(latlongpair.GeoPoint1, latlongpair.GeoPoint2);

        XmlDocument locationsResponse = MakeRequest(RequestText);
        //Create namespace manager
        XmlNamespaceManager nsmgr = new XmlNamespaceManager(locationsResponse.NameTable);
        nsmgr.AddNamespace("rest", "http://schemas.microsoft.com/search/local/ws/rest/v1");

        //Ovde kupim sve Itinerere čak i početnu i krajnju tačku. to se kasnije izbacuje
        XmlNodeList locationElements = locationsResponse.SelectNodes("//rest:ItineraryItem", nsmgr);

        List<CGeoPoint> itin = new List<CGeoPoint>();
        foreach (XmlNode location in locationElements)
        {
            decimal lat = decimal.Parse(location.SelectSingleNode(".//rest:Latitude", nsmgr).InnerText);
            decimal longit = decimal.Parse(location.SelectSingleNode(".//rest:Longitude", nsmgr).InnerText);
            string mantype = location.SelectSingleNode(".//rest:ManeuverType", nsmgr).InnerText;
            mantype = mantype.ToUpper();

            if (mantype == "KEEPSTRAIGHT" || mantype == "CONTINUEROUTE")
            {
                //Do nothing... jump over
            }
            else
            {
                CGeoPoint ll = new CGeoPoint(lat, longit);
                itin.Add(ll);
            }
        }
        return itin;
    }  
public List GetItin(CGeoPair latlongpair)
{
string RequestText=CreateRequest(latlongpair.GeoPoint1,latlongpair.GeoPoint2);
XmlDocument locationsResponse=MakeRequest(RequestText);
//创建命名空间管理器
XmlNamespaceManager nsmgr=新的XmlNamespaceManager(locationsResponse.NameTable);
nsmgr.AddNamespace(“rest”http://schemas.microsoft.com/search/local/ws/rest/v1");
//在伊兹巴库耶的卡斯尼耶附近的一个村庄
XmlNodeList locationElements=locationsResponse.SelectNodes(//rest:InvestureItem,nsmgr);
List itin=新列表();
foreach(locationElements中的XmlNode位置)
{
decimal lat=decimal.Parse(location.SelectSingleNode(“../rest:Latitude”,nsmgr.InnerText));
decimal longit=decimal.Parse(location.SelectSingleNode(“../rest:Longitude”,nsmgr.InnerText));
string mantype=location.SelectSingleNode(“.//rest:moveType”,nsmgr).InnerText;
mantype=mantype.ToUpper();
if(mantype==“KEEPSTRAIGHT”| | mantype==“CONTINUEROUTE”)
{
//什么也不做……跳过去
}
其他的
{
CGeoPoint ll=新CGeoPoint(纬度、经度);
加上(ll);
}
}
返回itin;
}  

请用语言标记问题(
c#
可能)。