Skip to content

Snap preventions default - #3075

Merged
karussell merged 2 commits into
masterfrom
snap_preventions_default
Oct 28, 2024
Merged

karussell merged 2 commits into
masterfrom
snap_preventions_default

Conversation

@karussell

@karussell karussell commented Oct 28, 2024 •

Copy link
Copy Markdown
Member

For route planning the current empty default for "snap_preventions" is suboptimal. This PR makes it possible to provide a default snap_preventions list on the server-side which can be overwritten on the client-side.

url += "&" + Parameters.Routing.SNAP_PREVENTION + "=" + encodeURL(snapPrevention);
if (ghRequest.hasSnapPreventions()) {
if (ghRequest.getSnapPreventions().isEmpty())
url += "&" + Parameters.Routing.SNAP_PREVENTION + "="; // send empty value to indicate explicit empty list

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For GET requests sending an empty list to overwrite the server-side default is a bit special using an empty value like &snap_prevention= in the URL.

private List<String> pointHints = new ArrayList<>();
private List<String> curbsides = new ArrayList<>();
private List<String> snapPreventions = new ArrayList<>();
private List<String> snapPreventions;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default must be null to differentiate between empty and not-specified snap_preventions list.


if (uriInfo.getQueryParameters().containsKey(SNAP_PREVENTION)) {
if (snapPreventions.size() == 1 && snapPreventions.contains(""))
request.setSnapPreventions(List.of()); // e.g. "&snap_prevention=&" to force empty list

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For GET requests sending an empty list to overwrite the server-side default is a bit special using an empty value like &snap_prevention= in the URL.

@karussell
karussell merged commit 85d7079 into master Oct 28, 2024
@karussell
karussell deleted the snap_preventions_default branch October 28, 2024 15:31
karussell added a commit that referenced this pull request Oct 28, 2024
@AndreB99

AndreB99 commented Dec 14, 2024 •

Copy link
Copy Markdown

What if i want to do it in the local version of the open source routing engine?

I'm not being able to alter the snap preventions, it's always going for the default even if i do List snappreventions = new ArrayList<>(); and then GHRequest req = new GHRequest(start.valid_lat, start.valid_lon, end.valid_lat, end.valid_lon)
.setProfile("car")
.setSnapPreventions(snappreventions);

@karussell karussell added this to the 10.0 milestone Aug 26, 2025

This branch was previously deployed

1 inactive deployment
benchmarks — c6629b64 Deployed Oct 28, 2024 by karussell
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.

2 participants