2016-03-16 06:58:39 -04:00
|
|
|
#include <boost/test/test_case_template.hpp>
|
2016-04-13 11:23:03 -04:00
|
|
|
#include <boost/test/unit_test.hpp>
|
2016-03-16 06:58:39 -04:00
|
|
|
|
2016-04-13 11:23:03 -04:00
|
|
|
#include "coordinates.hpp"
|
2016-03-24 16:02:55 -04:00
|
|
|
#include "fixture.hpp"
|
2016-03-16 07:42:26 -04:00
|
|
|
|
2019-09-16 09:39:09 -04:00
|
|
|
#include <engine/api/flatbuffers/fbresult_generated.h>
|
2016-03-16 07:42:26 -04:00
|
|
|
#include "osrm/trip_parameters.hpp"
|
|
|
|
|
|
|
|
#include "osrm/coordinate.hpp"
|
|
|
|
#include "osrm/engine_config.hpp"
|
|
|
|
#include "osrm/json_container.hpp"
|
|
|
|
#include "osrm/osrm.hpp"
|
2016-04-13 11:23:03 -04:00
|
|
|
#include "osrm/status.hpp"
|
2016-03-16 07:42:26 -04:00
|
|
|
|
2016-03-16 06:58:39 -04:00
|
|
|
BOOST_AUTO_TEST_SUITE(trip)
|
|
|
|
|
2017-02-10 05:13:20 -05:00
|
|
|
BOOST_AUTO_TEST_CASE(test_roundtrip_response_for_locations_in_small_component)
|
2016-03-16 07:42:26 -04:00
|
|
|
{
|
|
|
|
using namespace osrm;
|
|
|
|
|
2017-03-21 06:27:15 -04:00
|
|
|
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
2016-04-13 11:23:03 -04:00
|
|
|
const auto locations = get_locations_in_small_component();
|
2016-03-16 07:42:26 -04:00
|
|
|
|
|
|
|
TripParameters params;
|
2016-04-13 11:23:03 -04:00
|
|
|
params.coordinates.push_back(locations.at(0));
|
|
|
|
params.coordinates.push_back(locations.at(1));
|
|
|
|
params.coordinates.push_back(locations.at(2));
|
2016-03-16 07:42:26 -04:00
|
|
|
|
2019-08-13 04:17:15 -04:00
|
|
|
engine::api::ResultT result = json::Object();
|
2016-03-16 07:42:26 -04:00
|
|
|
const auto rc = osrm.Trip(params, result);
|
2016-04-13 11:23:03 -04:00
|
|
|
BOOST_CHECK(rc == Status::Ok);
|
|
|
|
|
2019-08-15 04:40:23 -04:00
|
|
|
auto &json_result = result.get<json::Object>();
|
2019-08-13 04:17:15 -04:00
|
|
|
const auto code = json_result.values.at("code").get<json::String>().value;
|
2016-04-13 11:23:03 -04:00
|
|
|
BOOST_CHECK_EQUAL(code, "Ok");
|
|
|
|
|
2019-08-13 04:17:15 -04:00
|
|
|
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values;
|
2016-04-14 05:27:26 -04:00
|
|
|
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
|
|
|
|
|
2019-08-13 04:17:15 -04:00
|
|
|
const auto &trips = json_result.values.at("trips").get<json::Array>().values;
|
2016-04-14 05:27:26 -04:00
|
|
|
BOOST_CHECK_EQUAL(trips.size(), 1);
|
|
|
|
|
|
|
|
for (const auto &waypoint : waypoints)
|
|
|
|
{
|
|
|
|
const auto &waypoint_object = waypoint.get<json::Object>();
|
|
|
|
|
|
|
|
const auto location = waypoint_object.values.at("location").get<json::Array>().values;
|
|
|
|
const auto longitude = location[0].get<json::Number>().value;
|
|
|
|
const auto latitude = location[1].get<json::Number>().value;
|
|
|
|
BOOST_CHECK(longitude >= -180. && longitude <= 180.);
|
|
|
|
BOOST_CHECK(latitude >= -90. && latitude <= 90.);
|
|
|
|
|
|
|
|
const auto trip = waypoint_object.values.at("trips_index").get<json::Number>().value;
|
|
|
|
const auto pos = waypoint_object.values.at("waypoint_index").get<json::Number>().value;
|
|
|
|
BOOST_CHECK(trip >= 0 && trip < trips.size());
|
|
|
|
BOOST_CHECK(pos >= 0 && pos < waypoints.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-10 05:13:20 -05:00
|
|
|
BOOST_AUTO_TEST_CASE(test_roundtrip_response_for_locations_in_big_component)
|
2016-04-14 05:27:26 -04:00
|
|
|
{
|
|
|
|
using namespace osrm;
|
|
|
|
|
2017-03-21 06:27:15 -04:00
|
|
|
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
2016-04-14 05:27:26 -04:00
|
|
|
const auto locations = get_locations_in_big_component();
|
|
|
|
|
|
|
|
TripParameters params;
|
|
|
|
params.coordinates.push_back(locations.at(0));
|
|
|
|
params.coordinates.push_back(locations.at(1));
|
|
|
|
params.coordinates.push_back(locations.at(2));
|
|
|
|
|
2019-08-13 04:17:15 -04:00
|
|
|
engine::api::ResultT result = json::Object();
|
2016-04-14 05:27:26 -04:00
|
|
|
const auto rc = osrm.Trip(params, result);
|
|
|
|
BOOST_CHECK(rc == Status::Ok);
|
|
|
|
|
2019-08-15 04:40:23 -04:00
|
|
|
auto &json_result = result.get<json::Object>();
|
2019-08-13 04:17:15 -04:00
|
|
|
const auto code = json_result.values.at("code").get<json::String>().value;
|
2016-04-14 05:27:26 -04:00
|
|
|
BOOST_CHECK_EQUAL(code, "Ok");
|
|
|
|
|
2019-08-13 04:17:15 -04:00
|
|
|
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values;
|
2016-04-13 11:23:03 -04:00
|
|
|
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
|
|
|
|
|
2019-08-13 04:17:15 -04:00
|
|
|
const auto &trips = json_result.values.at("trips").get<json::Array>().values;
|
2016-04-13 11:23:03 -04:00
|
|
|
BOOST_CHECK_EQUAL(trips.size(), 1);
|
|
|
|
|
|
|
|
for (const auto &waypoint : waypoints)
|
|
|
|
{
|
|
|
|
const auto &waypoint_object = waypoint.get<json::Object>();
|
|
|
|
|
|
|
|
const auto location = waypoint_object.values.at("location").get<json::Array>().values;
|
|
|
|
const auto longitude = location[0].get<json::Number>().value;
|
|
|
|
const auto latitude = location[1].get<json::Number>().value;
|
|
|
|
BOOST_CHECK(longitude >= -180. && longitude <= 180.);
|
|
|
|
BOOST_CHECK(latitude >= -90. && latitude <= 90.);
|
2016-03-16 07:42:26 -04:00
|
|
|
|
2016-04-13 11:23:03 -04:00
|
|
|
const auto trip = waypoint_object.values.at("trips_index").get<json::Number>().value;
|
|
|
|
const auto pos = waypoint_object.values.at("waypoint_index").get<json::Number>().value;
|
|
|
|
BOOST_CHECK(trip >= 0 && trip < trips.size());
|
|
|
|
BOOST_CHECK(pos >= 0 && pos < waypoints.size());
|
|
|
|
}
|
2016-03-16 07:42:26 -04:00
|
|
|
}
|
2016-03-16 06:58:39 -04:00
|
|
|
|
2017-02-10 05:13:20 -05:00
|
|
|
BOOST_AUTO_TEST_CASE(test_roundtrip_response_for_locations_across_components)
|
2016-04-14 06:16:42 -04:00
|
|
|
{
|
|
|
|
using namespace osrm;
|
|
|
|
|
2017-03-21 06:27:15 -04:00
|
|
|
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
2016-04-14 06:16:42 -04:00
|
|
|
const auto small = get_locations_in_small_component();
|
|
|
|
const auto big = get_locations_in_big_component();
|
|
|
|
|
|
|
|
TripParameters params;
|
|
|
|
params.coordinates.push_back(small.at(0));
|
|
|
|
params.coordinates.push_back(big.at(0));
|
|
|
|
params.coordinates.push_back(small.at(1));
|
|
|
|
params.coordinates.push_back(big.at(1));
|
|
|
|
|
2019-08-13 04:17:15 -04:00
|
|
|
engine::api::ResultT result = json::Object();
|
2016-04-14 06:16:42 -04:00
|
|
|
const auto rc = osrm.Trip(params, result);
|
|
|
|
BOOST_CHECK(rc == Status::Ok);
|
|
|
|
|
2019-08-15 04:40:23 -04:00
|
|
|
auto &json_result = result.get<json::Object>();
|
2019-08-13 04:17:15 -04:00
|
|
|
const auto code = json_result.values.at("code").get<json::String>().value;
|
2016-04-14 06:16:42 -04:00
|
|
|
BOOST_CHECK_EQUAL(code, "Ok");
|
|
|
|
|
2019-08-13 04:17:15 -04:00
|
|
|
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values;
|
2016-04-14 06:16:42 -04:00
|
|
|
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
|
|
|
|
|
2019-08-13 04:17:15 -04:00
|
|
|
const auto &trips = json_result.values.at("trips").get<json::Array>().values;
|
2016-04-14 06:16:42 -04:00
|
|
|
BOOST_CHECK_EQUAL(trips.size(), 1);
|
2016-05-27 15:05:04 -04:00
|
|
|
// ^ First snapping, then SCC decomposition (see plugins/trip.cpp). Therefore only a single
|
|
|
|
// trip.
|
2016-04-14 06:16:42 -04:00
|
|
|
|
|
|
|
for (const auto &waypoint : waypoints)
|
|
|
|
{
|
|
|
|
const auto &waypoint_object = waypoint.get<json::Object>();
|
|
|
|
|
|
|
|
const auto location = waypoint_object.values.at("location").get<json::Array>().values;
|
|
|
|
const auto longitude = location[0].get<json::Number>().value;
|
|
|
|
const auto latitude = location[1].get<json::Number>().value;
|
|
|
|
BOOST_CHECK(longitude >= -180. && longitude <= 180.);
|
|
|
|
BOOST_CHECK(latitude >= -90. && latitude <= 90.);
|
|
|
|
|
|
|
|
const auto trip = waypoint_object.values.at("trips_index").get<json::Number>().value;
|
|
|
|
const auto pos = waypoint_object.values.at("waypoint_index").get<json::Number>().value;
|
|
|
|
BOOST_CHECK(trip >= 0 && trip < trips.size());
|
|
|
|
BOOST_CHECK(pos >= 0 && pos < waypoints.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-02-10 05:13:20 -05:00
|
|
|
BOOST_AUTO_TEST_CASE(test_tfse_1)
|
|
|
|
{
|
|
|
|
using namespace osrm;
|
|
|
|
|
2017-03-21 06:27:15 -04:00
|
|
|
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
2017-02-10 05:13:20 -05:00
|
|
|
const auto locations = get_locations_in_small_component();
|
|
|
|
|
|
|
|
TripParameters params;
|
|
|
|
params.coordinates.push_back(locations.at(0));
|
|
|
|
params.coordinates.push_back(locations.at(1));
|
|
|
|
params.coordinates.push_back(locations.at(2));
|
|
|
|
|
|
|
|
params.source = TripParameters::SourceType::First;
|
|
|
|
params.destination = TripParameters::DestinationType::Last;
|
|
|
|
params.roundtrip = false;
|
|
|
|
|
2019-08-13 04:17:15 -04:00
|
|
|
engine::api::ResultT result = json::Object();
|
2017-02-10 05:13:20 -05:00
|
|
|
const auto rc = osrm.Trip(params, result);
|
|
|
|
BOOST_CHECK(rc == Status::Ok);
|
|
|
|
|
2019-08-15 04:40:23 -04:00
|
|
|
auto &json_result = result.get<json::Object>();
|
2019-08-13 04:17:15 -04:00
|
|
|
const auto code = json_result.values.at("code").get<json::String>().value;
|
2017-02-10 05:13:20 -05:00
|
|
|
BOOST_CHECK_EQUAL(code, "Ok");
|
|
|
|
|
2019-08-13 04:17:15 -04:00
|
|
|
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values;
|
2017-02-10 05:13:20 -05:00
|
|
|
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
|
|
|
|
|
2019-08-13 04:17:15 -04:00
|
|
|
const auto &trips = json_result.values.at("trips").get<json::Array>().values;
|
2017-02-10 05:13:20 -05:00
|
|
|
BOOST_CHECK_EQUAL(trips.size(), 1);
|
|
|
|
|
|
|
|
for (const auto &waypoint : waypoints)
|
|
|
|
{
|
|
|
|
const auto &waypoint_object = waypoint.get<json::Object>();
|
|
|
|
|
|
|
|
const auto location = waypoint_object.values.at("location").get<json::Array>().values;
|
|
|
|
const auto longitude = location[0].get<json::Number>().value;
|
|
|
|
const auto latitude = location[1].get<json::Number>().value;
|
|
|
|
BOOST_CHECK(longitude >= -180. && longitude <= 180.);
|
|
|
|
BOOST_CHECK(latitude >= -90. && latitude <= 90.);
|
|
|
|
|
|
|
|
const auto trip = waypoint_object.values.at("trips_index").get<json::Number>().value;
|
|
|
|
const auto pos = waypoint_object.values.at("waypoint_index").get<json::Number>().value;
|
|
|
|
BOOST_CHECK(trip >= 0 && trip < trips.size());
|
|
|
|
BOOST_CHECK(pos >= 0 && pos < waypoints.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(test_tfse_2)
|
|
|
|
{
|
|
|
|
using namespace osrm;
|
|
|
|
|
2017-03-21 06:27:15 -04:00
|
|
|
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
2017-02-10 05:13:20 -05:00
|
|
|
const auto locations = get_locations_in_big_component();
|
|
|
|
|
|
|
|
TripParameters params;
|
|
|
|
params.coordinates.push_back(locations.at(0));
|
|
|
|
params.coordinates.push_back(locations.at(2));
|
|
|
|
params.coordinates.push_back(locations.at(1));
|
|
|
|
|
|
|
|
params.source = TripParameters::SourceType::First;
|
|
|
|
params.destination = TripParameters::DestinationType::Last;
|
|
|
|
params.roundtrip = false;
|
|
|
|
|
2019-08-13 04:17:15 -04:00
|
|
|
engine::api::ResultT result = json::Object();
|
2017-02-10 05:13:20 -05:00
|
|
|
const auto rc = osrm.Trip(params, result);
|
|
|
|
BOOST_CHECK(rc == Status::Ok);
|
|
|
|
|
2019-08-15 04:40:23 -04:00
|
|
|
auto &json_result = result.get<json::Object>();
|
2019-08-13 04:17:15 -04:00
|
|
|
const auto code = json_result.values.at("code").get<json::String>().value;
|
2017-02-10 05:13:20 -05:00
|
|
|
BOOST_CHECK_EQUAL(code, "Ok");
|
|
|
|
|
2019-08-13 04:17:15 -04:00
|
|
|
const auto &waypoints = json_result.values.at("waypoints").get<json::Array>().values;
|
2017-02-10 05:13:20 -05:00
|
|
|
BOOST_CHECK_EQUAL(waypoints.size(), params.coordinates.size());
|
|
|
|
|
2019-08-13 04:17:15 -04:00
|
|
|
const auto &trips = json_result.values.at("trips").get<json::Array>().values;
|
2017-02-10 05:13:20 -05:00
|
|
|
BOOST_CHECK_EQUAL(trips.size(), 1);
|
|
|
|
|
|
|
|
for (const auto &waypoint : waypoints)
|
|
|
|
{
|
|
|
|
const auto &waypoint_object = waypoint.get<json::Object>();
|
|
|
|
|
|
|
|
const auto location = waypoint_object.values.at("location").get<json::Array>().values;
|
|
|
|
const auto longitude = location[0].get<json::Number>().value;
|
|
|
|
const auto latitude = location[1].get<json::Number>().value;
|
|
|
|
BOOST_CHECK(longitude >= -180. && longitude <= 180.);
|
|
|
|
BOOST_CHECK(latitude >= -90. && latitude <= 90.);
|
|
|
|
|
|
|
|
const auto trip = waypoint_object.values.at("trips_index").get<json::Number>().value;
|
|
|
|
const auto pos = waypoint_object.values.at("waypoint_index").get<json::Number>().value;
|
|
|
|
BOOST_CHECK(trip >= 0 && trip < trips.size());
|
|
|
|
BOOST_CHECK(pos >= 0 && pos < waypoints.size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ResetParams(const Locations &locations, osrm::TripParameters ¶ms)
|
|
|
|
{
|
|
|
|
params = osrm::TripParameters();
|
|
|
|
params.coordinates.push_back(locations.at(0));
|
|
|
|
params.coordinates.push_back(locations.at(1));
|
|
|
|
params.coordinates.push_back(locations.at(2));
|
|
|
|
}
|
|
|
|
void CheckNotImplemented(const osrm::OSRM &osrm, osrm::TripParameters ¶ms)
|
|
|
|
{
|
2019-08-13 04:17:15 -04:00
|
|
|
using namespace osrm;
|
|
|
|
engine::api::ResultT result = json::Object();
|
2017-02-10 05:13:20 -05:00
|
|
|
auto rc = osrm.Trip(params, result);
|
|
|
|
BOOST_REQUIRE(rc == osrm::Status::Error);
|
2019-08-15 04:40:23 -04:00
|
|
|
auto &json_result = result.get<json::Object>();
|
2019-08-13 04:17:15 -04:00
|
|
|
auto code = json_result.values.at("code").get<osrm::json::String>().value;
|
2017-02-10 05:13:20 -05:00
|
|
|
BOOST_CHECK_EQUAL(code, "NotImplemented");
|
|
|
|
}
|
|
|
|
|
|
|
|
void CheckOk(const osrm::OSRM &osrm, osrm::TripParameters ¶ms)
|
|
|
|
{
|
2019-08-13 04:17:15 -04:00
|
|
|
using namespace osrm;
|
|
|
|
engine::api::ResultT result = json::Object();
|
2017-02-10 05:13:20 -05:00
|
|
|
auto rc = osrm.Trip(params, result);
|
|
|
|
BOOST_REQUIRE(rc == osrm::Status::Ok);
|
2019-08-15 04:40:23 -04:00
|
|
|
auto &json_result = result.get<json::Object>();
|
2019-08-13 04:17:15 -04:00
|
|
|
auto code = json_result.values.at("code").get<osrm::json::String>().value;
|
2017-02-10 05:13:20 -05:00
|
|
|
BOOST_CHECK_EQUAL(code, "Ok");
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(test_tfse_illegal_parameters)
|
|
|
|
{
|
|
|
|
using namespace osrm;
|
|
|
|
|
2017-03-21 06:27:15 -04:00
|
|
|
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
2017-02-10 05:13:20 -05:00
|
|
|
const auto locations = get_locations_in_big_component();
|
|
|
|
auto params = osrm::TripParameters();
|
|
|
|
|
|
|
|
// one parameter set
|
|
|
|
ResetParams(locations, params);
|
|
|
|
params.roundtrip = false;
|
|
|
|
CheckNotImplemented(osrm, params);
|
|
|
|
|
|
|
|
// two parameter set
|
|
|
|
ResetParams(locations, params);
|
|
|
|
params.source = TripParameters::SourceType::Any;
|
|
|
|
params.roundtrip = false;
|
|
|
|
CheckNotImplemented(osrm, params);
|
|
|
|
|
|
|
|
ResetParams(locations, params);
|
|
|
|
params.source = TripParameters::SourceType::First;
|
|
|
|
params.roundtrip = false;
|
|
|
|
CheckNotImplemented(osrm, params);
|
|
|
|
|
|
|
|
ResetParams(locations, params);
|
|
|
|
params.destination = TripParameters::DestinationType::Any;
|
|
|
|
params.roundtrip = false;
|
|
|
|
CheckNotImplemented(osrm, params);
|
|
|
|
|
|
|
|
ResetParams(locations, params);
|
|
|
|
params.destination = TripParameters::DestinationType::Last;
|
|
|
|
params.roundtrip = false;
|
|
|
|
CheckNotImplemented(osrm, params);
|
|
|
|
|
|
|
|
// three parameters set
|
|
|
|
params.source = TripParameters::SourceType::Any;
|
|
|
|
params.destination = TripParameters::DestinationType::Any;
|
|
|
|
params.roundtrip = false;
|
|
|
|
CheckNotImplemented(osrm, params);
|
|
|
|
|
|
|
|
params.source = TripParameters::SourceType::Any;
|
|
|
|
params.destination = TripParameters::DestinationType::Last;
|
|
|
|
params.roundtrip = false;
|
|
|
|
CheckNotImplemented(osrm, params);
|
|
|
|
|
|
|
|
params.source = TripParameters::SourceType::First;
|
|
|
|
params.destination = TripParameters::DestinationType::Any;
|
|
|
|
params.roundtrip = false;
|
|
|
|
CheckNotImplemented(osrm, params);
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOST_AUTO_TEST_CASE(test_tfse_legal_parameters)
|
|
|
|
{
|
|
|
|
using namespace osrm;
|
2017-03-21 06:27:15 -04:00
|
|
|
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
2017-02-10 05:13:20 -05:00
|
|
|
const auto locations = get_locations_in_big_component();
|
|
|
|
json::Object result;
|
|
|
|
TripParameters params;
|
|
|
|
|
|
|
|
// no parameter set
|
|
|
|
ResetParams(locations, params);
|
|
|
|
CheckOk(osrm, params);
|
|
|
|
|
|
|
|
// one parameter set
|
|
|
|
ResetParams(locations, params);
|
|
|
|
params.roundtrip = true;
|
|
|
|
CheckOk(osrm, params);
|
|
|
|
|
|
|
|
ResetParams(locations, params);
|
|
|
|
params.source = TripParameters::SourceType::First;
|
|
|
|
CheckOk(osrm, params);
|
|
|
|
|
|
|
|
ResetParams(locations, params);
|
|
|
|
params.source = TripParameters::SourceType::Any;
|
|
|
|
CheckOk(osrm, params);
|
|
|
|
|
|
|
|
ResetParams(locations, params);
|
|
|
|
params.destination = TripParameters::DestinationType::Any;
|
|
|
|
CheckOk(osrm, params);
|
|
|
|
|
|
|
|
ResetParams(locations, params);
|
|
|
|
params.destination = TripParameters::DestinationType::Last;
|
|
|
|
CheckOk(osrm, params);
|
|
|
|
|
|
|
|
// two parameter set
|
|
|
|
ResetParams(locations, params);
|
|
|
|
params.destination = TripParameters::DestinationType::Last;
|
|
|
|
params.roundtrip = true;
|
|
|
|
CheckOk(osrm, params);
|
|
|
|
|
|
|
|
ResetParams(locations, params);
|
|
|
|
params.source = TripParameters::SourceType::First;
|
|
|
|
params.roundtrip = true;
|
|
|
|
CheckOk(osrm, params);
|
|
|
|
|
|
|
|
ResetParams(locations, params);
|
|
|
|
params.source = TripParameters::SourceType::First;
|
|
|
|
params.destination = TripParameters::DestinationType::Any;
|
|
|
|
CheckOk(osrm, params);
|
|
|
|
|
|
|
|
ResetParams(locations, params);
|
|
|
|
params.source = TripParameters::SourceType::Any;
|
|
|
|
params.destination = TripParameters::DestinationType::Last;
|
|
|
|
CheckOk(osrm, params);
|
|
|
|
|
|
|
|
ResetParams(locations, params);
|
|
|
|
params.source = TripParameters::SourceType::First;
|
|
|
|
params.destination = TripParameters::DestinationType::Last;
|
|
|
|
CheckOk(osrm, params);
|
|
|
|
|
|
|
|
ResetParams(locations, params);
|
|
|
|
params.source = TripParameters::SourceType::Any;
|
|
|
|
params.roundtrip = true;
|
|
|
|
CheckOk(osrm, params);
|
|
|
|
|
|
|
|
ResetParams(locations, params);
|
|
|
|
params.destination = TripParameters::DestinationType::Any;
|
|
|
|
params.roundtrip = true;
|
|
|
|
CheckOk(osrm, params);
|
|
|
|
|
|
|
|
ResetParams(locations, params);
|
|
|
|
params.source = TripParameters::SourceType::Any;
|
|
|
|
params.destination = TripParameters::DestinationType::Any;
|
|
|
|
CheckOk(osrm, params);
|
|
|
|
|
|
|
|
// three parameter set
|
|
|
|
params.source = TripParameters::SourceType::Any;
|
|
|
|
params.destination = TripParameters::DestinationType::Any;
|
|
|
|
params.roundtrip = true;
|
|
|
|
CheckOk(osrm, params);
|
|
|
|
|
|
|
|
params.source = TripParameters::SourceType::First;
|
|
|
|
params.destination = TripParameters::DestinationType::Last;
|
|
|
|
params.roundtrip = false;
|
|
|
|
CheckOk(osrm, params);
|
|
|
|
|
|
|
|
params.source = TripParameters::SourceType::Any;
|
|
|
|
params.destination = TripParameters::DestinationType::Last;
|
|
|
|
params.roundtrip = true;
|
|
|
|
CheckOk(osrm, params);
|
|
|
|
|
|
|
|
params.source = TripParameters::SourceType::First;
|
|
|
|
params.destination = TripParameters::DestinationType::Any;
|
|
|
|
params.roundtrip = true;
|
|
|
|
CheckOk(osrm, params);
|
|
|
|
|
|
|
|
params.source = TripParameters::SourceType::First;
|
|
|
|
params.destination = TripParameters::DestinationType::Last;
|
|
|
|
params.roundtrip = true;
|
|
|
|
CheckOk(osrm, params);
|
|
|
|
}
|
|
|
|
|
2019-09-16 09:39:09 -04:00
|
|
|
BOOST_AUTO_TEST_CASE(test_roundtrip_response_fb_serialization)
|
|
|
|
{
|
|
|
|
using namespace osrm;
|
|
|
|
|
|
|
|
auto osrm = getOSRM(OSRM_TEST_DATA_DIR "/ch/monaco.osrm");
|
|
|
|
const auto locations = get_locations_in_small_component();
|
|
|
|
|
|
|
|
TripParameters params;
|
|
|
|
params.coordinates.push_back(locations.at(0));
|
|
|
|
params.coordinates.push_back(locations.at(1));
|
|
|
|
params.coordinates.push_back(locations.at(2));
|
|
|
|
|
|
|
|
engine::api::ResultT result = flatbuffers::FlatBufferBuilder();
|
|
|
|
const auto rc = osrm.Trip(params, result);
|
|
|
|
BOOST_CHECK(rc == Status::Ok);
|
|
|
|
|
|
|
|
auto &fb_result = result.get<flatbuffers::FlatBufferBuilder>();
|
|
|
|
auto fb = engine::api::fbresult::GetFBResult(fb_result.GetBufferPointer());
|
|
|
|
|
|
|
|
BOOST_CHECK(!fb->error());
|
|
|
|
|
|
|
|
BOOST_CHECK(fb->waypoints() != nullptr);
|
|
|
|
const auto waypoints = fb->waypoints();
|
|
|
|
BOOST_CHECK(waypoints->size() == params.coordinates.size());
|
|
|
|
|
|
|
|
BOOST_CHECK(fb->routes() != nullptr);
|
|
|
|
const auto trips = fb->routes();
|
|
|
|
BOOST_CHECK_EQUAL(trips->size(), 1);
|
|
|
|
|
|
|
|
for (const auto &waypoint : *waypoints)
|
|
|
|
{
|
|
|
|
const auto longitude = waypoint->location()->longitude();
|
|
|
|
const auto latitude = waypoint->location()->latitude();
|
|
|
|
BOOST_CHECK(longitude >= -180. && longitude <= 180.);
|
|
|
|
BOOST_CHECK(latitude >= -90. && latitude <= 90.);
|
|
|
|
|
|
|
|
const auto trip = waypoint->trips_index();
|
|
|
|
const auto pos = waypoint->waypoint_index();
|
|
|
|
BOOST_CHECK(trip < trips->size());
|
|
|
|
BOOST_CHECK(pos < waypoints->size());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-16 06:58:39 -04:00
|
|
|
BOOST_AUTO_TEST_SUITE_END()
|