Runs scripts/format.sh

This commit is contained in:
Daniel J. Hofmann 2016-03-03 14:26:13 +01:00 committed by Patrick Niklaus
parent bb06e044f5
commit 7c30ea32bf
70 changed files with 457 additions and 399 deletions

View File

@ -38,7 +38,7 @@ int main(int argc, const char *argv[]) try
// The following shows how to use the Route service; configure this service // The following shows how to use the Route service; configure this service
RouteParameters params; RouteParameters params;
// Rout in monaco // Route in monaco
params.coordinates.push_back({util::FloatLongitude(7.419758), util::FloatLatitude(43.731142)}); params.coordinates.push_back({util::FloatLongitude(7.419758), util::FloatLatitude(43.731142)});
params.coordinates.push_back({util::FloatLongitude(7.419505), util::FloatLatitude(43.736825)}); params.coordinates.push_back({util::FloatLongitude(7.419505), util::FloatLatitude(43.736825)});

View File

@ -142,9 +142,9 @@ class GraphContractor
template <class ContainerT> template <class ContainerT>
GraphContractor(int nodes, GraphContractor(int nodes,
ContainerT &input_edge_list, ContainerT &input_edge_list,
std::vector<float> &&node_levels_, std::vector<float> &&node_levels_,
std::vector<EdgeWeight> &&node_weights_) std::vector<EdgeWeight> &&node_weights_)
: node_levels(std::move(node_levels_)), node_weights(std::move(node_weights_)) : node_levels(std::move(node_levels_)), node_weights(std::move(node_weights_))
{ {
std::vector<ContractorEdge> edges; std::vector<ContractorEdge> edges;
@ -239,7 +239,8 @@ class GraphContractor
} }
} }
} }
util::SimpleLogger().Write() << "merged " << edges.size() - edge << " edges out of " << edges.size(); util::SimpleLogger().Write() << "merged " << edges.size() - edge << " edges out of "
<< edges.size();
edges.resize(edge); edges.resize(edge);
contractor_graph = std::make_shared<ContractorGraph>(nodes, edges); contractor_graph = std::make_shared<ContractorGraph>(nodes, edges);
edges.clear(); edges.clear();
@ -696,7 +697,7 @@ class GraphContractor
// New Node discovered -> Add to Heap + Node Info Storage // New Node discovered -> Add to Heap + Node Info Storage
if (!heap.WasInserted(to)) if (!heap.WasInserted(to))
{ {
heap.Insert(to, to_distance, ContractorHeapData {current_hop, false}); heap.Insert(to, to_distance, ContractorHeapData{current_hop, false});
} }
// Found a shorter Path -> Update distance // Found a shorter Path -> Update distance
else if (to_distance < heap.GetKey(to)) else if (to_distance < heap.GetKey(to))
@ -803,7 +804,7 @@ class GraphContractor
} }
heap.Clear(); heap.Clear();
heap.Insert(source, 0, ContractorHeapData {}); heap.Insert(source, 0, ContractorHeapData{});
int max_distance = 0; int max_distance = 0;
unsigned number_of_targets = 0; unsigned number_of_targets = 0;
@ -858,7 +859,7 @@ class GraphContractor
max_distance = std::max(max_distance, path_distance); max_distance = std::max(max_distance, path_distance);
if (!heap.WasInserted(target)) if (!heap.WasInserted(target))
{ {
heap.Insert(target, INVALID_EDGE_WEIGHT, ContractorHeapData {0, true}); heap.Insert(target, INVALID_EDGE_WEIGHT, ContractorHeapData{0, true});
++number_of_targets; ++number_of_targets;
} }
} }

View File

@ -15,13 +15,16 @@ namespace api
struct MatchParameters : public RouteParameters struct MatchParameters : public RouteParameters
{ {
MatchParameters() MatchParameters()
: RouteParameters(false, false, RouteParameters::GeometriesType::Polyline, RouteParameters::OverviewType::Simplified, {}) : RouteParameters(false,
false,
RouteParameters::GeometriesType::Polyline,
RouteParameters::OverviewType::Simplified,
{})
{ {
} }
template<typename... Args> template <typename... Args>
MatchParameters(std::vector<unsigned> timestamps_, MatchParameters(std::vector<unsigned> timestamps_, Args... args_)
Args... args_)
: RouteParameters{std::forward<Args>(args_)...}, timestamps{std::move(timestamps_)} : RouteParameters{std::forward<Args>(args_)...}, timestamps{std::move(timestamps_)}
{ {
} }
@ -29,10 +32,10 @@ struct MatchParameters : public RouteParameters
std::vector<unsigned> timestamps; std::vector<unsigned> timestamps;
bool IsValid() const bool IsValid() const
{ {
return RouteParameters::IsValid() && (timestamps.empty() || timestamps.size() == coordinates.size()); return RouteParameters::IsValid() &&
(timestamps.empty() || timestamps.size() == coordinates.size());
} }
}; };
} }
} }
} }

View File

@ -26,20 +26,23 @@ class NearestAPI final : public BaseAPI
{ {
} }
void MakeResponse(const std::vector<std::vector<PhantomNodeWithDistance>> &phantom_nodes, util::json::Object& response) const void MakeResponse(const std::vector<std::vector<PhantomNodeWithDistance>> &phantom_nodes,
util::json::Object &response) const
{ {
BOOST_ASSERT(phantom_nodes.size() == 1); BOOST_ASSERT(phantom_nodes.size() == 1);
BOOST_ASSERT(parameters.coordinates.size() == 1); BOOST_ASSERT(parameters.coordinates.size() == 1);
util::json::Array waypoints; util::json::Array waypoints;
waypoints.values.resize(phantom_nodes.front().size()); waypoints.values.resize(phantom_nodes.front().size());
std::transform(phantom_nodes.front().begin(), std::transform(phantom_nodes.front().begin(), phantom_nodes.front().end(),
phantom_nodes.front().end(), waypoints.values.begin(), [this](const PhantomNodeWithDistance& phantom_with_distance) waypoints.values.begin(),
{ [this](const PhantomNodeWithDistance &phantom_with_distance)
auto waypoint = MakeWaypoint(parameters.coordinates.front(), phantom_with_distance.phantom_node); {
waypoint.values["distance"] = phantom_with_distance.distance; auto waypoint = MakeWaypoint(parameters.coordinates.front(),
return waypoint; phantom_with_distance.phantom_node);
}); waypoint.values["distance"] = phantom_with_distance.distance;
return waypoint;
});
response.values["code"] = "ok"; response.values["code"] = "ok";
response.values["waypoints"] = std::move(waypoints); response.values["waypoints"] = std::move(waypoints);

View File

@ -28,14 +28,15 @@ struct RouteParameters : public BaseParameters
RouteParameters() = default; RouteParameters() = default;
template<typename... Args> template <typename... Args>
RouteParameters(const bool steps_, RouteParameters(const bool steps_,
const bool alternative_, const bool alternative_,
const GeometriesType geometries_, const GeometriesType geometries_,
const OverviewType overview_, const OverviewType overview_,
std::vector<boost::optional<bool>> uturns_, Args... args_) std::vector<boost::optional<bool>> uturns_,
: BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternative{alternative_}, geometries{geometries_}, Args... args_)
overview{overview_}, uturns{std::move(uturns_)} : BaseParameters{std::forward<Args>(args_)...}, steps{steps_}, alternative{alternative_},
geometries{geometries_}, overview{overview_}, uturns{std::move(uturns_)}
{ {
} }

View File

@ -37,7 +37,8 @@ class TableAPI final : public BaseAPI
util::json::Object &response) const util::json::Object &response) const
{ {
auto number_of_sources = parameters.sources.size(); auto number_of_sources = parameters.sources.size();
auto number_of_destinations = parameters.destinations.size();; auto number_of_destinations = parameters.destinations.size();
;
// symmetric case // symmetric case
if (parameters.sources.empty()) if (parameters.sources.empty())
@ -60,7 +61,8 @@ class TableAPI final : public BaseAPI
response.values["destinations"] = MakeWaypoints(phantoms, parameters.destinations); response.values["destinations"] = MakeWaypoints(phantoms, parameters.destinations);
} }
response.values["durations"] = MakeTable(durations, number_of_sources, number_of_destinations); response.values["durations"] =
MakeTable(durations, number_of_sources, number_of_destinations);
response.values["code"] = "ok"; response.values["code"] = "ok";
} }
@ -105,14 +107,15 @@ class TableAPI final : public BaseAPI
auto row_begin_iterator = values.begin() + (row * number_of_columns); auto row_begin_iterator = values.begin() + (row * number_of_columns);
auto row_end_iterator = values.begin() + ((row + 1) * number_of_columns); auto row_end_iterator = values.begin() + ((row + 1) * number_of_columns);
json_row.values.resize(number_of_columns); json_row.values.resize(number_of_columns);
std::transform(row_begin_iterator, row_end_iterator, json_row.values.begin(), [](const EdgeWeight duration) std::transform(row_begin_iterator, row_end_iterator, json_row.values.begin(),
{ [](const EdgeWeight duration)
if (duration == INVALID_EDGE_WEIGHT) {
{ if (duration == INVALID_EDGE_WEIGHT)
return util::json::Value(util::json::Null()); {
} return util::json::Value(util::json::Null());
return util::json::Value(util::json::Number(duration / 10.)); }
}); return util::json::Value(util::json::Number(duration / 10.));
});
json_table.values.push_back(std::move(json_row)); json_table.values.push_back(std::move(json_row));
} }
return json_table; return json_table;

View File

@ -15,12 +15,8 @@ struct TileParameters final
unsigned z; unsigned z;
// FIXME check if x and y work with z // FIXME check if x and y work with z
bool IsValid() bool IsValid() { return z < 20; };
{
return z < 20;
};
}; };
} }
} }
} }

View File

@ -14,9 +14,8 @@ namespace api
struct TripParameters : public RouteParameters struct TripParameters : public RouteParameters
{ {
//bool IsValid() const; Falls back to base class // bool IsValid() const; Falls back to base class
}; };
} }
} }
} }

View File

@ -74,7 +74,7 @@ class BaseDataFacade
// Gets the weight values for each segment in an uncompressed geometry. // Gets the weight values for each segment in an uncompressed geometry.
// Should always be 1 shorter than GetUncompressedGeometry // Should always be 1 shorter than GetUncompressedGeometry
virtual void GetUncompressedWeights(const EdgeID id, virtual void GetUncompressedWeights(const EdgeID id,
std::vector<EdgeWeight> &result_weights) const = 0; std::vector<EdgeWeight> &result_weights) const = 0;
virtual extractor::guidance::TurnInstruction virtual extractor::guidance::TurnInstruction
GetTurnInstructionForEdgeID(const unsigned id) const = 0; GetTurnInstructionForEdgeID(const unsigned id) const = 0;

View File

@ -208,7 +208,8 @@ class InternalDataFacade final : public BaseDataFacade
if (number_of_compressed_geometries > 0) if (number_of_compressed_geometries > 0)
{ {
geometry_stream.read((char *)&(m_geometry_list[0]), geometry_stream.read((char *)&(m_geometry_list[0]),
number_of_compressed_geometries * sizeof(extractor::CompressedEdgeContainer::CompressedEdge)); number_of_compressed_geometries *
sizeof(extractor::CompressedEdgeContainer::CompressedEdge));
} }
} }
@ -217,7 +218,8 @@ class InternalDataFacade final : public BaseDataFacade
BOOST_ASSERT_MSG(!m_coordinate_list->empty(), "coordinates must be loaded before r-tree"); BOOST_ASSERT_MSG(!m_coordinate_list->empty(), "coordinates must be loaded before r-tree");
m_static_rtree.reset(new InternalRTree(ram_index_path, file_index_path, m_coordinate_list)); m_static_rtree.reset(new InternalRTree(ram_index_path, file_index_path, m_coordinate_list));
m_geospatial_query.reset(new InternalGeospatialQuery(*m_static_rtree, m_coordinate_list, *this)); m_geospatial_query.reset(
new InternalGeospatialQuery(*m_static_rtree, m_coordinate_list, *this));
} }
void LoadStreetNames(const boost::filesystem::path &names_file) void LoadStreetNames(const boost::filesystem::path &names_file)
@ -553,19 +555,27 @@ class InternalDataFacade final : public BaseDataFacade
result_nodes.clear(); result_nodes.clear();
result_nodes.reserve(end - begin); result_nodes.reserve(end - begin);
std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end, [&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge){ result_nodes.emplace_back(edge.node_id); }); std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end,
[&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge)
{
result_nodes.emplace_back(edge.node_id);
});
} }
virtual void GetUncompressedWeights(const EdgeID id, virtual void
std::vector<EdgeWeight> &result_weights) const override final GetUncompressedWeights(const EdgeID id,
std::vector<EdgeWeight> &result_weights) const override final
{ {
const unsigned begin = m_geometry_indices.at(id); const unsigned begin = m_geometry_indices.at(id);
const unsigned end = m_geometry_indices.at(id + 1); const unsigned end = m_geometry_indices.at(id + 1);
result_weights.clear(); result_weights.clear();
result_weights.reserve(end - begin); result_weights.reserve(end - begin);
std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end, [&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge){ result_weights.emplace_back(edge.weight); }); std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end,
[&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge)
{
result_weights.emplace_back(edge.weight);
});
} }
std::string GetTimestamp() const override final { return m_timestamp; } std::string GetTimestamp() const override final { return m_timestamp; }

View File

@ -218,10 +218,10 @@ class SharedDataFacade final : public BaseDataFacade
auto geometries_list_ptr = auto geometries_list_ptr =
data_layout->GetBlockPtr<extractor::CompressedEdgeContainer::CompressedEdge>( data_layout->GetBlockPtr<extractor::CompressedEdgeContainer::CompressedEdge>(
shared_memory, storage::SharedDataLayout::GEOMETRIES_LIST); shared_memory, storage::SharedDataLayout::GEOMETRIES_LIST);
typename util::ShM<extractor::CompressedEdgeContainer::CompressedEdge, true>::vector geometry_list( typename util::ShM<extractor::CompressedEdgeContainer::CompressedEdge, true>::vector
geometries_list_ptr, geometry_list(geometries_list_ptr,
data_layout->num_entries[storage::SharedDataLayout::GEOMETRIES_LIST]); data_layout->num_entries[storage::SharedDataLayout::GEOMETRIES_LIST]);
m_geometry_list = std::move(geometry_list); m_geometry_list = std::move(geometry_list);
} }
@ -239,7 +239,8 @@ class SharedDataFacade final : public BaseDataFacade
} }
data_timestamp_ptr = static_cast<storage::SharedDataTimestamp *>( data_timestamp_ptr = static_cast<storage::SharedDataTimestamp *>(
storage::makeSharedMemory(storage::CURRENT_REGIONS, storage::makeSharedMemory(storage::CURRENT_REGIONS,
sizeof(storage::SharedDataTimestamp), false, false)->Ptr()); sizeof(storage::SharedDataTimestamp), false, false)
->Ptr());
CURRENT_LAYOUT = storage::LAYOUT_NONE; CURRENT_LAYOUT = storage::LAYOUT_NONE;
CURRENT_DATA = storage::DATA_NONE; CURRENT_DATA = storage::DATA_NONE;
CURRENT_TIMESTAMP = 0; CURRENT_TIMESTAMP = 0;
@ -310,8 +311,8 @@ class SharedDataFacade final : public BaseDataFacade
LoadNames(); LoadNames();
LoadCoreInformation(); LoadCoreInformation();
util::SimpleLogger().Write() util::SimpleLogger().Write() << "number of geometries: "
<< "number of geometries: " << m_coordinate_list->size(); << m_coordinate_list->size();
for (unsigned i = 0; i < m_coordinate_list->size(); ++i) for (unsigned i = 0; i < m_coordinate_list->size(); ++i)
{ {
if (!GetCoordinateOfNode(i).IsValid()) if (!GetCoordinateOfNode(i).IsValid())
@ -381,19 +382,27 @@ class SharedDataFacade final : public BaseDataFacade
result_nodes.clear(); result_nodes.clear();
result_nodes.reserve(end - begin); result_nodes.reserve(end - begin);
std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end, [&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge){ result_nodes.emplace_back(edge.node_id); }); std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end,
[&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge)
{
result_nodes.emplace_back(edge.node_id);
});
} }
virtual void GetUncompressedWeights(const EdgeID id, virtual void
std::vector<EdgeWeight> &result_weights) const override final GetUncompressedWeights(const EdgeID id,
std::vector<EdgeWeight> &result_weights) const override final
{ {
const unsigned begin = m_geometry_indices.at(id); const unsigned begin = m_geometry_indices.at(id);
const unsigned end = m_geometry_indices.at(id + 1); const unsigned end = m_geometry_indices.at(id + 1);
result_weights.clear(); result_weights.clear();
result_weights.reserve(end - begin); result_weights.reserve(end - begin);
std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end, [&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge){ result_weights.emplace_back(edge.weight); }); std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end,
[&](const osrm::extractor::CompressedEdgeContainer::CompressedEdge &edge)
{
result_weights.emplace_back(edge.weight);
});
} }
virtual unsigned GetGeometryIndexForEdgeID(const unsigned id) const override final virtual unsigned GetGeometryIndexForEdgeID(const unsigned id) const override final

View File

@ -28,7 +28,9 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
using CoordinateList = typename RTreeT::CoordinateList; using CoordinateList = typename RTreeT::CoordinateList;
public: public:
GeospatialQuery(RTreeT &rtree_, std::shared_ptr<CoordinateList> coordinates_, DataFacadeT &datafacade_) GeospatialQuery(RTreeT &rtree_,
std::shared_ptr<CoordinateList> coordinates_,
DataFacadeT &datafacade_)
: rtree(rtree_), coordinates(std::move(coordinates_)), datafacade(datafacade_) : rtree(rtree_), coordinates(std::move(coordinates_)), datafacade(datafacade_)
{ {
} }
@ -352,10 +354,11 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
int forward_offset = 0, forward_weight = 0; int forward_offset = 0, forward_weight = 0;
int reverse_offset = 0, reverse_weight = 0; int reverse_offset = 0, reverse_weight = 0;
if (data.forward_packed_geometry_id != SPECIAL_EDGEID) { if (data.forward_packed_geometry_id != SPECIAL_EDGEID)
{
std::vector<EdgeWeight> forward_weight_vector; std::vector<EdgeWeight> forward_weight_vector;
datafacade.GetUncompressedWeights(data.forward_packed_geometry_id, datafacade.GetUncompressedWeights(data.forward_packed_geometry_id,
forward_weight_vector); forward_weight_vector);
for (std::size_t i = 0; i < data.fwd_segment_position; i++) for (std::size_t i = 0; i < data.fwd_segment_position; i++)
{ {
forward_offset += forward_weight_vector[i]; forward_offset += forward_weight_vector[i];
@ -363,32 +366,37 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
forward_weight = forward_weight_vector[data.fwd_segment_position]; forward_weight = forward_weight_vector[data.fwd_segment_position];
} }
if (data.reverse_packed_geometry_id != SPECIAL_EDGEID) { if (data.reverse_packed_geometry_id != SPECIAL_EDGEID)
{
std::vector<EdgeWeight> reverse_weight_vector; std::vector<EdgeWeight> reverse_weight_vector;
datafacade.GetUncompressedWeights(data.reverse_packed_geometry_id, datafacade.GetUncompressedWeights(data.reverse_packed_geometry_id,
reverse_weight_vector); reverse_weight_vector);
BOOST_ASSERT(data.fwd_segment_position < reverse_weight_vector.size()); BOOST_ASSERT(data.fwd_segment_position < reverse_weight_vector.size());
for (std::size_t i = 0; i < reverse_weight_vector.size() - data.fwd_segment_position - 1; i++) for (std::size_t i = 0;
i < reverse_weight_vector.size() - data.fwd_segment_position - 1; i++)
{ {
reverse_offset += reverse_weight_vector[i]; reverse_offset += reverse_weight_vector[i];
} }
reverse_weight = reverse_weight_vector[reverse_weight_vector.size() - reverse_weight =
data.fwd_segment_position - 1]; reverse_weight_vector[reverse_weight_vector.size() - data.fwd_segment_position - 1];
} }
ratio = std::min(1.0, std::max(0.0, ratio)); ratio = std::min(1.0, std::max(0.0, ratio));
if (SPECIAL_NODEID != data.forward_edge_based_node_id) { if (SPECIAL_NODEID != data.forward_edge_based_node_id)
{
forward_weight *= ratio; forward_weight *= ratio;
} }
if (SPECIAL_NODEID != data.reverse_edge_based_node_id) { if (SPECIAL_NODEID != data.reverse_edge_based_node_id)
{
reverse_weight *= 1.0 - ratio; reverse_weight *= 1.0 - ratio;
} }
auto transformed = PhantomNodeWithDistance{PhantomNode{data, forward_weight, forward_offset, auto transformed =
reverse_weight, reverse_offset, point_on_segment}, PhantomNodeWithDistance{PhantomNode{data, forward_weight, forward_offset,
current_perpendicular_distance}; reverse_weight, reverse_offset, point_on_segment},
current_perpendicular_distance};
return transformed; return transformed;
} }

View File

@ -134,6 +134,7 @@ RouteLeg assembleLeg(const DataFacadeT &facade,
// `forward_weight`: duration of (d,t) // `forward_weight`: duration of (d,t)
// `forward_offset`: duration of (c, d) // `forward_offset`: duration of (c, d)
// //
// TODO discuss, this should not be the case after danpats fixes
// The PathData will contain entries of b, c and d. But only c will contain // The PathData will contain entries of b, c and d. But only c will contain
// a duration value since its the only point associated with a turn. // a duration value since its the only point associated with a turn.
// As such we want to slice of the duration for (a,s) and add the duration for // As such we want to slice of the duration for (a,s) and add the duration for

View File

@ -13,22 +13,21 @@ namespace engine
{ {
namespace guidance namespace guidance
{ {
inline Route assembleRoute(const std::vector<RouteLeg> &route_legs) inline Route assembleRoute(const std::vector<RouteLeg> &route_legs)
{ {
auto distance = std::accumulate(route_legs.begin(), auto distance = std::accumulate(route_legs.begin(), route_legs.end(), 0.,
route_legs.end(), 0., [](const double sum, const RouteLeg &leg)
[](const double sum, const RouteLeg &leg) {
{ return sum + leg.distance;
return sum + leg.distance; });
}); auto duration = std::accumulate(route_legs.begin(), route_legs.end(), 0.,
auto duration = std::accumulate(route_legs.begin(), route_legs.end(), 0., [](const double sum, const RouteLeg &leg)
[](const double sum, const RouteLeg &leg) {
{ return sum + leg.duration;
return sum + leg.duration; });
});
return Route{duration, distance}; return Route{duration, distance};
} }
} // namespace guidance } // namespace guidance
} // namespace engine } // namespace engine

View File

@ -104,26 +104,18 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
{ {
const auto name = facade.get_name_for_id(path_point.name_id); const auto name = facade.get_name_for_id(path_point.name_id);
const auto distance = leg_geometry.segment_distances[segment_index]; const auto distance = leg_geometry.segment_distances[segment_index];
steps.push_back(RouteStep{path_point.name_id, steps.push_back(RouteStep{
name, path_point.name_id, name, path_point.duration_until_turn / 10.0, distance,
path_point.duration_until_turn / 10.0, path_point.travel_mode, maneuver, leg_geometry.FrontIndex(segment_index),
distance, leg_geometry.BackIndex(segment_index) + 1});
path_point.travel_mode,
maneuver,
leg_geometry.FrontIndex(segment_index),
leg_geometry.BackIndex(segment_index) + 1});
maneuver = detail::stepManeuverFromGeometry( maneuver = detail::stepManeuverFromGeometry(
path_point.turn_instruction, leg_geometry, segment_index, path_point.exit); path_point.turn_instruction, leg_geometry, segment_index, path_point.exit);
segment_index++; segment_index++;
} }
} }
const auto distance = leg_geometry.segment_distances[segment_index]; const auto distance = leg_geometry.segment_distances[segment_index];
steps.push_back(RouteStep{target_node.name_id, steps.push_back(RouteStep{target_node.name_id, facade.get_name_for_id(target_node.name_id),
facade.get_name_for_id(target_node.name_id), target_duration, distance, target_mode, maneuver,
target_duration,
distance,
target_mode,
maneuver,
leg_geometry.FrontIndex(segment_index), leg_geometry.FrontIndex(segment_index),
leg_geometry.BackIndex(segment_index) + 1}); leg_geometry.BackIndex(segment_index) + 1});
} }
@ -134,20 +126,15 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
// |-------------t target_duration // |-------------t target_duration
// x---*---*---*---z compressed edge // x---*---*---*---z compressed edge
// |-------| duration // |-------| duration
StepManeuver maneuver = {source_node.location, StepManeuver maneuver = {source_node.location, 0., 0.,
0.,
0.,
extractor::guidance::TurnInstruction{ extractor::guidance::TurnInstruction{
extractor::guidance::TurnType::Location, initial_modifier}, extractor::guidance::TurnType::Location, initial_modifier},
INVALID_EXIT_NR}; INVALID_EXIT_NR};
steps.push_back(RouteStep{source_node.name_id, steps.push_back(RouteStep{source_node.name_id, facade.get_name_for_id(source_node.name_id),
facade.get_name_for_id(source_node.name_id),
target_duration - source_duration, target_duration - source_duration,
leg_geometry.segment_distances[segment_index], leg_geometry.segment_distances[segment_index], source_mode,
source_mode, std::move(maneuver), leg_geometry.FrontIndex(segment_index),
std::move(maneuver),
leg_geometry.FrontIndex(segment_index),
leg_geometry.BackIndex(segment_index) + 1}); leg_geometry.BackIndex(segment_index) + 1});
} }
@ -159,20 +146,13 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
target_location.get())) target_location.get()))
: extractor::guidance::DirectionModifier::UTurn; : extractor::guidance::DirectionModifier::UTurn;
// This step has length zero, the only reason we need it is the target location // This step has length zero, the only reason we need it is the target location
steps.push_back( steps.push_back(RouteStep{
RouteStep{target_node.name_id, target_node.name_id, facade.get_name_for_id(target_node.name_id), 0., 0., target_mode,
facade.get_name_for_id(target_node.name_id), StepManeuver{target_node.location, 0., 0.,
0., extractor::guidance::TurnInstruction{extractor::guidance::TurnType::Location,
0., final_modifier},
target_mode, INVALID_EXIT_NR},
StepManeuver{target_node.location, leg_geometry.locations.size(), leg_geometry.locations.size()});
0.,
0.,
extractor::guidance::TurnInstruction{
extractor::guidance::TurnType::Location, final_modifier},
INVALID_EXIT_NR},
leg_geometry.locations.size(),
leg_geometry.locations.size()});
return steps; return steps;
} }

View File

@ -1,16 +1,18 @@
#ifndef ROUTE_HPP #ifndef ROUTE_HPP
#define ROUTE_HPP #define ROUTE_HPP
namespace osrm { namespace osrm
namespace engine { {
namespace guidance { namespace engine
{
namespace guidance
{
struct Route struct Route
{ {
double duration; double duration;
double distance; double distance;
}; };
} }
} }
} }

View File

@ -22,7 +22,6 @@ struct RouteLeg
std::string summary; std::string summary;
std::vector<RouteStep> steps; std::vector<RouteStep> steps;
}; };
} }
} }
} }

View File

@ -31,7 +31,6 @@ struct RouteStep
std::size_t geometry_begin; std::size_t geometry_begin;
std::size_t geometry_end; std::size_t geometry_end;
}; };
} }
} }
} }

View File

@ -14,11 +14,11 @@ namespace map_matching
struct MatchingConfidence struct MatchingConfidence
{ {
private: private:
using ClassifierT = BayesClassifier<LaplaceDistribution, LaplaceDistribution, double>; using ClassifierT = BayesClassifier<LaplaceDistribution, LaplaceDistribution, double>;
using TraceClassification = ClassifierT::ClassificationT; using TraceClassification = ClassifierT::ClassificationT;
public: public:
MatchingConfidence() MatchingConfidence()
: // the values were derived from fitting a laplace distribution : // the values were derived from fitting a laplace distribution
// to the values of manually classified traces // to the values of manually classified traces
@ -47,8 +47,8 @@ public:
BOOST_ASSERT(label_with_confidence.first == ClassifierT::ClassLabel::NEGATIVE); BOOST_ASSERT(label_with_confidence.first == ClassifierT::ClassLabel::NEGATIVE);
return 1 - label_with_confidence.second; return 1 - label_with_confidence.second;
} }
private:
private:
ClassifierT classifier; ClassifierT classifier;
}; };
} }

View File

@ -18,7 +18,6 @@ struct SubMatching
std::vector<unsigned> indices; std::vector<unsigned> indices;
double confidence; double confidence;
}; };
} }
} }
} }

View File

@ -47,7 +47,6 @@ class TripPlugin final : public BasePlugin
Status HandleRequest(const api::TripParameters &parameters, util::json::Object &json_result); Status HandleRequest(const api::TripParameters &parameters, util::json::Object &json_result);
}; };
} }
} }
} }

View File

@ -50,8 +50,10 @@ class ManyToManyRouting final
const std::vector<std::size_t> &source_indices, const std::vector<std::size_t> &source_indices,
const std::vector<std::size_t> &target_indices) const const std::vector<std::size_t> &target_indices) const
{ {
const auto number_of_sources = source_indices.empty() ? phantom_nodes.size() : source_indices.size(); const auto number_of_sources =
const auto number_of_targets = target_indices.empty() ? phantom_nodes.size() : target_indices.size(); source_indices.empty() ? phantom_nodes.size() : source_indices.size();
const auto number_of_targets =
target_indices.empty() ? phantom_nodes.size() : target_indices.size();
const auto number_of_entries = number_of_sources * number_of_targets; const auto number_of_entries = number_of_sources * number_of_targets;
std::vector<EdgeWeight> result_table(number_of_entries, std::vector<EdgeWeight> result_table(number_of_entries,
std::numeric_limits<EdgeWeight>::max()); std::numeric_limits<EdgeWeight>::max());
@ -90,7 +92,7 @@ class ManyToManyRouting final
// for each source do forward search // for each source do forward search
unsigned row_idx = 0; unsigned row_idx = 0;
const auto search_source_phantom = [&](const PhantomNode& phantom) const auto search_source_phantom = [&](const PhantomNode &phantom)
{ {
query_heap.Clear(); query_heap.Clear();
// insert target(s) at distance 0 // insert target(s) at distance 0

View File

@ -244,7 +244,8 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
const auto haversine_distance = util::coordinate_calculation::haversineDistance( const auto haversine_distance = util::coordinate_calculation::haversineDistance(
prev_coordinate, current_coordinate); prev_coordinate, current_coordinate);
// assumes minumum of 0.1 m/s // assumes minumum of 0.1 m/s
const int duration_uppder_bound = ((haversine_distance + max_distance_delta) * 0.25) * 10; const int duration_uppder_bound =
((haversine_distance + max_distance_delta) * 0.25) * 10;
// compute d_t for this timestamp and the next one // compute d_t for this timestamp and the next one
for (const auto s : util::irange<std::size_t>(0u, prev_viterbi.size())) for (const auto s : util::irange<std::size_t>(0u, prev_viterbi.size()))
@ -274,8 +275,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
network_distance = super::GetNetworkDistanceWithCore( network_distance = super::GetNetworkDistanceWithCore(
forward_heap, reverse_heap, forward_core_heap, reverse_core_heap, forward_heap, reverse_heap, forward_core_heap, reverse_core_heap,
prev_unbroken_timestamps_list[s].phantom_node, prev_unbroken_timestamps_list[s].phantom_node,
current_timestamps_list[s_prime].phantom_node, current_timestamps_list[s_prime].phantom_node, duration_uppder_bound);
duration_uppder_bound);
} }
else else
{ {

View File

@ -767,7 +767,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
SearchEngineData::QueryHeap &reverse_core_heap, SearchEngineData::QueryHeap &reverse_core_heap,
const PhantomNode &source_phantom, const PhantomNode &source_phantom,
const PhantomNode &target_phantom, const PhantomNode &target_phantom,
int duration_upper_bound=INVALID_EDGE_WEIGHT) const int duration_upper_bound = INVALID_EDGE_WEIGHT) const
{ {
BOOST_ASSERT(forward_heap.Empty()); BOOST_ASSERT(forward_heap.Empty());
BOOST_ASSERT(reverse_heap.Empty()); BOOST_ASSERT(reverse_heap.Empty());
@ -821,7 +821,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
SearchEngineData::QueryHeap &reverse_heap, SearchEngineData::QueryHeap &reverse_heap,
const PhantomNode &source_phantom, const PhantomNode &source_phantom,
const PhantomNode &target_phantom, const PhantomNode &target_phantom,
int duration_upper_bound=INVALID_EDGE_WEIGHT) const int duration_upper_bound = INVALID_EDGE_WEIGHT) const
{ {
BOOST_ASSERT(forward_heap.Empty()); BOOST_ASSERT(forward_heap.Empty());
BOOST_ASSERT(reverse_heap.Empty()); BOOST_ASSERT(reverse_heap.Empty());

View File

@ -243,7 +243,8 @@ class ShortestPathRouting final
const std::vector<boost::optional<bool>> &uturn_indicators, const std::vector<boost::optional<bool>> &uturn_indicators,
InternalRouteResult &raw_route_data) const InternalRouteResult &raw_route_data) const
{ {
BOOST_ASSERT(uturn_indicators.empty() || uturn_indicators.size() == phantom_nodes_vector.size() + 1); BOOST_ASSERT(uturn_indicators.empty() ||
uturn_indicators.size() == phantom_nodes_vector.size() + 1);
engine_working_data.InitializeOrClearFirstThreadLocalStorage( engine_working_data.InitializeOrClearFirstThreadLocalStorage(
super::facade->GetNumberOfNodes()); super::facade->GetNumberOfNodes());
engine_working_data.InitializeOrClearSecondThreadLocalStorage( engine_working_data.InitializeOrClearSecondThreadLocalStorage(
@ -285,8 +286,11 @@ class ShortestPathRouting final
const auto &source_phantom = phantom_node_pair.source_phantom; const auto &source_phantom = phantom_node_pair.source_phantom;
const auto &target_phantom = phantom_node_pair.target_phantom; const auto &target_phantom = phantom_node_pair.target_phantom;
const bool use_uturn_default = !use_uturn_indicators || !uturn_indicators[current_leg + 1]; const bool use_uturn_default =
const bool allow_u_turn_at_via = (use_uturn_default && UTURN_DEFAULT) || (!use_uturn_default && *uturn_indicators[current_leg + 1]); !use_uturn_indicators || !uturn_indicators[current_leg + 1];
const bool allow_u_turn_at_via =
(use_uturn_default && UTURN_DEFAULT) ||
(!use_uturn_default && *uturn_indicators[current_leg + 1]);
bool search_to_forward_node = target_phantom.forward_node_id != SPECIAL_NODEID; bool search_to_forward_node = target_phantom.forward_node_id != SPECIAL_NODEID;
bool search_to_reverse_node = target_phantom.reverse_node_id != SPECIAL_NODEID; bool search_to_reverse_node = target_phantom.reverse_node_id != SPECIAL_NODEID;

View File

@ -11,7 +11,6 @@ enum class Status
Ok, Ok,
Error Error
}; };
} }
} }

View File

@ -18,9 +18,9 @@ class CompressedEdgeContainer
public: public:
struct CompressedEdge struct CompressedEdge
{ {
public: public:
NodeID node_id; // refers to an internal node-based-node NodeID node_id; // refers to an internal node-based-node
EdgeWeight weight; // the weight of the edge leading to this node EdgeWeight weight; // the weight of the edge leading to this node
}; };
using EdgeBucket = std::vector<CompressedEdge>; using EdgeBucket = std::vector<CompressedEdge>;
@ -32,9 +32,8 @@ class CompressedEdgeContainer
const EdgeWeight weight1, const EdgeWeight weight1,
const EdgeWeight weight2); const EdgeWeight weight2);
void AddUncompressedEdge(const EdgeID edgei_id, void
const NodeID target_node, AddUncompressedEdge(const EdgeID edgei_id, const NodeID target_node, const EdgeWeight weight);
const EdgeWeight weight);
bool HasEntryForID(const EdgeID edge_id) const; bool HasEntryForID(const EdgeID edge_id) const;
void PrintStatistics() const; void PrintStatistics() const;

View File

@ -27,8 +27,8 @@ namespace detail
const constexpr double DESIRED_SEGMENT_LENGTH = 10.0; const constexpr double DESIRED_SEGMENT_LENGTH = 10.0;
const constexpr bool shiftable_ccw[] = {false, true, true, false, false, true, true, false}; const constexpr bool shiftable_ccw[] = {false, true, true, false, false, true, true, false};
const constexpr bool shiftable_cw[] = {false, false, true, true, false, false, true, true}; const constexpr bool shiftable_cw[] = {false, false, true, true, false, false, true, true};
const constexpr uint8_t modifier_bounds[detail::num_direction_modifiers] = { const constexpr uint8_t modifier_bounds[detail::num_direction_modifiers] = {0, 36, 93, 121,
0, 36, 93, 121, 136, 163, 220, 255}; 136, 163, 220, 255};
const constexpr double discrete_angle_step_size = 360. / 256.; const constexpr double discrete_angle_step_size = 360. / 256.;
template <typename IteratorType> template <typename IteratorType>
@ -294,14 +294,10 @@ inline DirectionModifier getTurnDirection(const double angle)
// swaps left <-> right modifier types // swaps left <-> right modifier types
inline DirectionModifier mirrorDirectionModifier(const DirectionModifier modifier) inline DirectionModifier mirrorDirectionModifier(const DirectionModifier modifier)
{ {
const constexpr DirectionModifier results[] = {DirectionModifier::UTurn, const constexpr DirectionModifier results[] = {
DirectionModifier::SharpLeft, DirectionModifier::UTurn, DirectionModifier::SharpLeft, DirectionModifier::Left,
DirectionModifier::Left, DirectionModifier::SlightLeft, DirectionModifier::Straight, DirectionModifier::SlightRight,
DirectionModifier::SlightLeft, DirectionModifier::Right, DirectionModifier::SharpRight};
DirectionModifier::Straight,
DirectionModifier::SlightRight,
DirectionModifier::Right,
DirectionModifier::SharpRight};
return results[modifier]; return results[modifier];
} }

View File

@ -5,8 +5,7 @@
namespace osrm namespace osrm
{ {
using engine::EngineConfig; using engine::EngineConfig;
} }
#endif #endif

View File

@ -3,6 +3,6 @@
#include "util/json_container.hpp" #include "util/json_container.hpp"
namespace osrm namespace osrm
{ {
namespace json = osrm::util::json; namespace json = osrm::util::json;
} }
#endif #endif

View File

@ -5,7 +5,7 @@
namespace osrm namespace osrm
{ {
using engine::api::MatchParameters; using engine::api::MatchParameters;
} }
#endif #endif

View File

@ -5,7 +5,7 @@
namespace osrm namespace osrm
{ {
using engine::api::NearestParameters; using engine::api::NearestParameters;
} }
#endif #endif

View File

@ -5,7 +5,7 @@
namespace osrm namespace osrm
{ {
using engine::api::RouteParameters; using engine::api::RouteParameters;
} }
#endif #endif

View File

@ -5,7 +5,7 @@
namespace osrm namespace osrm
{ {
using engine::Status; using engine::Status;
} }
#endif #endif

View File

@ -5,7 +5,7 @@
namespace osrm namespace osrm
{ {
using engine::api::TableParameters; using engine::api::TableParameters;
} }
#endif #endif

View File

@ -5,7 +5,7 @@
namespace osrm namespace osrm
{ {
using engine::api::TripParameters; using engine::api::TripParameters;
} }
#endif #endif

View File

@ -33,22 +33,26 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<std::string::iterator>
using Iterator = std::string::iterator; using Iterator = std::string::iterator;
using RadiusesT = std::vector<boost::optional<double>>; using RadiusesT = std::vector<boost::optional<double>>;
BaseParametersGrammar(qi::rule<Iterator> &root_rule_, BaseParametersGrammar(qi::rule<Iterator> &root_rule_, engine::api::BaseParameters &parameters_)
engine::api::BaseParameters &parameters_)
: BaseParametersGrammar::base_type(root_rule_), base_parameters(parameters_) : BaseParametersGrammar::base_type(root_rule_), base_parameters(parameters_)
{ {
const auto add_bearing = [this](boost::optional<boost::fusion::vector2<short, short>> bearing_range) { const auto add_bearing =
[this](boost::optional<boost::fusion::vector2<short, short>> bearing_range)
{
boost::optional<engine::api::BaseParameters::Bearing> bearing; boost::optional<engine::api::BaseParameters::Bearing> bearing;
if (bearing_range) if (bearing_range)
{ {
bearing = engine::api::BaseParameters::Bearing {boost::fusion::at_c<0>(*bearing_range), boost::fusion::at_c<1>(*bearing_range)}; bearing = engine::api::BaseParameters::Bearing{
boost::fusion::at_c<0>(*bearing_range), boost::fusion::at_c<1>(*bearing_range)};
} }
base_parameters.bearings.push_back(std::move(bearing)); base_parameters.bearings.push_back(std::move(bearing));
}; };
const auto set_radiuses = [this](RadiusesT& radiuses) { const auto set_radiuses = [this](RadiusesT &radiuses)
{
base_parameters.radiuses = std::move(radiuses); base_parameters.radiuses = std::move(radiuses);
}; };
const auto add_hint = [this](const std::string& hint_string) { const auto add_hint = [this](const std::string &hint_string)
{
if (hint_string.size() > 0) if (hint_string.size() > 0)
{ {
base_parameters.hints.push_back(engine::Hint::FromBase64(hint_string)); base_parameters.hints.push_back(engine::Hint::FromBase64(hint_string));
@ -56,9 +60,9 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<std::string::iterator>
}; };
const auto add_coordinate = [this](const boost::fusion::vector<double, double> &lonLat) const auto add_coordinate = [this](const boost::fusion::vector<double, double> &lonLat)
{ {
base_parameters.coordinates.emplace_back( base_parameters.coordinates.emplace_back(util::Coordinate(
util::Coordinate(util::FixedLongitude(boost::fusion::at_c<0>(lonLat) * COORDINATE_PRECISION), util::FixedLongitude(boost::fusion::at_c<0>(lonLat) * COORDINATE_PRECISION),
util::FixedLatitude(boost::fusion::at_c<1>(lonLat) * COORDINATE_PRECISION))); util::FixedLatitude(boost::fusion::at_c<1>(lonLat) * COORDINATE_PRECISION)));
}; };
const auto polyline_to_coordinates = [this](const std::string &polyline) const auto polyline_to_coordinates = [this](const std::string &polyline)
{ {
@ -70,7 +74,9 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<std::string::iterator>
base64_char = qi::char_("a-zA-Z0-9--_"); base64_char = qi::char_("a-zA-Z0-9--_");
radiuses_rule = qi::lit("radiuses=") >> -qi::double_ % ";"; radiuses_rule = qi::lit("radiuses=") >> -qi::double_ % ";";
hints_rule = qi::lit("hints=") >> qi::as_string[qi::repeat(engine::ENCODED_HINT_SIZE)[base64_char]][add_hint] % ";"; hints_rule =
qi::lit("hints=") >>
qi::as_string[qi::repeat(engine::ENCODED_HINT_SIZE)[base64_char]][add_hint] % ";";
bearings_rule = bearings_rule =
qi::lit("bearings=") >> (-(qi::short_ >> ',' >> qi::short_))[add_bearing] % ";"; qi::lit("bearings=") >> (-(qi::short_ >> ',' >> qi::short_))[add_bearing] % ";";
polyline_rule = qi::as_string[qi::lit("polyline(") >> +polyline_chars >> polyline_rule = qi::as_string[qi::lit("polyline(") >> +polyline_chars >>
@ -81,11 +87,11 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<std::string::iterator>
base_rule = bearings_rule | radiuses_rule[set_radiuses] | hints_rule; base_rule = bearings_rule | radiuses_rule[set_radiuses] | hints_rule;
} }
protected: protected:
qi::rule<Iterator> base_rule; qi::rule<Iterator> base_rule;
qi::rule<Iterator> query_rule; qi::rule<Iterator> query_rule;
private: private:
engine::api::BaseParameters &base_parameters; engine::api::BaseParameters &base_parameters;
qi::rule<Iterator> bearings_rule; qi::rule<Iterator> bearings_rule;
qi::rule<Iterator> hints_rule; qi::rule<Iterator> hints_rule;

View File

@ -68,9 +68,10 @@ struct MatchParametersGrammar final : public BaseParametersGrammar
qi::lit("overview=full")[set_full_type] | qi::lit("overview=full")[set_full_type] |
qi::lit("overview=false")[set_false_type]; qi::lit("overview=false")[set_false_type];
timestamps_rule = qi::lit("timestamps=") >> qi::uint_ % ";"; timestamps_rule = qi::lit("timestamps=") >> qi::uint_ % ";";
match_rule = steps_rule[set_steps] | geometries_rule | match_rule = steps_rule[set_steps] | geometries_rule | overview_rule |
overview_rule | timestamps_rule[set_timestamps]; timestamps_rule[set_timestamps];
root_rule = query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (match_rule | base_rule) % '&'); root_rule =
query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (match_rule | base_rule) % '&');
} }
engine::api::MatchParameters parameters; engine::api::MatchParameters parameters;

View File

@ -31,7 +31,8 @@ struct NearestParametersGrammar final : public BaseParametersGrammar
parameters.number_of_results = number; parameters.number_of_results = number;
}; };
nearest_rule = (qi::lit("number=") >> qi::uint_)[set_number]; nearest_rule = (qi::lit("number=") >> qi::uint_)[set_number];
root_rule = query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (nearest_rule | base_rule) % '&'); root_rule =
query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (nearest_rule | base_rule) % '&');
} }
engine::api::NearestParameters parameters; engine::api::NearestParameters parameters;

View File

@ -76,7 +76,8 @@ struct RouteParametersGrammar : public BaseParametersGrammar
route_rule = steps_rule[set_steps] | alternative_rule[set_alternative] | geometries_rule | route_rule = steps_rule[set_steps] | alternative_rule[set_alternative] | geometries_rule |
overview_rule | uturns_rule[set_uturns]; overview_rule | uturns_rule[set_uturns];
root_rule = query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (route_rule | base_rule) % '&'); root_rule =
query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (route_rule | base_rule) % '&');
} }
engine::api::RouteParameters parameters; engine::api::RouteParameters parameters;

View File

@ -36,11 +36,14 @@ struct TableParametersGrammar final : public BaseParametersGrammar
{ {
parameters.sources = std::move(sources); parameters.sources = std::move(sources);
}; };
destinations_rule = (qi::lit("destinations=") >> (qi::ulong_ % ";")[set_destiantions]) | qi::lit("destinations=all"); destinations_rule = (qi::lit("destinations=") >> (qi::ulong_ % ";")[set_destiantions]) |
sources_rule = (qi::lit("sources=") >> (qi::ulong_ % ";")[set_sources]) | qi::lit("sources=all"); qi::lit("destinations=all");
sources_rule =
(qi::lit("sources=") >> (qi::ulong_ % ";")[set_sources]) | qi::lit("sources=all");
table_rule = destinations_rule | sources_rule; table_rule = destinations_rule | sources_rule;
root_rule = query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (table_rule | base_rule) % '&'); root_rule =
query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (table_rule | base_rule) % '&');
} }
engine::api::TableParameters parameters; engine::api::TableParameters parameters;

View File

@ -26,20 +26,29 @@ struct TileParametersGrammar final : boost::spirit::qi::grammar<std::string::ite
{ {
using Iterator = std::string::iterator; using Iterator = std::string::iterator;
TileParametersGrammar() TileParametersGrammar() : TileParametersGrammar::base_type(root_rule)
: TileParametersGrammar::base_type(root_rule)
{ {
const auto set_x = [this](const unsigned x_) { parameters.x = x_; }; const auto set_x = [this](const unsigned x_)
const auto set_y = [this](const unsigned y_) { parameters.y = y_; }; {
const auto set_z = [this](const unsigned z_) { parameters.z = z_; }; parameters.x = x_;
};
const auto set_y = [this](const unsigned y_)
{
parameters.y = y_;
};
const auto set_z = [this](const unsigned z_)
{
parameters.z = z_;
};
query_rule = qi::lit("tile(") >> qi::uint_[set_x] >> qi::lit(",") >> qi::uint_[set_y] >> qi::lit(",") >> qi::uint_[set_z] >> qi::lit(")"); query_rule = qi::lit("tile(") >> qi::uint_[set_x] >> qi::lit(",") >> qi::uint_[set_y] >>
qi::lit(",") >> qi::uint_[set_z] >> qi::lit(")");
root_rule = query_rule >> qi::lit(".mvt"); root_rule = query_rule >> qi::lit(".mvt");
} }
engine::api::TileParameters parameters; engine::api::TileParameters parameters;
private: private:
qi::rule<Iterator> root_rule; qi::rule<Iterator> root_rule;
qi::rule<Iterator> query_rule; qi::rule<Iterator> query_rule;
}; };

View File

@ -64,7 +64,8 @@ struct TripParametersGrammar final : public BaseParametersGrammar
qi::lit("overview=false")[set_false_type]; qi::lit("overview=false")[set_false_type];
trip_rule = steps_rule[set_steps] | geometries_rule | overview_rule; trip_rule = steps_rule[set_steps] | geometries_rule | overview_rule;
root_rule = query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (trip_rule | base_rule) % '&'); root_rule =
query_rule >> -qi::lit(".json") >> -(qi::lit("?") >> (trip_rule | base_rule) % '&');
} }
engine::api::TripParameters parameters; engine::api::TripParameters parameters;

View File

@ -15,14 +15,13 @@ namespace api
{ {
// Starts parsing and iter and modifies it until iter == end or parsing failed // Starts parsing and iter and modifies it until iter == end or parsing failed
boost::optional<ParsedURL> parseURL(std::string::iterator& iter, std::string::iterator end); boost::optional<ParsedURL> parseURL(std::string::iterator &iter, std::string::iterator end);
// copy on purpose because we need mutability // copy on purpose because we need mutability
inline boost::optional<ParsedURL> parseURL(std::string url_string) inline boost::optional<ParsedURL> parseURL(std::string url_string)
{ {
auto iter = url_string.begin(); auto iter = url_string.begin();
return parseURL(iter, url_string.end()); return parseURL(iter, url_string.end());
} }
} }
} }
} }

View File

@ -24,8 +24,6 @@ bool constrainParamSize(const char *msg_template,
} }
return false; return false;
} }
} }
} }
} }

View File

@ -32,7 +32,6 @@ class ServiceHandler
engine::Status RunQuery(api::ParsedURL parsed_url, ResultT &result); engine::Status RunQuery(api::ParsedURL parsed_url, ResultT &result);
private: private:
std::unordered_map<std::string, std::unique_ptr<service::BaseService>> service_map; std::unordered_map<std::string, std::unique_ptr<service::BaseService>> service_map;
OSRM routing_machine; OSRM routing_machine;
}; };

View File

@ -13,10 +13,11 @@ namespace storage
using DataPaths = std::unordered_map<std::string, boost::filesystem::path>; using DataPaths = std::unordered_map<std::string, boost::filesystem::path>;
class Storage class Storage
{ {
public: public:
Storage(const DataPaths& data_paths); Storage(const DataPaths &data_paths);
int Run(); int Run();
private:
private:
DataPaths paths; DataPaths paths;
}; };
} }

View File

@ -195,11 +195,13 @@ struct RectangleInt2D
return lons_contained && lats_contained; return lons_contained && lats_contained;
} }
friend std::ostream& operator<<(std::ostream& out, const RectangleInt2D& rect); friend std::ostream &operator<<(std::ostream &out, const RectangleInt2D &rect);
}; };
inline std::ostream& operator<<(std::ostream& out, const RectangleInt2D& rect) inline std::ostream &operator<<(std::ostream &out, const RectangleInt2D &rect)
{ {
out << std::setprecision(12) << "(" << toFloating(rect.min_lon) << "," << toFloating(rect.max_lon) << "," << toFloating(rect.min_lat) << "," << toFloating(rect.max_lat) << ")"; out << std::setprecision(12) << "(" << toFloating(rect.min_lon) << ","
<< toFloating(rect.max_lon) << "," << toFloating(rect.min_lat) << ","
<< toFloating(rect.max_lat) << ")";
return out; return out;
} }
} }

View File

@ -28,14 +28,8 @@ namespace json
namespace detail namespace detail
{ {
const constexpr char *modifier_names[] = {"uturn", const constexpr char *modifier_names[] = {"uturn", "sharp right", "right", "slight right",
"sharp right", "straight", "slight left", "left", "sharp left"};
"right",
"slight right",
"straight",
"slight left",
"left",
"sharp left"};
// translations of TurnTypes. Not all types are exposed to the outside world. // translations of TurnTypes. Not all types are exposed to the outside world.
// invalid types should never be returned as part of the API // invalid types should never be returned as part of the API

View File

@ -59,8 +59,8 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter
auto snapped_phantoms = SnapPhantomNodes(phantom_node_pairs); auto snapped_phantoms = SnapPhantomNodes(phantom_node_pairs);
InternalRouteResult raw_route; InternalRouteResult raw_route;
auto build_phantom_pairs = auto build_phantom_pairs = [&raw_route](const PhantomNode &first_node,
[&raw_route](const PhantomNode &first_node, const PhantomNode &second_node) const PhantomNode &second_node)
{ {
raw_route.segment_end_coordinates.push_back(PhantomNodes{first_node, second_node}); raw_route.segment_end_coordinates.push_back(PhantomNodes{first_node, second_node});
}; };

View File

@ -70,10 +70,15 @@ std::string encodePolyline(CoordVectorForwardIter begin, CoordVectorForwardIter
delta_numbers.reserve((size - 1) * 2); delta_numbers.reserve((size - 1) * 2);
int current_lat = 0; int current_lat = 0;
int current_lon = 0; int current_lon = 0;
std::for_each(begin, end, [&delta_numbers, &current_lat, &current_lon](const util::Coordinate loc) std::for_each(begin, end,
[&delta_numbers, &current_lat, &current_lon](const util::Coordinate loc)
{ {
const int lat_diff = std::round(static_cast<int>(loc.lat) * detail::COORDINATE_TO_POLYLINE) - current_lat; const int lat_diff =
const int lon_diff = std::round(static_cast<int>(loc.lon) * detail::COORDINATE_TO_POLYLINE) - current_lon; std::round(static_cast<int>(loc.lat) * detail::COORDINATE_TO_POLYLINE) -
current_lat;
const int lon_diff =
std::round(static_cast<int>(loc.lon) * detail::COORDINATE_TO_POLYLINE) -
current_lon;
delta_numbers.emplace_back(lat_diff); delta_numbers.emplace_back(lat_diff);
delta_numbers.emplace_back(lon_diff); delta_numbers.emplace_back(lon_diff);
current_lat += lat_diff; current_lat += lat_diff;

View File

@ -78,7 +78,7 @@ void CompressedEdgeContainer::SerializeInternalVector(const std::string &path) c
const unsigned unpacked_size = current_vector.size(); const unsigned unpacked_size = current_vector.size();
control_sum += unpacked_size; control_sum += unpacked_size;
BOOST_ASSERT(std::numeric_limits<unsigned>::max() != unpacked_size); BOOST_ASSERT(std::numeric_limits<unsigned>::max() != unpacked_size);
for (const auto & current_node : current_vector) for (const auto &current_node : current_vector)
{ {
geometry_out_stream.write((char *)&(current_node), sizeof(CompressedEdge)); geometry_out_stream.write((char *)&(current_node), sizeof(CompressedEdge));
} }
@ -143,7 +143,7 @@ void CompressedEdgeContainer::CompressEdge(const EdgeID edge_id_1,
// weight1 is the distance to the (currently) last coordinate in the bucket // weight1 is the distance to the (currently) last coordinate in the bucket
if (edge_bucket_list1.empty()) if (edge_bucket_list1.empty())
{ {
edge_bucket_list1.emplace_back(CompressedEdge { via_node_id, weight1 }); edge_bucket_list1.emplace_back(CompressedEdge{via_node_id, weight1});
} }
BOOST_ASSERT(0 < edge_bucket_list1.size()); BOOST_ASSERT(0 < edge_bucket_list1.size());
@ -174,11 +174,11 @@ void CompressedEdgeContainer::CompressEdge(const EdgeID edge_id_1,
else else
{ {
// we are certain that the second edge is atomic. // we are certain that the second edge is atomic.
edge_bucket_list1.emplace_back( CompressedEdge { target_node_id, weight2 }); edge_bucket_list1.emplace_back(CompressedEdge{target_node_id, weight2});
} }
} }
void CompressedEdgeContainer::AddUncompressedEdge(const EdgeID edge_id, void CompressedEdgeContainer::AddUncompressedEdge(const EdgeID edge_id,
const NodeID target_node_id, const NodeID target_node_id,
const EdgeWeight weight) const EdgeWeight weight)
{ {
@ -215,12 +215,10 @@ void CompressedEdgeContainer::AddUncompressedEdge(const EdgeID edge_id,
// Don't re-add this if it's already in there. // Don't re-add this if it's already in there.
if (edge_bucket_list.empty()) if (edge_bucket_list.empty())
{ {
edge_bucket_list.emplace_back(CompressedEdge { target_node_id, weight }); edge_bucket_list.emplace_back(CompressedEdge{target_node_id, weight});
} }
} }
void CompressedEdgeContainer::PrintStatistics() const void CompressedEdgeContainer::PrintStatistics() const
{ {
const uint64_t compressed_edges = m_compressed_geometries.size(); const uint64_t compressed_edges = m_compressed_geometries.size();

View File

@ -278,8 +278,7 @@ int Extractor::run()
util::SimpleLogger().Write() << "Saving edge-based node weights to file."; util::SimpleLogger().Write() << "Saving edge-based node weights to file.";
TIMER_START(timer_write_node_weights); TIMER_START(timer_write_node_weights);
util::serializeVector(config.edge_based_node_weights_output_path, util::serializeVector(config.edge_based_node_weights_output_path, edge_based_node_weights);
edge_based_node_weights);
TIMER_STOP(timer_write_node_weights); TIMER_STOP(timer_write_node_weights);
util::SimpleLogger().Write() << "Done writing. (" << TIMER_SEC(timer_write_node_weights) util::SimpleLogger().Write() << "Done writing. (" << TIMER_SEC(timer_write_node_weights)
<< ")"; << ")";

View File

@ -41,9 +41,7 @@ void ExtractorCallbacks::ProcessNode(const osmium::Node &input_node,
external_memory.all_nodes_list.push_back( external_memory.all_nodes_list.push_back(
{util::toFixed(util::FloatLongitude(input_node.location().lon())), {util::toFixed(util::FloatLongitude(input_node.location().lon())),
util::toFixed(util::FloatLatitude(input_node.location().lat())), util::toFixed(util::FloatLatitude(input_node.location().lat())),
OSMNodeID(input_node.id()), OSMNodeID(input_node.id()), result_node.barrier, result_node.traffic_lights});
result_node.barrier,
result_node.traffic_lights});
} }
void ExtractorCallbacks::ProcessRestriction( void ExtractorCallbacks::ProcessRestriction(
@ -125,8 +123,8 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
if (forward_weight_data.type == InternalExtractorEdge::WeightType::INVALID && if (forward_weight_data.type == InternalExtractorEdge::WeightType::INVALID &&
backward_weight_data.type == InternalExtractorEdge::WeightType::INVALID) backward_weight_data.type == InternalExtractorEdge::WeightType::INVALID)
{ {
util::SimpleLogger().Write(logDEBUG) util::SimpleLogger().Write(logDEBUG) << "found way with bogus speed, id: "
<< "found way with bogus speed, id: " << input_way.id(); << input_way.id();
return; return;
} }
@ -187,11 +185,9 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
}); });
external_memory.way_start_end_id_list.push_back( external_memory.way_start_end_id_list.push_back(
{OSMWayID(input_way.id()), {OSMWayID(input_way.id()), OSMNodeID(input_way.nodes().back().ref()),
OSMNodeID(input_way.nodes().back().ref()),
OSMNodeID(input_way.nodes()[input_way.nodes().size() - 2].ref()), OSMNodeID(input_way.nodes()[input_way.nodes().size() - 2].ref()),
OSMNodeID(input_way.nodes()[1].ref()), OSMNodeID(input_way.nodes()[1].ref()), OSMNodeID(input_way.nodes()[0].ref())});
OSMNodeID(input_way.nodes()[0].ref())});
} }
else else
{ {
@ -223,11 +219,9 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
} }
external_memory.way_start_end_id_list.push_back( external_memory.way_start_end_id_list.push_back(
{OSMWayID(input_way.id()), {OSMWayID(input_way.id()), OSMNodeID(input_way.nodes().back().ref()),
OSMNodeID(input_way.nodes().back().ref()),
OSMNodeID(input_way.nodes()[input_way.nodes().size() - 2].ref()), OSMNodeID(input_way.nodes()[input_way.nodes().size() - 2].ref()),
OSMNodeID(input_way.nodes()[1].ref()), OSMNodeID(input_way.nodes()[1].ref()), OSMNodeID(input_way.nodes()[0].ref())});
OSMNodeID(input_way.nodes()[0].ref())});
} }
} }
} }

View File

@ -156,12 +156,10 @@ void GraphCompressor::Compress(const std::unordered_set<NodeID> &barrier_nodes,
restriction_map.FixupArrivingTurnRestriction(node_w, node_v, node_u, graph); restriction_map.FixupArrivingTurnRestriction(node_w, node_v, node_u, graph);
// store compressed geometry in container // store compressed geometry in container
geometry_compressor.CompressEdge( geometry_compressor.CompressEdge(forward_e1, forward_e2, node_v, node_w,
forward_e1, forward_e2, node_v, node_w, forward_weight1, forward_weight2);
forward_weight1, forward_weight2); geometry_compressor.CompressEdge(reverse_e1, reverse_e2, node_v, node_u,
geometry_compressor.CompressEdge( reverse_weight1, reverse_weight2);
reverse_e1, reverse_e2, node_v, node_u,
reverse_weight1, reverse_weight2);
} }
} }
@ -179,7 +177,6 @@ void GraphCompressor::Compress(const std::unordered_set<NodeID> &barrier_nodes,
geometry_compressor.AddUncompressedEdge(edge_id, target, data.distance); geometry_compressor.AddUncompressedEdge(edge_id, target, data.distance);
} }
} }
} }
void GraphCompressor::PrintStatistics(unsigned original_number_of_nodes, void GraphCompressor::PrintStatistics(unsigned original_number_of_nodes,

View File

@ -29,14 +29,12 @@ namespace osrm
namespace server namespace server
{ {
void RequestHandler::RegisterServiceHandler(std::unique_ptr<ServiceHandler> service_handler_) void RequestHandler::RegisterServiceHandler(std::unique_ptr<ServiceHandler> service_handler_)
{ {
service_handler = std::move(service_handler_); service_handler = std::move(service_handler_);
} }
void RequestHandler::HandleRequest(const http::request &current_request, void RequestHandler::HandleRequest(const http::request &current_request, http::reply &current_reply)
http::reply &current_reply)
{ {
if (!service_handler) if (!service_handler)
{ {
@ -78,15 +76,16 @@ void RequestHandler::HandleRequest(const http::request &current_request,
<< request_string; << request_string;
auto api_iterator = request_string.begin(); auto api_iterator = request_string.begin();
auto maybe_parsed_url = api::parseURL(api_iterator, request_string.end());; auto maybe_parsed_url = api::parseURL(api_iterator, request_string.end());
;
ServiceHandler::ResultT result; ServiceHandler::ResultT result;
// check if the was an error with the request // check if the was an error with the request
if (maybe_parsed_url && api_iterator == request_string.end()) if (maybe_parsed_url && api_iterator == request_string.end())
{ {
const engine::Status status = service_handler->RunQuery(std::move(*maybe_parsed_url), result); const engine::Status status =
service_handler->RunQuery(std::move(*maybe_parsed_url), result);
if (status != engine::Status::Ok) if (status != engine::Status::Ok)
{ {
// 4xx bad request return code // 4xx bad request return code
@ -101,18 +100,18 @@ void RequestHandler::HandleRequest(const http::request &current_request,
{ {
const auto position = std::distance(request_string.begin(), api_iterator); const auto position = std::distance(request_string.begin(), api_iterator);
const auto context_begin = request_string.begin() + std::max(position - 3UL, 0UL); const auto context_begin = request_string.begin() + std::max(position - 3UL, 0UL);
const auto context_end = request_string.begin() + std::min(position + 3UL, request_string.size()); const auto context_end =
request_string.begin() + std::min(position + 3UL, request_string.size());
std::string context(context_begin, context_end); std::string context(context_begin, context_end);
current_reply.status = http::reply::bad_request; current_reply.status = http::reply::bad_request;
result = util::json::Object(); result = util::json::Object();
auto& json_result = result.get<util::json::Object>(); auto &json_result = result.get<util::json::Object>();
json_result.values["code"] = "invalid-url"; json_result.values["code"] = "invalid-url";
json_result.values["message"] = json_result.values["message"] = "URL string malformed close to position " +
"URL string malformed close to position " + std::to_string(position) + ": \"" + context + "\""; std::to_string(position) + ": \"" + context + "\"";
} }
current_reply.headers.emplace_back("Access-Control-Allow-Origin", "*"); current_reply.headers.emplace_back("Access-Control-Allow-Origin", "*");
current_reply.headers.emplace_back("Access-Control-Allow-Methods", "GET"); current_reply.headers.emplace_back("Access-Control-Allow-Methods", "GET");
current_reply.headers.emplace_back("Access-Control-Allow-Headers", current_reply.headers.emplace_back("Access-Control-Allow-Headers",
@ -121,14 +120,15 @@ void RequestHandler::HandleRequest(const http::request &current_request,
{ {
current_reply.headers.emplace_back("Content-Type", "application/json; charset=UTF-8"); current_reply.headers.emplace_back("Content-Type", "application/json; charset=UTF-8");
current_reply.headers.emplace_back("Content-Disposition", current_reply.headers.emplace_back("Content-Disposition",
"inline; filename=\"response.json\""); "inline; filename=\"response.json\"");
util::json::render(current_reply.content, result.get<util::json::Object>()); util::json::render(current_reply.content, result.get<util::json::Object>());
} }
else else
{ {
BOOST_ASSERT(result.is<std::string>()); BOOST_ASSERT(result.is<std::string>());
std::copy(result.get<std::string>().cbegin(), result.get<std::string>().cend(), std::back_inserter(current_reply.content)); std::copy(result.get<std::string>().cbegin(), result.get<std::string>().cend(),
std::back_inserter(current_reply.content));
current_reply.headers.emplace_back("Content-Type", "application/x-protobuf"); current_reply.headers.emplace_back("Content-Type", "application/x-protobuf");
} }
@ -144,6 +144,5 @@ void RequestHandler::HandleRequest(const http::request &current_request,
<< ", uri: " << current_request.uri; << ", uri: " << current_request.uri;
} }
} }
} }
} }

View File

@ -39,7 +39,8 @@ RequestParser::parse(http::request &current_request, char *begin, char *end)
return std::make_tuple(result, selected_compression); return std::make_tuple(result, selected_compression);
} }
RequestParser::RequestStatus RequestParser::consume(http::request &current_request, const char input) RequestParser::RequestStatus RequestParser::consume(http::request &current_request,
const char input)
{ {
switch (state) switch (state)
{ {

View File

@ -43,7 +43,7 @@ std::string getWrongOptionHelp(const engine::api::MatchParameters &parameters)
engine::Status MatchService::RunQuery(std::string &query, ResultT &result) engine::Status MatchService::RunQuery(std::string &query, ResultT &result)
{ {
result = util::json::Object(); result = util::json::Object();
auto& json_result = result.get<util::json::Object>(); auto &json_result = result.get<util::json::Object>();
auto query_iterator = query.begin(); auto query_iterator = query.begin();
auto parameters = auto parameters =

View File

@ -42,7 +42,7 @@ std::string getWrongOptionHelp(const engine::api::NearestParameters &parameters)
engine::Status NearestService::RunQuery(std::string &query, ResultT &result) engine::Status NearestService::RunQuery(std::string &query, ResultT &result)
{ {
result = util::json::Object(); result = util::json::Object();
auto& json_result = result.get<util::json::Object>(); auto &json_result = result.get<util::json::Object>();
auto query_iterator = query.begin(); auto query_iterator = query.begin();
auto parameters = auto parameters =

View File

@ -25,7 +25,8 @@ ServiceHandler::ServiceHandler(osrm::EngineConfig &config) : routing_machine(con
service_map["tile"] = util::make_unique<service::TileService>(routing_machine); service_map["tile"] = util::make_unique<service::TileService>(routing_machine);
} }
engine::Status ServiceHandler::RunQuery(api::ParsedURL parsed_url, service::BaseService::ResultT &result) engine::Status ServiceHandler::RunQuery(api::ParsedURL parsed_url,
service::BaseService::ResultT &result)
{ {
const auto &service_iter = service_map.find(parsed_url.service); const auto &service_iter = service_map.find(parsed_url.service);
if (service_iter == service_map.end()) if (service_iter == service_map.end())

View File

@ -320,8 +320,8 @@ int Storage::Run()
boost::iostreams::seek(geometry_input_stream, number_of_geometries_indices * sizeof(unsigned), boost::iostreams::seek(geometry_input_stream, number_of_geometries_indices * sizeof(unsigned),
BOOST_IOS::cur); BOOST_IOS::cur);
geometry_input_stream.read((char *)&number_of_compressed_geometries, sizeof(unsigned)); geometry_input_stream.read((char *)&number_of_compressed_geometries, sizeof(unsigned));
shared_layout_ptr->SetBlockSize<extractor::CompressedEdgeContainer::CompressedEdge>(SharedDataLayout::GEOMETRIES_LIST, shared_layout_ptr->SetBlockSize<extractor::CompressedEdgeContainer::CompressedEdge>(
number_of_compressed_geometries); SharedDataLayout::GEOMETRIES_LIST, number_of_compressed_geometries);
// allocate shared memory block // allocate shared memory block
util::SimpleLogger().Write() << "allocating shared memory of " util::SimpleLogger().Write() << "allocating shared memory of "
<< shared_layout_ptr->GetSizeOfLayout() << " bytes"; << shared_layout_ptr->GetSizeOfLayout() << " bytes";
@ -420,8 +420,9 @@ int Storage::Run()
(char *)geometries_index_ptr, (char *)geometries_index_ptr,
shared_layout_ptr->GetBlockSize(SharedDataLayout::GEOMETRIES_INDEX)); shared_layout_ptr->GetBlockSize(SharedDataLayout::GEOMETRIES_INDEX));
} }
extractor::CompressedEdgeContainer::CompressedEdge *geometries_list_ptr = shared_layout_ptr->GetBlockPtr<extractor::CompressedEdgeContainer::CompressedEdge, true>( extractor::CompressedEdgeContainer::CompressedEdge *geometries_list_ptr =
shared_memory_ptr, SharedDataLayout::GEOMETRIES_LIST); shared_layout_ptr->GetBlockPtr<extractor::CompressedEdgeContainer::CompressedEdge, true>(
shared_memory_ptr, SharedDataLayout::GEOMETRIES_LIST);
geometry_input_stream.read((char *)&temporary_value, sizeof(unsigned)); geometry_input_stream.read((char *)&temporary_value, sizeof(unsigned));
BOOST_ASSERT(temporary_value == BOOST_ASSERT(temporary_value ==

View File

@ -114,8 +114,7 @@ int main(int argc, char *argv[]) try
auto number_of_nodes = osrm::tools::loadGraph(argv[1], coordinate_list, graph_edge_list); auto number_of_nodes = osrm::tools::loadGraph(argv[1], coordinate_list, graph_edge_list);
tbb::parallel_sort(graph_edge_list.begin(), graph_edge_list.end()); tbb::parallel_sort(graph_edge_list.begin(), graph_edge_list.end());
const auto graph = const auto graph = std::make_shared<osrm::tools::TarjanGraph>(number_of_nodes, graph_edge_list);
std::make_shared<osrm::tools::TarjanGraph>(number_of_nodes, graph_edge_list);
graph_edge_list.clear(); graph_edge_list.clear();
graph_edge_list.shrink_to_fit(); graph_edge_list.shrink_to_fit();
@ -181,8 +180,7 @@ int main(int argc, char *argv[]) try
{ {
total_network_length += total_network_length +=
100 * osrm::util::coordinate_calculation::greatCircleDistance( 100 * osrm::util::coordinate_calculation::greatCircleDistance(
coordinate_list[source], coordinate_list[source], coordinate_list[target]);
coordinate_list[target]);
BOOST_ASSERT(current_edge != SPECIAL_EDGEID); BOOST_ASSERT(current_edge != SPECIAL_EDGEID);
BOOST_ASSERT(source != SPECIAL_NODEID); BOOST_ASSERT(source != SPECIAL_NODEID);
@ -203,8 +201,7 @@ int main(int argc, char *argv[]) try
static_cast<double>(osrm::util::toFloating(coordinate_list[target].lon)), static_cast<double>(osrm::util::toFloating(coordinate_list[target].lon)),
static_cast<double>(osrm::util::toFloating(coordinate_list[target].lat))); static_cast<double>(osrm::util::toFloating(coordinate_list[target].lat)));
OGRFeature *po_feature = OGRFeature *po_feature = OGRFeature::CreateFeature(po_layer->GetLayerDefn());
OGRFeature::CreateFeature(po_layer->GetLayerDefn());
po_feature->SetGeometry(&line_string); po_feature->SetGeometry(&line_string);
if (OGRERR_NONE != po_layer->CreateFeature(po_feature)) if (OGRERR_NONE != po_layer->CreateFeature(po_feature))
@ -223,8 +220,8 @@ int main(int argc, char *argv[]) try
<< "generating output took: " << TIMER_MSEC(SCC_OUTPUT) / 1000. << "s"; << "generating output took: " << TIMER_MSEC(SCC_OUTPUT) / 1000. << "s";
osrm::util::SimpleLogger().Write() osrm::util::SimpleLogger().Write()
<< "total network distance: " << "total network distance: " << static_cast<uint64_t>(total_network_length / 100 / 1000.)
<< static_cast<uint64_t>(total_network_length / 100 / 1000.) << " km"; << " km";
osrm::util::SimpleLogger().Write() << "finished component analysis"; osrm::util::SimpleLogger().Write() << "finished component analysis";
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@ -29,10 +29,11 @@ return_code parseArguments(int argc, char *argv[], extractor::ExtractorConfig &e
// declare a group of options that will be allowed both on command line // declare a group of options that will be allowed both on command line
boost::program_options::options_description config_options("Configuration"); boost::program_options::options_description config_options("Configuration");
config_options.add_options()("profile,p", config_options.add_options()(
boost::program_options::value<boost::filesystem::path>( "profile,p",
&extractor_config.profile_path)->default_value("profile.lua"), boost::program_options::value<boost::filesystem::path>(&extractor_config.profile_path)
"Path to LUA routing profile")( ->default_value("profile.lua"),
"Path to LUA routing profile")(
"threads,t", "threads,t",
boost::program_options::value<unsigned int>(&extractor_config.requested_num_threads) boost::program_options::value<unsigned int>(&extractor_config.requested_num_threads)
->default_value(tbb::task_scheduler_init::default_num_threads()), ->default_value(tbb::task_scheduler_init::default_num_threads()),
@ -42,8 +43,9 @@ return_code parseArguments(int argc, char *argv[], extractor::ExtractorConfig &e
->implicit_value(true) ->implicit_value(true)
->default_value(false), ->default_value(false),
"Generate a lookup table for internal edge-expanded-edge IDs to OSM node pairs")( "Generate a lookup table for internal edge-expanded-edge IDs to OSM node pairs")(
"small-component-size", boost::program_options::value<unsigned int>( "small-component-size",
&extractor_config.small_component_size)->default_value(1000), boost::program_options::value<unsigned int>(&extractor_config.small_component_size)
->default_value(1000),
"Number of nodes required before a strongly-connected-componennt is considered big " "Number of nodes required before a strongly-connected-componennt is considered big "
"(affects nearest neighbor snapping)"); "(affects nearest neighbor snapping)");

View File

@ -64,8 +64,7 @@ int main(int argc, char *argv[]) try
osrm::util::LogPolicy::GetInstance().Unmute(); osrm::util::LogPolicy::GetInstance().Unmute();
if (1 == argc) if (1 == argc)
{ {
osrm::util::SimpleLogger().Write(logWARNING) << "usage: " << argv[0] osrm::util::SimpleLogger().Write(logWARNING) << "usage: " << argv[0] << " /path/on/device";
<< " /path/on/device";
return -1; return -1;
} }
@ -89,8 +88,7 @@ int main(int argc, char *argv[]) try
fcntl(fileno(fd), F_NOCACHE, 1); fcntl(fileno(fd), F_NOCACHE, 1);
fcntl(fileno(fd), F_RDAHEAD, 0); fcntl(fileno(fd), F_RDAHEAD, 0);
TIMER_START(write_1gb); TIMER_START(write_1gb);
write(fileno(fd), (char *)random_array, write(fileno(fd), (char *)random_array, osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
TIMER_STOP(write_1gb); TIMER_STOP(write_1gb);
fclose(fd); fclose(fd);
#endif #endif
@ -148,8 +146,7 @@ int main(int argc, char *argv[]) try
osrm::util::SimpleLogger().Write(logDEBUG) << "opened, error: " << strerror(errno); osrm::util::SimpleLogger().Write(logDEBUG) << "opened, error: " << strerror(errno);
return -1; return -1;
} }
char *raw_array = char *raw_array = (char *)memalign(512, osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
(char *)memalign(512, osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
#endif #endif
TIMER_START(read_1gb); TIMER_START(read_1gb);
#ifdef __APPLE__ #ifdef __APPLE__
@ -158,8 +155,7 @@ int main(int argc, char *argv[]) try
fd = fopen(test_path.string().c_str(), "r"); fd = fopen(test_path.string().c_str(), "r");
#endif #endif
#ifdef __linux__ #ifdef __linux__
int ret = int ret = read(file_desc, raw_array, osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
read(file_desc, raw_array, osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned));
osrm::util::SimpleLogger().Write(logDEBUG) << "read " << ret osrm::util::SimpleLogger().Write(logDEBUG) << "read " << ret
<< " bytes, error: " << strerror(errno); << " bytes, error: " << strerror(errno);
close(file_desc); close(file_desc);
@ -168,8 +164,8 @@ int main(int argc, char *argv[]) try
#endif #endif
TIMER_STOP(read_1gb); TIMER_STOP(read_1gb);
osrm::util::SimpleLogger().Write(logDEBUG) << "reading raw 1GB took " osrm::util::SimpleLogger().Write(logDEBUG) << "reading raw 1GB took " << TIMER_SEC(read_1gb)
<< TIMER_SEC(read_1gb) << "s"; << "s";
osrm::util::SimpleLogger().Write() << "raw read performance: " << std::setprecision(5) osrm::util::SimpleLogger().Write() << "raw read performance: " << std::setprecision(5)
<< std::fixed << 1024 * 1024 / TIMER_SEC(read_1gb) << std::fixed << 1024 * 1024 / TIMER_SEC(read_1gb)
<< "MB/sec"; << "MB/sec";
@ -184,8 +180,7 @@ int main(int argc, char *argv[]) try
lseek(file_desc, 0, SEEK_SET); lseek(file_desc, 0, SEEK_SET);
#endif #endif
// make 1000 random access, time each I/O seperately // make 1000 random access, time each I/O seperately
unsigned number_of_blocks = unsigned number_of_blocks = (osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned) - 1) / 4096;
(osrm::tools::NUMBER_OF_ELEMENTS * sizeof(unsigned) - 1) / 4096;
std::random_device rd; std::random_device rd;
std::default_random_engine e1(rd()); std::default_random_engine e1(rd());
std::uniform_int_distribution<unsigned> uniform_dist(0, number_of_blocks - 1); std::uniform_int_distribution<unsigned> uniform_dist(0, number_of_blocks - 1);
@ -212,15 +207,13 @@ int main(int argc, char *argv[]) try
if (((off_t)-1) == ret1) if (((off_t)-1) == ret1)
{ {
osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset; osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset;
osrm::util::SimpleLogger().Write(logWARNING) << "seek error " osrm::util::SimpleLogger().Write(logWARNING) << "seek error " << strerror(errno);
<< strerror(errno);
throw osrm::util::exception("seek error"); throw osrm::util::exception("seek error");
} }
if (-1 == ret2) if (-1 == ret2)
{ {
osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset; osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset;
osrm::util::SimpleLogger().Write(logWARNING) << "read error " osrm::util::SimpleLogger().Write(logWARNING) << "read error " << strerror(errno);
<< strerror(errno);
throw osrm::util::exception("read error"); throw osrm::util::exception("read error");
} }
timing_results_raw_random.push_back(TIMER_SEC(random_access)); timing_results_raw_random.push_back(TIMER_SEC(random_access));
@ -274,15 +267,13 @@ int main(int argc, char *argv[]) try
if (((off_t)-1) == ret1) if (((off_t)-1) == ret1)
{ {
osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset; osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset;
osrm::util::SimpleLogger().Write(logWARNING) << "seek error " osrm::util::SimpleLogger().Write(logWARNING) << "seek error " << strerror(errno);
<< strerror(errno);
throw osrm::util::exception("seek error"); throw osrm::util::exception("seek error");
} }
if (-1 == ret2) if (-1 == ret2)
{ {
osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset; osrm::util::SimpleLogger().Write(logWARNING) << "offset: " << current_offset;
osrm::util::SimpleLogger().Write(logWARNING) << "read error " osrm::util::SimpleLogger().Write(logWARNING) << "read error " << strerror(errno);
<< strerror(errno);
throw osrm::util::exception("read error"); throw osrm::util::exception("read error");
} }
timing_results_raw_seq.push_back(TIMER_SEC(read_every_100)); timing_results_raw_seq.push_back(TIMER_SEC(read_every_100));

View File

@ -60,13 +60,11 @@ int main() try
osrm::util::SimpleLogger().Write() << "Releasing all locks"; osrm::util::SimpleLogger().Write() << "Releasing all locks";
osrm::util::SimpleLogger().Write() << "ATTENTION! BE CAREFUL!"; osrm::util::SimpleLogger().Write() << "ATTENTION! BE CAREFUL!";
osrm::util::SimpleLogger().Write() << "----------------------"; osrm::util::SimpleLogger().Write() << "----------------------";
osrm::util::SimpleLogger().Write() osrm::util::SimpleLogger().Write() << "This tool may put osrm-routed into an undefined state!";
<< "This tool may put osrm-routed into an undefined state!";
osrm::util::SimpleLogger().Write() osrm::util::SimpleLogger().Write()
<< "Type 'Y' to acknowledge that you know what your are doing."; << "Type 'Y' to acknowledge that you know what your are doing.";
osrm::util::SimpleLogger().Write() osrm::util::SimpleLogger().Write() << "\n\nDo you want to purge all shared memory allocated "
<< "\n\nDo you want to purge all shared memory allocated " << "by osrm-datastore? [type 'Y' to confirm]";
<< "by osrm-datastore? [type 'Y' to confirm]";
const auto letter = getchar(); const auto letter = getchar();
if (letter != 'Y') if (letter != 'Y')

View File

@ -6,49 +6,67 @@
#include "engine/datafacade/datafacade_base.hpp" #include "engine/datafacade/datafacade_base.hpp"
#include "contractor/query_edge.hpp" #include "contractor/query_edge.hpp"
namespace osrm { namespace osrm
namespace test {
template <class EdgeDataT> class MockDataFacadeT final : public osrm::engine::datafacade::BaseDataFacade<EdgeDataT>
{ {
private: namespace test
EdgeDataT foo; {
public:
template <class EdgeDataT>
class MockDataFacadeT final : public osrm::engine::datafacade::BaseDataFacade<EdgeDataT>
{
private:
EdgeDataT foo;
public:
unsigned GetNumberOfNodes() const { return 0; } unsigned GetNumberOfNodes() const { return 0; }
unsigned GetNumberOfEdges() const { return 0; } unsigned GetNumberOfEdges() const { return 0; }
unsigned GetOutDegree(const NodeID /* n */) const { return 0; } unsigned GetOutDegree(const NodeID /* n */) const { return 0; }
NodeID GetTarget(const EdgeID /* e */) const { return SPECIAL_NODEID; } NodeID GetTarget(const EdgeID /* e */) const { return SPECIAL_NODEID; }
const EdgeDataT &GetEdgeData(const EdgeID /* e */) const { const EdgeDataT &GetEdgeData(const EdgeID /* e */) const { return foo; }
return foo;
}
EdgeID BeginEdges(const NodeID /* n */) const { return SPECIAL_EDGEID; } EdgeID BeginEdges(const NodeID /* n */) const { return SPECIAL_EDGEID; }
EdgeID EndEdges(const NodeID /* n */) const { return SPECIAL_EDGEID; } EdgeID EndEdges(const NodeID /* n */) const { return SPECIAL_EDGEID; }
osrm::engine::datafacade::EdgeRange GetAdjacentEdgeRange(const NodeID /* node */) const { osrm::engine::datafacade::EdgeRange GetAdjacentEdgeRange(const NodeID /* node */) const
return util::irange(static_cast<EdgeID>(0),static_cast<EdgeID>(0)); {
return util::irange(static_cast<EdgeID>(0), static_cast<EdgeID>(0));
} }
EdgeID FindEdge(const NodeID /* from */, const NodeID /* to */) const { return SPECIAL_EDGEID; } EdgeID FindEdge(const NodeID /* from */, const NodeID /* to */) const { return SPECIAL_EDGEID; }
EdgeID FindEdgeInEitherDirection(const NodeID /* from */, const NodeID /* to */) const { return SPECIAL_EDGEID; } EdgeID FindEdgeInEitherDirection(const NodeID /* from */, const NodeID /* to */) const
EdgeID {
FindEdgeIndicateIfReverse(const NodeID /* from */, const NodeID /* to */, bool & /* result */) const { return SPECIAL_EDGEID; } return SPECIAL_EDGEID;
util::FixedPointCoordinate GetCoordinateOfNode(const unsigned /* id */) const { }
FixedPointCoordinate foo(0,0); EdgeID FindEdgeIndicateIfReverse(const NodeID /* from */,
const NodeID /* to */,
bool & /* result */) const
{
return SPECIAL_EDGEID;
}
util::FixedPointCoordinate GetCoordinateOfNode(const unsigned /* id */) const
{
FixedPointCoordinate foo(0, 0);
return foo; return foo;
} }
bool EdgeIsCompressed(const unsigned /* id */) const { return false; } bool EdgeIsCompressed(const unsigned /* id */) const { return false; }
unsigned GetGeometryIndexForEdgeID(const unsigned /* id */) const { return SPECIAL_NODEID; } unsigned GetGeometryIndexForEdgeID(const unsigned /* id */) const { return SPECIAL_NODEID; }
void GetUncompressedGeometry(const EdgeID /* id */, void GetUncompressedGeometry(const EdgeID /* id */,
std::vector<NodeID> &/* result_nodes */) const {} std::vector<NodeID> & /* result_nodes */) const
{
}
void GetUncompressedWeights(const EdgeID /* id */, void GetUncompressedWeights(const EdgeID /* id */,
std::vector<EdgeWeight> & /* result_weights */) const {} std::vector<EdgeWeight> & /* result_weights */) const
extractor::TurnInstruction GetTurnInstructionForEdgeID(const unsigned /* id */) const { {
}
extractor::TurnInstruction GetTurnInstructionForEdgeID(const unsigned /* id */) const
{
return osrm::extractor::TurnInstruction::NoTurn; return osrm::extractor::TurnInstruction::NoTurn;
} }
extractor::TravelMode GetTravelModeForEdgeID(const unsigned /* id */) const extractor::TravelMode GetTravelModeForEdgeID(const unsigned /* id */) const
{ {
return TRAVEL_MODE_DEFAULT; return TRAVEL_MODE_DEFAULT;
} }
std::vector<typename osrm::engine::datafacade::BaseDataFacade<EdgeDataT>::RTreeLeaf> GetEdgesInBox(const util::FixedPointCoordinate & /* south_west */, std::vector<typename osrm::engine::datafacade::BaseDataFacade<EdgeDataT>::RTreeLeaf>
const util::FixedPointCoordinate & /*north_east */) { GetEdgesInBox(const util::FixedPointCoordinate & /* south_west */,
const util::FixedPointCoordinate & /*north_east */)
{
std::vector<typename osrm::engine::datafacade::BaseDataFacade<EdgeDataT>::RTreeLeaf> foo; std::vector<typename osrm::engine::datafacade::BaseDataFacade<EdgeDataT>::RTreeLeaf> foo;
return foo; return foo;
} }
@ -56,7 +74,8 @@ template <class EdgeDataT> class MockDataFacadeT final : public osrm::engine::da
NearestPhantomNodesInRange(const util::FixedPointCoordinate /* input_coordinate */, NearestPhantomNodesInRange(const util::FixedPointCoordinate /* input_coordinate */,
const float /* max_distance */, const float /* max_distance */,
const int /* bearing = 0 */, const int /* bearing = 0 */,
const int /* bearing_range = 180 */) { const int /* bearing_range = 180 */)
{
std::vector<osrm::engine::PhantomNodeWithDistance> foo; std::vector<osrm::engine::PhantomNodeWithDistance> foo;
return foo; return foo;
} }
@ -64,14 +83,17 @@ template <class EdgeDataT> class MockDataFacadeT final : public osrm::engine::da
NearestPhantomNodes(const util::FixedPointCoordinate /* input_coordinate */, NearestPhantomNodes(const util::FixedPointCoordinate /* input_coordinate */,
const unsigned /* max_results */, const unsigned /* max_results */,
const int /* bearing = 0 */, const int /* bearing = 0 */,
const int /* bearing_range = 180 */) { const int /* bearing_range = 180 */)
{
std::vector<osrm::engine::PhantomNodeWithDistance> foo; std::vector<osrm::engine::PhantomNodeWithDistance> foo;
return foo; return foo;
} }
std::pair<osrm::engine::PhantomNode, osrm::engine::PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent( std::pair<osrm::engine::PhantomNode, osrm::engine::PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(
const util::FixedPointCoordinate /* input_coordinate */, const util::FixedPointCoordinate /* input_coordinate */,
const int /* bearing = 0 */, const int /* bearing = 0 */,
const int /* bearing_range = 180 */) { const int /* bearing_range = 180 */)
{
std::pair<osrm::engine::PhantomNode, osrm::engine::PhantomNode> foo; std::pair<osrm::engine::PhantomNode, osrm::engine::PhantomNode> foo;
return foo; return foo;
} }
@ -81,7 +103,6 @@ template <class EdgeDataT> class MockDataFacadeT final : public osrm::engine::da
std::string get_name_for_id(const unsigned /* name_id */) const { return ""; } std::string get_name_for_id(const unsigned /* name_id */) const { return ""; }
std::size_t GetCoreSize() const { return 0; } std::size_t GetCoreSize() const { return 0; }
std::string GetTimestamp() const { return ""; } std::string GetTimestamp() const { return ""; }
}; };
using MockDataFacade = MockDataFacadeT<contractor::QueryEdge::EdgeData>; using MockDataFacade = MockDataFacadeT<contractor::QueryEdge::EdgeData>;

View File

@ -80,28 +80,48 @@ template <typename ParameterT> std::size_t testInvalidOptions(std::string option
BOOST_AUTO_TEST_CASE(invalid_route_urls) BOOST_AUTO_TEST_CASE(invalid_route_urls)
{ {
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&bla=foo"), 22UL); BOOST_CHECK_EQUAL(
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&bearings=foo"), 32UL); testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&bla=foo"), 22UL);
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&uturns=foo"), 30UL); BOOST_CHECK_EQUAL(
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&radiuses=foo"), 32UL); testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&bearings=foo"),
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&hints=foo"), 22UL); 32UL);
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&geometries=foo"), 22UL); BOOST_CHECK_EQUAL(
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&overview=foo"), 22L); testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&uturns=foo"),
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&alternative=foo"), 22UL); 30UL);
BOOST_CHECK_EQUAL(
testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&radiuses=foo"),
32UL);
BOOST_CHECK_EQUAL(
testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&hints=foo"), 22UL);
BOOST_CHECK_EQUAL(
testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&geometries=foo"),
22UL);
BOOST_CHECK_EQUAL(
testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&overview=foo"),
22L);
BOOST_CHECK_EQUAL(
testInvalidOptions<engine::api::RouteParameters>("1,2;3,4?overview=false&alternative=foo"),
22UL);
} }
BOOST_AUTO_TEST_CASE(invalid_table_urls) BOOST_AUTO_TEST_CASE(invalid_table_urls)
{ {
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::TableParameters>("1,2;3,4?sources=1&bla=foo"), 17UL); BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::TableParameters>("1,2;3,4?sources=1&bla=foo"),
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::TableParameters>("1,2;3,4?destinations=1&bla=foo"), 22UL); 17UL);
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::TableParameters>("1,2;3,4?sources=1&destinations=1&bla=foo"), 32UL); BOOST_CHECK_EQUAL(
testInvalidOptions<engine::api::TableParameters>("1,2;3,4?destinations=1&bla=foo"), 22UL);
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::TableParameters>(
"1,2;3,4?sources=1&destinations=1&bla=foo"),
32UL);
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::TableParameters>("1,2;3,4?sources=foo"), 7UL); BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::TableParameters>("1,2;3,4?sources=foo"), 7UL);
BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::TableParameters>("1,2;3,4?destinations=foo"), 7UL); BOOST_CHECK_EQUAL(testInvalidOptions<engine::api::TableParameters>("1,2;3,4?destinations=foo"),
7UL);
} }
BOOST_AUTO_TEST_CASE(valid_route_urls) BOOST_AUTO_TEST_CASE(valid_route_urls)
{ {
std::vector<util::Coordinate> coords_1 = {{util::FloatLongitude(1), util::FloatLatitude(2)}, {util::FloatLongitude(3), util::FloatLatitude(4)}}; std::vector<util::Coordinate> coords_1 = {{util::FloatLongitude(1), util::FloatLatitude(2)},
{util::FloatLongitude(3), util::FloatLatitude(4)}};
engine::api::RouteParameters reference_1{}; engine::api::RouteParameters reference_1{};
reference_1.coordinates = coords_1; reference_1.coordinates = coords_1;
@ -136,7 +156,8 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
engine::api::RouteParameters::OverviewType::False, uturns_3}; engine::api::RouteParameters::OverviewType::False, uturns_3};
reference_3.coordinates = coords_1; reference_3.coordinates = coords_1;
auto result_3 = api::parseParameters<engine::api::RouteParameters>( auto result_3 = api::parseParameters<engine::api::RouteParameters>(
"1,2;3,4?steps=false&alternative=false&geometries=geojson&overview=false&uturns=true;false;"); "1,2;3,4?steps=false&alternative=false&geometries=geojson&overview=false&uturns=true;"
"false;");
BOOST_CHECK(result_3); BOOST_CHECK(result_3);
BOOST_CHECK_EQUAL(reference_3.steps, result_3->steps); BOOST_CHECK_EQUAL(reference_3.steps, result_3->steps);
BOOST_CHECK_EQUAL(reference_3.alternative, result_3->alternative); BOOST_CHECK_EQUAL(reference_3.alternative, result_3->alternative);
@ -165,7 +186,8 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
std::vector<boost::optional<double>>{}, std::vector<boost::optional<double>>{},
std::vector<boost::optional<engine::api::BaseParameters::Bearing>>{}}; std::vector<boost::optional<engine::api::BaseParameters::Bearing>>{}};
auto result_4 = api::parseParameters<engine::api::RouteParameters>( auto result_4 = api::parseParameters<engine::api::RouteParameters>(
"1,2;3,4?steps=false&hints=rVghAzxMzABMAwAA5h4CAKMIAAAQAAAAGAAAAAYAAAAAAAAAch8BAJ4AAACpWCED_" "1,2;3,4?steps=false&hints="
"rVghAzxMzABMAwAA5h4CAKMIAAAQAAAAGAAAAAYAAAAAAAAAch8BAJ4AAACpWCED_"
"0vMAAEAAQGLSzmR;_4ghA4JuzAD_" "0vMAAEAAQGLSzmR;_4ghA4JuzAD_"
"IAAAo28BAOYAAAAzAAAAAgAAAEwAAAAAAAAAdIwAAJ4AAAAXiSEDfm7MAAEAAQGLSzmR;03AhA0vnzAA_SAAA_____" "IAAAo28BAOYAAAAzAAAAAgAAAEwAAAAAAAAAdIwAAJ4AAAAXiSEDfm7MAAEAAQGLSzmR;03AhA0vnzAA_SAAA_____"
"3wEAAAYAAAAQAAAAB4AAABAAAAAoUYBAJ4AAADlcCEDSefMAAMAAQGLSzmR"); "3wEAAAYAAAAQAAAAB4AAABAAAAAoUYBAJ4AAADlcCEDSefMAAMAAQGLSzmR");
@ -180,20 +202,18 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
CHECK_EQUAL_RANGE(reference_4.coordinates, result_4->coordinates); CHECK_EQUAL_RANGE(reference_4.coordinates, result_4->coordinates);
std::vector<boost::optional<engine::api::BaseParameters::Bearing>> bearings_4 = { std::vector<boost::optional<engine::api::BaseParameters::Bearing>> bearings_4 = {
boost::none, boost::none, engine::api::BaseParameters::Bearing{200, 10},
engine::api::BaseParameters::Bearing {200, 10}, engine::api::BaseParameters::Bearing{100, 5},
engine::api::BaseParameters::Bearing {100, 5},
}; };
engine::api::RouteParameters reference_5{ engine::api::RouteParameters reference_5{false,
false, true,
true, engine::api::RouteParameters::GeometriesType::Polyline,
engine::api::RouteParameters::GeometriesType::Polyline, engine::api::RouteParameters::OverviewType::Simplified,
engine::api::RouteParameters::OverviewType::Simplified, std::vector<boost::optional<bool>>{},
std::vector<boost::optional<bool>>{}, coords_1,
coords_1, std::vector<boost::optional<engine::Hint>>{},
std::vector<boost::optional<engine::Hint>> {}, std::vector<boost::optional<double>>{},
std::vector<boost::optional<double>>{}, bearings_4};
bearings_4};
auto result_5 = api::parseParameters<engine::api::RouteParameters>( auto result_5 = api::parseParameters<engine::api::RouteParameters>(
"1,2;3,4?steps=false&bearings=;200,10;100,5"); "1,2;3,4?steps=false&bearings=;200,10;100,5");
BOOST_CHECK(result_5); BOOST_CHECK(result_5);
@ -206,26 +226,29 @@ BOOST_AUTO_TEST_CASE(valid_route_urls)
CHECK_EQUAL_RANGE(reference_5.radiuses, result_5->radiuses); CHECK_EQUAL_RANGE(reference_5.radiuses, result_5->radiuses);
CHECK_EQUAL_RANGE(reference_5.coordinates, result_5->coordinates); CHECK_EQUAL_RANGE(reference_5.coordinates, result_5->coordinates);
std::vector<util::Coordinate> coords_2 = {{util::FloatLongitude(0), util::FloatLatitude(1)}, {util::FloatLongitude(2), util::FloatLatitude(3)}, std::vector<util::Coordinate> coords_2 = {{util::FloatLongitude(0), util::FloatLatitude(1)},
{util::FloatLongitude(4), util::FloatLatitude(5)}}; {util::FloatLongitude(2), util::FloatLatitude(3)},
{util::FloatLongitude(4), util::FloatLatitude(5)}};
engine::api::RouteParameters reference_6{}; engine::api::RouteParameters reference_6{};
reference_6.coordinates = coords_2; reference_6.coordinates = coords_2;
auto result_6 = api::parseParameters<engine::api::RouteParameters>("polyline(_ibE?_seK_seK_seK_seK)"); auto result_6 =
api::parseParameters<engine::api::RouteParameters>("polyline(_ibE?_seK_seK_seK_seK)");
BOOST_CHECK(result_6); BOOST_CHECK(result_6);
BOOST_CHECK_EQUAL(reference_6.steps, result_6->steps); BOOST_CHECK_EQUAL(reference_6.steps, result_6->steps);
BOOST_CHECK_EQUAL(reference_6.alternative, result_6->alternative); BOOST_CHECK_EQUAL(reference_6.alternative, result_6->alternative);
BOOST_CHECK_EQUAL(reference_6.geometries, result_6->geometries); BOOST_CHECK_EQUAL(reference_6.geometries, result_6->geometries);
BOOST_CHECK_EQUAL(reference_6.overview, result_6->overview); BOOST_CHECK_EQUAL(reference_6.overview, result_6->overview);
CHECK_EQUAL_RANGE(reference_6.uturns, result_6->uturns); CHECK_EQUAL_RANGE(reference_6.uturns, result_6->uturns);
CHECK_EQUAL_RANGE(reference_6.bearings, result_6->bearings); CHECK_EQUAL_RANGE(reference_6.bearings, result_6->bearings);
CHECK_EQUAL_RANGE(reference_6.radiuses, result_6->radiuses); CHECK_EQUAL_RANGE(reference_6.radiuses, result_6->radiuses);
CHECK_EQUAL_RANGE(reference_6.coordinates, result_6->coordinates); CHECK_EQUAL_RANGE(reference_6.coordinates, result_6->coordinates);
} }
BOOST_AUTO_TEST_CASE(valid_table_urls) BOOST_AUTO_TEST_CASE(valid_table_urls)
{ {
std::vector<util::Coordinate> coords_1 = {{util::FloatLongitude(1), util::FloatLatitude(2)}, {util::FloatLongitude(3), util::FloatLatitude(4)}}; std::vector<util::Coordinate> coords_1 = {{util::FloatLongitude(1), util::FloatLatitude(2)},
{util::FloatLongitude(3), util::FloatLatitude(4)}};
engine::api::TableParameters reference_1{}; engine::api::TableParameters reference_1{};
reference_1.coordinates = coords_1; reference_1.coordinates = coords_1;
@ -241,18 +264,20 @@ BOOST_AUTO_TEST_CASE(valid_table_urls)
std::vector<std::size_t> destinations_2 = {4, 5}; std::vector<std::size_t> destinations_2 = {4, 5};
engine::api::TableParameters reference_2{sources_2, destinations_2}; engine::api::TableParameters reference_2{sources_2, destinations_2};
reference_2.coordinates = coords_1; reference_2.coordinates = coords_1;
auto result_2 = api::parseParameters<engine::api::TableParameters>("1,2;3,4?sources=1;2;3&destinations=4;5"); auto result_2 = api::parseParameters<engine::api::TableParameters>(
"1,2;3,4?sources=1;2;3&destinations=4;5");
BOOST_CHECK(result_2); BOOST_CHECK(result_2);
CHECK_EQUAL_RANGE(reference_2.sources, result_2->sources); CHECK_EQUAL_RANGE(reference_2.sources, result_2->sources);
CHECK_EQUAL_RANGE(reference_2.destinations, result_2->destinations); CHECK_EQUAL_RANGE(reference_2.destinations, result_2->destinations);
CHECK_EQUAL_RANGE(reference_2.bearings, result_2->bearings); CHECK_EQUAL_RANGE(reference_2.bearings, result_2->bearings);
CHECK_EQUAL_RANGE(reference_2.radiuses, result_2->radiuses); CHECK_EQUAL_RANGE(reference_2.radiuses, result_2->radiuses);
CHECK_EQUAL_RANGE(reference_2.coordinates, result_2->coordinates); CHECK_EQUAL_RANGE(reference_2.coordinates, result_2->coordinates);
} }
BOOST_AUTO_TEST_CASE(valid_match_urls) BOOST_AUTO_TEST_CASE(valid_match_urls)
{ {
std::vector<util::Coordinate> coords_1 = {{util::FloatLongitude(1), util::FloatLatitude(2)}, {util::FloatLongitude(3), util::FloatLatitude(4)}}; std::vector<util::Coordinate> coords_1 = {{util::FloatLongitude(1), util::FloatLatitude(2)},
{util::FloatLongitude(3), util::FloatLatitude(4)}};
engine::api::MatchParameters reference_1{}; engine::api::MatchParameters reference_1{};
reference_1.coordinates = coords_1; reference_1.coordinates = coords_1;
@ -290,7 +315,8 @@ BOOST_AUTO_TEST_CASE(valid_tile_urls)
BOOST_AUTO_TEST_CASE(valid_trip_urls) BOOST_AUTO_TEST_CASE(valid_trip_urls)
{ {
std::vector<util::Coordinate> coords_1 = {{util::FloatLongitude(1), util::FloatLatitude(2)}, {util::FloatLongitude(3), util::FloatLatitude(4)}}; std::vector<util::Coordinate> coords_1 = {{util::FloatLongitude(1), util::FloatLatitude(2)},
{util::FloatLongitude(3), util::FloatLatitude(4)}};
engine::api::TripParameters reference_1{}; engine::api::TripParameters reference_1{};
reference_1.coordinates = coords_1; reference_1.coordinates = coords_1;

View File

@ -36,8 +36,7 @@ BOOST_AUTO_TEST_CASE(io_data)
osrm::util::deserializeVector(IO_TMP_FILE, data_out); osrm::util::deserializeVector(IO_TMP_FILE, data_out);
BOOST_REQUIRE_EQUAL(data_in.size(), data_out.size()); BOOST_REQUIRE_EQUAL(data_in.size(), data_out.size());
BOOST_CHECK_EQUAL_COLLECTIONS(data_out.begin(), data_out.end(), data_in.begin(), BOOST_CHECK_EQUAL_COLLECTIONS(data_out.begin(), data_out.end(), data_in.begin(), data_in.end());
data_in.end());
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@ -96,8 +96,8 @@ BOOST_FIXTURE_TEST_CASE(array_test, TestRandomArrayEntryFixture)
BOOST_AUTO_TEST_CASE(target_test) BOOST_AUTO_TEST_CASE(target_test)
{ {
std::vector<TestInputEdge> input_edges = { std::vector<TestInputEdge> input_edges = {TestInputEdge{0, 1, TestData{1}},
TestInputEdge{0, 1, TestData{1}}, TestInputEdge{3, 0, TestData{2}}}; TestInputEdge{3, 0, TestData{2}}};
TestStaticGraph simple_graph = TestStaticGraph(4, input_edges); TestStaticGraph simple_graph = TestStaticGraph(4, input_edges);
auto target = simple_graph.GetTarget(simple_graph.FindEdge(3, 0)); auto target = simple_graph.GetTarget(simple_graph.FindEdge(3, 0));

View File

@ -25,7 +25,6 @@
#include <unordered_set> #include <unordered_set>
#include <vector> #include <vector>
BOOST_AUTO_TEST_SUITE(static_rtree) BOOST_AUTO_TEST_SUITE(static_rtree)
using namespace osrm; using namespace osrm;
@ -306,8 +305,11 @@ BOOST_AUTO_TEST_CASE(regression_test)
{ {
Coord{FloatLongitude{0.0}, FloatLatitude{40.0}}, // Coord{FloatLongitude{0.0}, FloatLatitude{40.0}}, //
Coord{FloatLongitude{5.0}, FloatLatitude{35.0}}, // Coord{FloatLongitude{5.0}, FloatLatitude{35.0}}, //
Coord{FloatLongitude{5.0}, FloatLatitude{5.0,}}, // Coord{FloatLongitude{5.0},
Coord{FloatLongitude{10.0}, FloatLatitude{0.0}}, // FloatLatitude{
5.0,
}}, //
Coord{FloatLongitude{10.0}, FloatLatitude{0.0}}, //
Coord{FloatLongitude{10.0}, FloatLatitude{20.0}}, // Coord{FloatLongitude{10.0}, FloatLatitude{20.0}}, //
Coord{FloatLongitude{5.0}, FloatLatitude{20.0}}, // Coord{FloatLongitude{5.0}, FloatLatitude{20.0}}, //
Coord{FloatLongitude{100.0}, FloatLatitude{40.0}}, // Coord{FloatLongitude{100.0}, FloatLatitude{40.0}}, //
@ -407,7 +409,8 @@ BOOST_AUTO_TEST_CASE(bearing_tests)
build_rtree<GraphFixture, MiniStaticRTree>("test_bearing", &fixture, leaves_path, nodes_path); build_rtree<GraphFixture, MiniStaticRTree>("test_bearing", &fixture, leaves_path, nodes_path);
MiniStaticRTree rtree(nodes_path, leaves_path, fixture.coords); MiniStaticRTree rtree(nodes_path, leaves_path, fixture.coords);
std::unique_ptr<MockDataFacade> mockfacade_ptr(new MockDataFacade); std::unique_ptr<MockDataFacade> mockfacade_ptr(new MockDataFacade);
engine::GeospatialQuery<MiniStaticRTree, MockDataFacade> query(rtree, fixture.coords, *mockfacade_ptr); engine::GeospatialQuery<MiniStaticRTree, MockDataFacade> query(rtree, fixture.coords,
*mockfacade_ptr);
Coordinate input(FloatLongitude(5.1), FloatLatitude(5.0)); Coordinate input(FloatLongitude(5.1), FloatLatitude(5.0));
@ -472,7 +475,8 @@ BOOST_AUTO_TEST_CASE(bbox_search_tests)
build_rtree<GraphFixture, MiniStaticRTree>("test_bbox", &fixture, leaves_path, nodes_path); build_rtree<GraphFixture, MiniStaticRTree>("test_bbox", &fixture, leaves_path, nodes_path);
MiniStaticRTree rtree(nodes_path, leaves_path, fixture.coords); MiniStaticRTree rtree(nodes_path, leaves_path, fixture.coords);
std::unique_ptr<MockDataFacade> mockfacade_ptr(new MockDataFacade); std::unique_ptr<MockDataFacade> mockfacade_ptr(new MockDataFacade);
engine::GeospatialQuery<MiniStaticRTree, MockDataFacade> query(rtree, fixture.coords, *mockfacade_ptr); engine::GeospatialQuery<MiniStaticRTree, MockDataFacade> query(rtree, fixture.coords,
*mockfacade_ptr);
{ {
RectangleInt2D bbox = {FloatLongitude(0.5), FloatLongitude(1.5), FloatLatitude(0.5), RectangleInt2D bbox = {FloatLongitude(0.5), FloatLongitude(1.5), FloatLatitude(0.5),