I’m wanting to use foot encoding but remove the use of footpaths and unsure how to go about it.
Currently;
GraphHopper graphHopper = new GraphHopper().setGraphHopperLocation(LocationGrapphopperFiles)
.setEncodingManager(new EncodingManager("car,bike,foot"))
.setOSMFile(LocationRoutingFile)
.forDesktop();
This is so I can view routes for Car,Bike or Foot.
But for only foot I want to change safeHighwayTags.add("footpath"); to restrictedValues.add("footpath");
Where I get stuck is how to override FootFlagEncoder to remove specific HighwayTags.
Is anyone able to provide some insight of what I should be doing to remove the use of footpaths?
Thanks for the info.
I searched through and couldn’t find docs on implementing the config.yml profile.
Am I correct in thinking that graphHopper.init(new GraphHopperConfig(new PMap("/path/to/config.yml"))); is the way to set it up in java?
Also to make sure that if using the config file I don’t have to set things like graph location, elevation etc as these are set within java.
GraphHopper graphHopper = new GraphHopperOSM().setGraphHopperLocation(LocationGrapphopperFiles)
.setEncodingManager(encodingManager)
.setDataReaderFile(LocationRoutingFile)
.setElevation(true)
.setElevationProvider(new CGIARProvider().setBaseURL("C:/Users/elevation/"))
.setProfiles(Arrays.asList(
new Profile("foot").setVehicle("foot").setWeighting("fastest"),
new Profile("custom_foot").setVehicle("foot").setWeighting("custom"),
new Profile("bike").setVehicle("bike").setWeighting("fastest"),
new Profile("car").setVehicle("car").setWeighting("fastest")))
.forDesktop();
//graphHopper.init(new GraphHopperConfig(new PMap(LocationGrapphopperFiles+"/config.yml")));
graphHopper.importOrLoad();
So the custom_foot profile is read from the config.yml, which references
Which then uses priority: { road_class: { track: 0 } } ??
Or by setting the config.yml it means I no longer need to .setProfiles and just set them up within the config instead?
For Java you do not need to load the config.yml file and can do everything with “objects”. See e.g. CustomWeightingRouteResourceTest on the configuration (using CustomProfile).
GraphHopper graphHopper = new GraphHopperOSM().setGraphHopperLocation(LocationGrapphopperFiles)
.setEncodingManager(encodingManager)
.setDataReaderFile(LocationRoutingFile)
.setElevation(true)
.setElevationProvider(new CGIARProvider().setBaseURL("C:/Users/Elevations/"))
.setProfiles(Arrays.asList(
new Profile("foot").setVehicle("foot").setWeighting("fastest"),
new Profile("bike").setVehicle("bike").setWeighting("fastest"),
new Profile("bike2").setVehicle("bike2").setWeighting("fastest"),
new Profile("car").setVehicle("car").setWeighting("fastest"),
new CustomProfile("paxster").setCustomModel(new CustomModel()).setVehicle("foot").setWeighting("custom").putHint("custom_model_file", RouteToMap.class.getClassLoader().getResource("paxster.yml").getFile())))
.forDesktop();
With paxster.yml being
priority: { road_class: { footway: 0 } }
Unfortunately footpaths are still being used.
Issue being;
Really stuck on this
What is going wrong? The way I’m setting up the profile allows me to use the “paxster” profile but it is still using footpaths.
Do I need to setup anything in the routing request other than to use “paxster”?
CustomModel model = new CustomModel();
HashMap map = new HashMap();
map.put("footway", 0);
model.getPriority().put("road_class", map);
For playing around I recommend to use GraphHopper Maps and the input text box instead of a file-based approach that requires a re-import. See our recent blog posts about this new feature:
There you will also see how to enable the path details which gives you information about e.g. the road_class property along the path. With that information you can also be sure to use the correct name to pick it for avoidance.
I did play around with the Flex that you setup and it worked great. I looked through all sorts of docs but I couldn’t find the correct method to set it in Java. I’m by no means an expert in Java as I have just started learning it.
This has resolved my issue of erroneous footpaths not being connected on a country wide level.
Thanks for the update. The documentation for the Java part is surely suboptimal, but as the feature is intended for users without Java skills that makes sense
Still if something is not well documented you can always have a look into our tests. Every feature has a test coverage somewhere and so the usage via Java is always shown there even if it is not documented.
Yeah, I always look through the tests to see how stuff has been implemented but I find myself getting stuck as I did with CustomWeightingRouteResourceTest putHint("custom_model_file",RouteToMap.class.getClassLoader().getResource("paxster.yml").getFile()
Especially as you mention for features intended for different implementations.
There is something in some routes causing the route to fail. I’m guessing its unable to calculate the path between some points with priority footpath = 0.
It works fine with car and foot base profiles. Is there anything to get around this issue? I’ve tried setting the priority for footpath very low but it will still use the footpaths that mess things up.
Is it a case of trying and if error then use a different profile?
I will investigate further to assess which path is causing the issue. As of now there are over 1000 points mapped (not a huge area though) and from the looks of it, it seems to be a footpath that is going along side an express way but I have to be sure.
[com.graphhopper.util.exceptions.ConnectionNotFoundException: Connection between locations not found]
I limit to 1084 points and it works fine, limit to 1085 and it fails.
Between 1084 - 703/26 Library Lane -36.7265512372916, 174.696570519881
and 1085 - 7 Rose Garden Lane -36.7254772797197, 174.70740666905
[com.graphhopper.util.exceptions.ConnectionNotFoundException: Connection between locations not found]
Note that Rose Garden Lane is a service lane. So adding;
priority:
road_class:
service: 0.1
footway: 0
Still results in Connection between locations not found
This is how a car reaches there - why does no pathing want to use rose garden lane? It has assumed 2 way, all vehicles are allowed access, surface is asphalt. It does have a speed hump though, would that impact it?
The first part of Rose Garden Lane on the right is unnamed service type.
Something to note; adding the local MVT layer shows it stops when going down the service lane;
So can walking be allowed to reach the point from a far away point as the car profile does? This would hopefully eliminate future issues.
Edit
I updated my PBF and everything seems to be fine now. Thanks for your help, I will be able to self diagnose more next time