コード例 #1
0
ファイル: Race.xaml.cs プロジェクト: ChadMcCallum/rapido
 protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
 {
     StartWatcher();
     var app = ((App)Application.Current);
     currentCourse = app.CurrentCourse;
     mode = app.CurrentMode;
     SetupSplits();
     InitMap();
     timer = new DispatcherTimer();
     timer.Tick += timer_Tick;
     timer.Interval = TimeSpan.FromSeconds(0.1);
 }
コード例 #2
0
ファイル: PathParser.cs プロジェクト: ChadMcCallum/rapido
        public static IEnumerable<Path> Parse(String pathKml)
        {
            var xDoc = XDocument.Parse(pathKml);

            foreach (var placemarkElem in xDoc.Descendants("{http://www.opengis.net/kml/2.2}Placemark"))
            {
                var coordinatesElem = placemarkElem.Descendants("{http://www.opengis.net/kml/2.2}coordinates").First();
                var descriptionElem = placemarkElem.Descendants("{http://www.opengis.net/kml/2.2}description").First();

                var description = descriptionElem.Value;

                var match = Regex.Match(description, @"[\d\.]+");
                var length = Double.Parse(match.Value);

                var coordinatePairs = coordinatesElem.Value.Split(' ');

                var coordinateList = new List<Path.Coordinate>();

                foreach (var coordiate in coordinatePairs)
                {
                    if (String.IsNullOrWhiteSpace(coordiate))
                        continue;
                    coordinateList.Add (new Path.Coordinate { Latitude = Double.Parse(coordiate.Split(',')[1]), Longitude = Double.Parse(coordiate.Split(',')[0]) } );
                }

                var path = new Path
                {
                    Length = length,
                    Key = String.Format("{0},{1}", coordinateList.First().Latitude.ToString(), coordinateList.First().Longitude.ToString()),
                    Description = descriptionElem.Value,
                    Coordinates = coordinateList
                };

                yield return path;
            }
        }