Skip to content

Split custom model docs into client and server parts, update to JSON - #2289

Merged
easbar merged 3 commits into
masterfrom
custom_model_docs
Apr 20, 2021
Merged

easbar merged 3 commits into
masterfrom
custom_model_docs

Conversation

@easbar

@easbar easbar commented Apr 20, 2021

Copy link
Copy Markdown
Member

Fix #2275.

@easbar easbar added this to the 3.0 milestone Apr 20, 2021

@karussell karussell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

Comment thread docs/core/custom-models.md Outdated
Comment on lines +525 to +538
## 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

@karussell karussell Apr 20, 2021 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok yes good idea

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@karussell karussell Apr 20, 2021 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@easbar easbar Apr 20, 2021 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@karussell karussell Apr 20, 2021 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok so let's see when we actually do it and then probably copy it (or most parts of it)?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@easbar
easbar merged commit d738ac3 into master Apr 20, 2021
@easbar
easbar deleted the custom_model_docs branch April 20, 2021 16:27
Comment thread docs/core/custom-models.md Outdated
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

@karussell karussell Apr 21, 2021 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for later reference - there was a mistake and it should be --data @custom.json instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update custom model and profile documentation

2 participants