Beispiel #1
0
        public void CalculateProfile()
        {
            GpsUtils.BoundingRect(_myLocation, _visibility * 1000, out var min, out var max);

            _data = new List <GpsLocation>();
            string inputFileName = @"c:\Temp\ElevationMap\ALPSMLC30_N049E018_DSM.tif";

            GeoTiffReaderList.ReadTiff(inputFileName, min, max, _myLocation, 3, _data);

            //Calculate old profile

            /*ElevationProfile ep = new ElevationProfile();
             * ep.GenerateElevationProfile(_myLocation, _visibility, _data, progress => { });
             * elevationProfileOld = ep.GetProfile();*/

            //Calucate new profile

            var etc = new ElevationTileCollection(_myLocation, (int)_visibility);
            var d   = etc.GetSizeToDownload();

            etc.Download(progress => { });
            etc.Read(progress => { });
            profileGenerator.Generate(_myLocation, 12, etc, progress => { });

            /*ProfileGeneratorOld ep2 = new ProfileGeneratorOld();
             * //ep2.GenerateElevationProfile3(_myLocation, _visibility, _data, progress => { });
             * ep2.GenerateElevationProfile3(_myLocation, _visibility, elevationPainter3.list, progress => { });
             * elevationProfileNew = ep2.GetProfile();*/

            ElevationProfile ep3 = new ElevationProfile();

            ep3.GenerateElevationProfile3(_myLocation, _visibility, profileGenerator.GetProfile(), progress => { });
            elevationProfileNew = ep3.GetProfile();

            Invalidate();
        }
Beispiel #2
0
        protected override ElevationProfileData RunInBackground(params GpsLocation[] @params)
        {
            try
            {
                var parts = new List <Part>
                {
                    new Part()
                    {
                        Title = "DownloadTile", TimeComplexity = 50, Count = _elevationTileCollection.GetCountToDownload()
                    },
                    new Part()
                    {
                        Title = "ReadTile", TimeComplexity = 10, Count = _elevationTileCollection.GetCount()
                    },
                    new Part()
                    {
                        Title = "Generate", TimeComplexity = 1, Count = 360
                    },
                    new Part()
                    {
                        Title = "MakeLines", TimeComplexity = 1, Count = 360
                    }
                };

                float totalTimeComplexity = parts.Select(x => x.Count * x.TimeComplexity).Aggregate((sum, part) => sum + part);
                int   totalProgress       = 0;

                var downloadingOk = _elevationTileCollection.Download(progress =>
                {
                    var localProgress = progress * parts[0].TimeComplexity;
                    OnProgressChange?.Invoke((int)((totalProgress + localProgress) / totalTimeComplexity * 100f));
                });
                totalProgress += parts[0].Count * parts[0].TimeComplexity;

                var readingOk = _elevationTileCollection.Read(progress =>
                {
                    var localProgress = progress * parts[1].TimeComplexity;
                    OnProgressChange?.Invoke((int)((totalProgress + localProgress) / totalTimeComplexity * 100f));
                });
                totalProgress += parts[1].Count * parts[1].TimeComplexity;

                ElevationDataGenerator ep = new ElevationDataGenerator();
                ep.Generate(MyLocation, MaxDistance, _elevationTileCollection, progress =>
                {
                    var localProgress = progress * parts[2].TimeComplexity;
                    OnProgressChange?.Invoke((int)((totalProgress + localProgress) / totalTimeComplexity * 100f));
                });
                totalProgress += parts[2].Count * parts[2].TimeComplexity;


                ElevationProfile ep2 = new ElevationProfile();
                ep2.GenerateElevationProfile3(MyLocation, MaxDistance, ep.GetProfile(), progress =>
                {
                    var localProgress = progress * parts[3].TimeComplexity;
                    OnProgressChange?.Invoke((int)((totalProgress + localProgress) / totalTimeComplexity * 100f));
                });
                totalProgress += parts[3].Count * parts[3].TimeComplexity;

                var epd = ep2.GetProfile();

                if (!downloadingOk || !readingOk)
                {
                    epd.ErrorMessage = _elevationTileCollection.GetErrorList();
                }

                return(epd);
            }
            catch (Exception ex)
            {
                return(new ElevationProfileData(ExceptionHelper.Exception2ErrorMessage(ex)));
            }
        }