Skip to content

Commit

Permalink
Merge pull request #888 from valhalla/kk_mmroute
Browse files Browse the repository at this point in the history
add back the max search limit to meili for candidate search
  • Loading branch information
kevinkreiser committed Aug 10, 2017
2 parents 93a8c6b + 1cfde1d commit 025bcef
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 218 deletions.
4 changes: 3 additions & 1 deletion scripts/valhalla_build_config
Expand Up @@ -82,6 +82,7 @@ config = {
'beta': 3,
'max_route_distance_factor': 5,
'max_route_time_factor': 5,
'max_search_radius': 100,
'breakage_distance': 2000,
'interpolation_distance': 10,
'search_radius': 50,
Expand Down Expand Up @@ -193,7 +194,7 @@ config = {
'trace': {
'max_distance': 200000.0,
'max_gps_accuracy': 100.0,
'max_search_radius': 100,
'max_search_radius': 100.0,
'max_shape': 16000,
'max_best_paths': 4,
'max_best_paths_shape': 100
Expand Down Expand Up @@ -282,6 +283,7 @@ help_text = {
'max_route_distance_factor': 'A non-negative value used to limit the routing search range which is the distance to next measurement multiplied by this factor',
'max_route_time_factor': 'A non-negative value used to limit the routing search range which is the time to the next measurement multiplied by this factor',
'breakage_distance': 'A non-negative value. If two successive measurements are far than this distance, then connectivity in between will not be considered',
'max_search_radius': 'A non-negative value specifying the maximum radius in meters about a given point to search for candidate edges for routing',
'interpolation_distance': 'If two successive measurements are closer than this distance, then the later one will be interpolated into the matched route',
'search_radius': 'A non-negative value to specify the search radius (in meters) within which to search road candidates for each measurement',
'geometry': 'TODO: ',
Expand Down
209 changes: 0 additions & 209 deletions src/meili/geojson_reader.cc

This file was deleted.

14 changes: 8 additions & 6 deletions src/meili/map_matcher.cc
Expand Up @@ -284,18 +284,20 @@ MapMatcher::OfflineMatch(
return {};
}

const auto max_search_radius = config_.get<float>("max_search_radius"),
sq_max_search_radius = max_search_radius * max_search_radius;
const auto interpolation_distance = config_.get<float>("interpolation_distance"),
sq_interpolation_distance = interpolation_distance * interpolation_distance;
std::unordered_map<StateId::Time, std::vector<Measurement>> interpolated_measurements;

// Always match the first measurement
auto time = AppendMeasurement(*begin);
auto time = AppendMeasurement(*begin, sq_max_search_radius);
auto latest_match_measurement = begin;
for (auto measurement = std::next(begin); measurement != end; measurement++) {
const auto sq_distance = GreatCircleDistanceSquared(*latest_match_measurement, *measurement);
// Always match the last measurement
if (sq_interpolation_distance < sq_distance || std::next(measurement) == end) {
time = AppendMeasurement(*measurement);
time = AppendMeasurement(*measurement, sq_max_search_radius);
latest_match_measurement = measurement;
} else {
interpolated_measurements[time].push_back(*measurement);
Expand Down Expand Up @@ -352,16 +354,16 @@ MapMatcher::OfflineMatch(


StateId::Time
MapMatcher::AppendMeasurement(const Measurement& measurement)
MapMatcher::AppendMeasurement(const Measurement& measurement, const float sq_max_search_radius)
{
// Test interrupt
if (interrupt_) {
(*interrupt_)();
}
auto sq_radius = std::min(sq_max_search_radius,
std::max(measurement.sq_search_radius(), measurement.sq_gps_accuracy()));
const auto& candidates = candidatequery_.Query(
measurement.lnglat(),
std::max(measurement.sq_search_radius(), measurement.sq_gps_accuracy()),
mapmatching_.costing()->GetEdgeFilter());
measurement.lnglat(), sq_radius, mapmatching_.costing()->GetEdgeFilter());
return mapmatching_.AppendState(measurement, candidates.begin(), candidates.end());
}

Expand Down
2 changes: 1 addition & 1 deletion valhalla/meili/map_matcher.h
Expand Up @@ -56,7 +56,7 @@ class MapMatcher final
}

private:
StateId::Time AppendMeasurement(const Measurement& measurement);
StateId::Time AppendMeasurement(const Measurement& measurement, const float sq_max_search_radius);

boost::property_tree::ptree config_;

Expand Down
2 changes: 1 addition & 1 deletion valhalla/valhalla.h.in
Expand Up @@ -3,7 +3,7 @@

#define VALHALLA_VERSION_MAJOR 2
#define VALHALLA_VERSION_MINOR 3
#define VALHALLA_VERSION_PATCH 3
#define VALHALLA_VERSION_PATCH 4

//whether the API was configured with http service support or not
@HAVE_HTTP_DEFINE@
Expand Down

0 comments on commit 025bcef

Please sign in to comment.