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

48 lines
1.3 KiB
C++
Raw Normal View History

2016-01-28 10:28:44 -05:00
#ifndef ENGINE_API_BASE_PARAMETERS_HPP
#define ENGINE_API_BASE_PARAMETERS_HPP
#include "engine/hint.hpp"
2016-03-04 17:17:57 -05:00
#include "engine/bearing.hpp"
2016-01-28 10:28:44 -05:00
#include "util/coordinate.hpp"
#include <boost/optional.hpp>
#include <vector>
2016-02-22 16:09:50 -05:00
#include <algorithm>
2016-01-28 10:28:44 -05:00
namespace osrm
{
namespace engine
{
namespace api
{
struct BaseParameters
{
std::vector<util::Coordinate> coordinates;
2016-01-28 10:28:44 -05:00
std::vector<boost::optional<Hint>> hints;
std::vector<boost::optional<double>> radiuses;
std::vector<boost::optional<Bearing>> bearings;
// FIXME add validation for invalid bearing values
bool IsValid() const
{
return (hints.empty() || hints.size() == coordinates.size()) &&
(bearings.empty() || bearings.size() == coordinates.size()) &&
2016-02-22 16:09:50 -05:00
(radiuses.empty() || radiuses.size() == coordinates.size()) &&
std::all_of(bearings.begin(), bearings.end(),
[](const boost::optional<Bearing> bearing_and_range)
{
if (bearing_and_range)
{
2016-03-04 17:17:57 -05:00
return bearing_and_range->IsValid();
2016-02-22 16:09:50 -05:00
}
return true;
});
2016-01-28 10:28:44 -05:00
}
};
}
}
}
#endif // ROUTE_PARAMETERS_HPP