Open Street Map Tile Downloader

OpenTopoMap

When making maps a lot of Open Street Map based tile servers exists with the base maps and overlay maps. Also, a lot of tile download programs exist, like:

Why then another OSM Tile Downloader? I particularly like the OpenTopoMap maps.

opentopomap

However, recently the tile servers of OpenTopoMap changed to https instead of http. Even worse, they use self-signed certificates. None of the downloaders I found can cope with these OpenTopoMap https tile servers. I therefore wrote a Java program that is able to accept the non-signed certificates and can download from OpenTopoMap,

OsmTileDownloader

Download

Use and distribute the way you like.

Usage

Start with java -jar TileDownloader.jar (yes, you need a Java JRE or JDK)

You can enter up to three tile servers. For each server a thread is created, so three parallel downloads are executed. You can enter the plain URL, like: https://c.tile.opentopomap.org or a custom one, like http://abo.wanderreitkarte.de/$z/$x/$y.png/ticket/1234 required for example for the Reit- und Wanderkarte site. In the latter $z represents the zoom level, $x and $y the tile indices. During download they are replaced by the actual values.

The output directory is the directory where the downloaded tiles are stored. The program automatically generates the subdirectories like 17/60475/54357.png.

The default image is an image to be used if an image cannot be downloaded. At OpenTopoMap I found a lot of sea tiles non-existent, so I use following png (256×256):

default

The zoom level is the requested zoom level. Top left you can enter the lat and lon coordinates. Use for example OpenStreetMap export to select a bounding box and copy the coordinates.

Delay is a kind of throttling: it is the delay between subsequent requests to the same server.

With Taho.exe

I myself use the downloader in combination with Taho.exe. Taho first downloads the tiles and then creates the maps (in my case: for OziExplorer). However, when the tiles exist in the right directory, tiles are not downloaded again and the program starts building the maps (note: only when existing tiles are recent; when older than a couple of days, taho starts downloading them again). Roughly the process consists of following steps:

  1. Start taho.exe with the base map and overlay map selected (doesn’t matter which, we use the overlay as placeholder). Stop after a few seconds. Directory structure has been created now.
  2. Download the OpenTopoMap tiles with TileDownloader
  3. Copy the OpenTopoMap tiles to the overlay directory taho.exe created.
  4. Restart taho.exe and create the maps with the same basemap and overlay map tiles. Since the tiles are in place, taho.exe doesn’t download again

Service unavailable and retries

When downloading from OpenTopoMap often ‘503-Service Unavailable’ is encountered. Apparently, some kind of throttling kicks in when doing a lot of requests. Therefore the program executes up to 15 retries, with a back-off scheme (1 – 2 – 4 – 8 -16 – 32- 60 – 60 – 60 … seconds delay before subsequent retries). If a tile cannot be downloaded after retries the request is handed to one of the other servers. The program ceases to download from the malfunctioning server.

Another finding is that the number of retries increase with the number of servers (1, 2 or 3). Apparently the servers are behind a single load balancer executing the throttling… Therefore there is not much of an advantage of using multiple servers.

Final Notes

  • 29-03-2017: SSL Certificates at OpenTopoMap seem to have been improved and well signed now!
  • 29-03-2017: https://opentopomap.org or https://opentopomap.org/$z/$x.$y.png seem to be a working alternative for the a, b and c server. I guess https://a.tile.opentopomap.org,  https://b.tile.opentopomap.org and https://c.tile.opentopomap.org all end up at https://opentopomap.org: all sites end up at the same IP address.
  • 07-04-2017: No more tiles seem to be missing now, like before. ‘Empty sea’ tiles are also present.
  • 07-04-2017: Download speed seems to be ok now, or the throttling is less stringent. Far less ‘503-service unavailables’ encountered.