Geshode
Geshode

Reputation: 3764

osmdroid: Tile server which allows bulk download

I am working on an application, for which I need to be able to use map data, while offline. I have looked up how to use the CacheManager and how to download tiles referencing the SampleCacheDownloader.java.

I am using the following code to download the tiles:

CacheManager cMgr = new CacheManager(map);
BoundingBox bBox = cMgr.extendedBoundsFromGeoPoints(currentGeoPoints, 16);

cMgr.downloadAreaAsync(this, bBox, 16, 21, new CacheManager.CacheManagerCallback() {
    @Override
    public void onTaskComplete() {
    }

    @Override
    public void updateProgress(int progress, int currentZoomLevel, int zoomMin, int zoomMax) {
    }

    @Override
    public void downloadStarted() {
    }

    @Override
    public void setPossibleTilesInArea(int total) {
    }

    @Override
    public void onTaskFailed(int errors) {
    }
});

The code works, as in starting the download. But all the tile servers, which are included in the TileSourceFactory class either throw the TileSourcePolicyException "This online tile source doesn't support bulk download" (e.g. MAPNIK and WIKIMEDIA) or fail to get the tiles, because they don't exist for the set zoom levels (e.g. USGS_SAT and USGS_TOPO).

So my question is, are there other publicly available tile servers or do I have to set up my own to be able to download tiles in bulk? Or do I have the completely wrong approach to caching the tiles included in a bounding box with set zoom levels?

Upvotes: 0

Views: 364

Answers (1)

Andrei Izbiakov
Andrei Izbiakov

Reputation: 1

I had the same issue after I updated osmdroid-android lib from 5.6.5 to 6.1.18.

It look like the guys from osm decided to reduce the load to main server and force the map sources policies. So, now the bulk tiles download is forbidden for some tile sources. But, the old version still work. I think it means that basically the old urls are valid and allow bulk download and it is not against the policy.

I guess you can just configure a tile source similar how it was in old library:

    public static ITileSource MAP_DATA_SOURCE = new XYTileSource("Mapnik",
        0, 19, 256, ".png", new String[] {
        "http://a.tile.openstreetmap.org/",
        "http://b.tile.openstreetmap.org/",
        "http://c.tile.openstreetmap.org/" },
        "© OpenStreetMap contributors");

Upvotes: 0

Related Questions