3️⃣Start Download
Last updated
Last updated
© Luka Stillingfleet (JaffaKetchup)
Now that you have constructed a DownloadableRegion
, you're almost ready to go.
Before you call startForeground
(via FMTCStore().download
) to start the download, check out the customization parameters:
parallelThreads
(defaults to 5)
The number of simultaneous download threads to run
maxBufferLength
(defaults to 200)
The number of tiles to temporarily persist in memory before writing to the cache
skipExistingTiles
(defaults to false
)
Whether to avoid re-downloading tiles that have already been cached
skipSeaTiles
(defaults to true
)
Whether to avoid caching tiles that are entirely sea (based on whether they have the same pixels as the tile at z17, x0, y0, which is assumed to be sea)
rateLimit
The maximum number of tiles that can be attempted per second
maxReportInterval
(defaults to 1 second)
The duration in which to emit at least one DownloadProgress
event
disableRecovery
(defaults to false
)
Whether to avoid registering this download with the Recovery system for safe recovery if the download fails
Ensure skipSeaTiles
is disabled when downloading from a server where the tile at z17, x0, y0 is not a consitently colored sea tile, or where different sea tiles look different, such as with satellite imagery. FMTC cannot yet skip sea tiles that match these conditions.
The Recovery system can slow a download, as it must be regularly updated with the latest progress of the download, and this data is not currently batched (so it occurs for every downloaded tile). This is an optimization planned for later implementation.
Therefore, where speed is significant and the download is unlikely to be unexpectedly interrupted, consider disabling download recovery.
Before using FMTC, especially to bulk download or import/export, ensure you comply with the appropriate restrictions and terms of service set by your tile server. Failure to do so may lead to any punishment, at the tile server's discretion.
This library and/or the creator(s) are not responsible for any violations you make using this package.
For example, OpenStreetMap's tile server forbids bulk downloading: https://operations.osmfoundation.org/policies/tiles. And Mapbox has restrictions on importing/exporting from outside of the user's own device.
For testing purposes, check out the testing tile server included in the FMTC project: Testing Tile Server.
Whilst not recommended, it is possible to start and control multiple downloads simultaneously, by using a unique Object
as the instanceId
argument. This 'key' can then later be used to control its respective download instance.
Note that this option may be unstable.
The startForeground
method returns a (non-broadcast) Stream
of DownloadProgress
events, which contain information about the overall progress of the download, as well as the state of the latest tile attempt.
To reflect the information from a single event back to the user, use a StreamBuilder
, and build the UI dependent on the 'snapshots' of the stream. If you need to keep track of information from across multiple events, see Keeping Track Across Events below.
In addition to display each individual event to your user, you may also need to keep track of information from across multiple DownloadProgress
events. In this case, you'll likely need to use the latestTileEvent
getter to access the latest TileEvent
object, and keep track of its properties.
For example, you may wish to keep a list of all the failed tiles' URLs.
However, there are 3 important things to keep in mind when doing this: