-
Notifications
You must be signed in to change notification settings - Fork 986
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Offline map caches like zip or mbtiles should not be considered for cache trimming #198
Comments
You're putting the database in the wrong spot. Try /sdcard/osmdroid/, not
|
It strikes me as odd that it does work from the tiles directory, though. |
They wouldn't be shown if if the tile source name given to osmdroid does not match the source name listed in the zip, sqlite, etc. I think mbtiles is not affected by this since they don't store the tile source name in the database. You can also try using the OfflineTileProvider, which ignores the tile source entirely and just loads up whatever zip or database that you give it |
In MapTileArchiveProvider.java (in package org.osmdroid.tileprovider.modules) private void findArchiveFiles() {
mArchiveFiles.clear();
if (!getSdCardAvailable()) {
return;
}
// path should be optionally configurable
File cachePaths = OpenStreetMapTileProviderConstants.TILE_PATH_BASE;
final File[] files = cachePaths.listFiles();
if (files != null) {
for (final File file : files) {
final IArchiveFile archiveFile = ArchiveFileFactory.getArchiveFile(file);
if (archiveFile != null) {
mArchiveFiles.add(archiveFile);
}
}
}
} cachePaths is set to the tiles path to search for the archives / databases. If you change this to File cachePaths = OpenStreetMapTileProviderConstants.OSMDROID_PATH; then everything works as you previously described.
I have verified this by creating and then independently loading a zip file, an sqlite db, and an mbtiles db - as long as the source name is correct for whichever format you use, everything is fine. I can also verify that the .mbtiles file name must match the source name in order for it to be displayed. |
The cache path typically maps to /sdcard/osmdroid/tiles where as the OSMDROID_PATH is /sdcard/osmdroid. I'm confused and I'm not too sure what the issue is at this point. Is the root problem that sqlite, zip, etc are loaded from within /sdcard/osmdroid/tiles/? or that your database was deleted because it was in /sdcard/osmdroid/tiles/? |
Apologies, I think I've morphed the problem after digging through the code. The problem is two-fold:
In the code block I posted in my previous post, I noticed that the archive loader defaults to loading the archives / databases from the
Sorry for being an insufferable pedant :) |
ahh i see the problem... |
…for cache trimming (using wrong base path)
Looks like it was me that buggered it up back in august. I pushed the changes to branch #198. Would you mind testing it on your end? |
I've given it a reasonable test - everything now works as expected. Thanks! |
merged. thanks for testing! |
This issue is pretty much as the title states:
Using MOBAC, I initially created an mbtiles database that contains the tiles that I'm interested in displaying offline. The file is large, but not excessively so at ~1.3GB.
If I place this mbtiles database on the SD card at
/sdcard/osmdroid/tiles
it is immediately deleted the next time I start up osmdroid. If I use MOBAC to pack an OsmDroid ZIP archive, the zip is also deleted on the next startup of osmdroid.The telltale clue I finally got with the mbtiles, after several red herrings, is a pair of lines from logcat (edited):
D OsmDroid: Trimming tile cache from 1358250840 to 524288000
and then eventually
D OsmDroid: Finished trimming tile cache
.The next few lines on logcat spell out the fact that the SQLite cannot find the mbtiles file:
E SQLiteLog: (1802) os_unix.c:29136: (2) fstat (/sdcard/osmdroid/tiles/xxx.mbtiles)
E SQLiteLog: (1802) disk I/O error.
W OsmDroid: Error getting db stream: /17/76816/73878
Another thing I should probably mention is that I'm using a hybrid of online and offline tiles using the basic map tile provider as it provides the filesystem provider, the archive provider and the downloader provider without having to do any additional work. For the online tiles, I simply use Mapnik.
I can understand this being very helpful for purging the older / lesser used individual tiles from online caches, but surely if I'm supplying the bulk of the map in the form of a package, be it mbtiles or zip, I don't want that purged :)
At the moment, the work-around that I'm using is to just set the cache larger via
OpenStreetMapTileProviderConstants.setCacheSizes()
and setting the cache and trimming sizes a fair amount larger than I actually need.The text was updated successfully, but these errors were encountered: