Marble/RoutingInstructions: Difference between revisions
Earthwings (talk | contribs) (svn => git) |
(Update configure flag) |
||
(8 intermediate revisions by 3 users not shown) | |||
Line 9: | Line 9: | ||
The source code is distributed with Marble and can be compiled with cmake. The only dependency is Qt. | The source code is distributed with Marble and can be compiled with cmake. The only dependency is Qt. | ||
< | <syntaxhighlight lang="bash"> | ||
mkdir routing-instructions | mkdir routing-instructions | ||
cd routing-instructions | cd routing-instructions | ||
Line 15: | Line 15: | ||
mkdir build | mkdir build | ||
cd build | cd build | ||
cmake - | cmake -DWITH_KF5=FALSE -DBUILD_MARBLE_TOOLS=ON ../src | ||
make routing-instructions | make routing-instructions | ||
</ | </syntaxhighlight> | ||
The binary now lies in | The binary now lies in tools/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: | ||
< | <syntaxhighlight lang="bash"> | ||
sudo cp | sudo cp tools/routing-instructions/routing-instructions /usr/local/bin/ | ||
</ | </syntaxhighlight> | ||
== Translations == | == 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. | 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. | ||
< | <syntaxhighlight lang="text"> | ||
# Assuming you are in the build directory | # Assuming you are in the build directory | ||
cd .. | cd .. | ||
cd src/tools/translations | cd src/tools/translations | ||
./routing_instructions_i18n.bash | ./routing_instructions_i18n.bash | ||
</ | </syntaxhighlight> | ||
While downloading and converting files, output like this is generated: | While downloading and converting files, output like this is generated: | ||
< | <syntaxhighlight lang="text"> | ||
Processing translations, please wait. This can take some time... | Processing translations, please wait. This can take some time... | ||
en_GB: 9 of 24 driving instructions translated | en_GB: 9 of 24 driving instructions translated | ||
Line 56: | Line 56: | ||
sr@ijekavian sr@ijekavianlatin sr@latin ta te tg th tr ug uz uz@cyrillic vi wa | sr@ijekavian sr@ijekavianlatin sr@latin ta te tg th tr ug uz uz@cyrillic vi wa | ||
xh zh_CN zh_HK | xh zh_CN zh_HK | ||
</ | </syntaxhighlight> | ||
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: | 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: | ||
Line 64: | Line 64: | ||
A manual installation of these files thus can be done like this: | A manual installation of these files thus can be done like this: | ||
< | <syntaxhighlight lang="bash">sudo mkdir -p /usr/share/marble/translations | ||
sudo mv routing-instructions_*.qm /usr/share/marble/translations/ | sudo mv routing-instructions_*.qm /usr/share/marble/translations/ | ||
</ | </syntaxhighlight> | ||
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. | 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. | ||
Line 72: | Line 72: | ||
== Examples == | == Examples == | ||
A conversion with the output of a previous gosmore routing call in input.txt: | A conversion with the output of a previous gosmore routing call in input.txt: | ||
< | <syntaxhighlight lang="bash">$ routing-instructions input.txt | ||
[ 0 m ] Continue on Hermann-Schneider-Allee. Follow the road for 2.0 km. | [ 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. | [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. | [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. | [4.4 km] Turn left into Durmersheimer Straße. Follow the road for 60 m. | ||
</ | </syntaxhighlight> | ||
A conversion, overriding the system locale to translate to swedish: | A conversion, overriding the system locale to translate to swedish: | ||
< | <syntaxhighlight lang="bash">$ LC_ALL="sv" routing-instructions input.txt | ||
[ 0 m ] Fortsätt på Hermann-Schneider-Allee. Följ vägen 2.0 km. | [ 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. | [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. | [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. | [4.4 km] Sväng åt vänster till Durmersheimer Straße. Följ vägen 60 m. | ||
</ | </syntaxhighlight> | ||
The conversion can also be called in pipe mode: | The conversion can also be called in pipe mode: | ||
< | <syntaxhighlight lang="bash">$ 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 | 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. | [ 0 m ] Siga em frente em Hermann-Schneider-Allee. Siga a estrada para a 2.0 km. | ||
Line 94: | Line 94: | ||
[3.0 km] Vire à direita em Rheinhafenstraße. Siga a estrada para a 1.5 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. | [4.4 km] Vire à esquerda em Durmersheimer Straße. Siga a estrada para a 60 m. | ||
</ | </syntaxhighlight> | ||
The --csv and --dense options are useful to process the generated text further: | The --csv and --dense options are useful to process the generated text further: | ||
< | <syntaxhighlight lang="bash">$ LC_ALL="zh_TW" routing-instructions --csv input.txt | ||
48.998184,8.299257,繼續開 Hermann-Schneider-Allee。 沿著路開到 2.0 km。 | 48.998184,8.299257,繼續開 Hermann-Schneider-Allee。 沿著路開到 2.0 km。 | ||
49.005632,8.322305,繼續開 Daxlander Straße。 沿著路開到 1.0 km。 | 49.005632,8.322305,繼續開 Daxlander Straße。 沿著路開到 1.0 km。 | ||
49.007614,8.334716,右轉到 Rheinhafenstraße。 沿著路開到 1.5 km。 | 49.007614,8.334716,右轉到 Rheinhafenstraße。 沿著路開到 1.5 km。 | ||
48.999764,8.349166,左轉到 Durmersheimer Straße。 沿著路開到 60 m。 | 48.999764,8.349166,左轉到 Durmersheimer Straße。 沿著路開到 60 m。 | ||
</ | </syntaxhighlight> | ||
See --help for other parameters. | See --help for other parameters. |
Latest revision as of 11:19, 21 October 2016
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 -DWITH_KF5=FALSE -DBUILD_MARBLE_TOOLS=ON ../src
make routing-instructions
The binary now lies in tools/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 tools/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.
# 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