osrm-backend/include/engine/api/match_parameters.hpp

98 lines
3.4 KiB
C++
Raw Normal View History

/*
Copyright (c) 2016, Project OSRM contributors
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright notice, this list
of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
2016-01-28 10:28:44 -05:00
#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
2016-01-28 10:28:44 -05:00
#include "engine/api/route_parameters.hpp"
#include <vector>
namespace osrm
{
namespace engine
{
namespace api
{
2016-04-01 11:23:41 -04:00
/**
* Parameters specific to the OSRM Match service.
*
* Holds member attributes:
* - timestamps: timestamp(s) for the corresponding input coordinate(s)
*
* \see OSRM, Coordinate, Hint, Bearing, RouteParame, RouteParameters, TableParameters,
* NearestParameters, TripParameters, MatchParameters and TileParameters
*/
2016-01-28 10:28:44 -05:00
struct MatchParameters : public RouteParameters
{
2016-02-22 11:33:31 -05:00
MatchParameters()
2016-03-03 08:26:13 -05:00
: RouteParameters(false,
false,
2016-03-03 08:26:13 -05:00
false,
RouteParameters::GeometriesType::Polyline,
RouteParameters::OverviewType::Simplified,
{})
2016-02-22 11:33:31 -05:00
{
}
2016-03-03 08:26:13 -05:00
template <typename... Args>
MatchParameters(std::vector<unsigned> timestamps_, Args... args_)
2016-02-22 11:33:31 -05:00
: RouteParameters{std::forward<Args>(args_)...}, timestamps{std::move(timestamps_)}
{
}
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;
2016-02-17 20:21:47 -05:00
bool IsValid() const
{
2016-03-03 08:26:13 -05:00
return RouteParameters::IsValid() &&
(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;
2016-02-17 20:21:47 -05:00
}
2016-01-28 10:28:44 -05:00
};
}
}
}
#endif