Repository navigation
Split custom model docs into client and server parts, update to JSON - #2289
Conversation
| ## How to use Custom Models | ||
|
|
||
| ### via HTTP | ||
|
|
||
| Using custom models is simple. You just need to add the `custom_model` property to your request JSON. This only works | ||
| for certain profiles, however, and so far only POST /route (but not GET /route or /isochrone, /spt or /map-matching) | ||
| are supported. | ||
|
|
||
| ### via GraphHopper maps | ||
|
|
||
| GraphHopper maps offers an interactive text editor that can be used to comfortably enter custom models. You can open it | ||
| by pressing the 'custom' button. It will check the syntax of your custom model and mark errors in red. You can press | ||
| Ctrl+Space or Alt+Enter to retrieve auto-complete suggestions. Pressing Ctrl+Enter will send a routing request for the | ||
| custom model you entered. No newline at end of file |
There was a problem hiding this comment.
I would even move this section to the top of the description?
What I find also important is the show a complete example e.g. "The POST body for a query in Berlin looks like:"
{
"points": [
[ 13.31543, 52.509535 ],
[ 13.29779, 52.512434 ]
],
"profile": "car",
"custom_model": {
"priority": [
{
"if": "road_class == MOTORWAY",
"multiply_by": 0
}
]
}
} "If you put this into a file route.json you can immediately try this:"
curl -XPOST -H "Content-Type: application/json" "http://localhost:8989/route" --data route.json
There was a problem hiding this comment.
curl -XPOST -H "Content-Type: application/json" "http://localhost:8989/route" --data route.json
This requires a local server, shall we change localhost to the custom model demo server IP?
There was a problem hiding this comment.
I would like to get rid of these demo servers, when we get this feature on graphhopper.com ( hopefully soonish ;) )
And I think that the reader here will have the ability to set up a local routing server. For our docs at https://docs.graphhopper.com we probably have to copy these docs anyway (?) (but yes, best would be if we can copy them 1:1)
There was a problem hiding this comment.
Instead of copying the docs we could also just move them entirely? But for docs.graphhopper.com maybe we want to be specific about which encoded values exist etc. too. So far I thought custom-models.md is for client-side only users (like on GH maps) so they do not need to know about setting up a local server. Setting up a local server is described in profiles.md. But maybe we can just remove the comment about curl here because how to send a GH request is described elsewhere anyway. (and it only works for linux)
There was a problem hiding this comment.
Yes, feel free to remove the curl command.
Instead of copying the docs we could also just move them entirely?
In general we cannot use the same docs here as we use in docs.graphhopper.com. I'm not sure if we would need a separate documentation for custom models and although introducing this separation causes lots of headache it also allows us to independently move forward here without "production" limitations.
There was a problem hiding this comment.
Ok so let's see when we actually do it and then probably copy it (or most parts of it)?
| If you put this JSON into a file `custom.json` you can send the request like this: | ||
|
|
||
| ```shell | ||
| curl -XPOST -H "Content-Type: application/json" "http://localhost:8989/route" --data custom.json |
There was a problem hiding this comment.
Just for later reference - there was a mistake and it should be --data @custom.json instead.
Fix #2275.