示例#1
0
        internal new GpxImporter PrepareImporterWithBytes(byte[] buffer)
        {
            var readerBase = new GpxImporter();

            readerBase.Init(new StreamWrapper(new MemoryStream(buffer)));
            return(readerBase);
        }
示例#2
0
        internal GpxImporter PrepareGpxImporterWithBytes(byte[] buffer)
        {
            var readerBase = new GpxImporter();

            readerBase.Init(ByteBuffer.FromBuffer(buffer));
            return(readerBase);
        }
示例#3
0
        internal Score LoadLyricsTemplateFile()
        {
            const string path     = "TestFiles/GuitarPro6/LyricsTemplate.gpx";
            var          buffer   = ByteBuffer.FromBuffer(File.ReadAllBytes(path));
            var          importer = new GpxImporter();

            importer.Init(buffer);
            return(importer.ReadScore());
        }
示例#4
0
        public void TestImportGpxSports()
        {
            string path = @"data\data_tiny.gpx";
            IActivitiesImporter importer = new GpxImporter();

            IDictionary <string, string> sports;

            using (FileStream fs = File.OpenRead(path))
            {
                sports = importer.GetSports(fs);
            }
            sports.Should().HaveCountGreaterOrEqualTo(1, "expected data_tiny.gpx to contain at least 1 sport");
        }
示例#5
0
 public AthleteDetailsVM(IDataAccessService DbAccess, FitLogImporter FitLogImporter, GpxImporter GpxImporter)
 {
     _Logger         = NLog.LogManager.GetCurrentClassLogger();
     _DbAccess       = DbAccess;
     _FitLogImporter = FitLogImporter;
     _GpxImporter    = GpxImporter;
     Messenger.Default.Register <NotificationMessage <IList <AthleteEntity> > >(this, message =>
     {
         if (message.Notification == MessengerNotifications.LOADED)
         {
             if (message.Content == null)
             {
                 Athletes = new ObservableCollection <AthleteEntity>();
             }
             else
             {
                 Athletes = new ObservableCollection <AthleteEntity>(message.Content);
             }
         }
     });
     Messenger.Default.Register <NotificationMessage <ImporterTypeEnum> >(this, message =>
     {
         if (message.Notification == MessengerNotifications.IMPORT)
         {
             ImportDialog(message.Content);
         }
     });
     Messenger.Default.Register <NotificationMessage <AthleteEntity> >(this, message =>
     {
         if (message.Notification == MessengerNotifications.NEW)
         {
             var athlete = message.Content;
             Athletes.Add(athlete);
             SelectedAthlete = athlete;
         }
     });
     Messenger.Default.Register <NotificationMessage <ACTION_TYPE> >(this, message =>
     {
         if (message.Notification == MessengerNotifications.ASK_FOR_ACTION && message.Content == ACTION_TYPE.DELETE_SELECTED_ACTIVITIES)
         {
             DispatcherHelper.CheckBeginInvokeOnUI(() =>
             {
                 var toRemove = new List <ActivityEntity>(SelectedActivities);
                 foreach (var activity in toRemove)
                 {
                     _SelectedAthlete.Activities.Remove(activity);
                 }
             });
         }
     });
 }
示例#6
0
 private async Task <MemoryActivity> Import(string fileName)
 {
     using (var input = await TestFileHelper.OpenForReadAsync(fileName))
     {
         var activity = new MemoryActivity();
         var importer = new GpxImporter(activity);
         importer.Load(input);
         //var exporter = new FitExporter(activity);
         //using (var output = await TestFileHelper.OpenForWriteAsync(_fileName + ".fit"))
         //{
         //    exporter.Save(output);
         //}
         return(activity);
     }
 }
        protected Score TestReferenceFile(string file, string renderLayout = "page", bool renderAllTracks = false)
        {
            var gpxImporter = new GpxImporter();
            var sw          = new Stopwatch();

            try
            {
                sw.Restart();
                var buffer   = File.ReadAllBytes(file);
                var importer = PrepareImporterWithBytes(buffer);
                var score    = importer.ReadScore();
                sw.Stop();

                if (renderAllTracks)
                {
                    Render(score.Tracks.ToArray(), Path.ChangeExtension(file, ".all.png"), renderLayout);
                }
                else
                {
                    foreach (var track in score.Tracks)
                    {
                        Render(new[] { track }, Path.ChangeExtension(file, "." + track.Index + ".png"), renderLayout);
                    }
                }


                var   reference = Path.ChangeExtension(file, ".gpx");
                Score referenceScore;
                if (!File.Exists(reference))
                {
                    Assert.Inconclusive();
                }

                gpxImporter.Init(ByteBuffer.FromBuffer(File.ReadAllBytes(reference)));
                referenceScore = gpxImporter.ReadScore();
                AreEqual(referenceScore, score);

                return(score);
            }
            catch (UnsupportedFormatException e)
            {
                Assert.Fail("Failed to load file {0}: {1}", file, e);
                throw;
            }
        }
示例#8
0
        static void Main(string[] args)
        {
            var inputFile  = @"C:\Users\Епишкин Дмитрий\Desktop\ВЛУ\keyPoints3.gpx";
            var outputFile = @"C:\Users\Епишкин Дмитрий\Desktop\ВЛУ\000.gpx";

            var importer = new GpxImporter();
            var exporter = new GpxExporter();

            var keyPoints = importer.ImportWaypoints(inputFile);

            var profile = ProfileFactory.CreateWithFixedStep(keyPoints, 200, i => "000-" + (i + 1).ToString("D3"));

            //var profile = GridFactory.CreateRectangle(keyPoints[0], 500, 100, 10000, 5000, Math.PI / 4);

            exporter.ExportWaypoints(outputFile, profile);

            System.Console.WriteLine(@"Готово");
            System.Console.ReadKey();
        }
示例#9
0
        public void TestImportGpxData()
        {
            string      path     = @"data\data_tiny.gpx";
            GpxImporter importer = new GpxImporter();

            IList <ActivityEntity> activities;

            using (FileStream fs = File.OpenRead(path))
            {
                activities = new List <ActivityEntity>(importer.ImportActivitiesStream(fs, new Dictionary <string, ACTIVITY_SPORT> {
                    { "1", ACTIVITY_SPORT.BIKING },
                    { "2", ACTIVITY_SPORT.RUNNING },
                    { "3", ACTIVITY_SPORT.SWIMMING }
                }));
            }
            activities.Should().HaveCountGreaterOrEqualTo(1, "expected data_mini.fitlog to contain at least 1 activity");
            var activity = activities.Where(a => a.OriginId == "StravaGPX2020-05-17T07:24:45Z").Single();

            activity.Tracks.Should().ContainSingle();
        }
示例#10
0
        protected void Start(Stream source, int millisecondsDelay)
        {
            if (_task != null)
            {
                return;
            }

            _task = Task.Run(() =>
            {
                // import activity from GPX
                var activity = new MemoryActivity();
                var importer = new GpxImporter(activity);
                importer.Load(source);
                // mock positions from the activity
                while (true)
                {
                    foreach (var frame in activity.TimeFrames)
                    {
                        Task.Delay(millisecondsDelay).Wait(); // wait for 1 second
                        if (!_isConnected)
                        {
                            continue;
                        }

                        if (frame.Position.HasValue)
                        {
                            if (StatusChanged != null)
                            {
                                _status.Position = frame.Position.Value;
                                var args         = new GeoLocatorStatusChangedEventArgs(_status);
                                StatusChanged(this, args);
                            }
                        }
                    }
                }
            });
            _task.ConfigureAwait(false);
        }