public async Task Line_SanPedroTwoTrackFileLineToGeoJsonAndBack() { var testFile = new FileInfo(Path.Combine(Directory.GetCurrentDirectory(), "TestMedia", "TwoTrackGpxNearTheSanPedro.gpx")); Assert.True(testFile.Exists, "Test File Found"); var tracks = await SpatialHelpers.TracksFromGpxFile(testFile, DebugTrackers.DebugProgressTracker()); Assert.AreEqual(2, tracks.Count, "Should find 2 tracks"); Assert.True(tracks.All(x => !string.IsNullOrWhiteSpace(x.description)), "Found Tracks with Blank Description?"); var shortTrack = tracks.OrderBy(x => x.track.Count).First().track; var geoJson = await SpatialHelpers.GeoJsonWithLineStringFromCoordinateList(shortTrack, false, DebugTrackers.DebugProgressTracker()); var shortTrackFromGeoJson = SpatialHelpers.CoordinateListFromGeoJsonFeatureCollectionWithLinestring(geoJson); Assert.AreEqual(shortTrack.Count, shortTrackFromGeoJson.Count, "Count of Track Points does not match"); for (var i = 0; i < shortTrack.Count; i++) { Assert.AreEqual(shortTrack[i].X, shortTrackFromGeoJson[i].X, $"Point {i} X Values don't match"); Assert.AreEqual(shortTrack[i].Y, shortTrackFromGeoJson[i].Y, $"Point {i} Y Values don't match"); Assert.AreEqual(shortTrack[i].Z, shortTrackFromGeoJson[i].Z, $"Point {i} Z Values don't match"); } }
public async Task L01_HorseshoeMesaLineContent() { var testFile = new FileInfo(Path.Combine(Directory.GetCurrentDirectory(), "TestMedia", "GrandCanyonHorseShoeMesaEastSideLoop.gpx")); Assert.True(testFile.Exists, "GPX Test File Found"); var lineTest = new LineContent { ContentId = Guid.NewGuid(), BodyContent = "Horseshoe Mesa East Side Loop", BodyContentFormat = ContentFormatDefaults.Content.ToString(), CreatedOn = DateTime.Now, CreatedBy = "GPX Import Test", Folder = "GrandCanyon", Title = "Horseshoe Mesa East Side Loop", Slug = "horseshoe-mesa-east-side-loop", ShowInMainSiteFeed = true, Summary = "Horseshoe Mesa East Side Loop", Tags = "grand-canyon, horse-shoe-mesa", UpdateNotesFormat = ContentFormatDefaults.Content.ToString() }; var track = (await SpatialHelpers.TracksFromGpxFile(testFile, DebugTrackers.DebugProgressTracker())) .First(); var stats = SpatialHelpers.LineStatsInMetricFromCoordinateList(track.track); lineTest.ClimbElevation = stats.ElevationClimb; lineTest.DescentElevation = stats.ElevationDescent; lineTest.MinimumElevation = stats.MinimumElevation; lineTest.MaximumElevation = stats.MaximumElevation; lineTest.LineDistance = stats.Length; lineTest.Line = await SpatialHelpers.GeoJsonWithLineStringFromCoordinateList(track.track, false, DebugTrackers.DebugProgressTracker()); var validationResult = await LineGenerator.Validate(lineTest); Assert.IsFalse(validationResult.HasError); var saveResult = await LineGenerator.SaveAndGenerateHtml(lineTest, null, DebugTrackers.DebugProgressTracker()); Assert.IsFalse(saveResult.generationReturn.HasError); }