Repository navigation
Implements a more precise way to add new intermediate points in web UI - #791
Conversation
|
Thanks! Will try it out in the next days |
There was a problem hiding this comment.
I know it is a bit nitpicking but as we 'emulate' GeoJSON we would need underscore - does this make sense :) ?
I.e.
snapped_waypoints: path.snapped_waypoints
|
Thanks again - works perfectly :) ! Would you mind to fix the minor mentioned thing and (if possible) add a quick test for it here? |
e7b1634 to
0fab398
Compare
I would like to add a test, but this does not seem very easy at the moment. We could run a kind of integration test in the web browser (maybe using phantomJS). Alternatively, we could extract the function that finds the correct index for the waypoint and test it, but in this case we would still have to mock some of the dependencies, like the mapLayer and some more Leaflet stuff (L.latLng etc.). As far as I can tell for both solutions we are missing some infrastructure right now. I also thought about if some of the functionality needed here should be available within graphhopper, so we could reduce the amount of logic in the UI layer. For example when calculating a route for given via-points, is it possible to keep track which parts of the resulting route lie between which via-points ? What I mean is this: Request: A --> B --> C (route from A to C via B) Is there a way to obtain the via-points that are the start and end of a given route segment, e.g. is it possible to call something like |
Ok, no problem. I just thought somehow assuming 3 points and then add another and asserting the correct index is somehow possible.
I would prefer to keep one tool for now (Jasmine) but we should investigate alternatives.
That would be okay for now
Interesting thought. We already can calculate distances to 'edges' but this is not published as API.
There are two possibilities with which one could achieve this
We could make it easier with a simple array where values correspond to the point indices for every via-point, something like |
I will try this for now. |
|
Thanks a bunch! |
90f366c to
fd98c15
Compare
| @@ -0,0 +1,74 @@ | |||
| // because leaflet-src.js requires window, document etc. we need to provide these variables... | |||
There was a problem hiding this comment.
This is pretty ugly. Maybe you have a better idea ? We could keep the tests separate from leaflet entirely by reimplementing/copy&pasting the functionality of L.latLng, but I do not think this is much nicer. We could also put this workaround into a separate file.
There was a problem hiding this comment.
No idea, but looks okay to me. We are kind of mocking away these dependencies which could lead to trouble but for now this should be sufficient. In long term we should try to move more parts into a better structured code ;( (more seperate from UI)
|
I separated the method for finding the correct index and wrote two tests for it. Maybe you can have a look again now. Let me know if you do not like the naming etc. ! |
I was thinking about a tool that allows us to simulate clicks on the map and for example check whether the url changes in a correct way, not sure if this can be done only with Jasmine. |
If this was available we would at least not have to find the next way point by iterating over the route. |
Thanks a bunch, this is what I meant and looks good :) !
ah, yes. Something like selenium? I see this more like the integration testing which is currently not existant and possibly also important. The unit testing part should be more or less decoupled from the UI and doable with jasmine (I know the architecture is currently bad to have this properly separated)
Ok, maybe create an issue for this so it does not get lost? |
|
Merged and already live :) ! Thanks again! |
|
Cool. Thanks a lot. It looks great. |
|
@ammagamma Nice feature, works pretty good. When start and end is the same point, the order of points is not correctly calculated anyomre, maybe you can checkt? |
|
@boldtrn do you have an example as I cannot reproduce this. |
|
Sure sorry, I should have provided an example from the start. Now add a point western of the route, for example in Siegen, using the right click dialog. It will be the 1st waypoint, wereas it should be the 3rd. |
|
@boldtrn thanks for testing, this is indeed a problem, which occurs whenever a waypoint is crossed multiple times. I will look for a better solution. |
Yes thats what I meant |
Previously, the order of intermediate points was simply equal to the order in which the points were added. This PR changes this behavior such that a newly added point is inserted between the closest two existing waypoints.
Edit: I just realized there is still a problem with alternative routes ... (fixed in second commit)