wip
This commit is contained in:
parent
ad990aafe7
commit
1f6e4ff9db
@ -10,8 +10,7 @@
|
|||||||
|
|
||||||
namespace osrm::engine::api
|
namespace osrm::engine::api
|
||||||
{
|
{
|
||||||
using ResultT =
|
using ResultT = std::variant<util::json::Object, std::string, flatbuffers::FlatBufferBuilder>;
|
||||||
std::variant<util::json::Object, std::string, flatbuffers::FlatBufferBuilder>;
|
|
||||||
} // namespace osrm::engine::api
|
} // namespace osrm::engine::api
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -426,8 +426,7 @@ class RouteAPI : public BaseAPI
|
|||||||
routeObject.add_legs(legs_vector);
|
routeObject.add_legs(legs_vector);
|
||||||
if (overview)
|
if (overview)
|
||||||
{
|
{
|
||||||
std::visit(GeometryVisitor<fbresult::RouteObjectBuilder>(routeObject),
|
std::visit(GeometryVisitor<fbresult::RouteObjectBuilder>(routeObject), geometry);
|
||||||
geometry);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return routeObject.Finish();
|
return routeObject.Finish();
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "util/typedefs.hpp"
|
#include "util/typedefs.hpp"
|
||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <mapbox/variant.hpp>
|
#include <variant>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
namespace osrm::extractor
|
namespace osrm::extractor
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "util/std_hash.hpp"
|
#include "util/std_hash.hpp"
|
||||||
#include "util/vector_view.hpp"
|
#include "util/vector_view.hpp"
|
||||||
|
|
||||||
#include <mapbox/variant.hpp>
|
#include <variant>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "util/typedefs.hpp"
|
#include "util/typedefs.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <mapbox/variant.hpp>
|
#include <variant>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace osrm::extractor
|
namespace osrm::extractor
|
||||||
@ -61,50 +61,50 @@ struct InputViaWayPath
|
|||||||
|
|
||||||
struct InputTurnPath
|
struct InputTurnPath
|
||||||
{
|
{
|
||||||
mapbox::util::variant<InputViaNodePath, InputViaWayPath> node_or_way;
|
std::variant<InputViaNodePath, InputViaWayPath> node_or_way;
|
||||||
|
|
||||||
TurnPathType Type() const
|
TurnPathType Type() const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(node_or_way.which() < TurnPathType::NUM_TURN_PATH_TYPES);
|
BOOST_ASSERT(node_or_way.index() < TurnPathType::NUM_TURN_PATH_TYPES);
|
||||||
return static_cast<TurnPathType>(node_or_way.which());
|
return static_cast<TurnPathType>(node_or_way.index());
|
||||||
}
|
}
|
||||||
|
|
||||||
OSMWayID From() const
|
OSMWayID From() const
|
||||||
{
|
{
|
||||||
return node_or_way.which() == TurnPathType::VIA_NODE_TURN_PATH
|
return node_or_way.index() == TurnPathType::VIA_NODE_TURN_PATH
|
||||||
? mapbox::util::get<InputViaNodePath>(node_or_way).from
|
? std::get<InputViaNodePath>(node_or_way).from
|
||||||
: mapbox::util::get<InputViaWayPath>(node_or_way).from;
|
: std::get<InputViaWayPath>(node_or_way).from;
|
||||||
}
|
}
|
||||||
|
|
||||||
OSMWayID To() const
|
OSMWayID To() const
|
||||||
{
|
{
|
||||||
return node_or_way.which() == TurnPathType::VIA_NODE_TURN_PATH
|
return node_or_way.index() == TurnPathType::VIA_NODE_TURN_PATH
|
||||||
? mapbox::util::get<InputViaNodePath>(node_or_way).to
|
? std::get<InputViaNodePath>(node_or_way).to
|
||||||
: mapbox::util::get<InputViaWayPath>(node_or_way).to;
|
: std::get<InputViaWayPath>(node_or_way).to;
|
||||||
}
|
}
|
||||||
|
|
||||||
InputViaWayPath &AsViaWayPath()
|
InputViaWayPath &AsViaWayPath()
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(node_or_way.which() == TurnPathType::VIA_WAY_TURN_PATH);
|
BOOST_ASSERT(node_or_way.index() == TurnPathType::VIA_WAY_TURN_PATH);
|
||||||
return mapbox::util::get<InputViaWayPath>(node_or_way);
|
return std::get<InputViaWayPath>(node_or_way);
|
||||||
}
|
}
|
||||||
|
|
||||||
const InputViaWayPath &AsViaWayPath() const
|
const InputViaWayPath &AsViaWayPath() const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(node_or_way.which() == TurnPathType::VIA_WAY_TURN_PATH);
|
BOOST_ASSERT(node_or_way.index() == TurnPathType::VIA_WAY_TURN_PATH);
|
||||||
return mapbox::util::get<InputViaWayPath>(node_or_way);
|
return std::get<InputViaWayPath>(node_or_way);
|
||||||
}
|
}
|
||||||
|
|
||||||
InputViaNodePath &AsViaNodePath()
|
InputViaNodePath &AsViaNodePath()
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(node_or_way.which() == TurnPathType::VIA_NODE_TURN_PATH);
|
BOOST_ASSERT(node_or_way.index() == TurnPathType::VIA_NODE_TURN_PATH);
|
||||||
return mapbox::util::get<InputViaNodePath>(node_or_way);
|
return std::get<InputViaNodePath>(node_or_way);
|
||||||
}
|
}
|
||||||
|
|
||||||
const InputViaNodePath &AsViaNodePath() const
|
const InputViaNodePath &AsViaNodePath() const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(node_or_way.which() == TurnPathType::VIA_NODE_TURN_PATH);
|
BOOST_ASSERT(node_or_way.index() == TurnPathType::VIA_NODE_TURN_PATH);
|
||||||
return mapbox::util::get<InputViaNodePath>(node_or_way);
|
return std::get<InputViaNodePath>(node_or_way);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -175,63 +175,63 @@ struct ViaWayPath
|
|||||||
// between node/way paths
|
// between node/way paths
|
||||||
struct TurnPath
|
struct TurnPath
|
||||||
{
|
{
|
||||||
mapbox::util::variant<ViaNodePath, ViaWayPath> node_or_way;
|
std::variant<ViaNodePath, ViaWayPath> node_or_way;
|
||||||
|
|
||||||
NodeID To() const
|
NodeID To() const
|
||||||
{
|
{
|
||||||
return node_or_way.which() == TurnPathType::VIA_NODE_TURN_PATH
|
return node_or_way.index() == TurnPathType::VIA_NODE_TURN_PATH
|
||||||
? mapbox::util::get<ViaNodePath>(node_or_way).to
|
? std::get<ViaNodePath>(node_or_way).to
|
||||||
: mapbox::util::get<ViaWayPath>(node_or_way).to;
|
: std::get<ViaWayPath>(node_or_way).to;
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID From() const
|
NodeID From() const
|
||||||
{
|
{
|
||||||
return node_or_way.which() == TurnPathType::VIA_NODE_TURN_PATH
|
return node_or_way.index() == TurnPathType::VIA_NODE_TURN_PATH
|
||||||
? mapbox::util::get<ViaNodePath>(node_or_way).from
|
? std::get<ViaNodePath>(node_or_way).from
|
||||||
: mapbox::util::get<ViaWayPath>(node_or_way).from;
|
: std::get<ViaWayPath>(node_or_way).from;
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeID FirstVia() const
|
NodeID FirstVia() const
|
||||||
{
|
{
|
||||||
if (node_or_way.which() == TurnPathType::VIA_NODE_TURN_PATH)
|
if (node_or_way.index() == TurnPathType::VIA_NODE_TURN_PATH)
|
||||||
{
|
{
|
||||||
return mapbox::util::get<ViaNodePath>(node_or_way).via;
|
return std::get<ViaNodePath>(node_or_way).via;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(!mapbox::util::get<ViaWayPath>(node_or_way).via.empty());
|
BOOST_ASSERT(!std::get<ViaWayPath>(node_or_way).via.empty());
|
||||||
return mapbox::util::get<ViaWayPath>(node_or_way).via[0];
|
return std::get<ViaWayPath>(node_or_way).via[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ViaWayPath &AsViaWayPath()
|
ViaWayPath &AsViaWayPath()
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(node_or_way.which() == TurnPathType::VIA_WAY_TURN_PATH);
|
BOOST_ASSERT(node_or_way.index() == TurnPathType::VIA_WAY_TURN_PATH);
|
||||||
return mapbox::util::get<ViaWayPath>(node_or_way);
|
return std::get<ViaWayPath>(node_or_way);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ViaWayPath &AsViaWayPath() const
|
const ViaWayPath &AsViaWayPath() const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(node_or_way.which() == TurnPathType::VIA_WAY_TURN_PATH);
|
BOOST_ASSERT(node_or_way.index() == TurnPathType::VIA_WAY_TURN_PATH);
|
||||||
return mapbox::util::get<ViaWayPath>(node_or_way);
|
return std::get<ViaWayPath>(node_or_way);
|
||||||
}
|
}
|
||||||
|
|
||||||
ViaNodePath &AsViaNodePath()
|
ViaNodePath &AsViaNodePath()
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(node_or_way.which() == TurnPathType::VIA_NODE_TURN_PATH);
|
BOOST_ASSERT(node_or_way.index() == TurnPathType::VIA_NODE_TURN_PATH);
|
||||||
return mapbox::util::get<ViaNodePath>(node_or_way);
|
return std::get<ViaNodePath>(node_or_way);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ViaNodePath &AsViaNodePath() const
|
const ViaNodePath &AsViaNodePath() const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(node_or_way.which() == TurnPathType::VIA_NODE_TURN_PATH);
|
BOOST_ASSERT(node_or_way.index() == TurnPathType::VIA_NODE_TURN_PATH);
|
||||||
return mapbox::util::get<ViaNodePath>(node_or_way);
|
return std::get<ViaNodePath>(node_or_way);
|
||||||
}
|
}
|
||||||
|
|
||||||
TurnPathType Type() const
|
TurnPathType Type() const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(node_or_way.which() < TurnPathType::NUM_TURN_PATH_TYPES);
|
BOOST_ASSERT(node_or_way.index() < TurnPathType::NUM_TURN_PATH_TYPES);
|
||||||
return static_cast<TurnPathType>(node_or_way.which());
|
return static_cast<TurnPathType>(node_or_way.index());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator==(const TurnPath &other) const
|
bool operator==(const TurnPath &other) const
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <variant>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
@ -50,7 +51,7 @@ struct PluginParameters
|
|||||||
bool renderToBuffer = false;
|
bool renderToBuffer = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
using ObjectOrString = typename mapbox::util::variant<osrm::json::Object, std::string>;
|
using ObjectOrString = typename std::variant<osrm::json::Object, std::string>;
|
||||||
|
|
||||||
template <typename ResultT> inline Napi::Value render(const Napi::Env &env, const ResultT &result);
|
template <typename ResultT> inline Napi::Value render(const Napi::Env &env, const ResultT &result);
|
||||||
|
|
||||||
@ -61,7 +62,7 @@ template <> Napi::Value inline render(const Napi::Env &env, const std::string &r
|
|||||||
|
|
||||||
template <> Napi::Value inline render(const Napi::Env &env, const ObjectOrString &result)
|
template <> Napi::Value inline render(const Napi::Env &env, const ObjectOrString &result)
|
||||||
{
|
{
|
||||||
if (result.is<osrm::json::Object>())
|
if (std::holds_alternative<osrm::json::Object>(result))
|
||||||
{
|
{
|
||||||
// Convert osrm::json object tree into matching v8 object tree
|
// Convert osrm::json object tree into matching v8 object tree
|
||||||
Napi::Value value;
|
Napi::Value value;
|
||||||
@ -95,7 +96,7 @@ inline void ParseResult(const osrm::Status &result_status, osrm::json::Object &r
|
|||||||
|
|
||||||
if (result_status == osrm::Status::Error)
|
if (result_status == osrm::Status::Error)
|
||||||
{
|
{
|
||||||
throw std::logic_error(code_iter->second.get<osrm::json::String>().value.c_str());
|
throw std::logic_error(std::get<osrm::json::String>(code_iter->second).value.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
result.values.erase(code_iter);
|
result.values.erase(code_iter);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include "osrm/osrm.hpp"
|
#include "osrm/osrm.hpp"
|
||||||
#include "util/coordinate.hpp"
|
#include "util/coordinate.hpp"
|
||||||
|
|
||||||
#include <mapbox/variant.hpp>
|
#include <variant>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
@ -31,11 +31,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#ifndef JSON_CONTAINER_HPP
|
#ifndef JSON_CONTAINER_HPP
|
||||||
#define JSON_CONTAINER_HPP
|
#define JSON_CONTAINER_HPP
|
||||||
|
|
||||||
#include <variant>
|
|
||||||
#include <boost/variant/recursive_wrapper.hpp>
|
#include <boost/variant/recursive_wrapper.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
#include <variant>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace osrm::util::json
|
namespace osrm::util::json
|
||||||
@ -96,13 +96,7 @@ struct Null
|
|||||||
*
|
*
|
||||||
* Dispatch on its type by either by using apply_visitor or its get function.
|
* Dispatch on its type by either by using apply_visitor or its get function.
|
||||||
*/
|
*/
|
||||||
using Value = std::variant<String,
|
using Value = std::variant<String, Number, Object, Array, True, False, Null>;
|
||||||
Number,
|
|
||||||
Object,
|
|
||||||
Array,
|
|
||||||
True,
|
|
||||||
False,
|
|
||||||
Null>;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Typed Object.
|
* Typed Object.
|
||||||
|
@ -81,8 +81,8 @@ struct Comparator
|
|||||||
|
|
||||||
const auto &rhs_child = rhs.values.find(key)->second;
|
const auto &rhs_child = rhs.values.find(key)->second;
|
||||||
const auto &lhs_child = lhs.values.find(key)->second;
|
const auto &lhs_child = lhs.values.find(key)->second;
|
||||||
auto is_same = std::visit(
|
auto is_same =
|
||||||
Comparator(reason, lhs_path + "." + key, rhs_path + "." + key),
|
std::visit(Comparator(reason, lhs_path + "." + key, rhs_path + "." + key),
|
||||||
lhs_child,
|
lhs_child,
|
||||||
rhs_child);
|
rhs_child);
|
||||||
if (!is_same)
|
if (!is_same)
|
||||||
@ -104,8 +104,7 @@ struct Comparator
|
|||||||
|
|
||||||
for (auto i = 0UL; i < lhs.values.size(); ++i)
|
for (auto i = 0UL; i < lhs.values.size(); ++i)
|
||||||
{
|
{
|
||||||
auto is_same =
|
auto is_same = std::visit(Comparator(reason,
|
||||||
std::visit(Comparator(reason,
|
|
||||||
lhs_path + "[" + std::to_string(i) + "]",
|
lhs_path + "[" + std::to_string(i) + "]",
|
||||||
rhs_path + "[" + std::to_string(i) + "]"),
|
rhs_path + "[" + std::to_string(i) + "]"),
|
||||||
lhs.values[i],
|
lhs.values[i],
|
||||||
@ -151,8 +150,7 @@ struct Comparator
|
|||||||
|
|
||||||
inline bool compare(const Value &reference, const Value &result, std::string &reason)
|
inline bool compare(const Value &reference, const Value &result, std::string &reason)
|
||||||
{
|
{
|
||||||
return std::visit(
|
return std::visit(Comparator(reason, "reference", "result"), reference, result);
|
||||||
Comparator(reason, "reference", "result"), reference, result);
|
|
||||||
}
|
}
|
||||||
} // namespace osrm::util::json
|
} // namespace osrm::util::json
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ try
|
|||||||
const auto rc = osrm.Match(params, result);
|
const auto rc = osrm.Match(params, result);
|
||||||
auto &json_result = std::get<json::Object>(result);
|
auto &json_result = std::get<json::Object>(result);
|
||||||
if (rc != Status::Ok ||
|
if (rc != Status::Ok ||
|
||||||
json_result.values.at("matchings").get<json::Array>().values.size() != 1)
|
std::get<json::Array>(json_result.values.at("matchings")).values.size() != 1)
|
||||||
{
|
{
|
||||||
throw std::runtime_error{"Couldn't match"};
|
throw std::runtime_error{"Couldn't match"};
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ inline void async(const Napi::CallbackInfo &info,
|
|||||||
osrm::engine::api::ResultT r;
|
osrm::engine::api::ResultT r;
|
||||||
r = osrm::util::json::Object();
|
r = osrm::util::json::Object();
|
||||||
const auto status = ((*osrm).*(service))(*params, r);
|
const auto status = ((*osrm).*(service))(*params, r);
|
||||||
auto &json_result = r.get<osrm::json::Object>();
|
auto &json_result = std::get<osrm::json::Object>(r);
|
||||||
ParseResult(status, json_result);
|
ParseResult(status, json_result);
|
||||||
if (pluginParams.renderToBuffer)
|
if (pluginParams.renderToBuffer)
|
||||||
{
|
{
|
||||||
|
@ -64,10 +64,9 @@ void test_match(bool use_json_only_api)
|
|||||||
std::get<json::Number>(waypoint_object.values.at("matchings_index")).value;
|
std::get<json::Number>(waypoint_object.values.at("matchings_index")).value;
|
||||||
const auto waypoint_index =
|
const auto waypoint_index =
|
||||||
std::get<json::Number>(waypoint_object.values.at("waypoint_index")).value;
|
std::get<json::Number>(waypoint_object.values.at("waypoint_index")).value;
|
||||||
const auto &route_legs = std::get<json::Array>(std::get<json::Object>(matchings[matchings_index]
|
const auto &route_legs =
|
||||||
)
|
std::get<json::Array>(
|
||||||
.values.at("legs")
|
std::get<json::Object>(matchings[matchings_index]).values.at("legs"))
|
||||||
)
|
|
||||||
.values;
|
.values;
|
||||||
BOOST_CHECK_LT(waypoint_index, route_legs.size() + 1);
|
BOOST_CHECK_LT(waypoint_index, route_legs.size() + 1);
|
||||||
BOOST_CHECK_LT(matchings_index, number_of_matchings);
|
BOOST_CHECK_LT(matchings_index, number_of_matchings);
|
||||||
@ -122,7 +121,7 @@ void test_match_split(bool use_json_only_api)
|
|||||||
const auto code = std::get<json::String>(json_result.values.at("code")).value;
|
const auto code = std::get<json::String>(json_result.values.at("code")).value;
|
||||||
BOOST_CHECK_EQUAL(code, "Ok");
|
BOOST_CHECK_EQUAL(code, "Ok");
|
||||||
|
|
||||||
const auto &tracepoints =std::get<json::Array>(json_result.values.at("tracepoints")).values;
|
const auto &tracepoints = std::get<json::Array>(json_result.values.at("tracepoints")).values;
|
||||||
BOOST_CHECK_EQUAL(tracepoints.size(), params.coordinates.size());
|
BOOST_CHECK_EQUAL(tracepoints.size(), params.coordinates.size());
|
||||||
|
|
||||||
const auto &matchings = std::get<json::Array>(json_result.values.at("matchings")).values;
|
const auto &matchings = std::get<json::Array>(json_result.values.at("matchings")).values;
|
||||||
|
@ -54,8 +54,8 @@ void test_route_same_coordinates_fixture(bool use_json_only_api)
|
|||||||
std::get<json::Object>(itr).values["hint"] = "";
|
std::get<json::Object>(itr).values["hint"] = "";
|
||||||
|
|
||||||
// Round value to 6 decimal places for double comparison later
|
// Round value to 6 decimal places for double comparison later
|
||||||
std::get<json::Object>(itr).values["distance"] =
|
std::get<json::Object>(itr).values["distance"] = round(
|
||||||
round(std::get<json::Number>(std::get<json::Object>(itr).values["distance"]).value * 1000000);
|
std::get<json::Number>(std::get<json::Object>(itr).values["distance"]).value * 1000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto location = json::Array{{{7.437070}, {43.749248}}};
|
const auto location = json::Array{{{7.437070}, {43.749248}}};
|
||||||
@ -221,14 +221,17 @@ void test_route_same_coordinates(bool use_json_only_api)
|
|||||||
{
|
{
|
||||||
const auto &step_object = std::get<json::Object>(step);
|
const auto &step_object = std::get<json::Object>(step);
|
||||||
|
|
||||||
const auto distance = std::get<json::Number>(step_object.values.at("distance")).value;
|
const auto distance =
|
||||||
|
std::get<json::Number>(step_object.values.at("distance")).value;
|
||||||
BOOST_CHECK_EQUAL(distance, 0);
|
BOOST_CHECK_EQUAL(distance, 0);
|
||||||
|
|
||||||
const auto duration = std::get<json::Number>(step_object.values.at("duration")).value;
|
const auto duration =
|
||||||
|
std::get<json::Number>(step_object.values.at("duration")).value;
|
||||||
BOOST_CHECK_EQUAL(duration, 0);
|
BOOST_CHECK_EQUAL(duration, 0);
|
||||||
|
|
||||||
// geometries=polyline by default
|
// geometries=polyline by default
|
||||||
const auto geometry = std::get<json::String>(step_object.values.at("geometry")).value;
|
const auto geometry =
|
||||||
|
std::get<json::String>(step_object.values.at("geometry")).value;
|
||||||
BOOST_CHECK(!geometry.empty());
|
BOOST_CHECK(!geometry.empty());
|
||||||
|
|
||||||
// nothing can be said about name, empty or contains way name
|
// nothing can be said about name, empty or contains way name
|
||||||
@ -239,7 +242,8 @@ void test_route_same_coordinates(bool use_json_only_api)
|
|||||||
const auto mode = std::get<json::String>(step_object.values.at("mode")).value;
|
const auto mode = std::get<json::String>(step_object.values.at("mode")).value;
|
||||||
BOOST_CHECK(!name.empty());
|
BOOST_CHECK(!name.empty());
|
||||||
|
|
||||||
const auto &maneuver = std::get<json::Object>(step_object.values.at("maneuver")).values;
|
const auto &maneuver =
|
||||||
|
std::get<json::Object>(step_object.values.at("maneuver")).values;
|
||||||
|
|
||||||
const auto type = std::get<json::String>(maneuver.at("type")).value;
|
const auto type = std::get<json::String>(maneuver.at("type")).value;
|
||||||
BOOST_CHECK(!type.empty());
|
BOOST_CHECK(!type.empty());
|
||||||
@ -260,7 +264,8 @@ void test_route_same_coordinates(bool use_json_only_api)
|
|||||||
const auto &bearings =
|
const auto &bearings =
|
||||||
std::get<json::Array>(intersection_object.at("bearings")).values;
|
std::get<json::Array>(intersection_object.at("bearings")).values;
|
||||||
BOOST_CHECK(!bearings.empty());
|
BOOST_CHECK(!bearings.empty());
|
||||||
const auto &entries = std::get<json::Array>(intersection_object.at("entry")).values;
|
const auto &entries =
|
||||||
|
std::get<json::Array>(intersection_object.at("entry")).values;
|
||||||
BOOST_CHECK(bearings.size() == entries.size());
|
BOOST_CHECK(bearings.size() == entries.size());
|
||||||
|
|
||||||
for (const auto &bearing : bearings)
|
for (const auto &bearing : bearings)
|
||||||
@ -274,7 +279,8 @@ void test_route_same_coordinates(bool use_json_only_api)
|
|||||||
}
|
}
|
||||||
if (step_count + 1 < steps.size())
|
if (step_count + 1 < steps.size())
|
||||||
{
|
{
|
||||||
const auto out = std::get<json::Number>(intersection_object.at("out")).value;
|
const auto out =
|
||||||
|
std::get<json::Number>(intersection_object.at("out")).value;
|
||||||
BOOST_CHECK(out < bearings.size());
|
BOOST_CHECK(out < bearings.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -523,7 +529,8 @@ void speed_annotation_matches_duration_and_distance(bool use_json_only_api)
|
|||||||
BOOST_CHECK(rc == Status::Ok);
|
BOOST_CHECK(rc == Status::Ok);
|
||||||
|
|
||||||
const auto &routes = std::get<json::Array>(json_result.values["routes"]).values;
|
const auto &routes = std::get<json::Array>(json_result.values["routes"]).values;
|
||||||
const auto &legs = std::get<json::Array>(std::get<json::Object>(routes[0]).values.at("legs")).values;
|
const auto &legs =
|
||||||
|
std::get<json::Array>(std::get<json::Object>(routes[0]).values.at("legs")).values;
|
||||||
const auto &annotation =
|
const auto &annotation =
|
||||||
std::get<json::Object>(std::get<json::Object>(legs[0]).values.at("annotation"));
|
std::get<json::Object>(std::get<json::Object>(legs[0]).values.at("annotation"));
|
||||||
const auto &speeds = std::get<json::Array>(annotation.values.at("speed")).values;
|
const auto &speeds = std::get<json::Array>(annotation.values.at("speed")).values;
|
||||||
@ -573,16 +580,16 @@ void test_manual_setting_of_annotations_property(bool use_json_only_api)
|
|||||||
const auto code = std::get<json::String>(json_result.values.at("code")).value;
|
const auto code = std::get<json::String>(json_result.values.at("code")).value;
|
||||||
BOOST_CHECK_EQUAL(code, "Ok");
|
BOOST_CHECK_EQUAL(code, "Ok");
|
||||||
|
|
||||||
auto annotations = std::get<json::Object>(
|
auto annotations =
|
||||||
|
std::get<json::Object>(
|
||||||
std::get<json::Object>(
|
std::get<json::Object>(
|
||||||
std::get<json::Array>(
|
std::get<json::Array>(
|
||||||
std::get<json::Object>(
|
std::get<json::Object>(
|
||||||
std::get<json::Array>(json_result.values["routes"])
|
std::get<json::Array>(json_result.values["routes"]).values[0])
|
||||||
.values[0])
|
|
||||||
.values["legs"])
|
.values["legs"])
|
||||||
.values[0])
|
.values[0])
|
||||||
.values["annotation"])
|
.values["annotation"])
|
||||||
.values;
|
.values;
|
||||||
BOOST_CHECK_EQUAL(annotations.size(), 7);
|
BOOST_CHECK_EQUAL(annotations.size(), 7);
|
||||||
}
|
}
|
||||||
BOOST_AUTO_TEST_CASE(test_manual_setting_of_annotations_property_old_api)
|
BOOST_AUTO_TEST_CASE(test_manual_setting_of_annotations_property_old_api)
|
||||||
|
@ -135,7 +135,7 @@ void test_table_three_coords_one_source_one_dest_matrix_no_waypoints(bool use_js
|
|||||||
BOOST_CHECK_EQUAL(distances_array.size(), params.sources.size());
|
BOOST_CHECK_EQUAL(distances_array.size(), params.sources.size());
|
||||||
for (unsigned int i = 0; i < distances_array.size(); i++)
|
for (unsigned int i = 0; i < distances_array.size(); i++)
|
||||||
{
|
{
|
||||||
const auto distances_matrix =std::get<json::Array>(distances_array[i]).values;
|
const auto distances_matrix = std::get<json::Array>(distances_array[i]).values;
|
||||||
BOOST_CHECK_EQUAL(distances_matrix.size(),
|
BOOST_CHECK_EQUAL(distances_matrix.size(),
|
||||||
params.sources.size() * params.destinations.size());
|
params.sources.size() * params.destinations.size());
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -16,7 +16,8 @@ inline bool waypoint_check(osrm::json::Value waypoint)
|
|||||||
throw util::exception("Must pass in a waypoint object");
|
throw util::exception("Must pass in a waypoint object");
|
||||||
}
|
}
|
||||||
const auto waypoint_object = std::get<json::Object>(waypoint);
|
const auto waypoint_object = std::get<json::Object>(waypoint);
|
||||||
const auto waypoint_location = std::get<json::Array>(waypoint_object.values.at("location")).values;
|
const auto waypoint_location =
|
||||||
|
std::get<json::Array>(waypoint_object.values.at("location")).values;
|
||||||
util::FloatLongitude lon{std::get<json::Number>(waypoint_location[0]).value};
|
util::FloatLongitude lon{std::get<json::Number>(waypoint_location[0]).value};
|
||||||
util::FloatLatitude lat{std::get<json::Number>(waypoint_location[1]).value};
|
util::FloatLatitude lat{std::get<json::Number>(waypoint_location[1]).value};
|
||||||
util::Coordinate location_coordinate(lon, lat);
|
util::Coordinate location_coordinate(lon, lat);
|
||||||
|
Loading…
Reference in New Issue
Block a user