Merge branch 'master' into sf-re-use-heap-in-getNetworkDistance
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#define ENGINE_API_BASE_RESULT_HPP
|
||||
|
||||
#include <flatbuffers/flatbuffers.h>
|
||||
#include <mapbox/variant.hpp>
|
||||
#include <variant>
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
|
||||
namespace osrm::engine::api
|
||||
{
|
||||
using ResultT =
|
||||
mapbox::util::variant<util::json::Object, std::string, flatbuffers::FlatBufferBuilder>;
|
||||
using ResultT = std::variant<util::json::Object, std::string, flatbuffers::FlatBufferBuilder>;
|
||||
} // namespace osrm::engine::api
|
||||
|
||||
#endif
|
||||
|
||||
@@ -41,7 +41,7 @@ inline bool hasValidLanes(const guidance::IntermediateIntersection &intersection
|
||||
return intersection.lanes.lanes_in_turn > 0;
|
||||
}
|
||||
|
||||
util::json::Array coordinateToLonLat(const util::Coordinate &coordinate);
|
||||
util::json::Value coordinateToLonLat(const util::Coordinate &coordinate);
|
||||
|
||||
/**
|
||||
* Ensures that a bearing value is a whole number, and clamped to the range 0-359
|
||||
@@ -79,7 +79,7 @@ util::json::Object makeGeoJSONGeometry(ForwardIter begin, ForwardIter end)
|
||||
coordinates.values.push_back(location);
|
||||
coordinates.values.push_back(location);
|
||||
}
|
||||
geojson.values["coordinates"] = std::move(coordinates);
|
||||
geojson.values["coordinates"] = util::json::Value{std::move(coordinates)};
|
||||
|
||||
return geojson;
|
||||
}
|
||||
|
||||
@@ -30,14 +30,14 @@ class MatchAPI final : public RouteAPI
|
||||
osrm::engine::api::ResultT &response) const
|
||||
{
|
||||
BOOST_ASSERT(sub_matchings.size() == sub_routes.size());
|
||||
if (response.is<flatbuffers::FlatBufferBuilder>())
|
||||
if (std::holds_alternative<flatbuffers::FlatBufferBuilder>(response))
|
||||
{
|
||||
auto &fb_result = response.get<flatbuffers::FlatBufferBuilder>();
|
||||
auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(response);
|
||||
MakeResponse(sub_matchings, sub_routes, fb_result);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto &json_result = response.get<util::json::Object>();
|
||||
auto &json_result = std::get<util::json::Object>(response);
|
||||
MakeResponse(sub_matchings, sub_routes, json_result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,14 +29,14 @@ class NearestAPI final : public BaseAPI
|
||||
BOOST_ASSERT(phantom_nodes.size() == 1);
|
||||
BOOST_ASSERT(parameters.coordinates.size() == 1);
|
||||
|
||||
if (response.is<flatbuffers::FlatBufferBuilder>())
|
||||
if (std::holds_alternative<flatbuffers::FlatBufferBuilder>(response))
|
||||
{
|
||||
auto &fb_result = response.get<flatbuffers::FlatBufferBuilder>();
|
||||
auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(response);
|
||||
MakeResponse(phantom_nodes, fb_result);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto &json_result = response.get<util::json::Object>();
|
||||
auto &json_result = std::get<util::json::Object>(response);
|
||||
MakeResponse(phantom_nodes, json_result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,14 +50,14 @@ class RouteAPI : public BaseAPI
|
||||
{
|
||||
BOOST_ASSERT(!raw_routes.routes.empty());
|
||||
|
||||
if (response.is<flatbuffers::FlatBufferBuilder>())
|
||||
if (std::holds_alternative<flatbuffers::FlatBufferBuilder>(response))
|
||||
{
|
||||
auto &fb_result = response.get<flatbuffers::FlatBufferBuilder>();
|
||||
auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(response);
|
||||
MakeResponse(raw_routes, waypoint_candidates, fb_result);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto &json_result = response.get<util::json::Object>();
|
||||
auto &json_result = std::get<util::json::Object>(response);
|
||||
MakeResponse(raw_routes, waypoint_candidates, json_result);
|
||||
}
|
||||
}
|
||||
@@ -158,8 +158,8 @@ class RouteAPI : public BaseAPI
|
||||
}
|
||||
|
||||
template <typename ForwardIter>
|
||||
mapbox::util::variant<flatbuffers::Offset<flatbuffers::String>,
|
||||
flatbuffers::Offset<flatbuffers::Vector<const fbresult::Position *>>>
|
||||
std::variant<flatbuffers::Offset<flatbuffers::String>,
|
||||
flatbuffers::Offset<flatbuffers::Vector<const fbresult::Position *>>>
|
||||
MakeGeometry(flatbuffers::FlatBufferBuilder &builder, ForwardIter begin, ForwardIter end) const
|
||||
{
|
||||
if (parameters.geometries == RouteParameters::GeometriesType::Polyline)
|
||||
@@ -408,8 +408,8 @@ class RouteAPI : public BaseAPI
|
||||
|
||||
// Fill geometry
|
||||
auto overview = MakeOverview(leg_geometries);
|
||||
mapbox::util::variant<flatbuffers::Offset<flatbuffers::String>,
|
||||
flatbuffers::Offset<flatbuffers::Vector<const fbresult::Position *>>>
|
||||
std::variant<flatbuffers::Offset<flatbuffers::String>,
|
||||
flatbuffers::Offset<flatbuffers::Vector<const fbresult::Position *>>>
|
||||
geometry;
|
||||
if (overview)
|
||||
{
|
||||
@@ -426,8 +426,7 @@ class RouteAPI : public BaseAPI
|
||||
routeObject.add_legs(legs_vector);
|
||||
if (overview)
|
||||
{
|
||||
mapbox::util::apply_visitor(GeometryVisitor<fbresult::RouteObjectBuilder>(routeObject),
|
||||
geometry);
|
||||
std::visit(GeometryVisitor<fbresult::RouteObjectBuilder>(routeObject), geometry);
|
||||
}
|
||||
|
||||
return routeObject.Finish();
|
||||
@@ -443,23 +442,22 @@ class RouteAPI : public BaseAPI
|
||||
if (requested_annotations & RouteParameters::AnnotationsType::Speed)
|
||||
{
|
||||
double prev_speed = 0;
|
||||
speed =
|
||||
GetAnnotations<float>(fb_result,
|
||||
leg_geometry,
|
||||
[&prev_speed](const guidance::LegGeometry::Annotation &anno)
|
||||
{
|
||||
if (anno.duration < std::numeric_limits<float>::min())
|
||||
{
|
||||
return prev_speed;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto speed =
|
||||
round(anno.distance / anno.duration * 10.) / 10.;
|
||||
prev_speed = speed;
|
||||
return util::json::clamp_float(speed);
|
||||
}
|
||||
});
|
||||
speed = GetAnnotations<float>(
|
||||
fb_result,
|
||||
leg_geometry,
|
||||
[&prev_speed](const guidance::LegGeometry::Annotation &anno)
|
||||
{
|
||||
if (anno.duration < std::numeric_limits<float>::min())
|
||||
{
|
||||
return prev_speed;
|
||||
}
|
||||
else
|
||||
{
|
||||
auto speed = std::round(anno.distance / anno.duration * 10.) / 10.;
|
||||
prev_speed = speed;
|
||||
return util::json::clamp_float(speed);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
flatbuffers::Offset<flatbuffers::Vector<uint32_t>> duration;
|
||||
@@ -645,7 +643,7 @@ class RouteAPI : public BaseAPI
|
||||
stepBuilder.add_rotary_pronunciation(rotary_pronunciation_string);
|
||||
stepBuilder.add_intersections(intersections_vector);
|
||||
stepBuilder.add_maneuver(maneuver_buffer);
|
||||
mapbox::util::apply_visitor(GeometryVisitor<fbresult::StepBuilder>(stepBuilder), geometry);
|
||||
std::visit(GeometryVisitor<fbresult::StepBuilder>(stepBuilder), geometry);
|
||||
return stepBuilder.Finish();
|
||||
};
|
||||
|
||||
|
||||
@@ -50,14 +50,14 @@ class TableAPI final : public BaseAPI
|
||||
const std::vector<TableCellRef> &fallback_speed_cells,
|
||||
osrm::engine::api::ResultT &response) const
|
||||
{
|
||||
if (response.is<flatbuffers::FlatBufferBuilder>())
|
||||
if (std::holds_alternative<flatbuffers::FlatBufferBuilder>(response))
|
||||
{
|
||||
auto &fb_result = response.get<flatbuffers::FlatBufferBuilder>();
|
||||
auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(response);
|
||||
MakeResponse(tables, candidates, fallback_speed_cells, fb_result);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto &json_result = response.get<util::json::Object>();
|
||||
auto &json_result = std::get<util::json::Object>(response);
|
||||
MakeResponse(tables, candidates, fallback_speed_cells, json_result);
|
||||
}
|
||||
}
|
||||
@@ -377,7 +377,8 @@ class TableAPI final : public BaseAPI
|
||||
return util::json::Value(
|
||||
util::json::Number(from_alias<double>(duration) / 10.));
|
||||
});
|
||||
json_table.values.push_back(std::move(json_row));
|
||||
|
||||
json_table.values.push_back(util::json::Value{json_row});
|
||||
}
|
||||
return json_table;
|
||||
}
|
||||
@@ -406,7 +407,7 @@ class TableAPI final : public BaseAPI
|
||||
return util::json::Value(util::json::Number(
|
||||
std::round(from_alias<double>(distance) * 10) / 10.));
|
||||
});
|
||||
json_table.values.push_back(std::move(json_row));
|
||||
json_table.values.push_back(util::json::Value{json_row});
|
||||
}
|
||||
return json_table;
|
||||
}
|
||||
@@ -415,15 +416,18 @@ class TableAPI final : public BaseAPI
|
||||
MakeEstimatesTable(const std::vector<TableCellRef> &fallback_speed_cells) const
|
||||
{
|
||||
util::json::Array json_table;
|
||||
std::for_each(fallback_speed_cells.begin(),
|
||||
fallback_speed_cells.end(),
|
||||
[&](const auto &cell)
|
||||
{
|
||||
util::json::Array row;
|
||||
row.values.push_back(util::json::Number(cell.row));
|
||||
row.values.push_back(util::json::Number(cell.column));
|
||||
json_table.values.push_back(std::move(row));
|
||||
});
|
||||
std::for_each(
|
||||
fallback_speed_cells.begin(),
|
||||
fallback_speed_cells.end(),
|
||||
[&](const auto &cell)
|
||||
{
|
||||
util::json::Array row;
|
||||
util::json::Value jCellRow{util::json::Number(static_cast<double>(cell.row))};
|
||||
util::json::Value jCellColumn{util::json::Number(static_cast<double>(cell.column))};
|
||||
row.values.push_back(jCellRow);
|
||||
row.values.push_back(jCellColumn);
|
||||
json_table.values.push_back(util::json::Value{row});
|
||||
});
|
||||
return json_table;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,14 +27,14 @@ class TripAPI final : public RouteAPI
|
||||
{
|
||||
BOOST_ASSERT(sub_trips.size() == sub_routes.size());
|
||||
|
||||
if (response.is<flatbuffers::FlatBufferBuilder>())
|
||||
if (std::holds_alternative<flatbuffers::FlatBufferBuilder>(response))
|
||||
{
|
||||
auto &fb_result = response.get<flatbuffers::FlatBufferBuilder>();
|
||||
auto &fb_result = std::get<flatbuffers::FlatBufferBuilder>(response);
|
||||
MakeResponse(sub_trips, sub_routes, candidates, fb_result);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto &json_result = response.get<util::json::Object>();
|
||||
auto &json_result = std::get<util::json::Object>(response);
|
||||
MakeResponse(sub_trips, sub_routes, candidates, json_result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,14 +54,10 @@ namespace osrm::engine
|
||||
*
|
||||
* In addition, shared memory can be used for datasets loaded with osrm-datastore.
|
||||
*
|
||||
* You can chose between three algorithms:
|
||||
* You can chose between two algorithms:
|
||||
* - Algorithm::CH
|
||||
* Contraction Hierarchies, extremely fast queries but slow pre-processing. The default right
|
||||
* now.
|
||||
* - Algorithm::CoreCH
|
||||
* Deprecated, to be removed in v6.0
|
||||
* Contraction Hierachies with partial contraction for faster pre-processing but slower
|
||||
* queries.
|
||||
* - Algorithm::MLD
|
||||
* Multi Level Dijkstra, moderately fast in both pre-processing and query.
|
||||
*
|
||||
@@ -74,7 +70,6 @@ struct EngineConfig final
|
||||
enum class Algorithm
|
||||
{
|
||||
CH,
|
||||
CoreCH, // Deprecated, will be removed in v6.0
|
||||
MLD
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
#include <numbers>
|
||||
|
||||
namespace osrm::engine::map_matching
|
||||
{
|
||||
@@ -21,10 +21,8 @@ struct NormalDistribution
|
||||
// FIXME implement log-probability version since it's faster
|
||||
double Density(const double val) const
|
||||
{
|
||||
using namespace boost::math::constants;
|
||||
|
||||
const double x = val - mean;
|
||||
return 1.0 / (std::sqrt(two_pi<double>()) * standard_deviation) *
|
||||
return 1.0 / (std::sqrt(2 * std::numbers::pi) * standard_deviation) *
|
||||
std::exp(-x * x / (standard_deviation * standard_deviation));
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#include "util/integer_range.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
#include <numbers>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
namespace osrm::engine::map_matching
|
||||
{
|
||||
|
||||
static const double log_2_pi = std::log(2. * boost::math::constants::pi<double>());
|
||||
static const double log_2_pi = std::log(2. * std::numbers::pi);
|
||||
static const double IMPOSSIBLE_LOG_PROB = -std::numeric_limits<double>::infinity();
|
||||
static const double MINIMAL_LOG_PROB = std::numeric_limits<double>::lowest();
|
||||
static const std::size_t INVALID_STATE = std::numeric_limits<std::size_t>::max();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#define ENGINE_MAP_MATCHING_CONFIDENCE_HPP
|
||||
|
||||
#include "engine/map_matching/bayes_classifier.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <cmath>
|
||||
|
||||
namespace osrm::engine::map_matching
|
||||
|
||||
@@ -95,7 +95,7 @@ class BasePlugin
|
||||
const std::string &message,
|
||||
osrm::engine::api::ResultT &result) const
|
||||
{
|
||||
mapbox::util::apply_visitor(ErrorRenderer(code, message), result);
|
||||
std::visit(ErrorRenderer(code, message), result);
|
||||
return Status::Error;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ namespace osrm::engine
|
||||
|
||||
// Algorithm-dependent heaps
|
||||
// - CH algorithms use CH heaps
|
||||
// - CoreCH algorithms use CH
|
||||
// - MLD algorithms use MLD heaps
|
||||
|
||||
template <typename Algorithm> struct SearchEngineData
|
||||
|
||||
Reference in New Issue
Block a user