Revert "Hardcode search radius parameters"

This reverts commit 2c9e18d5a9.
This commit is contained in:
Patrick Niklaus
2016-12-20 23:34:15 +00:00
committed by Daniel Patterson
parent c5e3fa916f
commit cc14fb8bff
3 changed files with 44 additions and 12 deletions
+18 -1
View File
@@ -28,6 +28,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ENGINE_API_MATCH_PARAMETERS_HPP
#define ENGINE_API_MATCH_PARAMETERS_HPP
#define SEARCH_RADIUS_BASE_DEFAULT 45
#define SEARCH_RADIUS_BASE_LIMIT 100
#define SEARCH_RADIUS_MULTIPLIER_DEFAULT 3.5
#define SEARCH_RADIUS_MULTIPLIER_LIMIT 10
#define SEARCH_RADIUS_MAX_DEFAULT 200
#define SEARCH_RADIUS_MAX_LIMIT 500
#include "engine/api/route_parameters.hpp"
#include <vector>
@@ -67,10 +74,20 @@ struct MatchParameters : public RouteParameters
}
std::vector<unsigned> timestamps;
double search_radius_base = SEARCH_RADIUS_BASE_DEFAULT;
double search_radius_multiplier = SEARCH_RADIUS_MULTIPLIER_DEFAULT;
double search_radius_max = SEARCH_RADIUS_MAX_DEFAULT;
bool IsValid() const
{
return RouteParameters::IsValid() &&
(timestamps.empty() || timestamps.size() == coordinates.size());
(timestamps.empty() || timestamps.size() == coordinates.size()) &&
search_radius_base >= 0 && search_radius_multiplier >= 0 && search_radius_max > 0 &&
// limit the search_radius parameters to sane values to prevent overloading the server
search_radius_base <= SEARCH_RADIUS_BASE_LIMIT &&
search_radius_multiplier <= SEARCH_RADIUS_MULTIPLIER_LIMIT &&
search_radius_max <= SEARCH_RADIUS_MAX_LIMIT;
}
};
}