limit download max zoom to current layer max zoom

This commit is contained in:
stopflock
2025-12-02 14:32:42 -06:00
parent c4d9cd7986
commit 0d13fdee37
4 changed files with 24 additions and 8 deletions

View File

@@ -98,9 +98,6 @@ cp lib/keys.dart.example lib/keys.dart
## Roadmap
### Needed Bugfixes
- Remove potentially wrong FOVs from default profiles
- Download area zoom goes too far
- Update node cache to reflect cleared queue entries
- Are offline areas preferred for fast loading even when online? Check working.
### Current Development

View File

@@ -1,4 +1,10 @@
{
"1.5.4": {
"content": [
"• FIXED: Download area max zoom level is now limited to the currently selected tile provider's maximum zoom level (e.g., OpenTopoMap limited to Z18, Bing Maps to Z20)",
"• IMPROVED: Download area dialog properly respects tile provider capabilities and prevents downloading tiles beyond what the provider supports"
]
},
"1.5.3": {
"content": [
"• MAJOR: Proper three-stage upload process - uploads now correctly track changeset creation, node operation, and changeset closing as separate steps",

View File

@@ -59,10 +59,16 @@ class _DownloadAreaDialogState extends State<DownloadAreaDialog> {
final minZoom = 1; // Always start from zoom 1 to show area overview when zoomed out
final maxZoom = _zoom.toInt();
// Calculate maximum possible zoom based on tile count limit
// Calculate maximum possible zoom based on tile count limit and tile provider max zoom
final maxPossibleZoom = _calculateMaxZoomForTileLimit(bounds, minZoom);
final nTiles = computeTileList(bounds, minZoom, maxZoom).length;
// Clamp current zoom to the effective maximum if it exceeds it
if (_zoom > maxPossibleZoom) {
_zoom = maxPossibleZoom.toDouble();
}
final actualMaxZoom = _zoom.toInt();
final nTiles = computeTileList(bounds, minZoom, actualMaxZoom).length;
final tileEstimateKb = _getTileEstimateKb();
final totalMb = (nTiles * tileEstimateKb) / 1024.0;
final roundedMb = (totalMb * 10).round() / 10; // Round to nearest tenth
@@ -76,15 +82,22 @@ class _DownloadAreaDialogState extends State<DownloadAreaDialog> {
}
/// Calculate the maximum zoom level that keeps tile count under the absolute limit
/// and respects the selected tile type's maximum zoom level
int _calculateMaxZoomForTileLimit(LatLngBounds bounds, int minZoom) {
for (int zoom = minZoom; zoom <= kAbsoluteMaxZoom; zoom++) {
final appState = context.read<AppState>();
final selectedTileType = appState.selectedTileType;
// Use tile type's max zoom if available, otherwise fall back to absolute max
final effectiveMaxZoom = selectedTileType?.maxZoom ?? kAbsoluteMaxZoom;
for (int zoom = minZoom; zoom <= effectiveMaxZoom; zoom++) {
final tileCount = computeTileList(bounds, minZoom, zoom).length;
if (tileCount > kAbsoluteMaxTileCount) {
// Return the previous zoom level that was still under the absolute limit
return math.max(minZoom, zoom - 1);
}
}
return kAbsoluteMaxZoom;
return effectiveMaxZoom;
}
/// Get tile size estimate in KB, using preview tile data if available, otherwise fallback to constant

View File

@@ -1,7 +1,7 @@
name: deflockapp
description: Map public surveillance infrastructure with OpenStreetMap
publish_to: "none"
version: 1.5.3+24 # The thing after the + is the version code, incremented with each release
version: 1.5.4+25 # The thing after the + is the version code, incremented with each release
environment:
sdk: ">=3.5.0 <4.0.0" # oauth2_client 4.x needs Dart 3.5+