Skip to content

OSM2XP 5 road network rules

32kda edited this page Apr 24, 2022 · 4 revisions

Important: OSM2XP 5.x is in alpha stage, and for now a work on it is frozen for now due to the lack of free time

OSM2XP 5 has a new ability - specifying a ruleset on JavaScript-based language to determine a path type constant based on OSM way tags. Example:

"Name","Rule","PathType"
"Motorway(3+ lanes)","item.highway=='motorway' && item.lanes>=3","100"
"Motorway(<=2 lanes)","item.highway=='motorway'","110"
"Motorway(link)","item.highway=='motorway_link'","120"
"Trunk road(3+ lanes)","item.highway=='trunk' && item.lanes>=3","100"
"Trunk road(<=2 lanes)","item.highway=='trunk'","110"
"Trunk road(link)","item.highway=='trunk_link'","120"

"Oneway road(2+ lanes)","(item.highway=='primary' || item.highway=='secondary' || item.highway=='tertiary') && item.oneway == 'yes' && item.lanes >= 2","24"
"Oneway road","['primary','primary_link','secondary','secondary_link','tertiary','tertiary_link'].indexOf(item.highway) > -1 && item.oneway == 'yes'","64"
"Primary road(2+ lanes)","item.highway=='primary' && item.lanes >= 2","14"
"Primary road","item.highway=='primary' || item.highway=='primary_link'","34"
"Secondary road(2+ lanes)","item.highway=='secondary' && item.lanes >= 2","14"
"Secondary road","item.highway=='secondary' || item.highway=='secondary_link'","34"
"Tertiary road(2+ lanes)","item.highway=='tertiary' && item.lanes >= 2","14"
"Tertiary road","item.highway=='tertiary' || item.highway=='tertiary_link'","34"
"Residential road(oneway)","item.highway=='residential' && item.oneway == 'yes'","68"
"Residential road","item.highway=='residential'","54"
"Living street(oneway)","item.highway=='living_street' && item.oneway == 'yes'","68"
"Living street","item.highway=='living_street'","58"
"Pedestrian","item.highway=='pedestrian'","70"
"Pedestrian","item.highway=='construction'","54"
"Unclassified/service road(oneway)","item.oneway == 'yes' && (item.highway=='unclassified' || item.highway == 'service')","60"
"Unclassified road","item.highway=='unclassified'","54"
"Service road","item.highway=='service' && item.access != 'no' && item.access != 'private'","58"

This code is placed into the file called like roads_city_eu.csv, where roads/railways is the path type, city/country means area type (refer other tutorials on how this is determined) and if suffix _eu is added - the this network is designed for EU area. If no _eu is present, this would be used for all other countries. There are 3 columns - rule name, rule JavaScript, code and resulting path code (integer number). Rules are matched from top to bottom, so if rules on lines 3,4 and 5 matches some way - path type from rule 3 would be used.

In the rule itself, item. is the special, "current" object name. This object has all of current way/relation properties as fields. For example, condition item.highway == 'primary' will be true (will matc) the way having highway=primary tag on OSM.

All rule csv files could be found under {osm2xp}/xplane folder, thanks Oliver (DerRoteBaron) for describing these rules and corresponding path types.