I faced a real challenge when digging into the code of BRouter and that had nothing to do with the complexity of the algorithms :-). Due to my problems with the code I decided to couple Brouter and the navigation processing as loosely as possible. I wanted to use and modify Brouter as little as possible.
Being mostly independent from BRouter is good for reusing the code it in another context but not for the overall performance.
The performance is okay in a single instance environment. I do not recommend using it for running a heavily used public routing server.
The code is only tested in a BRouter-Server context. I did not test it in any other way.
Like parts of BRouter the actual navigation hint processing is moved to a script.
For scripting the SISC Scheme interpreter in included. This should give all the power to scripting you could hope for.
In the current version a very simple hiking navigation script is included.
The main purpose of this code is working with my modified QLandkarteGT installation giving some navigation hits.
I did not bother modifying the maven configuration. I use Eclipse build in functionality for building the code. So, please try to live with that and do not throw dung at me for not updating the proper build environment.
I actually modified these Brouter-Source-Files only slightly:
brouter-core/ btools.router.OsmTrack
brouter-core/ btools.router.RoutingEngine
brouter-server/ btools.router.RouteServer
I added 4 classes in:
brouter-core/ btools.router.navi.
All the rest of the code is in the separate project navigator.
Attached you will find the source as well as the compiled version.
Have fun,
Ralf
PS: I'm here the first time and just realized not to be able to attach anything.
Here is the link: http://www.datafilehost.com/d/dca5097e
Thank you for the hint. I agree, collecting the nodes from the final path should suffice.
Regarding the potential performance issues. The scheme interpreter is initialized for each navigation processing from start. This could take >100 ms or so. I'm quite sure that could be improved, but did not bother for my purpose.
Hi Ralf,
Am Sonntag, 21. Juni 2015 20:00:32 UTC+2 schrieb Ralf:
> I added navigation functionality to BRouter modified QlandkarteGT slightliy to use the extra data now coming from Brouter.
interesting.
regarding this script-based approach for voice hints and the way to carry them in a gpx I will have a deeper look.
> I think you are also aware, that at least some Locus users (including me ;-) ) would love to have navigation hints support in Brouter. There is a discussion about it in the Locus forum, but nobody has a clue how to transfer the hints to the navigation app (via gpx?). Maybe Ralf's implementation could help to shed some light on this?
>
> regards,
> zossebart
>
Zossebart,
I can see no technical restriction why the code should not work in an app anvironment in principle. I did not test it yet and I doubt that it will just run out of the box. Most likely there is a necessity to enhance/modify the current interface, but not the core functionality.
In regard locus:
It depends on how locus expects the handover of navigation hints. The current implementation within Brouter writes the collected navigation hints as way points into the gpx stream. This part of the code is extremely simple and only a few lines long.
If another transformation to fit the needs of locus is required... well this should be an easy job.
The gpx format defines in essence a way to disciple positions (waypoints) (POI and such) position defining a track and positions defining a route.
Each of these positions can hold the same meta data, such as geo position, name, comment, type, description, time and such.
There is no defined attribute to place navigation hints (let me know if this is not correct). Therefore systems either use a proprietary extension or misuse one of the existing attributes to store and evaluate navigation hints.
To pass navigation hints to QLandkateGT I added waypoins and placed the navigation hint in the name attribute. I used the comment attribute to store the index of the related track step for this navigation hint. I added a few lines of code to the QLandkarteGT to use this information for its internal processing.
I'm using OruxMaps for hiking and OruxMaps has the capability to read the names of waypoints. With an additional little program I convert the QLandkarteGT gpx export, holding “my” navigation hints as positions defining a route to just plain waypoints.
If the navigation hints are just waypoints and the hint is the name of that waypoint OruxMaps is happy, and so am I :)
You see, all depends on how locus expects to get navigation hints. Providing them within the gpx-file is no thing. If the data exchange between BRouter and Lucos is not gpx but another format, things might be different.
I think we should wait for Arndt to answer this, but I can't imagine that the internal format is gpx, because it has lots of overhead.
Am Freitag, 10. Juli 2015 14:02:28 UTC+2 schrieb Zossebart:I think we should wait for Arndt to answer this, but I can't imagine that the internal format is gpx, because it has lots of overhead.
It is GPX. Here's the aidl-definition of the interface that Locus uses:
http://brouter.de/brouter/IBRouterService.aidl
OsmAnd still uses KML, but for just historical reasons. Meanwhile there's also GeoJSON (added by Norbert as a low-overhead format for BRouter-Web), but that's not yet supported by the aidl-interface.
I'm following the discussion with great interest, but, to be fair, I'm not going to implement into the Android app some quick-hack that's Locus-Only
, or german-only,
and I'm somewhat sceptical about adding a third-party scripting library to the android app. This Android App is all about memory queezing and keeping it slim, so beeing conservative on technologies is the only way to avoid regressions.
I wonder what would be a generic way of transferring navi instruction hints between applications. For portability, text strings in any language are clearly not the way to go (even if it's english). So maybe sort of a coded value (e.g. 0x1 == straight, 0x2 == left, 0x3 == right, 0x4 == u-turn, maybe with turn angles in degrees)? It's too bad that something like this doesn't seem to exist right now, or we don't know of it.
.. would it be possible to implement it in java inside the app, instead of using the script approach? Maybe that would't be as much of a problem performance-wise?
Do 3rd party online router services provide navigation hints ?
Or, are they created by target application like OSMAnd, based on
provided route ?
Given the variety of existing solutions, you might as well define your own one. Obviously, everyone does this ;-)
Or you could decide to re-use one of the existing solutions (probably the one most of the apps already support) and implement it into brouter (provided the licence allows this).
This is likely to be my topic for the next Karlsruhe hack-weekend at geofabrik in to weeks.
Yes I think the most promising approach is to not care on interface formats, but just on the model and the algorithm, that is, produce good data, choose a data-model with a small missmatch to the existing approaches, write that in comment-syntax into the xml and see wht happens.
This is likely to be my topic for the next Karlsruhe hack-weekend at geofabrik in to weeks.
... Therefore, I would prefer a format with the turn instructions packed into waypoints (<wpt>), like Locus or GPSIES does.
I hope we can make some progress in this field. I (and I think many more) would love to have turn instructions natively provided by Brouter!
I did not succeed to have Locus process these voice hints. But in my tests today, I did not succeed to create any reasonable voice hints in Locus, not even after switching to MapQuest, all I heard was confusing, so maybe I am doing something wrong.
</rtept>
<rtept lat="49.2094392" lon="10.0648713">
<desc>keep right</desc>
<extensions>
<turn>KR</turn>
<offset>103</offset>
</extensions>
</rtept>
Offset is the the number of the trackpoint with the same coordinates. Desc is shown in the navigation list but seems not to be spoken. Turn are the instructions, see https://github.com/osmandapp/Osmand/blob/master/OsmAnd-java/src/net/osmand/router/TurnType.java but you can't import C (go straight).
I guess I have finally got it, your ways seems correct to me now. :-)
Dne neděle 10. dubna 2016 14:46:45 UTC+2 abre...@googlemail.com napsal(a):@Poutnik: thanks for your feedback (private message?). For your remark on way-priorities: my approach generates voice hints for equal-priority junctions, so I guess having track=road=path all equal is o.k.?
Do you plan to implement also keep left / keep right ?
Like e.g. if there are 2 ways within +/- 15 degrees , possibly making confusion which one of them is the straight one.
Yes I think the most promising approach is to not care on interface formats, but just on the model and the algorithm, that is, produce good data, choose a data-model with a small missmatch to the existing approaches, write that in comment-syntax into the xml and see wht happens.
I'm not sure what you mean by "comment-syntax into the xml"? Does this mean that the navi instructions in the first implementation will end up not being useable by an app, but at least human-readable as comments in the gpx-file for verification?
.. unless turnInstructionMode info would be kept out of the profiles.
That comment syntax would contain the superset of information of the existing formats, to keep the model-mismatch small. E.g. it would contain the lon/lat of the wayspoint *and* the offset of the corresponsing track-point (lon/lat is ambigious for tracks crossing themselves?). And it would contain the complete junction geometry, including angles and priorities of all ways, just to make it easy to check the decision the algortithm makes.
Like this:
/* --turn-instructions-start
--turn TSLR at 25(8.608944/49.674370) next 630 follow 4(25)5 ignore (-15)4 (50)4
--turn-instructions-end */
makes sense?