XML Configuration Files
New in version 1.4 of Routino is the use of configuration files to allow more information to be provided to the programs at run-time. The configuration files that are used are:- Tagging transformation rules for the planetsplitter program.
- Routing profiles for the router program.
- Output translations for the router program.
Tag Transformation Rules
The default name of the tagging transformation rules XML configuration file is tagging.xml in the same directory as the generated database files. Other filenames can be specified on the command line using the --tagging option. When processing the input it is possible to have a different set of tagging rules for each file; for example different rules for different countries.The tagging rules allow modifying the highway tags in the source file so that the routing can be performed on a simpler set of tags. This removes the special case tagging rules from the source code into the configuration file where they can be easily modified. Part of the provided tagging.xml file showing the rules for motorway_link and motorway highway types.
<?xml version="1.0" encoding="utf-8"?> <routino-tagging> <way> <if k="highway" v="motorway_link"> <set v="motorway"/> </if> <if k="highway" v="motorway"> <output k="highway"/> <output k="motorcycle" v="yes"/> <output k="motorcar" v="yes"/> <output k="goods" v="yes"/> <output k="hgv" v="yes"/> <output k="psv" v="yes"/> <output k="paved" v="yes"/> <output k="multilane" v="yes"/> <output k="oneway" v="yes"/> <unset k="highway"/> </if> ... </way> </routino-tagging>The rules all have the same format; an if or ifnot element at the top level for matching the input and some other elements inside to be used if there was a match.
Within the if and ifnot rules any of the rules can be used. These are if, ifnot, set, unset, output or logerror elements.
The rules for matching the if or ifnot elements are the following:
- An if rule that has both k and v specified is only matched if a tag exists in the input that matches both.
- An if rule that has only the k attribute is matched if a tag with that key exists.
- An if rule that has only the v attribute is matched for each tag with that value (i.e. the contents may be used more than once).
- An if rule that has neither attribute specified always matches.
- An ifnot rule that has both k and v specified is only matched if no tag exists in the input that matches both.
- An ifnot rule that has only the k attribute is matched only if no tag with that key exists.
- An ifnot rule that has only the v attribute is only matched if no tag with that value exists.
- An ifnot rule that has neither attribute specified never matches.
For set, unset, output or logerror elements inside of an if rule an unspecified value for the k or v attribute is replaced by the values from the tag that matched the outer if rule. This makes it simple to delete tags that match a particular rule without having to specify the parameters more than once. For elements inside of an ifnot element an unspecified value for the k or v attribute is replaced by the values from the outer ifnot rule. This means that either the outer ifnot element or the inner element must specify both k and v attributes between them. For nested if or ifnot elements the outer k and v attributes are not inherited by the inner elements.
The set and unset elements either create or delete a tag from the input data that was read from the file. If the set element is used and the tag already exists then it is modified. The output element adds a tag to the set that will be used by Routino to determine the data properties. If the output element is used and the tag already exists then it is modified.
The logerror element will cause an error message to be added to the error log file that reports that the key and attribute combination are not recognised. If the k attribute is specified but not the v attribute then the tag value that matches the specified key is looked up and used. An additional message attribute can be specified to be printed at the end of the logged error.
The default logged error message is:
Node XXX has an unrecognised tag 'key' = 'value' (in tagging rules); ignoring it.
The specified message attribute will replace the final part of the logged error.
Routing Profiles
The default name of the routing profiles XML configuration file is profiles.xml in the same directory as the database files. Other filenames can be specified on the command line using the --tagging option.The purpose of this configuration file is to allow easy modification of the routing parameters so that they do not all need to be specified on the command line. In versions of Routino before version 1.4 the default routing parameters (preferred highways, preferred speeds etc) were contained in the source code, now they are in a configuration file. When calculating a route the --profile option selects the named profile from the configuration file.
Part of the provided profiles.xml file showing the parameters for transport on foot is shown below:
<?xml version="1.0" encoding="UTF-8" ?> <routino-profiles> <profile name="foot" transport="foot"> <speeds> ... <speed highway="cycleway" kph="4" /> <speed highway="path" kph="4" /> <speed highway="steps" kph="4" /> </speeds> <preferences> ... <preference highway="cycleway" percent="95" /> <preference highway="path" percent="100" /> <preference highway="steps" percent="80" /> </preferences> <properties> <property type="paved" percent="50" /> <property type="multilane" percent="25" /> <property type="bridge" percent="50" /> <property type="tunnel" percent="50" /> ... </properties> <restrictions> <oneway obey="0" /> <weight limit="0.0" /> <height limit="0.0" /> <width limit="0.0" /> <length limit="0.0" /> </restrictions> </profile> <profile name="horse" transport="horse"> ... </profile> ... </routino-profiles>
Output Translations
The default name of the output translations XML configuration file is translations.xml in the same directory as the database files. Other filenames can be specified on the command line using the --translations option.The generated HTML and GPX output files (described in the next section) are created using the fragments of text that are defined in this file. Additional languages can be added to the file and are selected using the --language option to the router. If no language is specified the first one in the file is used.
Part of the provided translations.xml file showing some of the English language (en) translations is shown below:
<?xml version="1.0" encoding="utf-8"?> <routino-translations> <language lang="en"> ... <turn direction="-4" string="Very sharp left" /> <turn direction="-3" string="Sharp left" /> <turn direction="-2" string="Left" /> ... <heading direction="-4" string="South" /> <heading direction="-3" string="South-West" /> <heading direction="-2" string="West" /> ... <route type="shortest" string="Shortest" /> <route type="quickest" string="Quickest" /> <output-html> ... </output-html> <output-gpx> ... </output-gpx> </language> </routino-translations>