public async Task EntireRouteSegmentCalculation() { GpxFileParser gpxFileParse = new GpxFileParser(); CoordinatePointsList = await gpxFileParse.GetGpxCoordinateData(); int i = 0; int j = 1; double totalDistance = 0; Task routeSegmentTask = new Task(() => { while (j < CoordinatePointsList.Count()) { Waypoint p1 = new Waypoint(); Waypoint p2 = new Waypoint(); RouteSegmentVector routevector = new RouteSegmentVector(); p1 = CoordinatePointsList[i]; p2 = CoordinatePointsList[j]; routevector = SegmentCalculations(p1, p2); totalDistance += routevector.Gcd; routevector.AccumulativeGcd = totalDistance; routevector.Elevation = routevector.Point1.Elevation; routevector.Index = i; RouteSegmentVectors.Add(routevector); ++i; ++j; } }); routeSegmentTask.GetAwaiter(); }
private static PoiData GetPoiData(string dir, PoiCategory category, PoiCountry country) { try { var filename = $"{dir}\\{GetFileName(category)}"; var xml = File.ReadAllText(filename); var listOfPoi = GpxFileParser.Parse(xml, category, country, Guid.NewGuid()); var count = listOfPoi.Count; //DateTime creation = File.GetCreationTime(filename); DateTime modificationDate = File.GetLastWriteTime(filename); var pd = new PoiData() { Category = category, DateCreated = modificationDate, PointCount = count, Url = $"PoiData/{country}/{GetFileName(category)}", Description = "", Id = GetGuid(country, category) }; return(pd); } catch (Exception ex) { Console.WriteLine(ex.Message); return(null); } }
public void ParseGpxFile() { var gpxDocument = XDocument.Load(gpxFile); var parser = new GpxFileParser(); var parsed = parser.Parse(gpxDocument).Single(); var expected = new CacheData("GC7WP8Y", new LatLng(43.550767, 16.51405), -23.896, 905.656); parsed.Should().BeEquivalentTo(expected); }
protected override PoiList RunInBackground(params string[] @url) { try { OnStageChange?.Invoke(Resource.String.Download_Progress_Downloading, 1); var file = GpxFileProvider.GetFile(GpxFileProvider.GetUrl(url[0])); OnProgressChange?.Invoke(1); var listOfPoi = GpxFileParser.Parse(file, _source.Category, _source.Country, _source.Id, x => OnStageChange?.Invoke(Resource.String.Download_Progress_Processing, x), x => OnProgressChange?.Invoke(x)); return(listOfPoi); } catch (Exception ex) { OnError?.Invoke(ExceptionHelper.Exception2ErrorMessage(ex)); return(new PoiList()); } }