logo separator

[mkgmap-dev] Ranking of relations

From mike at tvage.co.uk mike at tvage.co.uk on Sat Jan 27 15:11:04 GMT 2024

HI Bernard,


I can’t see why bicycle routes should be displaying in the wrong order, but if an MTB route runs along a bicycle route and its relation is processed after the bicycle one, I think the route value will be changed from bicycle to mtb. I suggest using add instead of set on the relation statement for mountain bike routes:


type=route & route=mtb
            {add route='${route}'; set route_mtb_name='$(route_mtb_name),${name}'|'${name}'; set route_mtb_ref='$(route_mtb_ref),${ref}'|'${ref}';}




From: Bernard Mai <bm.ffb at gmx.de> 
Sent: 26 January 2024 10:50
To: mkgmap-dev at lists.mkgmap.org.uk
Subject: [mkgmap-dev] Ranking of relations


Dear all,
I want to generate an overlay map to be used as additional layer on a Garmin watch. This layer can be turned on/off on the watch and should show only bicycle routes (route=bicycle and route=mtb).
As most routes in openstreetmap are defined as relations I am using the following rules in my bike-routes style:

relations (file)
# Route relations as additional transparent layer for:
#   bicycle
#   mtb

# bicycle routes 
type=route & route=bicycle
            {set route='${route}';set route_name='$(route_name),${name}'|'${name}';set route_ref='$(route_ref),${ref}'|'${ref}';}
type=route & route=bicycle & network=icn            {apply {set route_icn=yes;}}
type=route & route=bicycle & network=ncn            {apply {set route_ncn=yes;}}
type=route & route=bicycle & network=rcn            {apply {set route_rcn=yes;}}
type=route & route=bicycle & network=lcn            {apply {set route_lcn=yes;}}

# mountainbike routes 
type=route & route=mtb
            {set route='${route}'; set route_mtb_name='$(route_mtb_name),${name}'|'${name}'; set route_mtb_ref='$(route_mtb_ref),${ref}'|'${ref}';}

lines (file)
# bicycle routes
route=bicycle & route_icn=yes    {name '${route_ref}'}                                                    [0x10f01 resolution 18-22 continue]
route=bicycle & route_icn=yes    {name '${route_name} (${route_ref})'|'${route_name}'|'${route_ref}'}    [0x10f02 resolution 23-24]

route=bicycle & route_ncn=yes                                                                            [0x10f01 resolution 20-22 continue]
route=bicycle & route_ncn=yes    {name '${route_ref}'}                                                    [0x10f02 resolution 23 continue]
route=bicycle & route_ncn=yes    {name '${route_name} (${route_ref})'|'${route_name}'|'${route_ref}'}    [0x10f02 resolution 24]

route=bicycle & route_rcn=yes                                                                            [0x10f03 resolution 20-22 continue]
route=bicycle & route_rcn=yes    {name '${route_ref}'}                                                    [0x10f04 resolution 23 continue]
route=bicycle & route_rcn=yes    {name '${route_name} (${route_ref})'|'${route_name}'|'${route_ref}'}    [0x10f04 resolution 24]

route=bicycle & route_lcn=yes    {name '${route_name} (${route_ref})'|'${route_name}'|'${route_ref}'}    [0x10f05 resolution 24]

# mtb routes
route=mtb     {name '${route_mtb_ref}'}                                                                    [0x10f06 resolution 23 continue]
route=mtb     {name '${route_mtb_name} (${route_mtb_ref})'|'${route_mtb_name}'|'${route_mtb_ref}'}        [0x10f06 resolution 24]

In general, these routes are drawn by mkgmap and I am able to generate an overlay map, but sometimes a route with "lower" priority (i. e. a route=mtb) hides a route with "higher" priority. In other words, I would like to show the routes in a ranking: The routes tagged with network=icn should be on top, followed by network=ncn and so on. The route=mtb should be only shown, if no other bicycle route is on the same way.
Is this possible to achieve with mkgmap alone? Or do I need some sort of additional script to rank the relations before rendering them with mkgmap?
I have read something, that the draw order depends on the ID of the relation and mkgmap renders the lower IDs first. But what about the higher relation IDs? It looks like ways tagged from the relation only get the tags from the relation with the lowest ID. Is this correct?
Does anybody have an idea, how this could be overcome?

Way ID has 3 bicycle relevant relations: relation IDs 2119154, 9623717,2956920. With the style from above only the last one (relation ID 2956920, route=mtb) is shown although the second one (relation ID 9623717, network=icn) would be desired as it is an international bicycle route.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.mkgmap.org.uk/pipermail/mkgmap-dev/attachments/20240127/46b4a643/attachment.html>

More information about the mkgmap-dev mailing list