GPX tracks colouring... suggestion

3,236 views
Skip to first unread message

Andrew Davie

unread,
Mar 8, 2016, 6:33:19 PM3/8/16
to Osmand
I am aware of the XML configuration for GPX track visuals, and that works well enough.

I was thinking how some GPX tracks I'd like to have one colour, some another colour (for example, coloured by who gave them to me).  Some I would like wide and highly visible, and some just very thin lined. Perhaps by how much I like the particular track.  So, obviously OsmAnd doesn't have a configuration interface for GPX colours/widths and it's just a single global setting in the XML.  But I would like to suggest a quick'n'dirty that would give the capability.

That is, if the filename of the GPX track included colour and line information, that would be easy enough to read and set when the track is loaded/displayed.

Something like instead of 'track.gpx' it could be 'track#FF00EE80FF.gpx'  to indicate the colour of the track.  The colour could easily be recognised by OsmAnd and stripped from the track name before display in the interface.  This would give us the ability to have coloured tracks at very little cost to the developers. Similarly, the track width could also be encoded into the file name. With this method, all existing tracks would work exactly the same, but we could now configure individual tracks if required.

I'd like to get up and running with OsmAnd development myself, but fear that this might take me some time to get my head around. 

sympa

unread,
Mar 10, 2016, 2:59:01 PM3/10/16
to Osmand
Probably not much more difficult to add this in the display function. Just an item with color, and when tapped a color/width to choose from. Each displayed track gets that color, and the color is probably remembered for later use.

That said I quite like Osmand. It has too many functions perhaps, not too few ;)

Andrew Davie

unread,
Mar 14, 2016, 7:03:30 AM3/14/16
to Osmand
Having spent some time preparing to implement the feature/capability I have suggested in the post beneath, I have found that this is actually already implemented in OsmAnd.  I am not aware of documentation saying so, but the source code was enough for me to see that if you add an 'extensions' group to any .gpx file, then you can specify the gpx colour in there.  For example, inside a gpx... 

                <extensions>

                <color>#802040FF</color>

                </extensions>


That's enough to colour the track (with alpha) when it's shown on the map.

This seems to work for me, but it was a bit of trial and error so hopefully this is the correct way to do it.

Wahoo!

P Wat

unread,
Mar 15, 2016, 9:20:34 AM3/15/16
to Osmand
There is also a way to turn the solid coloured line into dotted. - Very useful because you can then see the nature (surface/width/category) of the road/way you are about to follow.
Paul W

Andrew Davie

unread,
Mar 28, 2016, 6:52:29 AM3/28/16
to osm...@googlegroups.com
I did have quite some trouble setting up OsmAnd, despite claims it’s simple.
So, here are step by step instructions that I’ve succeeded with several times.

I used Android Studio to setup the SDK for the system
I have API 23 installed (6.0 Marshmallow)

You MUST use Java JDK 7, so get that installed

You MUST use NDK r10.
See http://pnsurez.blogspot.com.au/2015/07/download-android-ndk-tools.html for download links.

This particular NDK (r10) is *not* setup by Android Studio, so do that manually and set ANDROID_NDK (see below) to point to it.

Once you’ve done those installs, setup your environment variables for bash

I modified my ~/.bash_profile to contain the following environment variables
------
export ANDROID_SDK=/Users/boo/Library/Android/sdk
export ANDROID_NDK=/Users/boo/Documents/software/android-ndk-r10e
export ANDROID_HOME=/Users/boo/Library/Android/sdk
export JAVA_HOME=$(/usr/libexec/java_home -v 1.7)
------

The ANDROID_SDK and ANDROID_HOME are where Android studio placed stuff

Obviously you will need to change these directories to reflect where you have stuff on your system.

The JAVA_HOME is hopefully auto-configuring, so use that line as-is.

Your new environment variables won’t take effect until you start a new bash/console session so do that now.
Now we can move onto the source code.

Let’s start with a base directory to put it all in..

mkdir Osmand

cd Osmand

download the resources….
git clone https://github.com/osmandapp/OsmAnd-resources.git
This will create Osmand-resources directory
It needs to be renamed
mv Osmand-resources/ resources

Now we grab the source code
git clone https://github.com/osmandapp/Osmand.git

at this point we hopefully have the following structure

Osmand
- Osmand
- resources

cd Osmand
./gradlew —refresh-dependencies clean assembleFullLegacyFatDebug

If all goes OK, it will take ages to build but eventually BUILD SUCCESSFUL.

OK, that’s the command line working, let’s get to Android Studio
We should see a .apk file or two in
Osmand/OsmAnd/build/outputs/apk

Now let’s get it all working in Android Studio
Open Android Studio
Import grade project from the Osmand directory hanging off the root directory where you started
e.g., Osmand/Osmand
click on the project tab far left and open under Gradle Scripts the build.grade for module Osmand-SRTMPlugin
change the dependencies at the bottom to this..

dependencies {
compile "com.android.support:appcompat-v7:23.0.+"
}
Under the “Build Variants” tab, select OsmAnd module, change to
FreeLegacyFatDebug


Now we need to tell Android Studio to use the correct SDK and NDK
Go ‘Files/Project Structure’ and select SDK location tab
You need to setup SDK, NDK and Java. Here are mine - yours will be a bit different, but you get the basic idea...

Java JDK —> /Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
Android SDK —> /Users/boo/Library/Android/sdk (this is where Android Studio put it)
Android NDK —> /Users/boo/Documents/software/android-ndk-r10e (this is the NDK I installed manually)

obviously /Users/boo is my machine - so get those paths right for your machine/user and you should be good to go.

Now it should build and download to your device/emulator whenever you select
“Run/Debug ‘OsmAnd’”

Good luck!




Andrew Davie

unread,
Mar 28, 2016, 7:21:43 AM3/28/16
to osm...@googlegroups.com
Note: my silly mail program has replaced two dashes with a long dash in the instructions below
The line in question should be
./gradlew --refresh-dependencies clean assembleFullLegacyFatDebug
> --
> You received this message because you are subscribed to the Google Groups "Osmand" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to osmand+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

BL

unread,
Apr 13, 2016, 2:58:24 PM4/13/16
to Osmand
Hi Paul,

I'm curious about how you turn GPX lines from solid to dotted ones.  My goal is to tweak my GPX files using extensions group (thanks Andrew), not the osmand default rendering XML file.

Benoit

Andrew Davie

unread,
Apr 14, 2016, 7:07:07 PM4/14/16
to osm...@googlegroups.com
Don’t forget: tracks can be transparent - perhaps a better way than seeing what they overlay than using dotted lines.
The first two “numbers” in the colour give the transparency.



BL

unread,
Apr 15, 2016, 11:31:06 AM4/15/16
to Osmand
My goal is to "highlight" GPX stuff on the map.  I work for a tourism board and planning to supply GPX files (or any open standard that would best do the job) for each of our official touristic routes.  These files should contain both route trace and symbol for each touristic amenity within a given corridor along this trace.  In an ideal world, each amenity symbol would be "clickable" to show basic information about this place (name, type, address, phone...) within a popup bubble or so (KML/KMZ may be a better format for that, but it seems that osmand can't deal with those).  Osmand should also propose to navigate the user to this waypoint.  Any suggestion to acheive that using osmand?

About GPX transparency capability, it may be easier to manage if those files were treated as map overlays?

P Wat

unread,
Apr 15, 2016, 1:36:13 PM4/15/16
to Osmand
Hi BL - Sorry if I seem to have ignored your question.  I've been incommunicado.  If I remember correctly it was probably Poutnic who gave me a file to do dotted tracks.  I'll trawl back and let you know how/who.  Might be a day or two.
Paul W

P Wat

unread,
Apr 18, 2016, 10:18:49 AM4/18/16
to Osmand
HI BL
You had asked about how to turn GPX lines from solid to dotted ones.
Here is some material which may help, but note it is rather old and may have been superseded, or may clash with more recent versions of OsmAnd.
I had tried the dotted line back in early 2015, but have more recently been putting up with the solid purple.  I would welcome an effective way of being able to render the solid purple line as something more see-through - Dotted could be best because you can then see the nature of the otherwise-hidden road/ground beneath it.

See the discussion about Jan van Bekkum’s file in -

https://groups.google.com/forum/#!searchin/osmand/purple$20line/osmand/LnR2qaM9Jg0/ix8vXUIgrmkJ

And some follow-up material - from 8th April 2015 in here -

https://groups.google.com/forum/#!searchin/osmand/make$20your$20own$20render/osmand/B15t5obhars/zEwzC8J4YwQJ

 

Good luck
Paul W

BL

unread,
Apr 18, 2016, 1:24:25 PM4/18/16
to Osmand
Thank you Paul for taking time to share those tips with me.  No doubt, changing the behavior of osmand through "render.xml" files opens a broad palette of possibilities, as Andrew recently demonstrated on YouTube.  ;-)    I read those threads a few days ago before posting.  Unfortunately, I'm rather looking for a GPX driven customization, using the stock rendering system of osmand.  Reason is, tourists I want to supply GPX tracks to are not so technophiles, so I’d prefer avoid asking them to tweak osmand configuration.

Also, custom line rendering is more an accessory than a mandatory requirement for my project.  More essential to me is the ability to customize GPX contained waypoints in order to display specific graphic symbols along with basic information when a user selects one (name, type, address, phone...).  I still have to experiment and figure out how to do it using GPX files, if even workable.

Benoit
Message has been deleted

Andrew Davie

unread,
Apr 22, 2016, 8:14:47 PM4/22/16
to osm...@googlegroups.com
I implemented such a capability (a width multiplier) but it did not make it into the codebase.
I think it’s a good idea to allow it to be done this way because it lets you colour and scale (width) of individual segments of tracks.
However, this is going to be implemented in some other way via UI, as far as I understand.



On 23 Apr 2016, at 3:09 AM, timothy brink <turtl...@gmail.com> wrote:

Wow, this worked perfectly.  Any idea on how to change the width?

Wim Peeters

unread,
Jan 6, 2017, 5:33:55 AM1/6/17
to Osmand

Hello

As reply on the message of Andrew Davie:

I have a feature request for OSMAND+ 2.5.4 for colors on the screen.
The thing is, I use it on my mountain bike and I follow a track which I load with a GPX file. In the 2.5.4 version I can set the colors/thickness of the GPX file easily, nice, because I want these track default on THICK RED lines when I load an open these.
However it is very handy to also log/record the tracks and have them on screen also in THICK BLUE setting. The reason is that I can see where I have been already, specially when riding tracks which cross themselves or are very near to each other. 
But the thing is that OSMAND+ does not make difference between these two GPX, the setting is the same so each time I have to change it by hand, each time I start a recording I have to change the recorded track to THICK/BLUE

What I would like is a separate setting for:
1) GPS tracks loaded
2) GPS tracks recorded

gr Wim

nickjoh...@gmail.com

unread,
Jan 6, 2017, 10:09:51 AM1/6/17
to Osmand

I realise this isn't convenient, but you can edit your recorded GPX files to specify a colour int he files themselves.

OsmAnd will then always display the tracks in the specified colour.

See my comment on this issue for instructions:
https://github.com/osmandapp/Osmand/issues/3345

Nick

Wim Peeters

unread,
Jan 6, 2017, 3:57:57 PM1/6/17
to Osmand
Yes I know, nut I have go through these steps each and every time. Most of us just want one track on the screen and one recorded track as you bike. So it would be nice to have a default color setting for both, one orf rogrammed. rachIk nd ond orf ecording track, so you can easily see the difference on the screen. Without making the setting for each trach each time you go out.

In your example you will have to do this for each track, it could be default.

Gteeting Wim.

Scott Boag

unread,
Apr 11, 2017, 10:33:19 AM4/11/17
to Osmand
I don't see a build.gradle for Osmand-SRTMPlugin.  I do have a build.gradle for Osmand, which has some complex dependencies.  Should I replace those dependencies?  Or just add the new one??

Dan Toderici

unread,
Mar 3, 2018, 8:12:41 AM3/3/18
to Osmand
Android Studio, when importing the project made out of these subprojects, will show you only the build.gradle for the main ones. Try finding in project view the OSMAnd container, then in plugins folder there is Osmand-SRTMPlugin that has a build.gradle inside .
Reply all
Reply to author
Forward
0 new messages