Marble/RoutingInstructions

From KDE Community Wiki
Revision as of 21:08, 4 April 2011 by Earthwings (talk | contribs) (svn => git)

The application routing-instructions converts a textual representation of a route (a list of waypoints, road names and other meta information) to driving instructions. It is distributed as a part of Marble and was formerly called gosmore-instructions. It can generate driving instructions for Gosmore, Routino and Monav (Monav from within Marble only).

Use Cases

  • Generate a human-readable textual representation of a route
  • Generation of driving instructions for Yours and similar web services
  • Driving instructions shown in Marble are generated by the same code that is used by the routing-instructions binary. Exceptions to this are online routers (OpenRouteService, Yours) which do not deliver enough information to generate driving instructions

Installation

The source code is distributed with Marble and can be compiled with cmake. The only dependency is Qt.

mkdir routing-instructions cd routing-instructions git clone git://anongit.kde.org/marble src mkdir build cd build cmake -DQTONLY=ON ../src make routing-instructions The binary now lies in src/routing-instructions/routing-instructions and is ready to use. You can also run make install to have it installed. Notice that make install would also build and install Marble. You can do a manual installation instead: sudo cp src/routing-instructions/routing-instructions /usr/local/bin/

Translations

The translation of driving instructions to a language other than english needs translation files. There is a bash script that automates the conversion for you: It downloads the latest translations for all languages supported by KDE, removes uneeded translations to keep the file size small and converts it to Qt's .qm translation format.

  1. Assuming you are in the build directory

cd .. cd src/tools/translations ./routing_instructions_i18n.bash

While downloading and converting files, output like this is generated: Processing translations, please wait. This can take some time... en_GB: 9 of 24 driving instructions translated es: 9 of 24 driving instructions translated et: 9 of 24 driving instructions translated gl: 9 of 24 driving instructions translated hr: 9 of 24 driving instructions translated nb: 10 of 10 driving instructions translated nds: 6 of 24 driving instructions translated nl: 24 of 24 driving instructions translated pt: 24 of 24 driving instructions translated pt_BR: 9 of 24 driving instructions translated sv: 24 of 24 driving instructions translated uk: 24 of 24 driving instructions translated x-test: 24 of 24 driving instructions translated zh_TW: 9 of 24 driving instructions translated Languages not yet translated:

af ar as ast be be@latin bg bn bn_IN br ca ca@valencia crh cs csb cy da de el 

eo eu fa fi fr fy ga gu ha he hi hne hsb hu hy ia id is it ja ka kk km kn ko ku lb lt lv mai ml mk mr ms mt ne nn nso oc or pa pl ps ro ru rw se si sk sl sr sr@ijekavian sr@ijekavianlatin sr@latin ta te tg th tr ug uz uz@cyrillic vi wa xh zh_CN zh_HK

Once finished, a number of routing-instructions_$lang.qm files lie in the current directory. To have the routing-instructions binary find them, they need to be in one of these directories:

  • /usr/share/marble/translations/
  • /path/to/routing-instructions/translations
  • The current working directory

A manual installation of these files thus can be done like this: sudo mkdir -p /usr/share/marble/translations sudo mv routing-instructions_*.qm /usr/share/marble/translations/

The routing-instructions binary chooses that file for translation whose language code matches the current locale. For example, when using LC_ALL="de_DE.UTF-8" it would try to load routing-instructions_de_DE.qm in one of the above directories. If it's not found, it falls back to routing-instructions_de.qm and finally uses the builtin english language.

Examples

A conversion with the output of a previous gosmore routing call in input.txt: $ routing-instructions input.txt [ 0 m ] Continue on Hermann-Schneider-Allee. Follow the road for 2.0 km. [2.0 km] Continue on Daxlander Straße. Follow the road for 1.0 km. [3.0 km] Turn right into Rheinhafenstraße. Follow the road for 1.5 km. [4.4 km] Turn left into Durmersheimer Straße. Follow the road for 60 m.

A conversion, overriding the system locale to translate to swedish: $ LC_ALL="sv" routing-instructions input.txt [ 0 m ] Fortsätt på Hermann-Schneider-Allee. Följ vägen 2.0 km. [2.0 km] Fortsätt på Daxlander Straße. Följ vägen 1.0 km. [3.0 km] Sväng åt höger till Rheinhafenstraße. Följ vägen 1.5 km. [4.4 km] Sväng åt vänster till Durmersheimer Straße. Följ vägen 60 m.

The conversion can also be called in pipe mode: $ QUERY_STRING="flat=49.0&flon=8.3&tlat=49.0&tlon=8.35&fastest=1&v=motorcar" \ gosmore gosmore.pak | LC_ALL="pt_BR" routing-instructions [ 0 m ] Siga em frente em Hermann-Schneider-Allee. Siga a estrada para a 2.0 km. [2.0 km] Siga em frente em Daxlander Straße. Siga a estrada para a 1.0 km. [3.0 km] Vire à direita em Rheinhafenstraße. Siga a estrada para a 1.5 km. [4.4 km] Vire à esquerda em Durmersheimer Straße. Siga a estrada para a 60 m.

The --csv and --dense options are useful to process the generated text further: $ LC_ALL="zh_TW" routing-instructions --csv input.txt 48.998184,8.299257,繼續開 Hermann-Schneider-Allee。 沿著路開到 2.0 km。 49.005632,8.322305,繼續開 Daxlander Straße。 沿著路開到 1.0 km。 49.007614,8.334716,右轉到 Rheinhafenstraße。 沿著路開到 1.5 km。 48.999764,8.349166,左轉到 Durmersheimer Straße。 沿著路開到 60 m。

See --help for other parameters.

Bugs and Limitations

  • Measurement units and monetary separators are not yet localized
  • Please report bugs at KDE Bugzilla