Custom Model with POST Request

I use HTTP POST Request (with JSON Data) to get the routes and would like to add constraints so that some street segments are avoided. This is my request Data:

{
  "points": [
    [
      10.531678541332926,
      52.26561125630332
    ],
    [
      10.526497045349252,
      52.268357265465966
    ]
  ],
  "profile": "bike",
"priority": [
    {
      "if": "in_custom1",
      "multiply_by": "0"
    }
  ],
  "areas": {
    "type": "FeatureCollection",
    "features": [
      {
        "type": "Feature",
        "id": "custom1",
        "geometry": {
          "type": "Polygon",
          "coordinates": [
            [
              [
                10.5269,
                52.2673
              ],
              [
                10.5272,
                52.2676
              ],
              [
                10.5273,
                52.2666
              ],
              [
                10.5278,
                52.2668
              ],
              [
                10.5269,
                52.2673
              ]
            ]
          ]
        }
      }
    ]
  },
  "calc_points": true,
  "points_encoded": false
}

I added custom1 area so that this area would be avoided. When I got the data back, the route does not avoid the area that I defined. To clarify, this is the result on the map:

the four red dots are the coordinates of the Polygon in the custom1 area and the blue line is the resulting route. As I tested the same request on https://explorer.graphhopper.com, the result does not differ from the route on the image.

You need to use the format specified in the documentation.

I.e. you need the parameter “ch.disable”: true
and the custom model needs to go into an entry custom_model: {...

Thank you it worked!

1 Like