Esempio n. 1
0
        public static TravelData ParseXMLToRoad(XmlDocument data)
        {
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(data.NameTable);

            nsmgr.AddNamespace("rest", "http://schemas.microsoft.com/search/local/ws/rest/v1");
            XmlNodeList roadElements = data.SelectNodes("//rest:Line", nsmgr);

            if (roadElements.Count == 0)
            {
                MessageBox.Show("No road found :(", "Highway to hell", MessageBoxButton.OK, MessageBoxImage.Error);
                return(null);
            }
            else
            {
                LocationCollection locations = new LocationCollection();
                XmlNodeList        points    = roadElements[0].SelectNodes(".//rest:Point", nsmgr);
                foreach (XmlNode point in points)
                {
                    string latitude  = point.SelectSingleNode(".//rest:Latitude", nsmgr).InnerText;
                    string longitude = point.SelectSingleNode(".//rest:Longitude", nsmgr).InnerText;

                    locations.Add(XML.SetGeographicInfo(latitude, longitude));
                }
                TravelData travelData = new TravelData();
                travelData.StringDistance   = data.SelectSingleNode(".//rest:TravelDistance", nsmgr).InnerText;
                travelData.StringTravelTime = data.SelectSingleNode(".//rest:TravelDuration", nsmgr).InnerText;
                travelData.Locations        = locations;
                return(travelData);
            }
        }
Esempio n. 2
0
        public static TravelData ParseXMLToRoad(XmlDocument data)
        {
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(data.NameTable);
            nsmgr.AddNamespace("rest", "http://schemas.microsoft.com/search/local/ws/rest/v1");
            XmlNodeList roadElements = data.SelectNodes("//rest:Line", nsmgr);
            if (roadElements.Count == 0)
            {
                MessageBox.Show("No road found :(", "Highway to hell", MessageBoxButton.OK, MessageBoxImage.Error);
                return null;
            }
            else
            {
                LocationCollection locations = new LocationCollection();
                XmlNodeList points = roadElements[0].SelectNodes(".//rest:Point", nsmgr);
                foreach (XmlNode point in points)
                {
                    string latitude = point.SelectSingleNode(".//rest:Latitude", nsmgr).InnerText;
                    string longitude = point.SelectSingleNode(".//rest:Longitude", nsmgr).InnerText;

                    locations.Add(XML.SetGeographicInfo(latitude, longitude));
                }
                TravelData travelData = new TravelData();
                travelData.StringDistance = data.SelectSingleNode(".//rest:TravelDistance", nsmgr).InnerText;
                travelData.StringTravelTime = data.SelectSingleNode(".//rest:TravelDuration", nsmgr).InnerText;
                travelData.Locations = locations;
                return travelData;
            }
        }
Esempio n. 3
0
        public void ProcessRequest()
        {
            List<ViaLocation> address = WPF.RandomLocationsFromOrigin(currentLocation, WPF.Rng.Next(5, 200));
            destination = XML.ParseXMLToRoad(Http.Request(address));
            Console.WriteLine(destination.StringTravelTime);

            bool drive = CalculateEarnings();

            //MessageBox.Show("Driver " + id + " earned " + earning, drive.ToString(), MessageBoxButton.OK, MessageBoxImage.Information);
        }
Esempio n. 4
0
        public void ProcessRequest()
        {
            List <ViaLocation> address = WPF.RandomLocationsFromOrigin(currentLocation, WPF.Rng.Next(5, 200));

            destination = XML.ParseXMLToRoad(Http.Request(address));
            Console.WriteLine(destination.StringTravelTime);

            bool drive = CalculateEarnings();

            //MessageBox.Show("Driver " + id + " earned " + earning, drive.ToString(), MessageBoxButton.OK, MessageBoxImage.Information);
        }
Esempio n. 5
0
        public static MapPolyline DrawRoad(TravelData data)
        {
            MapPolyline polyline = new MapPolyline();
            Color color = new Color();
            color.A = 255;
            color.R = (byte)rng.Next(1, 254);
            color.G = (byte)rng.Next(1, 254);
            color.B = (byte)rng.Next(1, 254);

            polyline.Stroke = new System.Windows.Media.SolidColorBrush(color);
            polyline.StrokeThickness = 5;
            polyline.Opacity = 0.7;
            polyline.Locations = data.Locations;
            return polyline;
        }
Esempio n. 6
0
        public static MapPolyline DrawRoad(TravelData data)
        {
            MapPolyline polyline = new MapPolyline();
            Color       color    = new Color();

            color.A = 255;
            color.R = (byte)rng.Next(1, 254);
            color.G = (byte)rng.Next(1, 254);
            color.B = (byte)rng.Next(1, 254);

            polyline.Stroke          = new System.Windows.Media.SolidColorBrush(color);
            polyline.StrokeThickness = 5;
            polyline.Opacity         = 0.7;
            polyline.Locations       = data.Locations;
            return(polyline);
        }