For some time now, my PCDB Waypoints app has been failing to retrieve map tiles from the default OpenStreetMap server MapNik.  It looked at first as though the problem was with the app, but after lots of investigation it became apparent that the issue was rather more deepseated.  Deep down in the OpenStreetMap website is a statement that can block apps that appear to be making excessive demands on their servers.  Thinking that PCDB Waypoints may have been blocked in this way, I looked for alternatives and found one in MapQuest.  Tiles from that website displayed OK, so obviously the app software wasn't at fault.  However, although MapQuest says that is uses tiles from OpenStreetMap, this isn't actually the case and some of the finer details from OpenStreetMap (such as lighthouses!) was missing.

Further investigation in OSMDroid itself turned up the news that it wasn't PCDB Waypoints that had been blocked by, but a widget called the Apache HTTP Client.  This is used by default in all OSMDroid apps, and it was the cumulative effect of all OSMDroid instances that was overloading OpenStreetMap and which had been blocked.

Even further investigation disclosed that this issue had recently been addressed by OSMDroid, and a fix (Patch 515) was available. The effect of this was to put a string such as "osmdroid(PCDB Waypoints)" in each HTTP call, so that OpenStreetMap could differentiate between all the various OSMDroid apps out there in the market, and only block those that were truly at fault.

However, this fix wasn't available in the latest OSMDroid download (Version 4.0), and I could only apply it if I could get hold of the source code and incorporate this into the app.  There's nothing wrong with this; it's an integral part of the OSM philosophy that developers should be able to do this, and it's perfectly easy to download a .jar file containing all the source code of Version 4.0.  It's something I've been planning to do for some time, but to date I've always been able to make changes by including individual top-level code and adapting it as appropriate.  The code affected by Patch 515 is deep down in the workings of OSMDroid, and I couldn't apply the patch without downloading the whole caboodle.

Downloading it was one thing.  Incorporating it into PCDB Waypoints was another, and took a large part of today.  But eventually I managed it, compiled the app, installed it on my tablet and checked that I could use the MapQuest tile server OK.

Once that was achieved, I could then apply Patch 515, compile it, install it, and Hey Presto! MapNik tiles started to display again.

A very satisfactory outcome.

As I indicated above, I've been incorporating modified versions of some OSMDroid code into my app for some time.  Now that I've got the whole development working, I can start making these available to other users if they're interested.  For example, there's a version of IconOverlay that has a "MinZoomLevel" parameter, so the Icon isn't displayed at low zoom levels.  And a version of ItemizedIconOverlay that exploits this feature.  There are similar extensions to PathOverlay, a Lat/Lon grid overlay, and others.


Leave a Reply.