janbar / osmin

GPS Navigator On-Road/Off-Road for Android and Linux devices
GNU General Public License v3.0
99 stars 16 forks source link

Enhancement: Route visualisation during routing #7

Open Framstag opened 3 years ago

Framstag commented 3 years ago

The color use for the visualiation of the route doe snot seem to be optimal in regard to the highway colors. It should also be possible to add "symbols" using libosmscout styling functionality, if this improves the result.

janbar commented 3 years ago

I would like to know how to change dynamically the style of way without need of hard setup in the oss file. As sample in the source code there: https://github.com/janbar/osmin/blob/630bb8353f086c6c57228bf7c447057feb0ca1e7/src/gpxfilemodel.cpp#L297 I create the way to show a track from a GPX file. I haven't yet skills on the lib to do that dynamically. I started to read the wiki, but I need time to handle that. You could send me a sample of code. Also the app works on linux and you can build it easily to test without need of the mobile device.

Framstag commented 3 years ago

Hmm, there is a lot of boilerplate code but I assume in the end your Way is placed as poiWay into class MapData. Right?

From there it will be broken down into paths in MapPainter::CalculatePaths. This is where we resolve the style from the type (and possibly other parts of the data buffer). After much processing WayPathData and WayData structure for the renderer is filled and added to the list. These are used in the various DrawWayXXX methods later on.

(Btw., the renderer needs some refactoring, some methods are very long :-()

As you can see you do not have a context to correlate the RouteWay with other ways. Also style is returned by the style config only based on the attributes of the way buffer. One could of course add a callback or overwrite the "give style for way" method in the style config to return a dynamically allocated (and reference counted) style (one could implement this cleanly by adding a StyleProvider interface between map and style config that works on a type name). But you would have no context besides the actual way to make decisions. Adding a StyleProvider might also be some useful refactoring to cleanup call nervertheless ;-)

With this issue I was more thing about using alpha channel only color (to "just darken" or lighten the way) for the route way style together with some symbols like we use for one ways. In this case the style would be static but might still be better visible than it currently is, because it still may look like it "adapts".