Skip to content

Remove tertiary highways from preferred and increase speed on footways#3015

Merged
karussell merged 2 commits into
graphhopper:masterfrom
caspg:footways-for-bicycle
Jun 21, 2024
Merged

Remove tertiary highways from preferred and increase speed on footways#3015
karussell merged 2 commits into
graphhopper:masterfrom
caspg:footways-for-bicycle

Conversation

@caspg

@caspg caspg commented Jun 10, 2024

Copy link
Copy Markdown
Contributor

Right now, GH preffers tertiary roads over footways with bicycle=yes tags for bike profile.
This leads to not opimial routing, especially when those footways are connecting cycleways.

@ratrun suggested that we should remove tertiary from preffered highways and bump speed in the footway (only with bicycle=yes) #3014

Example 1

Before:
CleanShot 2024-06-10 at 09 35 28@2x

After:
CleanShot 2024-06-10 at 09 35 08@2x

Example 2

Before:
CleanShot 2024-06-10 at 09 36 15@2x

After:
CleanShot 2024-06-10 at 09 36 40@2x

@caspg

caspg commented Jun 10, 2024

Copy link
Copy Markdown
Contributor Author

I updated tests but not sure what to do with this one: https://github.com/graphhopper/graphhopper/blob/master/core/src/test/java/com/graphhopper/GraphHopperTest.java#L464

We probably need to find new example location?

@caspg caspg changed the title [DRAFT] remove tertiary highways from preferred and increase speed on footways [DRAFT] Fix for #3014: remove tertiary highways from preferred and increase speed on footways Jun 10, 2024
@karussell

Copy link
Copy Markdown
Member

Thanks for this fix and the examples.

We probably need to find new example location?

Can you import the test file into GH and show a screenshot of this route for master and your PR? I'm not yet sure if this is just cosmetics or if removing tertiary from preferHighwayTags has stronger consequences.

@caspg

caspg commented Jun 10, 2024

Copy link
Copy Markdown
Contributor Author

@karussell They look exactly the same. I run it with: They are not the same. I forgot to recompile.

profiles:
    - name: bike
      custom_model_files: [bike.json]

Master branch:
CleanShot 2024-06-10 at 14 58 13@2x

My branch:
zmiany

@karussell

karussell commented Jun 10, 2024

Copy link
Copy Markdown
Member

This still looks like reasonable alternative.

@ratrun isn't removing tertiary from the preferredTags a bit risky regarding other route choice? And should we test it more intense before merging? And if we do this, shouldn't it be done for all bike priority parsers for consistency reasons?

@ratrun

ratrun commented Jun 10, 2024

Copy link
Copy Markdown
Contributor

This still looks like reasonable alternative.

@ratrun isn't removing tertiary from the preferredTags a bit risky regarding other route choice? And should we test it more intense before merging?

I think that the only thing which might happen is that a tertiary is not taken any longer in favour of longer residential, so it should be OK.

And if we do this, shouldn't it be done for all bike priority parsers for consistency reasons?

I think that you are right for the MountainBikePriorityParser, but we should leave it unchanged for the RacingBikePriorityParser.

@caspg

caspg commented Jun 10, 2024

Copy link
Copy Markdown
Contributor Author

Yup, removing tertiary only from MTB and leaving in RacingBike seems reasonable. Will update PR.

@caspg

caspg commented Jun 11, 2024

Copy link
Copy Markdown
Contributor Author

@ratrun @karussell How should I change test? Also, in test it returns 1 route (probably without any alternative).
Earlier screenshots comes from running default bike.json custom model.

https://github.com/graphhopper/graphhopper/blob/master/core/src/test/java/com/graphhopper/GraphHopperTest.java#L464

[INFO]
[ERROR] Failures:
[ERROR]   GraphHopperTest.testAlternativeRoutesBike:464 expected: <3> but was: <1>

@karussell

Copy link
Copy Markdown
Member

It is strange that it does not return an alternative in the integration test but returned one in maps (the screenshot you showed). It would be important to have some alternatives in this test - maybe you can achieve this by slightly moving e.g. the destination coordinate towards the other alternative?

Or can you try maps again and use the config and file from the integration test?

@caspg

caspg commented Jun 12, 2024

Copy link
Copy Markdown
Contributor Author

@karussell How should my bike.json custom model look to match the test configuration? I run it with default bike.json before.

profiles:
    - name: bike
      custom_model_files: [bike.json]

EDIT:

I tried this config which I guess it's what test is using:

{
  "priority": [
    { "if": "bike_access", "multiply_by": "bike_priority" },
    { "else": "", "multiply_by": "0" }
  ],
  "speed": [
    { "if": "true", "limit_to": "bike_average_speed" }
  ]
}

I also got alternative routes. I run it with:

mvn clean install -DskipTests \
  &&  rm -rf graph-cache \
  && java -Xmx8g -Xms8g -Ddw.graphhopper.datareader.file=./core/files/north-bayreuth.osm.gz -jar web/target/graphhopper-web-*.jar server config-example.yml

@ratrun

ratrun commented Jun 16, 2024

Copy link
Copy Markdown
Contributor

@caspg I could not find out what you are doing differently, but I cannot reproduce your screenshots about the alternatives. Here is my screenshot for the original code. It matches the test with 3 alternatives:
Bildschirmfoto vom 2024-06-16 07-32-59

I'm using the checked in bike.json from git.

With your branch there is no alternative found as indicated by the test, but by slightly changing the destination coordinates into 49.982089,11.599224 the three alternatives are found again.

Therefore my suggestion is to change the test into:

        GHRequest req = new GHRequest(50.028917, 11.496506, 49.982089,11.599224).
                setAlgorithm(ALT_ROUTE).setProfile(profile);
        req.putHint("alternative_route.max_paths", 3);
        GHResponse rsp = hopper.route(req);
        assertFalse(rsp.hasErrors(), rsp.getErrors().toString());

        assertEquals(3, rsp.getAll().size());
        // via ramsenthal
        assertEquals(2697, rsp.getAll().get(0).getTime() / 1000);
        // via unterwaiz
        assertEquals(2985, rsp.getAll().get(1).getTime() / 1000);
        // via eselslohe -> theta; BTW: here smaller time as 2nd alternative due to priority influences time order
        assertEquals(2783, rsp.getAll().get(2).getTime() / 1000);

Here is the new screenshot:
Bildschirmfoto vom 2024-06-16 09-10-01

@caspg caspg changed the title [DRAFT] Fix for #3014: remove tertiary highways from preferred and increase speed on footways Fix for #3014: remove tertiary highways from preferred and increase speed on footways Jun 16, 2024
@caspg

caspg commented Jun 16, 2024

Copy link
Copy Markdown
Contributor Author

@ratrun Thanks! I've just updated the test and PR is ready for review.

@karussell karussell changed the title Fix for #3014: remove tertiary highways from preferred and increase speed on footways Remove tertiary highways from preferred and increase speed on footways Jun 21, 2024
@karussell karussell added this to the 10.0 milestone Jun 21, 2024
@karussell karussell merged commit 4731966 into graphhopper:master Jun 21, 2024
@karussell

Copy link
Copy Markdown
Member

Ok, thank you. Let's try this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants