merlos / mapcache Goto Github PK
View Code? Open in Web Editor NEWMap Cache for iOS. Pod to support offline maps written in Swift
Home Page: http://merlos.org/MapCache
License: MIT License
Map Cache for iOS. Pod to support offline maps written in Swift
Home Page: http://merlos.org/MapCache
License: MIT License
The variable is never used within the start()
Hi,
I tried to integrate this library in my project. It uses OpenRailwayMap tiles, which are 512x512 retina png tiles (e.g. https://a.tiles.openrailwaymap.org/standard/8/137/85.png). If I use the native MKTileOverlay (first example) it uses the full available resolution on a retina display, resulting in a sharp image with more details. If I use the MapCache overlay (second example), the tiles are blurry and have way less details. I assume something in the zoom height configuration on retina displays is wrong here, but I couldn't figure out what exactly.
Maybe @merlos you can take a look what could be the problem here?
If it helps, I can provide the code I used to achieve both outcomes.
Thanks!
Right now when a region is downloaded the delegate is notified whenever a certain percentages are achieved depending on the value of (incrementInPercentageNotification
) however there are other notifications that may be interesting:
In Open Street Maps (OSM), the max latitude that can be converted to tiles is +85.0511 and the minimum is -85.0511 (see https://wiki.openstreetmap.org/wiki/Slippy_map_tilenames).
However in Apple Maps allows to download from -90 to 90. So, a map that uses Apple Maps to display the coords will be able to request areas beyond the OSM limit.
Hi @merlos ,
I encountered a crash with MapCache while testing my app.
Reproduction
Then controlCapacity
function constantly delete files, which is expected. However, memory usage is growing quickly without pausing, eventually leading to a crash. It's easily reproducible.
Below is a screenshot.
First peak did not lead to crash. It's because there are not enough new tiles flushing out old ones (i.e. did not scroll the map long enough). Second peak crashed.
MapCache is in its early releases so many debug messages were added for debug purposes. However these logs are in the production version.
The library already has a logging class (https://github.com/merlos/MapCache/blob/master/MapCache/Classes/Log.swift) which is not used but that can be used to display messages only during debug easily.
I followed the example with the region downloader but the tiles are not persist when downloaded
When running the tests of DiscCacheSpecs
, sometimes they give error and other passes.
Initially, this seems a bad implementation of the tests and fail due to asynchronous runs.
While updating Open GPX Tracker if zoom is too large MapCache throws error
Fatal error: Not enough bits to represent the passed value: file Swift/Integers.swift, line 3443
To reproduce:
Create a controller with a MapView that uses Apple Maps. Use this map to select a region.
Download a region with a MapCache that uses Open Street Maps (OSM) as tile Server.
Create a second controller that displays another MapView but this time using MapCache with OSM as tile server. Use the same MapCache used for downloading the region (ie: same name).
You´ll see that the second map does not display the area selected in the controller of (1), the tiles downloaded were in a different location.
The problem is that whereas Apple Maps uses -90 to 90 as range in the latitude, OSM only uses -85.0511 to 85.0511, so the conversion coordinates to tiles does not work.
In the code, this conversion is done in TileCoords
Related with #5
In the loadTile
function, you are downloading tiles even if they are found in cache. result
will be called twice.
You should put the downloading task in the fetChfailure
block.
iOS13 now supports up to zoom 25, however many OSM tile servers only support till [19...22].
This makes MapCache to request tiles that will always return 404.
mapView:useCache adds an overlay.
Removing that overlay can be done.
Add an example to the documentation
On such cases the tiles are blank. @camdeardorff
Setting MapCacheConfig.maximumZ greater than 19 is pretty much pointless as far as TileCoords are involved.
As TileCoords' validate method throws ZoomError.largerThan19, I can't really use the MapCache for higher zoom levels although they are supported by my tile server.
I just updated my pod spec to 0.8.0 to try out the new over zoom feature but it doesn't seem to be implemented. Looking at the code I don't see the "CachedTileOverlayZoomRenderer.swift" file in the Pod. Is it possible something didn't make it to the release?
Hi @merlos. Thank you for the great library.
I have a couple of use cases where I want to show the previous overzoomed level while waiting for the next level to load.
First use case is to hide the loading of the tiles (prevent the gray boxes whilst the tile is loading).
Second use case is to show an overzoomed tile when a 404 is returned for that zoom level (due to the map server not having a full tile set at that zoom).
Any tips as to how this could be implemented in your code base?
I'd be happy to do the work if you can point me in the correct direction.
If RegionDownloader fails to download a tile it just increments the counter that keeps track of the number of fail to download files, but that´s it.
There should be a list with the tiles that were not downloaded, so any kind of retry strategy can be done.
Additionally it would be nice to have some kind of retry support.
Right now the cache does not have an expiration date. If the tile is in the cache it will always return the same cached tile.
However, maps are not static and evolve with time, so the cache should provide expiration support.
Additionally, it should be possible to create custom expiration strategies.
I'm noticing some odd behavior using Xcode 16 beta.
(1) sometimes not all the tiles load. The view just needs to be moved for them to load. But, as it is, the view can be incomplete.
(2) sometimes caching seems to go berserk. Even after the view is loaded and remains static, I see caching logs go on and on for some time. When this happens, changing the view can cause blank spots until the caching catches up or whatever.
I don't recall this behavior before.
How is it possible to download a selected area(not cache it )?
In 0.6.0 in order to access file and allocated disk sizes:
...
cache: MapCache
...
print(cache.diskCache.fileSize)
print(cache.calculateDiskSize())
it should be something like
cache.fileSize
cache.diskSize
Whereas in my dev environment unit testing works in build pipelines in github and in travisCI fail most of the time.
Primarily these are the expectations that do not work most of the time
✗ a_DiskCache__can_find_a_file_that_is_in_the_cache, expected to equal <4096>, got <8192>
✗ a_DiskCache__can_remove_the_file_from_the_cache, expected to eventually equal <4096>, got <8192>
✗ a_DiskCache__can_remove_the_file_from_the_cache, expected to eventually equal <0>, got <4096>
MapCache_Tests.DiskCacheSpecs
a_DiskCache__can_find_a_file_that_is_in_the_cache, expected to equal <4096>, got <8192>
/Users/travis/build/merlos/MapCache/Example/Tests/DiskCache/DiskCacheSpecs.swift:111
diskCache.setDataSync(data1!, forKey: filename1)
expect(diskCache.diskSize).to(equal(4096))
a_DiskCache__can_remove_the_file_from_the_cache, expected to eventually equal <4096>, got <8192>
/Users/travis/build/merlos/MapCache/Example/Tests/DiskCache/DiskCacheSpecs.swift:151
diskCache.setDataSync(data1!, forKey: filename1)
expect(diskCache.diskSize).toEventually(equal(4096))
// remove the file
a_DiskCache__can_remove_the_file_from_the_cache, expected to eventually equal <0>, got <4096>
/Users/travis/build/merlos/MapCache/Example/Tests/DiskCache/DiskCacheSpecs.swift:155
expect(diskCache.diskSize).toEventually(equal(0))
Current implementation requests tiles in a uniform random way. Each tile server has the same probability of being requested, however because of the randomness this can make that a server is hit 5 times in a row whereas the others are idle.
In order to improve this some kind of round robin strategy can be applied. We assume all servers are equally efficient and the requests are divided in sequence. With round robin the requests for a 3 subdomain server (a,b,c) the sequence of requests would be to the servers a, b, c, a, b, c, a, b, c, a, b, c, a, b, c...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.