While it is not possible to determine an actual filesize of an offline map package in advance, we can set a reasonable limit based on a minimum possible filesize of a 512px JPG, and a desired maximum MBTiles filesize limit of 500mb.
We can try this out with a "blank" tile (all white). I generated a few with mapgl-tile-renderer by downloading Planet tiles outside of the NICFI (tropical forest) AOI. The binary content stored in the MBTiles SQLite table for one such tile adds up to 18,963 bytes.
I prompted ChatGPT to run a similar estimation, arriving at a similar number:
import os
from PIL import Image
# Load the image
img = Image.open("/mnt/data/A_simple,_solid_color_image_of_a_light_blue_square.png")
# Convert to JPG with high compression (low quality setting)
compressed_image_path = "/mnt/data/compressed_high_compression.jpg"
img.save(compressed_image_path, 'JPEG', quality=5) # Set quality low to maximize compression
# Check the file size
compressed_image_size = os.path.getsize(compressed_image_path)
compressed_image_size
Result: 18,137 bytes
Hence, we can set a tile limit in the following way (500mb in bytes divided by one minimum size JPG):
500,000,000 / 18,137 = 275679
So, we round that down to 275,000, and use that as the threshold.
Screenshots
What I changed
Disable (and change color of) submit button if estimatedTiles > 275000.
Closes #12.
Goal
While it is not possible to determine an actual filesize of an offline map package in advance, we can set a reasonable limit based on a minimum possible filesize of a 512px JPG, and a desired maximum MBTiles filesize limit of 500mb.
We can try this out with a "blank" tile (all white). I generated a few with
mapgl-tile-renderer
by downloading Planet tiles outside of the NICFI (tropical forest) AOI. The binary content stored in the MBTiles SQLite table for one such tile adds up to 18,963 bytes.I prompted ChatGPT to run a similar estimation, arriving at a similar number:
Hence, we can set a tile limit in the following way (500mb in bytes divided by one minimum size JPG):
So, we round that down to 275,000, and use that as the threshold.
Screenshots
What I changed
Disable (and change color of) submit button if
estimatedTiles
> 275000.