public static Dictionary <string, List <GeoPoint> > FetchGraphData()
        {
            Dictionary <string, List <GeoPoint> > graphData = new Dictionary <string, List <GeoPoint> >();
            List <GeoPoint> allPoints  = new List <GeoPoint>();
            List <GeoPoint> placemarks = new List <GeoPoint>();
            List <GeoPoint> paths      = new List <GeoPoint>();
            XDocument       doc;

            GeoPoint tempPoint;

            try
            {
                System.IO.Stream src = Application.GetResourceStream(new Uri("MapData/GraphMap.osm", UriKind.Relative)).Stream;
                string           data;
                using (StreamReader sr = new StreamReader(src))
                {
                    doc = XDocument.Parse(sr.ReadToEnd());
                    IEnumerable <XElement> nodes = doc.Descendants("node");
                    foreach (XElement node in nodes)
                    {
                        tempPoint = new GeoPoint
                        {
                            Position = new GeoCoordinate(double.Parse(node.Attribute("lat").Value), double.Parse(node.Attribute("lon").Value)),
                            ID       = int.Parse(node.Attribute("id").Value)
                        };

                        if (node.Element("tag") != null)
                        {
                            tempPoint.Name = node.Element("tag").Attribute("v").Value;
                            placemarks.Add(tempPoint);
                        }
                        allPoints.Add(tempPoint);
                    }

                    graphData.Add("AllPoints", allPoints);
                    graphData.Add("Placemarks", placemarks);

                    GeoPath tempPath;
                    IEnumerable <XElement> ways = doc.Descendants("way");
                    foreach (XElement way in ways)
                    {
                        tempPath = new GeoPath {
                            Path = new List <GeoPoint>()
                        };
                        foreach (XElement waypoint in way.Descendants("nd"))
                        {
                            tempPath.Path.Add(new GeoPoint {
                                ID = int.Parse(waypoint.Attribute("ref").Value)
                            });
                        }

                        paths.Add(tempPath);
                    }

                    graphData.Add("Paths", paths);
                }
                return(graphData);
            }
            catch (Exception exp) { return(null); }
        }
示例#2
0
 public void SetFlightInfo(Flight flight, GetSchedule_Result scheduleResult, GeoPath from, GeoPath to)
 {
     Flight         = flight;
     From           = from;
     ScheduleResult = scheduleResult;
     To             = to;
     flightInfo1.SetFlight(flight, scheduleResult, from, to);
     seatClassBindingSource.DataSource = _controller.GetSeatClasses(scheduleResult.PlaneTypeName);
 }
示例#3
0
 public void SetFlight(Flight flight, GetSchedule_Result scheduleResult, GeoPath from, GeoPath to)
 {
     txBxFlightName.Text    = flight.FlightName;
     txBxCompanyName.Text   = scheduleResult.CompanyName;
     txBxDepartureDate.Text = flight.FlightDate.ToShortDateString() + @" " + scheduleResult.DepartureTime;
     txBxArrivalDate.Text   = scheduleResult.ArrivalDate.Date.ToShortDateString() + @" " + scheduleResult.ArrivalDate.TimeOfDay;
     txBxFrom.Text          = from.ToString();
     txBxTo.Text            = to.ToString();
     txBxPlaneType.Text     = scheduleResult.PlaneTypeName;
 }
示例#4
0
        private static GeoPolyline unprojectPolyline(Polyline polyline, GnomonicProjection projection)
        {
            GeoPolyline geoPolyline = new GeoPolyline();

            foreach (LinePath path in polyline.Paths)
            {
                GeoPath geoPath = new GeoPath();
                foreach (ICoordinate p in path.Vertices)
                {
                    geoPath.Vertices.Add(unprojectPoint(new PointD(p), projection));
                }

                geoPolyline.Paths.Add(geoPath);
            }

            return(geoPolyline);
        }
        public List <GetSchedule_Result> GetSchedule(GeoPath from, GeoPath to, DateTime dateFrom, DateTime dateTo)
        {
            if (from == null)
            {
                throw new ArgumentNullException(nameof(from));
            }
            if (to == null)
            {
                throw new ArgumentNullException(nameof(to));
            }
            if (dateFrom == null)
            {
                throw new ArgumentNullException(nameof(dateFrom));
            }
            if (dateTo == null)
            {
                throw new ArgumentNullException(nameof(dateTo));
            }
            try
            {
                _provider.AviaSalesConnection.Airports.Load();

                var airportFromId =
                    _provider
                    .AviaSalesConnection
                    .Airports
                    .Local.Where(airport => airport.AirportName == from.Airport &&
                                 airport.City.CityName == from.City).Select(i => i.Airport_ID)
                    .FirstOrDefault();

                var airportToId = _provider
                                  .AviaSalesConnection
                                  .Airports
                                  .Local.Where(airport => airport.AirportName == to.Airport &&
                                               airport.City.CityName == to.City).Select(i => i.Airport_ID)
                                  .FirstOrDefault();

                return(_provider.AviaSalesConnection.GetSchedule(airportFromId, airportToId, dateFrom, dateTo).ToList());
            }
            catch (Exception ex)
            {
                _logger.Debug(ex.InnerException ?? ex);
                throw ex.InnerException ?? ex;
            }
        }
        private static GeoPolyline unprojectPolyline(Polyline polyline, GnomonicProjection projection)
        {
            GeoPolyline geoPolyline = new GeoPolyline();
            foreach (LinePath path in polyline.Paths)
            {
                GeoPath geoPath = new GeoPath();
                foreach (ICoordinate p in path.Vertices)
                    geoPath.Vertices.Add(unprojectPoint(new PointD(p), projection));

                geoPolyline.Paths.Add(geoPath);
            }

            return geoPolyline;
        }