OpenStreetMap

OsmAnd - a worked example of a simple rendering style change

Posted by SomeoneElse on 6 December 2019 in English (English). Last updated on 14 August 2022.

Imagine I’ve just installed OsmAnd on an Android phone and want to change the rendering slightly.

For completeness, the OsmAnd version is 3.5.5, I downloaded it from Google Play, where it’s called “OsmAnd - Offline Travel Maps & Navigation”. The Android phone is a Blackberry DTEK50 (actually a badged Alcatel design) running Android 6.

I ran OsmAnd and skipped the initial download (because I’ve already got some .obf files to install), but you’ll probably want to download some local data.

I want to copy files to and from the device, so I’ll plug it into a PC. How you copy files depends on the OS on your PC. Next, plug the device in via USB and select “copy files via MTP” from the prompt that appears on the device (this actually varies by Android version, and what options are available to copy files to and from a device depend on that and the phone itself). A window showing an MTP connection to the device contents will probably appear - check you see something in there. If you don’t, unplug it and plug it in again.

I’m running Ubuntu Linux on the PC and want to copy files to and fro from the command line, so I’ll install something to allow me to do that, check that I can read something from the device, and unmount it again:

cd
mkdir mtp
sudo apt install jmtpfs
jmtpfs ./mtp
ls ./mtp
fusermount -u ./mtp

For me the “ls” above shows ‘Internal storage’. Before copying anything used by OsmAnd in the steps below I’ll make sure that it isn’t running on the phone. How to do this varies by phone - on mine it’s “menu” and then “close”.

Next, we’ll look at what maps are currently installed. How to do this varies by Android version, but this is how things appear on this Android 6 device:

ls -alt ./mtp/Internal\ storage/Android/data/net.osmand/files/

total 0
-rw-r--r--  1 ajtown ajtown 1585986668 Dec  6 19:47 Gb_england_europe.obf
drwxr-xr-x 11 ajtown ajtown          0 Dec  3 00:10 .
drwxr-xr-x  2 ajtown ajtown          0 Dec  3 00:10 backup
-rw-r--r--  1 ajtown ajtown        359 Dec  3 00:10 favourites.gpx
-rw-r--r--  1 ajtown ajtown        269 Dec  3 00:10 ind.cache
-rw-r--r--  1 ajtown ajtown    4413090 Dec  3 00:10 regions.ocbf
drwxr-xr-x  2 ajtown ajtown          0 Dec  3 00:10 roads
-rw-r--r--  1 ajtown ajtown   39985159 Dec  3 00:10 World_basemap_mini.obf
drwxr-xr-x  2 ajtown ajtown          0 Dec  3 00:10 fonts
drwxr-xr-x  2 ajtown ajtown          0 Dec  3 00:10 sounds
drwxr-xr-x  3 ajtown ajtown          0 Dec  3 00:10 tiles
drwxr-xr-x 13 ajtown ajtown          0 Dec  3 00:10 voice
drwxr-xr-x  4 ajtown ajtown          0 Dec  3 00:10 ..
-rw-r--r--  1 ajtown ajtown          0 Dec  3 00:10 .nomedia
drwxr-xr-x  2 ajtown ajtown          0 Dec  3 00:10 rendering
drwxr-xr-x  2 ajtown ajtown          0 Dec  3 00:10 routing
drwxr-xr-x  2 ajtown ajtown          0 Dec  3 00:10 tracks

Here’s the directory with the .xml file used for deciding how things in a “.obf” file appear on screen:

ls -alt ./mtp/Internal\ storage/Android/data/net.osmand/files/rendering

total 0
drwxr-xr-x 11 ajtown ajtown      0 Dec  3 00:10 ..
-rw-r--r--  1 ajtown ajtown 691532 Dec  3 00:10 default.render.xml
drwxr-xr-x  2 ajtown ajtown      0 Dec  3 00:10 .

We’ll take a copy of that locally to edit it, and then unmount it:

cp ./mtp/Internal\ storage/Android/data/net.osmand/files/rendering/default.render.xml .
fusermount -u ./mtp

At this point, it’s probably worth a look at the initial version of the default.render.xml file. It actually contains information about how something might appear depending on how a number of different flags are set (in that file you can see things like “nightMode”, “moreDetailed” and “baseAppMode” flags). To see an example of that look at this code - you can see how a bridleway might be rendered from zoom levels depending on various flags, all inside a top-level

<case minzoom="12" tag="highway" value="bridleway">

test. The last line of that section

<apply color_5="$bridlewayColor" pathEffect_5="4_2"/>

sets the colour to one defined above.

One of the simplest changes that it’s possible to make is simply changing the rendering colours.

Let’s make a simple series of changes from e.g.

    <renderingAttribute name="heathColor">
            <case attrColorValue="#d7ebba"/>
    </renderingAttribute>

to

    <renderingAttribute name="heathColor">
            <case attrColorValue="#E6E8C5"/>
    </renderingAttribute>

(and a number of similar ones to match the less “in your face” colours here.

The resulting XML file looks like this.

Stop OsmAnd on the device, copy the new file to the phone, and unmount it:

jmtpfs ./mtp
cp ~/src/osmand_files/default.render.xml ./mtp/Internal\ storage/Android/data/net.osmand/files/rendering/default.render.xml 
fusermount -u ./mtp

Here’s what it looked like before, and after: before after

Location: Osmotherley, North Yorkshire, England, United Kingdom

Login to leave a comment