public static ElevationTileCollection GetUniqueTilesForRemoval(long dedId, IEnumerable <DownloadedElevationData> allData, ElevationTileCollection tilesToBeRemoved)
        {
            //Get only tiles, that are not used by another areas
            var tilesForRemoval = new List <ElevationTile>();

            foreach (var tile in tilesToBeRemoved.AsEnumerable())
            {
                var doNotRemove = false;
                foreach (var anotherDedItem in allData)
                {
                    if (anotherDedItem.Id == dedId)
                    {//skip deleted item (but it is actually already removed)
                        continue;
                    }

                    var anotherDedTiles = new ElevationTileCollection(new GpsLocation(anotherDedItem.Longitude, anotherDedItem.Latitude, 0), anotherDedItem.Distance);
                    if (anotherDedTiles.HasElevation(tile.StartLocation, false))
                    {
                        doNotRemove = true;
                        break;
                    }
                }

                if (!doNotRemove)
                {
                    tilesForRemoval.Add(tile);
                }
            }

            return(new ElevationTileCollection(tilesForRemoval));
        }
        public static ElevationTileCollection GetTilesForRemoval(GpsLocation location, int oldDistance, int newDistance)
        {
            var dedTiles    = new ElevationTileCollection(location, newDistance);
            var dedTilesOld = new ElevationTileCollection(location, oldDistance);

            var tilesForRemoval = new List <ElevationTile>();

            foreach (var tile in dedTilesOld.AsEnumerable())
            {
                if (!dedTiles.HasElevation(tile.StartLocation, false))
                {
                    tilesForRemoval.Add(tile);
                }
            }

            return(new ElevationTileCollection(tilesForRemoval));
        }
예제 #3
0
        public void Generate(GpsLocation _myLocation, double maxDistanceKm, ElevationTileCollection etc, Action <int> onProgressChange)
        {
            _elevationProfileData = new ElevationProfileData(_myLocation, maxDistanceKm);

            /*for (ushort angle = 0; angle < 360; angle++)
             * {
             *  onProgressChange(angle);
             *
             *  var ed = new ElevationData(angle);
             *
             *  for (int d = 500; d < 12000; d += 25)
             *  {
             *      var x = GpsUtils.QuickGetGeoLocation(_myLocation, d, angle);
             *      if (etc.TryGetElevation(x, out var elevation, 1))
             *      {
             *          x.Altitude = elevation;
             *          x.Distance = d;
             *          x.Bearing = angle;
             *          x.GetVerticalViewAngle(_myLocation);
             *
             *          ed.Add(x);
             *      }
             *  }
             *
             *  _elevationProfileData.Add(ed);
             * }*/


            for (ushort a = 0; a < 360; a++)
            {
                onProgressChange(a);


                var ed = GetElevationDataForAngle(a, _myLocation, maxDistanceKm * 1000, etc);

                _elevationProfileData.Add(ed);
            }
        }
예제 #4
0
        private ElevationData GetElevationDataForAngle(ushort angle, GpsLocation myLocation, double maxDistance, ElevationTileCollection etc)
        {
            var ed = new ElevationData(angle);

            for (double d = 500; d < maxDistance; d += Math.Min(100, d / 100))
            {
                var x = GpsUtils.QuickGetGeoLocation(myLocation, d, angle);
                //int size = d < 5000 ? 1 : 3;
                int size = Math.Min(((int)d / 20000) + 1, 4);//0-20:1 20-40:2 40-60:3 60-100:4
                if (etc.TryGetElevation(x, out var elevation, size))
                {
                    x.Altitude = elevation;
                    x.Distance = d;
                    x.Bearing  = angle;
                    x.GetVerticalViewAngle(myLocation);

                    ed.Add(x);
                }
            }

            return(ed);
        }