private void CalculateDownloadSize(Poi poi) { string text = ""; bool enableDownloadButton = false; if (poi?.Id >= (long)PoiId.FIRST_VALID_ID || poi?.Id == (long)PoiId.CURRENT_LOCATION) { float size; var newDistance = GetDownloadDistance(); if (_oldDedItem == null || newDistance > _oldDedItem.Distance) { var gpsLocation = new GpsLocation(poi.Longitude, poi.Latitude, poi.Altitude); var etc = new ElevationTileCollection(gpsLocation, newDistance); size = etc.GetSizeToDownload(); text = String.Format(Resources.GetText(Resource.String.DownloadED_ExpectedSizeDownload), $"{size:F1}"); enableDownloadButton = true; } else if (newDistance < _oldDedItem.Distance) { var location = new GpsLocation(_oldDedItem.Longitude, _oldDedItem.Latitude, 0); var tilesToBeRemovedAll = ElevationTileCollection.GetTilesForRemoval(location, _oldDedItem.Distance, newDistance); var tilesToBeRemovedUnique = ElevationTileCollection.GetUniqueTilesForRemoval(_oldDedItem.Id, _allElevationData, tilesToBeRemovedAll); size = tilesToBeRemovedUnique.GetSize() / 1024f / 1024f; text = String.Format(Resources.GetText(Resource.String.DownloadED_ExpectedSizeRemove), $"{size:F1}"); enableDownloadButton = true; } } FindViewById <TextView>(Resource.Id.textViewDownloadSize).Text = text; FindViewById <Button>(Resource.Id.buttonSave).Enabled = enableDownloadButton; }
private void DeleteElevationTiles(DownloadedElevationData ded) { var dedTiles = new ElevationTileCollection(new GpsLocation(ded.Longitude, ded.Latitude, 0), ded.Distance); Task.Run(async() => { var downloadedElevationData = await AppContext.Database.GetDownloadedElevationDataAsync(); var tilesToBeRemoved = ElevationTileCollection.GetUniqueTilesForRemoval(ded.Id, downloadedElevationData, dedTiles); tilesToBeRemoved.Remove(); }); }
private void RemoveElevationData(DownloadedElevationData ded, int oldDedDistance) { var location = new GpsLocation(ded.Longitude, ded.Latitude, 0); var tilesToBeRemovedAll = ElevationTileCollection.GetTilesForRemoval(location, oldDedDistance, ded.Distance); var tilesToBeRemovedUnique = ElevationTileCollection.GetUniqueTilesForRemoval(ded.Id, _allElevationData, tilesToBeRemovedAll); tilesToBeRemovedUnique.Remove(); var edd = new ElevationDataDownload(new GpsLocation(ded.Longitude, ded.Latitude, 0), ded.Distance); ded.SizeInBytes = edd.GetSize(); AppContext.DownloadedElevationDataModel.UpdateItem(ded); Finish(); }