private void DrawLifts() { var lifts = _wayRepository.GetLifts(); foreach (var lift in lifts.Where(p => p.Type != "downhill")) { if (DisplayOptions.ShowLiftNames) { var firstNode = lift.Nodes.First(); MapItems.Pushpins.Add(new PointItem { Location = firstNode.ToLocation(), Name = lift.Name }); } var locationPath = ""; foreach (var node in lift.Nodes) { locationPath += $"{node.Latitude.ToString(CultureInfo.InvariantCulture)},{node.Longitude.ToString(CultureInfo.InvariantCulture)} "; } MapItems.Lifts.Add(new Polyline { Locations = LocationCollection.Parse(locationPath) }); } }
private void DrawSlopes() { MapItems.Slopes = new ObservableCollection <Polyline>(); var pistes = _wayRepository.GetSlopes(); foreach (var slope in pistes) { var locationPath = ""; foreach (var node in slope.Nodes) { locationPath += $"{node.Latitude.ToString(CultureInfo.InvariantCulture)},{node.Longitude.ToString(CultureInfo.InvariantCulture)} "; } MapItems.Slopes.Add(new Polyline { Locations = LocationCollection.Parse(locationPath), Color = slope.Difficulty == "easy" ? Brushes.Blue : slope.Difficulty == "advanced" ? Brushes.Black : Brushes.Red }); } }
private void ShowSelectedLap() { if (SelectedLap == null) { return; } MapItems.SeriesCollection = new SeriesCollection(); MapItems.SelectedLapPolyLine = new ObservableCollection <Polyline>(); MapItems.SelectedLiftPolyLine = new ObservableCollection <Polyline>(); var lineSeries = new LineSeries(); var chartValues = new ChartValues <double>(); var locationPath = ""; foreach (var trackingPoint in SelectedLap.TrackingPoints.Take(SelectedLap.TrackingPoints.Count - 4)) { chartValues.Add(trackingPoint.Altitude); locationPath += $"{trackingPoint.Position.Latitude.ToString(CultureInfo.InvariantCulture)},{trackingPoint.Position.Longitude.ToString(CultureInfo.InvariantCulture)} "; } lineSeries.Values = chartValues; MapItems.SeriesCollection.Add(lineSeries); RaisePropertyChanged(nameof(SeriesCollection)); MapItems.SelectedLapPolyLine.Add(new Polyline { Locations = LocationCollection.Parse(locationPath), Color = Brushes.Chartreuse }); }
public static async Task <List <SectorPolyline> > GetSectorList() { return(await Task <List <SectorPolyline> > .Factory.StartNew(() => { return new List <SectorPolyline> { new SectorPolyline { Locations = LocationCollection.Parse("48.46454,35.04720 48.46454,35.04820 48.46554,35.04820 48.46554,35.04720 48.46454,35.04720") } }; })); }
public static List <CapMessage> Request(LocationType locationType, string code) { try { List <CapMessage> results = new List <CapMessage>(); string url; if (locationType == LocationType.State || locationType == LocationType.Country) { url = string.Format(BASE_URL, code, "0"); } else { url = string.Format(BASE_URL, "wwaatmget", code + "&y=0"); } XDocument doc = XDocument.Load(url); if (doc.Root.Elements().Where(i => i.Name.LocalName == "entry").Elements().Where(i => i.Name.LocalName == "areaDesc").Count() > 0) { results = (from ele in doc.Root.Elements().Where(i => i.Name.LocalName == "entry") select new CapMessage { AlertLink = new Uri(ele.Elements().First(i => i.Name.LocalName == "link").Attribute("href").Value), Areas = ele.Elements().First(i => i.Name.LocalName == "areaDesc").Value.Split(';'), AuthorName = ele.Elements().First(i => i.Name.LocalName == "author").Elements().First(i => i.Name.LocalName == "name").Value, Category = ele.Elements().First(i => i.Name.LocalName == "category").Value, Certainty = ele.Elements().First(i => i.Name.LocalName == "certainty").Value, EffectiveTimestamp = GetDateTime(ele.Elements().First(i => i.Name.LocalName == "effective").Value), Event = ele.Elements().First(i => i.Name.LocalName == "event").Value, ExpiresTimestamp = GetDateTime(ele.Elements().First(i => i.Name.LocalName == "expires").Value), Generator = doc.Root.Elements().First(i => i.Name.LocalName == "generator").Value, Geocodes = GetValueNameDictionary(ele.Elements().First(i => i.Name.LocalName == "geocode").Descendants()), Id = ele.Elements().First(i => i.Name.LocalName == "id").Value, Locations = LocationCollection.Parse(ele.Elements().First(i => i.Name.LocalName == "polygon").Value), MsgType = ele.Elements().First(i => i.Name.LocalName == "msgType").Value, Parameters = GetValueNameDictionary(ele.Elements().First(i => i.Name.LocalName == "parameter").Descendants()), PublishedTimestamp = GetDateTime(ele.Elements().First(i => i.Name.LocalName == "published").Value), Severity = ele.Elements().First(i => i.Name.LocalName == "severity").Value, Summary = ele.Elements().First(i => i.Name.LocalName == "summary").Value, Title = ele.Elements().First(i => i.Name.LocalName == "title").Value, UpdatedTimestamp = GetDateTime(ele.Elements().First(i => i.Name.LocalName == "updated").Value), Urgency = ele.Elements().First(i => i.Name.LocalName == "urgency").Value }).ToList(); } return(results); } catch { return(null); } }
private void ShowSelectedLift() { if (SelectedLift == null) { return; } MapItems.SelectedLiftPolyLine = new ObservableCollection <Polyline>(); var locationPath = ""; foreach (var node in SelectedLift.Nodes) { locationPath += $"{node.Latitude.ToString(CultureInfo.InvariantCulture)},{node.Longitude.ToString(CultureInfo.InvariantCulture)} "; } MapItems.SelectedLiftPolyLine.Add(new Polyline { Locations = LocationCollection.Parse(locationPath), Color = Brushes.Yellow }); }
private void ShowHeartRateLine(Lap lap) { if (!DisplayOptions.ShowHeartRates) { return; } for (var i = 1; i < lap.TrackingPoints.Count; i++) { var currentPoint = lap.TrackingPoints[i]; var predecessor = lap.TrackingPoints[i - 1]; if (predecessor.Altitude < currentPoint.Altitude) { continue; } if (currentPoint.Position == null || predecessor.Position == null) { continue; } var heartRate = currentPoint.HeartRate - 50; var color = ColorHelper.NumberToColor(heartRate); var locationPath = $"{predecessor.Position.Latitude.ToString(CultureInfo.InvariantCulture)},{predecessor.Position.Longitude.ToString(CultureInfo.InvariantCulture)} "; locationPath += $"{currentPoint.Position.Latitude.ToString(CultureInfo.InvariantCulture)},{currentPoint.Position.Longitude.ToString(CultureInfo.InvariantCulture)}"; MapItems.SpeedLine.Add(new Polyline { Locations = LocationCollection.Parse(locationPath), Color = color }); } }
public ViewModel() { MapCenter = new Location(53.5, 8.2); Points = new ObservableCollection<Point>(); Points.Add( new Point { Name = "Steinbake Leitdamm", Location = new Location(53.51217, 8.16603) }); Points.Add( new Point { Name = "Buhne 2", Location = new Location(53.50926, 8.15815) }); Points.Add( new Point { Name = "Buhne 4", Location = new Location(53.50468, 8.15343) }); Points.Add( new Point { Name = "Buhne 6", Location = new Location(53.50092, 8.15267) }); Points.Add( new Point { Name = "Buhne 8", Location = new Location(53.49871, 8.15321) }); Points.Add( new Point { Name = "Buhne 10", Location = new Location(53.49350, 8.15563) }); Points.Add( new Point { Name = "Moving", Location = new Location(53.5, 8.25) }); Pushpins = new ObservableCollection<Point>(); Pushpins.Add( new Point { Name = "WHV - Eckwarderhörne", Location = new Location(53.5495, 8.1877) }); Pushpins.Add( new Point { Name = "JadeWeserPort", Location = new Location(53.5914, 8.14) }); Pushpins.Add( new Point { Name = "Kurhaus Dangast", Location = new Location(53.447, 8.1114) }); Pushpins.Add( new Point { Name = "Eckwarderhörne", Location = new Location(53.5207, 8.2323) }); //for (double lon = -720; lon <= 720; lon += 15) //{ // var lat = lon / 10; // Pushpins.Add( // new VmPoint // { // Name = string.Format("{0:00.0}°, {1:000}°", lat, lon), // Location = new Location(lat, lon) // }); //} Polylines = new ObservableCollection<Polyline>(); Polylines.Add( new Polyline { Locations = LocationCollection.Parse("53.5140,8.1451 53.5123,8.1506 53.5156,8.1623 53.5276,8.1757 53.5491,8.1852 53.5495,8.1877 53.5426,8.1993 53.5184,8.2219 53.5182,8.2386 53.5195,8.2387") }); Polylines.Add( new Polyline { Locations = LocationCollection.Parse("53.5978,8.1212 53.6018,8.1494 53.5859,8.1554 53.5852,8.1531 53.5841,8.1539 53.5802,8.1392 53.5826,8.1309 53.5867,8.1317 53.5978,8.1212") }); var timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.1) }; timer.Tick += (s, e) => { var p = Points.Last(); p.Location = new Location(p.Location.Latitude + 0.001, p.Location.Longitude + 0.002); if (p.Location.Latitude > 54d) { p.Name = "Stopped"; ((DispatcherTimer)s).Stop(); } }; timer.Start(); }
public MapViewModel() { Points.Add(new PointItem { Name = "Steinbake Leitdamm", Location = new Location(53.51217, 8.16603) }); Points.Add(new PointItem { Name = "Buhne 2", Location = new Location(53.50926, 8.15815) }); Points.Add(new PointItem { Name = "Buhne 4", Location = new Location(53.50468, 8.15343) }); Points.Add(new PointItem { Name = "Buhne 6", Location = new Location(53.50092, 8.15267) }); Points.Add(new PointItem { Name = "Buhne 8", Location = new Location(53.49871, 8.15321) }); Points.Add(new PointItem { Name = "Buhne 10", Location = new Location(53.49350, 8.15563) }); Pushpins.Add(new PointItem { Name = "WHV - Eckwarderhörne", Location = new Location(53.5495, 8.1877) }); Pushpins.Add(new PointItem { Name = "JadeWeserPort", Location = new Location(53.5914, 8.14) }); Pushpins.Add(new PointItem { Name = "Kurhaus Dangast", Location = new Location(53.447, 8.1114) }); Pushpins.Add(new PointItem { Name = "Eckwarderhörne", Location = new Location(53.5207, 8.2323) }); Polylines.Add(new Polyline { Locations = LocationCollection.Parse("53.5140,8.1451 53.5123,8.1506 53.5156,8.1623 53.5276,8.1757 53.5491,8.1852 53.5495,8.1877 53.5426,8.1993 53.5184,8.2219 53.5182,8.2386 53.5195,8.2387") }); Polylines.Add(new Polyline { Locations = LocationCollection.Parse("53.5978,8.1212 53.6018,8.1494 53.5859,8.1554 53.5852,8.1531 53.5841,8.1539 53.5802,8.1392 53.5826,8.1309 53.5867,8.1317 53.5978,8.1212") }); }
public void DrawPolygon(string polygon) { DrawPolygon(LocationCollection.Parse(polygon)); }
public static List <CountyZone> GetCountyZoneInformation(string shapeFilePath, string countyFilePath) { List <CountyZone> results = new List <CountyZone>(); //using (Shapefile shapeFile = new Shapefile(shapeFilePath)) { // foreach (Shape shape in shapeFile) { // CountyZone zone = new CountyZone(); // string[] metaData = shape.GetMetadataNames(); // zone.FIPS = shape.GetMetadata("fips"); // //zone.FeArea = (CountyZone.FeAreaEnum)Enum.Parse(typeof(CountyZone.FeAreaEnum), shape.GetMetadata("fe_area") == "" ? "None" : shape.GetMetadata("fe_area")); // zone.CountyName = shape.GetMetadata("countyname"); // zone.CountyWarningArea = shape.GetMetadata("cws"); // zone.Latitude = shape.GetMetadata("lat"); // zone.Longitude = shape.GetMetadata("lon"); // zone.State = shape.GetMetadata("state"); // //zone.TimeZone = (CountyZone.TimeZoneEnum)Enum.Parse(typeof(CountyZone.TimeZoneEnum), shape.GetMetadata("time_zone")); // if (shape.Type == ShapeType.Polygon) { // ShapePolygon polygon = shape as ShapePolygon; // string polyString = ""; // foreach (PointD point in ((ShapePolygon)shape).Parts[0]) { // polyString = polyString + point.Y.ToString() + "," + point.X.ToString() + " "; // } // zone.Locations = LocationCollection.Parse(polyString); // } // results.Add(zone); // } //} StreamReader textReader = new StreamReader(countyFilePath); string[] csv = textReader.ReadToEnd().Replace("\r", "").Split('\n'); textReader.Close(); foreach (string line in csv) { if (!string.IsNullOrWhiteSpace(line)) { string[] cols = line.Split('|'); Shapefile shapeFile = new Shapefile(shapeFilePath); Shape shape = shapeFile.Where(i => i.Type == ShapeType.Polygon && i.GetMetadata("state") == cols[0] && i.GetMetadata("countyname") == cols[5]).First(); string polyString = ""; foreach (PointD point in ((ShapePolygon)shape).Parts[0]) { polyString = polyString + point.Y.ToString() + "," + point.X.ToString() + " "; } results.Add(new CountyZone { CountyName = cols[5], CountyWarningArea = cols[2], FeArea = CountyZone.FeAreaEnum.None, FIPS = cols[6], Latitude = cols[9], Locations = LocationCollection.Parse(polyString), Longitude = cols[10], Name = cols[3], State = cols[0], TimeZone = CountyZone.TimeZoneEnum.AtlanticStandard, Zone = cols[1] }); } } return(results); }