abrensch / brouter

configurable OSM offline router with elevation awareness, Java + Android
MIT License
494 stars 117 forks source link

API Documentation #338

Open NicoHood opened 3 years ago

NicoHood commented 3 years ago

Hi there! I am currently looking through Brouter and its functions. I am wondering how the web service communicates with the backend. I assume it is some REST or maybe gRPC? I found no information about that at all and would like to get some information on that.

The background is, that I wanted to write some "unit" tests, to create an advanced profile based on those unit tests. At least I want to try to.

polyscias commented 3 years ago

The communication with BRouter is just through a web request for example, if you have brouter running locally you can do under Linux:

curl -o track.gpx "http://127.0.0.1:17777/brouter?lonlats=5.15,52.086%7C5.207,52.062&profile=trekking&alternativeidx=0&format=gpx&timode=3"

And that will give you a GPX track from 5.15,52.086 to 5.207,52.062 using the trekking profile, alternative 0 and with OSMand turn instructions (timode=3)

In the same way it is also possible to specify no-go area's, via points etc, see ServerHandler.java#L20 and further.

NicoHood commented 3 years ago

So it is actually a rest interface with only a single function?

How can I specify the output format? Like csv and if I want to export all tags or just the relevant?

polyscias commented 3 years ago

Yes, it is a single function.

To get another output format, see the document I linked earlier, more specifically the trackFormat parameter.

If you want more tags then you get for the csv or json format, you can specify them using the dummyUsage parameter, brouter-web for example wants also to see the smoothness tag, see trekking.brf#L305.

The background is, that I wanted to write some "unit" tests, to create an advanced profile based on those unit tests. At least I want to try to.

Sounds interesting, running the test is I think the easy part, what is more difficult is judging the results (semi-) automatically.

zod commented 2 years ago

If you want to compare changes in your profile to a previously created route https://github.com/Phyks/BrouterTesting (mentioned in the README) is very helpful