venkivenkat / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

MBTiles multiple providers #390

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

I have a created map view and 3 tile sources, each one in all available offline 
formats (except zip): sqlite, mbtiles, gemf. I want to change the map view's 
tile source with setTileSource without having to re-create the map view. The 
simple way is with setTileSource but this works correctly only with the sqlite 
format of tile sources.

The sqlite format has at table 'tiles' a column 'provider' where we put the 
name of the tile source. And at DatabaseFileArchive at getInputStream I see 
that the query checks the provider's name and so it selects the correct sqlite 
file for the tile source name.

But at mbtiles format the provider's name exists at table 'metadata' as 'name', 
and I see that at MBTilesFileArchive at getInputStream there is not any search 
for it. The result is that we cannot have multiple mbtiles, each one for a 
different tile source name and change them with mapView.setTileSource
The map view always use the first mbtile in its list, no matter what we set 
with setTileSource.

The only way around that seems to work is to use the MapView constructor with 
MapTileProviderArray in order to feed it with the mbtile file name. But that 
means that in order to change tile source at map view we must re-create the map 
view each time.

This issue happens also for the gemf offline format.

Thanks.

Original issue reported on code.google.com by devemu...@gmail.com on 4 Jan 2013 at 10:00

GoogleCodeExporter commented 9 years ago
The gemf stuff has no name chacking in it so if you have multiple overlapping 
files then you just get tiles from the first one.  It's a similar sort of 
problem to the MBTilesFileArchive.  I have code for the gemf stuff that has the 
nessasary name checking added in but if I remember there were minor changes 
needed in the interface to the rest of the system.

Original comment by iforpow...@gmail.com on 4 Jan 2013 at 10:56

GoogleCodeExporter commented 9 years ago
For offline formats that don't have in them the name of tile source and the 
code does not search for it, an idea in order to pick the right one would be to 
have their file name same as the tile source name. And then the code searches 
for offline formats with file name same with tile source name?

Original comment by devemu...@gmail.com on 5 Jan 2013 at 8:28

GoogleCodeExporter commented 9 years ago
I had the same requirement and I have fixed it by adding some metadata to the 
archives and tweaking MBTilesFileArchive.
Specifically I have added an entry 'tilesource' with the tile source name into 
the metadata table, as well as 'minzoom' and 'maxzoom'.

The changed MBTilesFileArchive will only deliver tiles if the tilesource 
matches and the zoom level falls within minzoom and maxzoom (this enhances the 
performance drstically if you provide large archives or mulitple archives for 
the same tile source - you could do the same using bounds).

Apparently this only works if you have some control over the archives used, 
i.e. you are able to add the metadata.

See attahced patch.

Original comment by osei...@gmail.com on 11 Jul 2013 at 2:35

Attachments: