How to get full path without simplification

I wrote a code like this:

GraphHopperConfig config = new GraphHopperConfig();
config.putObject("route.way_point_max_distance",0);
config.putObject("import.osm.ignored_highways","");
ArrayList<CHProfile> chProfiles = new ArrayList<>();
chProfiles.add(new CHProfile("people"));
config.setCHProfiles(chProfiles);
ArrayList<Profile> profiles = new ArrayList<>();
profiles.add(new Profile("people").setVehicle("foot").setWeighting("shortest").setTurnCosts(false));
config.setProfiles(profiles);
config.putObject("datareader.file", "D:/gis/roadnet/linetest.osm");
config.putObject("graph.location", "target/routing-graph-cache-test");
GraphHopper hopper;
hopper = new GraphHopper();
hopper.init(config);
hopper.importOrLoad();

GHRequest rep;
rep = new GHRequest(0.0000193,0.0000073,0.0019966,0.0019908).setProfile("people");
GHResponse rsp = hopper.route(rep);
System.out.println(rsp.getBest().getPoints());

I use a custom osm and it’s like this:

<?xml version='1.0' encoding='UTF-8'?>
<osm version='0.6' generator='JOSM'>
  <node id='25361' action='modify' visible='true' version='1' lat='0.0' lon='0.0' />
  <node id='25362' action='modify' visible='true' version='1' lat='0.001' lon='0.001' />
  <node id='25363' action='modify' visible='true' version='1' lat='0.002' lon='0.002' />
  <way id='582' action='modify' visible='true' version='1'>
    <nd ref='25361' />
    <nd ref='25362' />
    <nd ref='25363' />
    <tag k='highway' v='pedestrian' />
    <tag k='name' v='abc' />
  </way>
</osm>

The PointList of the best path only contains 2 snapped points without point(0.001,0.001)
I would like to know that how I could set the graphhopper to make sure to get all the nodes on the path without using the lower api.

There is a per request setting way_point_max_distance and an import setting: routing.way_point_max_distance that can be set to 0 if you want to disable it (it is 1 per default which is 1 meter and the max deviation used for the ramer-douglas-peucker simplification)

I do have the import setting in the code above:

config.putObject("route.way_point_max_distance",0);

Do I still need set way_point_max_distance per request?

Yes.

I’m using the GHRequest and GHResponse currently. How can I setting the way_point_max_distance in them?

You can use the request hints for this.

req.getHints().putObject(“way_point_max_distance”, 0);

I’ve added this in my request

        GHRequest req;
        req = new GHRequest(0.0000193,0.0000073,0.0019966,0.0019908).setProfile("people");
        req.getHints().putObject("way_point_max_distance", 0);
        GHResponse rsp = hopper.route(req);

and still, the pointlist of GHResponse which hopper.route returned to me only contained 2 points.
Do I also have to set the GHResponse?
and I forgot to mention before that I’m using the graphhopper 7.0

And the original data has more than 2 points?

Yes, and they look like this:

<?xml version='1.0' encoding='UTF-8'?>
<osm version='0.6' generator='JOSM'>
  <node id='25361' action='modify' visible='true' version='1' lat='0.0' lon='0.0' />
  <node id='25362' action='modify' visible='true' version='1' lat='0.001' lon='0.001' />
  <node id='25363' action='modify' visible='true' version='1' lat='0.002' lon='0.002' />
  <way id='582' action='modify' visible='true' version='1'>
    <nd ref='25361' />
    <nd ref='25362' />
    <nd ref='25363' />
    <tag k='highway' v='pedestrian' />
    <tag k='name' v='abc' />
  </way>
</osm>

They are on the same line though.

I think setting it to 0 won’t disable the simplification completely.

Can you try -1 for both instead of 0?

That’s what I’m thinking of earlier. I cleaned my cache and set both parameters in config and request to -1, but it still return the 2 snapped point of starting point and ending point only.

I just had a deeper look and this quick hack cannot work as the maximum distance is always normalized (RamerDouglasPeucker → setMaxDistance → calcNormalizedDist) and so the value is always positive and there is no inbuilt way to completely disable the path simplification except if you remove the code.

1 Like

I see, thank you so much.