mapbox-maps-ios icon indicating copy to clipboard operation
mapbox-maps-ios copied to clipboard

OfflineRegionManager ignoring minzoom

Open cbo1964 opened this issue 3 years ago • 0 comments

Environment

  • Xcode version: Version 13.3.1 (13E500a)
  • iOS version: 15.5
  • Devices affected: iOS iPhone/iPad
  • Maps SDK Version: 10.6.0

Observed behavior and steps to reproduce

The goal of my work is to be able to download the first zoomLevels (from 0 to 5) as soon as the app start so to have locally a sort of planisphere available even without internet connection (I have not found any way to embed a planisphere into the app). So, the idea is to make an OfflineDownload of the whole world for the first 6 zoomLevels (0..5). In our style we have many different sources for "detailed" zoom levels but only 1 for the planisphere zoom levels. What I observed is that the OfflineRegionManager download tiles also from the sources that do not cover the planisphere zoom levels.

To demonstrate the issue I extremely simplified our style and I used a modified version of the OfflineManagerExample using this OfflineRegionGeometryDefinition (to be noted that in this example I'm trying to download only zoomLevels fro 0 to 1 in order to have smaller tiles download numbers):

let offlineRegionDef1 = OfflineRegionGeometryDefinition( // styleURL: "http://www.gec-it.com/oldsite/aqua_style1.json", styleURL: "http://www.gec-it.com/oldsite/aqua_style2.json", geometry: .polygon(Polygon([[LocationCoordinate2D(latitude: -90, longitude: -180), LocationCoordinate2D(latitude: 90, longitude: -180), LocationCoordinate2D(latitude: 90, longitude: 180), LocationCoordinate2D(latitude: -90, longitude: 180)]])), minZoom: 0, maxZoom: 1, pixelRatio: 1, glyphsRasterizationMode: .noGlyphsRasterizedLocally)

What happen is that when I use the style1.json (you can download, I put them in a public folder) that has only 1 source:

"sources": { "plani": { "tiles": [ "https://www.globalterramaps.com/GetMyPBF.php?z={z}&x={x}&y={y}" ], "type": "vector", "minzoom": 0, "maxzoom": 5, "bounds": [-180, -90, 180, 90] } },

I get this result (I slightly modified the OfflineRegionManager example in order to also print the number of tiles to be downloaded:

                  Downloaded 1/10 resources and 433 bytes. Downloaded 0/5 Tiles.
                  Downloaded 2/10 resources and 7356 bytes. Downloaded 0/5 Tiles.
                  Downloaded 3/10 resources and 14279 bytes. Downloaded 0/5 Tiles.
                  Downloaded 4/10 resources and 621969 bytes. Downloaded 0/5 Tiles.
                  Downloaded 5/10 resources and 1229659 bytes. Downloaded 0/5 Tiles.
                  Downloaded 6/10 resources and 1255410 bytes. Downloaded 1/5 Tiles.
                  Downloaded 7/10 resources and 1277845 bytes. Downloaded 2/5 Tiles.
                  Downloaded 8/10 resources and 1346918 bytes. Downloaded 3/5 Tiles.
                  Downloaded 9/10 resources and 1445240 bytes. Downloaded 4/5 Tiles.
                  Downloaded 10/10 resources and 1548139 bytes. Downloaded 5/5 Tiles.
                  Downloaded 10/10 resources and 1548139 bytes. Downloaded 5/5 Tiles.
                  Download complete.
                  Success

where the 5 Tiles is what expected (1 for zoom 0 and 4 for zoom 1).

Instead when I use the style2 (where I added an additional source with minZoom: 8): "sources": { "plani": { "tiles": [ "https://www.globalterramaps.com/GetMyPBF.php?z={z}&x={x}&y={y}" ], "type": "vector", "minzoom": 0, "maxzoom": 5, "bounds": [-180, -90, 180, 90] }, "additional_rasters": { "scheme": "tms", "tiles": [ "https://www.globalterramaps.com/GetMyPNG.php?z={z}&x={x}&y={y}" ], "type": "raster", "minzoom": 8, "maxzoom": 18, "bounds": [-180, -90, 180, 90] } },

I get the following result:

                        Downloaded 1/65546 resources and 537 bytes. Downloaded 0/65541 Tiles.
                        Downloaded 2/65546 resources and 7460 bytes. Downloaded 0/65541 Tiles.
                        Downloaded 3/65546 resources and 615150 bytes. Downloaded 0/65541 Tiles.
                        Downloaded 67/65546 resources and 622073 bytes. Downloaded 63/65541 Tiles.
                        Downloaded 131/65546 resources and 1229763 bytes. Downloaded 126/65541 Tiles.
                        Downloaded 195/65546 resources and 1229763 bytes. Downloaded 190/65541 Tiles.
                        Downloaded 259/65546 resources and 1229763 bytes. Downloaded 254/65541 Tiles.
                        Downloaded 323/65546 resources and 1229763 bytes. Downloaded 318/65541 Tiles.
                        ....

where you can see the 65541 Tiles to be downloaded. It is true that the size is not increasing (the tiles simply do not exist) but it is taking a very long time to complete the download). It is also strange the 65541 number because it seems 5 + 65536, where 65536 is the number of tiles covering the whole world at zoomLevel 8, that is the zoomLevel at which is enabled the second source.

But this has no sense, why it should download any tile for the second source if it is enabled only at zoom 8 and I'm downloading from 0 to 1 ?

Thanks

cbo1964 avatar Jul 13 '22 10:07 cbo1964