GraphHopper.com | Forum | GitHub | Maps | Blog

Disabling CH not allowed on the server-side?


#1

Hello.

I have created a GraphHopper server on Windows. Directions API seems to be working, but I want to avoid motorways. In order to do so I have added “ch.disable=true” and “avoid=motorway” to the request, but the server returns:
“{“message”:“Disabling CH not allowed on the server-side”,“hints”:[{“message”:“Disabling CH not allowed on the server-side”,“details”:“java.lang.IllegalArgumentException”}]}”.

Does that mean we can’t have directions with avoid parameter?


#2

As this has performance implications for every request you have to explicitly allow this on the server side (and restart):

graphhopper:
    ...
    routing.ch.disabling_allowed: true

#3

Thanks, will try that.


#4

@karussell sure this will work on the open source routing engine as well?

avoid=motorway or avoid=toll seems not to have any effect in my local environment (0.11):

http://localhost:8989/maps/?point=46.016039%2C11.25824&point=46.355459%2C11.263046&locale=en-US&vehicle=car&weighting=fastest&elevation=false&ch.disable=true&avoid=toll&use_miles=false&layer=Omniscale

Thanks!


#5

Ah, you are right about this. We are currently implementing a better “flexible” system for those cases. Please see this branch instead: https://github.com/graphhopper/graphhopper/tree/flex_vehicleprofile

Where you can specify the avoid factor either per request in the json/yml or on import: https://github.com/graphhopper/graphhopper/blob/flex_vehicleprofile/web/src/test/resources/com/graphhopper/http/resources/fire_truck.yml#L20

We’ll probably merge this or a similar version of it in the near future.


Adding extra information to store highway type in the graph
#6

Many thanks - I’ll give a try during next days, as I’m getting an error while trying running flex_veichleprofile branch

## using java 1.8.0_102 (64bit) from 
## using existing osm file taa.pbf
## existing jar found web/target/graphhopper-web-0.12-SNAPSHOT.jar
## now web. JAVA_OPTS=-Xmx1000m -Xms1000m
io.dropwizard.configuration.ConfigurationParsingException: config.yml has an error:
  * Unrecognized field at: server.applicationConnectors
    Did you mean?:
      - application_connectors
      - application_context_path
      - admin_connectors
      - admin_min_threads
      - allowed_methods
        [22 more]

	at io.dropwizard.configuration.ConfigurationParsingException$Builder.build(ConfigurationParsingException.java:279)
	at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:140)
[...]

#7

Ah, yes. Thanks for the feedback on this fresh work. The problem is that I wanted to avoid to annotate every Java property which is in “camelCase” with its “under_score” JSON notation and so I used this configuration for jackson:

objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);

As this is a global change the config.yml has to be changed too:

# Dropwizard server configuration
server:
  application_connectors:
  - type: http
    port: 8989
    # for security reasons bind to localhost
    bind_host: localhost
  requestLog:
      appenders: []
  admin_connectors:
  - type: http
    port: 8990
    bind_host: localhost

Don’t ask me why requestLog has to stay in camelCase :slight_smile:

To see the branch in action you can look into the tests: https://github.com/graphhopper/graphhopper/blob/flex_vehicleprofile/web/src/test/java/com/graphhopper/http/resources/FlexResourceTest.java

If this branch is too experimental for your case, then this pull request could be interesting, but this requires probably a bit more Java and GH knowledge.


#8

Perfect, I can compile and lunch now. Thanks!

Options &ch.disable=true&avoid=toll do not seem to work our of the box, you wrote:

If I got it correctly, in order to implement toll avoidance, I need to define a new vehicle (fire_truck is an example) with proper wording in the “no_access” section - correct?

Thanks for your help


#9

The request format is different as we plan to make things more customizable URL parameters are not the best choice. You’ll need to POST a JSON. See the tests.

If I got it correctly, in order to implement toll avoidance, I need to define a new vehicle (fire_truck is an example) with proper wording in the “no_access” section - correct?

You can define a new vehicle in the config:

graph.encoding_manager: some_vehicle.yml

but it should also work to do a POST request against the new “/flex” endpoint, even if you only have car defined. To make it working use the JSON similar to the one in the test. (Currently this is inconsistent: import requires yml file, request requires JSON, in the future both will be supported for both scenarios)


#10

Ah, I believe I got it, I focused on the fire_truck example which makes a get request http://localhost:8080/route?...vehicle=fire_truck&weighting=flex while I see now I need to target /flex endpoint with a POST request as per the wheelchair examples.

Thanks again


#11

Maybe I should open another post, I’m having some troubles with the POST request, is there any document explaining the format?

curl -i -X POST -H 'Content-Type: application/json' -d '{"request": { "points" : [[11.248630, 46.030340], [11.265450, 46.325830] ] }, "model": { "base":"car"} }' http://localhost:8989/flex

HTTP/1.1 400 Bad Request
Date: Wed, 10 Oct 2018 20:00:01 GMT
Access-Control-Allow-Methods: GET, POST, HEAD, OPTIONS
Access-Control-Allow-Headers: Origin,Accept,X-Requested-With,Content-Type,Access-Control-Request-Method,Access-Control-Request-Headers
Access-Control-Allow-Origin: *
Content-Type: application/json
Content-Length: 188

{"message":"No path found due to maximum nodes exceeded 1000000","hints":[{"message":"No path found due to maximum nodes exceeded 1000000","details":"java.lang.IllegalArgumentException"}]}

Same thing if I try something more elaborated as in the java example linked above:

{
	"request": {
		"points": [
			[11.248630, 46.030340],
			[11.265450, 46.325830]
		]
	},
	"model": {
		"base": "car",
		"no_access": {
			"road_class": ["steps"]
		}
	}
}

note the GET query for same areas works:
http://localhost:8989/maps/?point=46.03034%2C11.24863&point=46.32583%2C11.26545&locale=en-US&vehicle=car&weighting=fastest&elevation=false&use_miles=false&layer=Omniscale


Flexible Vehicle Profiles
#12

See follow up here: Flexible Vehicle Profiles