diff --git a/README.md b/README.md index 33307ba..79a8613 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/assets/changelog.json b/assets/changelog.json index bfb02bb..91b651a 100644 --- a/assets/changelog.json +++ b/assets/changelog.json @@ -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", diff --git a/lib/widgets/download_area_dialog.dart b/lib/widgets/download_area_dialog.dart index 48c5635..2888490 100644 --- a/lib/widgets/download_area_dialog.dart +++ b/lib/widgets/download_area_dialog.dart @@ -59,10 +59,16 @@ class _DownloadAreaDialogState extends State { 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 { } /// 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(); + 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 diff --git a/pubspec.yaml b/pubspec.yaml index fc17c22..aa36258 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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+