Framstag / libosmscout

Libosmscout is a C++ library for offline map rendering, routing and location lookup based on OpenStreetMap data
Other
259 stars 81 forks source link

Make use of LocaleStringToUTF8String and vice versa in Demos #330

Open Framstag opened 7 years ago

Framstag commented 7 years ago

Make use of above methods to convert console input to database string (UTF-8) and vice versa where appropriate. See LocationLookup.cpp for an example.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/45418421-make-use-of-localestringtoutf8string-and-vice-versa-in-demos?utm_campaign=plugin&utm_content=tracker%2F22109906&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F22109906&utm_medium=issues&utm_source=github).
Framstag commented 7 years ago

Adapted the LocationXXX demos. Routing.cpp ist still missing (and the most complex one).

@rinigus: You mentioned, that you have some location aware code for generating routing description. Can you link the source? Perhaps the same code fragment can help here, too. Else I would have to spread UTF8StringToLocaString calls all over the code.

rinigus commented 7 years ago

Hi!

routing is, indeed, the most complicated case. It would be great if we can use the same source code and translations for it. So, I would give a bit more info regarding how its done in OSM Scout Server and let's see how we can reuse it as much as possible. Note that for translators its rather large job as well and we should reuse this resource as well.

Routing manoeuvrers description is based on Routing demo and Mapzen Valhalla's API. Choice of Mapzen API was based on the fact that it had a very good description and was already supported by the only app on Sailfish that provides you with routing live support. API is at https://mapzen.com/documentation/mobility/turn-by-turn/api-reference/#trip-legs-and-maneuvers and, in addition to the instruction, you have pre- and post-instructions. I don't have pre- and post- instructions for all cases, but some do. I think we could immediately try to get something similar in the Routing demo as well and it could also used by @Karry's OSM Scout - he is working on routing, as far as I understood from his latest release notes. These pre- and post- instructions are probably important when you want to hook spoken instructions with the app.

An example output of OSM Scout Server is at https://github.com/rinigus/osmscout-server/blob/master/examples/route.json#L3302 , highlighted case with pre-instruction.

Manoeuvres description are filled using the same loop as in Routing demo (https://github.com/rinigus/osmscout-server/blob/master/src/dbmaster_route.cpp#L276) with the specific human-readable translations given from https://github.com/rinigus/osmscout-server/blob/master/src/dbmaster_route.cpp#L395 using a class that fills instructions into given JSON object: https://github.com/rinigus/osmscout-server/blob/master/src/routingforhuman.cpp (see https://github.com/rinigus/osmscout-server/blob/master/src/routingforhuman.cpp#L124 for example).

All localization is provided using Qt's tr facility and that's probably one of the main issues with providing cross-platform cross-toolkit library. The translations are managed at https://www.transifex.com/rinigus/osm-scout-server/languages/ which is simple for translators and free for open source objects.

I guess the main issue with providing translations via library is figuring out how to make it in cross-platform way. Since the library supports solutions without Qt, we probably can't just rely on its approach. Although, maybe most of us actually use Qt backend anyway... Ideally, translations backend should be simple to use for programmers using library and translators. I am not aware of any localizations solution support in Windows nor Mac/iOS nor Android.