nrenner / brouter-web

Web client for BRouter, a routing engine based on OpenStreetMap
https://brouter.de/brouter-web/
MIT License
364 stars 69 forks source link

Support nogo polygons #144

Open Phyks opened 5 years ago

Phyks commented 5 years ago

Hi,

BRouter supports having any polygon (and polyline) as a nogo area instead of only circles since https://github.com/abrensch/brouter/pull/97. I think it would be super useful to have it in BRouter-web, first as users might be interested into having more control than just circles, but also as BRouter-web is a super nice interface to test and debug quickly BRouter code (so it would be super useful for devs :).

I know UMap (http://umap.openstreetmap.fr/, https://github.com/umap-project/umap/) lets user draw simply polygons on a Leaflet map, so maybe part of this code could be reused? (sorry, I don't know much about brouter-web internals :/)

FWIW, my typical use case for having polygons and polylines (beside dev) is that many cities around here are providing OpenData feeds of current road works. These could be loaded somehow in BRouter-web to avoid crossing these areas.

Thanks!

nrenner commented 5 years ago

I saw the polygon and polyline nogo extension.

The Leaflet.Editable plugin from uMap is now used for drawing circles and can also draw polygons and lines. I just happily removed the editing toolbar to also reduce the number of buttons on the screen and added a custom delete button to the circle feature, which would need to be adapted to polygons and lines as well.

Just wondering: I would have expected road works and traffic incidents to link to reference points or street segments, not areas?

Phyks commented 5 years ago

Thanks for the feedback!

Just wondering: I would have expected road works and traffic incidents to link to reference points or street segments, not areas?

I have some experience with opendata for road works and traffic incidents around France. They usually have a GeoJSON shape (LineString or Polygon most of the time) and a free form text field for the name of the road. The GeoJSON shape overlap with the actual OSM way is usually far from being perfect and the matching of the free form text field with OSM names could lead to a lot of false positives. Then, the best option so far seems to take the GeoJSON shape, eventually buffer it a bit, and use it as a nogo area.

Best,

nrenner commented 5 years ago

From #157:

The possibility to draw and edit the polygons as well as their weight. I'm not sure I can help a lot on this, I don't know much about the Leaflet plugin currently used

Drawing with Leaflet.Editable should work with the start* methods within a Leaflet.EasyButton similar to: https://github.com/nrenner/brouter-web/blob/70a0f73d12fde7c4972427bfc475874f9a0ba52c/js/plugin/NogoAreas.js#L56

Editing should work automatically on click on every layer.

As mentioned above, I added a custom delete button that would need to be adapted to polylines and polygons.

What kind of input do you imagine for the weight? An input field for a float cost value, a slider, a dropdown with categories?

Phyks commented 5 years ago

Editing should work automatically on click on every layer.

Indeed, I just made a minor fix and this is working.

What kind of input do you imagine for the weight? An input field for a float cost value, a slider, a dropdown with categories?

I was thinking maybe a small input field next to the custom delete button? I'm not sure whereas having per-nogo area weight within the web interface makes sense though. It could probably be easier to just have an extra button in the left menu, next to the trash icon, opening an input (same as search box) and setting the nogo weight globally.

nrenner commented 5 years ago

I guess we would need to try out how adding an input field looks like and if it's getting in the way. Alternatives might be using a popup-style toolbar or a toolbar at the top middle, don't know if it supports adding an input field instead of a button though.

Not sure if changing individual weights will be used, but e.g. it might make sense for disabling a nogo temporarily. And as it is supported, we might just as well show it off.

I'm trying to keep the number of buttons on the screen at a minimum. For a global setting I would prefer to add it to an options tab in the sidebar, that I plan to add anyway. Or maybe that could be a profile setting?

Phyks commented 5 years ago

Or maybe that could be a profile setting?

Not sure that's a good idea since profiles are used by BRouter itself and it would not make sense for BRouter to have such a value :/