optional distance tolerance paramter for rtree plugin #28
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
this PR adds optional "distance_tolerance" and "distance_unit" parameters for the rtree plugin. there is no associated issue so i'll describe the problem here.
problem
currently, if the user loads a road network and then submits a query that is well outside of the road network region, the rtree plugin will still find the nearest vertex. this leads to unexpected behavior where matched origins and destinations may be miles from the user-requested locations.
solution
when the nearest vertex is found, if the optional tolerance is provided, the plugin checks that the vertex found does not exceed the distance tolerance from the query coordinate. if the tolerance is exceeded, the query fails. if no tolerance is provided, then we get the original behavior (tolerance is infinite).
i have updated the osm_default_*.toml files to use a tolerance of 200 meters (0.2km). along the way i also fixed the display implementation for Unit types so that they are not enquoted by double-quotes in their string representation.
example
i have run a national query on a denver road network, where the destination coordinate is in Massachusetts which is 2000+ km outside of the nearest vertex: