Added a LoadMode property to tell MapCache how to load the tiles #21
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Following up on discussion from #17 I did find that using two closures did not seem to work properly. So since you can only select from either server or cache I made this modification.
I was able to make this work for my local fork. I added a property called LoadMode that determines how
loadTile(at path: MKTileOverlayPath...
loads tiles. The user could change this mode dynamically depending on their use case, their network connection status, etc.case always_server always fetches from server, updating cache. Useful when on unmetered and high bandwidth (eg. Wifi) connection. User always receives most recent data.
case cache_then_server is the current paradigm. Use the cache, unless not found, then fetch from server and update. Minimum amount of network access.
case cache_if_expired_then_server returns from cache if the cache file is new enough, otherwise fetch from server and update. This I left as a TODO because a method is needed to first retrieve the file date and compare it to .now minus some user supplied delta. This is useful if the user cares mostly about limiting network access, but will accept some loading of tiles from the server if the cache is too old.
case cache_only Only fetch from cache, never go out to server. Useful to completely eliminate any bandwidth usage (perhaps user is on a limited or expensive data connection - they want to just use their cache which they've presumably loaded up prior).