2016-04-13 17:07:24 -04:00
|
|
|
#ifndef OSRM_UNIT_TEST_WAYPOINT_CHECK
|
|
|
|
#define OSRM_UNIT_TEST_WAYPOINT_CHECK
|
|
|
|
|
|
|
|
#include "osrm/coordinate.hpp"
|
|
|
|
#include "osrm/json_container.hpp"
|
|
|
|
#include "util/exception.hpp"
|
|
|
|
|
|
|
|
using namespace osrm;
|
|
|
|
|
|
|
|
inline bool waypoint_check(json::Value waypoint)
|
|
|
|
{
|
|
|
|
if (!waypoint.is<mapbox::util::recursive_wrapper<util::json::Object>>())
|
|
|
|
{
|
|
|
|
throw util::exception("Must pass in a waypoint object");
|
|
|
|
}
|
|
|
|
const auto waypoint_object = waypoint.get<json::Object>();
|
|
|
|
const auto waypoint_location = waypoint_object.values.at("location").get<json::Array>().values;
|
2016-06-24 01:01:37 -04:00
|
|
|
util::FloatLongitude lon{waypoint_location[0].get<json::Number>().value};
|
|
|
|
util::FloatLatitude lat{waypoint_location[1].get<json::Number>().value};
|
2016-04-13 17:07:24 -04:00
|
|
|
util::Coordinate location_coordinate(lon, lat);
|
|
|
|
return location_coordinate.IsValid();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|