Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smarter search radius formula for map matching #3184

Merged
merged 5 commits into from
Nov 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/http.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,12 @@ In addition to the [general options](#general-options) the following options are
|timestamp |`integer` UNIX-like timestamp |
|radius |`double >= 0` (default 5m) |

The radius for each point should be the standard error of the location, measured in meters from the true location. Use
`Location.getAccuracy()` on Android or `CLLocation.horizontalAccuracy` on iOS. This value is used to determine which
points should be considered as candidates (larger radius means more candidates) and how likely each candidate is (larger
radius means far-away candidates are penalized less). The area to search is chosen such that the correct candidate
should be considered 99.9% of the time (for more details, see https://github.com/Project-OSRM/osrm-backend/pull/3184).

### Response
- `code` if the request was successful `Ok` otherwise see the service dependent and general status codes.
- `tracepoints`: Array of `Waypoint` objects representing all points of the trace in order.
Expand Down
20 changes: 10 additions & 10 deletions src/engine/plugins/match.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@
#include <string>
#include <vector>

static double search_radius_for_gps_radius(double gps_radius) {
// For a given GPS radius, determine the radius we need to search for candidate street segments
// to have a 99.9% chance of finding the correct segment.
// For more detail, see the analysis at https://github.com/Project-OSRM/osrm-backend/pull/3184
return std::min(gps_radius * 3.5 + 45, 200.0);
}

namespace osrm
{
namespace engine
Expand Down Expand Up @@ -152,16 +159,9 @@ Status MatchPlugin::HandleRequest(const std::shared_ptr<datafacade::BaseDataFaca
std::transform(parameters.radiuses.begin(),
parameters.radiuses.end(),
search_radiuses.begin(),
[](const boost::optional<double> &maybe_radius) {
if (maybe_radius)
{
return *maybe_radius * RADIUS_MULTIPLIER;
}
else
{
return DEFAULT_GPS_PRECISION * RADIUS_MULTIPLIER;
}

[&](const boost::optional<double> &maybe_radius) {
double gps_radius = maybe_radius ? *maybe_radius : DEFAULT_GPS_PRECISION;
return search_radius_for_gps_radius(gps_radius);
});
}

Expand Down