Kia ora,
I am using the ORS backend as a Java library for my offline project. The API is unsuitable due to the volume of my requests (70B+ per execution).
The following error occurs when I’m running several concurrent, single- (or multi-) threaded java processes which access the same graphs
directory on a slurm server (note: this is a slightly custom output):
java.lang.IllegalStateException: Your route has failed: class org.heigit.ors.exceptions.InternalServerException Unable to get an appropriate route profile for RoutePreference = driving-car
When I run a single process, the error does not occur (all else equal).
The error originates from the routeProfiles
map in RoutingProfilesCollection
being empty. I sufficiently find the RouteProfile
key
as 101
(with chEnabled = true
) and 1
as the default when ORS realises the map doesn’t contain the 101
key
(i.e., with chEnabled = false
).
Also note that I added the following to the add(int routePref, RoutingProfile rp, boolean isUnique)
method in RoutingProfilesCollection
:
System.err.println("Adding route profile: " + RoutingProfileType.getName(getRoutePreferenceKey(routePref, rp.isCHEnabled())) + " chEnabled: " + rp.isCHEnabled() + " is unique: " + isUnique);
Which outputs nothing when running on the server (hence the size-zero map), and outputs the following when running locally:
Adding route profile: unknown chEnabled: true is unique: false
I suspect the RouteProfile
should not default to unknown.
I call the following Java block when requesting a route:
RouteRequest req = getCoreRouteRequest(from, to); // see below method
RouteRequestOptions options = new RouteRequestOptions();
options.setAvoidBorders(APIEnums.AvoidBorders.CONTROLLED); // this breaks u-turns in rare cases, hence the try/catch below.
req.setRouteOptions(options);
RouteResult[] routeRes = null;
try {
routeRes = req.generateRouteFromRequest();
} catch (Exception e1){
try {
req = getCoreRouteRequest(from, to);
routeRes = req.generateRouteFromRequest();
} catch (Exception e2){
// fails with and without border avoidance. Stop the process.
System.err.println("Route from: " + from + " to: " + to);
new IllegalStateException("Your route has failed: " + e2.getClass() + " " + e2.getMessage()).printStackTrace();
System.exit(-1);
}
}
private RouteRequest getCoreRouteRequest(Coordinate from, Coordinate to){
RouteRequest req = new RouteRequest(Utility.coordinateLocsToArray(new Coordinate[]{from, to})); // just constructs the double[][] array
req.setProfile(APIEnums.Profile.DRIVING_CAR);
req.setAttributes(new APIEnums.Attributes[]{APIEnums.Attributes.DETOUR_FACTOR});
req.setExtraInfo(new APIEnums.ExtraInfo[]{APIEnums.ExtraInfo.OSM_ID});
req.setIncludeGeometry(true);
req.setRoutePreference(APIEnums.RoutePreference.FASTEST);
req.setUseContractionHierarchies(true); // an optimisation technique
return req;
If you have any ideas as to what might be causing this, I would greatly appreciate your help (again…)
Ngā mihi,
Mak
Finally, my config file is:
{
"ors": {
"services": {
"matrix": {
"enabled": true,
"maximum_routes": 1000000000,
"maximum_routes_flexible": 25,
"maximum_search_radius": 1000000000,
"maximum_visited_nodes": 1000000000,
"allow_resolve_locations": true,
"attribution": "openrouteservice.org, OpenStreetMap contributors"
},
"isochrones": {
"enabled": true,
"maximum_range_distance": [
{
"profiles": "any",
"value": 1000000000
},
{
"profiles": "driving-car, driving-hgv",
"value": 1000000000
}
],
"maximum_range_time": [
{
"profiles": "any",
"value": 1000000000
},
{
"profiles": "driving-car, driving-hgv",
"value": 1000000000
}
],
"fastisochrones": {
"maximum_range_distance": [
{
"profiles": "any",
"value": 1000000000
},
{
"profiles": "driving-car, driving-hgv",
"value": 1000000000
}
],
"maximum_range_time": [
{
"profiles": "any",
"value": 1000000000
},
{
"profiles": "driving-car, driving-hgv",
"value": 1000000000
}
],
"profiles": {
"default_params": {
"enabled": false,
"threads": 12,
"weightings": "recommended",
"maxcellnodes": 1000000000
},
"hgv": {
"enabled": false,
"threads": 12,
"weightings": "recommended, shortest",
"maxcellnodes": 1000000000
}
}
},
"maximum_intervals": 10,
"maximum_locations": 2,
"allow_compute_area": true
},
"routing": {
"enabled": true,
"mode": "normal",
"routing_description": "This is a routing file from openrouteservice",
"routing_name": "openrouteservice routing",
"sources": [
"gphhemd_data/osm_files/wgtn.osm.gz"
],
"init_threads": 2,
"attribution": "openrouteservice.org, OpenStreetMap contributors",
"elevation_preprocessed": false,
"profiles": {
"active": [
"car"
],
"default_params": {
"encoder_flags_size": 8,
"graphs_root_path": "gphhemd_data/graphs",
"elevation_provider": "multi",
"elevation_cache_path": "elevation-cache",
"elevation_cache_clear": false,
"instructions": true,
"maximum_distance": 1000000000,
"maximum_distance_dynamic_weights": 1000000000,
"maximum_distance_avoid_areas": 1000000000,
"maximum_waypoints": 50,
"maximum_snapping_radius": 1000000000,
"maximum_avoid_polygon_area": 200000000,
"maximum_avoid_polygon_extent": 20000,
"maximum_distance_alternative_routes": 1000000000,
"maximum_alternative_routes": 3,
"maximum_distance_round_trip_routes": 1000000000,
"maximum_speed_lower_bound": 80,
"preparation": {
"min_network_size": 200,
"min_one_way_network_size": 200,
"methods": {
"lm": {
"enabled": true,
"threads": 1,
"weightings": "recommended,shortest",
"landmarks": 16
}
}
},
"execution": {
"methods": {
"lm": {
"disabling_allowed": true,
"active_landmarks": 8
}
}
}
},
"profile-car": {
"profiles": "driving-car",
"parameters": {
"encoder_flags_size": 8,
"encoder_options": "turn_costs=true|block_fords=false|use_acceleration=true",
"maximum_distance": 1000000000,
"elevation": true,
"maximum_snapping_radius": 1000000000,
"preparation": {
"min_network_size": 200,
"min_one_way_network_size": 200,
"methods": {
"ch": {
"enabled": true,
"threads": 1,
"weightings": "fastest"
},
"lm": {
"enabled": false,
"threads": 1,
"weightings": "fastest,shortest",
"landmarks": 16
},
"core": {
"enabled": true,
"threads": 1,
"weightings": "fastest,shortest",
"landmarks": 64,
"lmsets": "highways;allow_all"
}
}
},
"execution": {
"methods": {
"ch": {
"disabling_allowed": true
},
"lm": {
"disabling_allowed": true,
"active_landmarks": 6
},
"core": {
"disabling_allowed": true,
"active_landmarks": 6
}
}
},
"ext_storages": {
"WayCategory": {},
"HeavyVehicle": {},
"WaySurfaceType": {},
"RoadAccessRestrictions": {
"use_for_warnings": true
}
}
}
},
"profile-hgv": {
"profiles": "driving-hgv",
"parameters": {
"encoder_flags_size": 8,
"encoder_options": "turn_costs=true|block_fords=false|use_acceleration=true",
"maximum_distance": 1000000000,
"elevation": true,
"preparation": {
"min_network_size": 200,
"min_one_way_network_size": 200,
"methods": {
"ch": {
"enabled": true,
"threads": 1,
"weightings": "recommended"
},
"core": {
"enabled": true,
"threads": 1,
"weightings": "recommended,shortest",
"landmarks": 64,
"lmsets": "highways;allow_all"
}
}
},
"execution": {
"methods": {
"ch": {
"disabling_allowed": true
},
"core": {
"disabling_allowed": true,
"active_landmarks": 6
}
}
},
"ext_storages": {
"WayCategory": {},
"HeavyVehicle": {
"restrictions": true
},
"WaySurfaceType": {}
}
}
},
"profile-bike-regular": {
"profiles": "cycling-regular",
"parameters": {
"encoder_options": "consider_elevation=true|turn_costs=true|block_fords=false",
"elevation": true,
"ext_storages": {
"WayCategory": {},
"WaySurfaceType": {},
"HillIndex": {},
"TrailDifficulty": {}
}
}
},
"profile-bike-mountain": {
"profiles": "cycling-mountain",
"parameters": {
"encoder_options": "consider_elevation=true|turn_costs=true|block_fords=false",
"elevation": true,
"ext_storages": {
"WayCategory": {},
"WaySurfaceType": {},
"HillIndex": {},
"TrailDifficulty": {}
}
}
},
"profile-bike-road": {
"profiles": "cycling-road",
"parameters": {
"encoder_options": "consider_elevation=true|turn_costs=true|block_fords=false",
"elevation": true,
"ext_storages": {
"WayCategory": {},
"WaySurfaceType": {},
"HillIndex": {},
"TrailDifficulty": {}
}
}
},
"profile-bike-electric": {
"profiles": "cycling-electric",
"parameters": {
"encoder_options": "consider_elevation=true|turn_costs=true|block_fords=false",
"elevation": true,
"ext_storages": {
"WayCategory": {},
"WaySurfaceType": {},
"HillIndex": {},
"TrailDifficulty": {}
}
}
},
"profile-walking": {
"profiles": "foot-walking",
"parameters": {
"encoder_options": "block_fords=false",
"elevation": true,
"ext_storages": {
"WayCategory": {},
"WaySurfaceType": {},
"HillIndex": {},
"TrailDifficulty": {}
}
}
},
"profile-hiking": {
"profiles": "foot-hiking",
"parameters": {
"encoder_options": "block_fords=false",
"elevation": true,
"ext_storages": {
"WayCategory": {},
"WaySurfaceType": {},
"HillIndex": {},
"TrailDifficulty": {}
}
}
},
"profile-wheelchair": {
"profiles": "wheelchair",
"parameters": {
"encoder_options": "block_fords=true",
"elevation": true,
"maximum_snapping_radius": 50,
"ext_storages": {
"WayCategory": {},
"WaySurfaceType": {},
"Wheelchair": {
"KerbsOnCrossings": "true"
},
"OsmId": {}
}
}
},
"profile-public-transport": {
"profiles": "public-transport",
"parameters": {
"encoder_options": "block_fords=false",
"elevation": true,
"maximum_visited_nodes": 1000000000,
"gtfs_file": "ors-api/src/test/files/vrn_gtfs.zip"
}
}
}
}
},
"logging": {
"enabled": true,
"level_file": "DEBUG_LOGGING.json",
"location": "./logs",
"stdout": true
},
"system_message": [
{
"active": false,
"text": "This message would be sent with every routing bike fastest request",
"condition": {
"request_service": "routing",
"request_profile": "cycling-regular,cycling-mountain,cycling-road,cycling-electric",
"request_preference": "fastest"
}
},
{
"active": false,
"text": "This message would be sent with every request for geojson response",
"condition": {
"api_format": "geojson"
}
},
{
"active": false,
"text": "This message would be sent with every request on API v1 from January 2020 until June 2050",
"condition": {
"api_version": 1,
"time_after": "2020-01-01T00:00:00Z",
"time_before": "2050-06-01T00:00:00Z"
}
},
{
"active": false,
"text": "This message would be sent with every request"
}
]
}
}