コード例 #1
0
        public async Task Line_GpxLineFromHorseshoeMesaFileWithMeasurements()
        {
            var testFile = new FileInfo(Path.Combine(Directory.GetCurrentDirectory(), "TestMedia",
                                                     "GrandCanyonHorseShoeMesaEastSideLoop.gpx"));

            Assert.True(testFile.Exists, "Test File Found");

            var tracks = await SpatialHelpers.TracksFromGpxFile(testFile, DebugTrackers.DebugProgressTracker());

            Assert.AreEqual(1, tracks.Count, "Should find 1 track");

            var coordinateList = tracks.First().track;

            var metricStats   = SpatialHelpers.LineStatsInMetricFromCoordinateList(coordinateList);
            var imperialStats = SpatialHelpers.LineStatsInImperialFromMetricStats(metricStats);

            Assert.IsTrue(imperialStats.Length.IsApproximatelyEqualTo(13, .3),
                          $"ExpertGPS Length 13.03, Measured {imperialStats.Length}");
            Assert.IsTrue(imperialStats.ElevationClimb.IsApproximatelyEqualTo(9000, 100),
                          $"ExpertGPS Climb 9023, Measured {imperialStats.ElevationClimb}");
            Assert.IsTrue(imperialStats.ElevationDescent.IsApproximatelyEqualTo(8932, 100),
                          $"ExpertGPS Descent 8932, Measured {imperialStats.ElevationDescent}");
            Assert.IsTrue(imperialStats.MinimumElevation.IsApproximatelyEqualTo(3591, 30),
                          $"ExpertGPS Min Elevation 13.03, Measured {imperialStats.MinimumElevation}");
            Assert.IsTrue(imperialStats.MaximumElevation.IsApproximatelyEqualTo(7384, 30),
                          $"ExpertGPS Max Elevation 13.03, Measured {imperialStats.MaximumElevation}");
        }
コード例 #2
0
        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);
        }