Format with clang-format 3.8

This commit is contained in:
Patrick Niklaus 2016-05-27 21:05:04 +02:00
parent 21c47514da
commit 6e16eab6ec
No known key found for this signature in database
GPG Key ID: E426891B5F978B1B
202 changed files with 2485 additions and 1863 deletions

View File

@ -1,20 +1,20 @@
#include "osrm/match_parameters.hpp"
#include "osrm/nearest_parameters.hpp"
#include "osrm/route_parameters.hpp"
#include "osrm/table_parameters.hpp"
#include "osrm/nearest_parameters.hpp"
#include "osrm/trip_parameters.hpp"
#include "osrm/match_parameters.hpp"
#include "osrm/coordinate.hpp"
#include "osrm/engine_config.hpp"
#include "osrm/json_container.hpp"
#include "osrm/status.hpp"
#include "osrm/osrm.hpp"
#include "osrm/status.hpp"
#include <exception>
#include <iostream>
#include <string>
#include <utility>
#include <iostream>
#include <exception>
#include <cstdlib>

View File

@ -32,11 +32,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "contractor/query_edge.hpp"
#include "extractor/edge_based_edge.hpp"
#include "extractor/edge_based_node.hpp"
#include "util/typedefs.hpp"
#include "util/deallocating_vector.hpp"
#include "util/typedefs.hpp"
#include <vector>
#include <string>
#include <vector>
#include <cstddef>

View File

@ -1,17 +1,17 @@
#ifndef GRAPH_CONTRACTOR_HPP
#define GRAPH_CONTRACTOR_HPP
#include "contractor/query_edge.hpp"
#include "util/binary_heap.hpp"
#include "util/deallocating_vector.hpp"
#include "util/dynamic_graph.hpp"
#include "util/percent.hpp"
#include "contractor/query_edge.hpp"
#include "util/xor_fast_hash.hpp"
#include "util/xor_fast_hash_storage.hpp"
#include "util/integer_range.hpp"
#include "util/percent.hpp"
#include "util/simple_logger.hpp"
#include "util/timing_util.hpp"
#include "util/typedefs.hpp"
#include "util/xor_fast_hash.hpp"
#include "util/xor_fast_hash_storage.hpp"
#include <boost/assert.hpp>
@ -165,14 +165,22 @@ class GraphContractor
<< static_cast<unsigned int>(diter->target);
}
#endif
edges.emplace_back(diter->source, diter->target,
static_cast<unsigned int>(std::max(diter->weight, 1)), 1,
diter->edge_id, false, diter->forward ? true : false,
edges.emplace_back(diter->source,
diter->target,
static_cast<unsigned int>(std::max(diter->weight, 1)),
1,
diter->edge_id,
false,
diter->forward ? true : false,
diter->backward ? true : false);
edges.emplace_back(diter->target, diter->source,
static_cast<unsigned int>(std::max(diter->weight, 1)), 1,
diter->edge_id, false, diter->backward ? true : false,
edges.emplace_back(diter->target,
diter->source,
static_cast<unsigned int>(std::max(diter->weight, 1)),
1,
diter->edge_id,
false,
diter->backward ? true : false,
diter->forward ? true : false);
}
// clear input vector
@ -276,8 +284,7 @@ class GraphContractor
std::vector<RemainingNodeData> remaining_nodes(number_of_nodes);
// initialize priorities in parallel
tbb::parallel_for(tbb::blocked_range<int>(0, number_of_nodes, InitGrainSize),
[this, &remaining_nodes](const tbb::blocked_range<int> &range)
{
[this, &remaining_nodes](const tbb::blocked_range<int> &range) {
for (int x = range.begin(), end = range.end(); x != end; ++x)
{
remaining_nodes[x].id = x;
@ -299,9 +306,8 @@ class GraphContractor
std::cout << "initializing elimination PQ ..." << std::flush;
tbb::parallel_for(tbb::blocked_range<int>(0, number_of_nodes, PQGrainSize),
[this, &node_priorities, &node_depth,
&thread_data_list](const tbb::blocked_range<int> &range)
{
[this, &node_priorities, &node_depth, &thread_data_list](
const tbb::blocked_range<int> &range) {
ContractorThreadData *data = thread_data_list.GetThreadData();
for (int x = range.begin(), end = range.end(); x != end; ++x)
{
@ -342,7 +348,8 @@ class GraphContractor
// remaining graph
std::vector<NodeID> new_node_id_from_orig_id_map(number_of_nodes, SPECIAL_NODEID);
for (const auto new_node_id : util::irange<std::size_t>(0UL, remaining_nodes.size()))
for (const auto new_node_id :
util::irange<std::size_t>(0UL, remaining_nodes.size()))
{
auto &node = remaining_nodes[new_node_id];
BOOST_ASSERT(node_priorities.size() > node.id);
@ -352,7 +359,8 @@ class GraphContractor
}
// build forward and backward renumbering map and remap ids in remaining_nodes
for (const auto new_node_id : util::irange<std::size_t>(0UL, remaining_nodes.size()))
for (const auto new_node_id :
util::irange<std::size_t>(0UL, remaining_nodes.size()))
{
auto &node = remaining_nodes[new_node_id];
// create renumbering maps in both directions
@ -378,7 +386,8 @@ class GraphContractor
// node is not yet contracted.
// add (renumbered) outgoing edges to new util::DynamicGraph.
ContractorEdge new_edge = {new_node_id_from_orig_id_map[source],
new_node_id_from_orig_id_map[target], data};
new_node_id_from_orig_id_map[target],
data};
new_edge.data.is_original_via_node_ID = true;
BOOST_ASSERT_MSG(SPECIAL_NODEID != new_node_id_from_orig_id_map[source],
@ -421,9 +430,8 @@ class GraphContractor
tbb::parallel_for(
tbb::blocked_range<std::size_t>(0, remaining_nodes.size(), IndependentGrainSize),
[this, &node_priorities, &remaining_nodes,
&thread_data_list](const tbb::blocked_range<std::size_t> &range)
{
[this, &node_priorities, &remaining_nodes, &thread_data_list](
const tbb::blocked_range<std::size_t> &range) {
ContractorThreadData *data = thread_data_list.GetThreadData();
// determine independent node set
for (auto i = range.begin(), end = range.end(); i != end; ++i)
@ -436,8 +444,7 @@ class GraphContractor
// sort all remaining nodes to the beginning of the sequence
const auto begin_independent_nodes = stable_partition(
remaining_nodes.begin(), remaining_nodes.end(), [](RemainingNodeData node_data)
{
remaining_nodes.begin(), remaining_nodes.end(), [](RemainingNodeData node_data) {
return !node_data.is_independent;
});
auto begin_independent_nodes_idx =
@ -448,11 +455,10 @@ class GraphContractor
{
// write out contraction level
tbb::parallel_for(
tbb::blocked_range<std::size_t>(begin_independent_nodes_idx,
end_independent_nodes_idx, ContractGrainSize),
[this, remaining_nodes, flushed_contractor,
current_level](const tbb::blocked_range<std::size_t> &range)
{
tbb::blocked_range<std::size_t>(
begin_independent_nodes_idx, end_independent_nodes_idx, ContractGrainSize),
[this, remaining_nodes, flushed_contractor, current_level](
const tbb::blocked_range<std::size_t> &range) {
if (flushed_contractor)
{
for (int position = range.begin(), end = range.end(); position != end;
@ -475,26 +481,24 @@ class GraphContractor
}
// contract independent nodes
tbb::parallel_for(tbb::blocked_range<std::size_t>(begin_independent_nodes_idx,
end_independent_nodes_idx,
ContractGrainSize),
[this, &remaining_nodes,
&thread_data_list](const tbb::blocked_range<std::size_t> &range)
{
ContractorThreadData *data = thread_data_list.GetThreadData();
for (int position = range.begin(), end = range.end();
position != end; ++position)
{
const NodeID x = remaining_nodes[position].id;
this->ContractNode<false>(data, x);
}
});
tbb::parallel_for(
tbb::blocked_range<std::size_t>(
begin_independent_nodes_idx, end_independent_nodes_idx, ContractGrainSize),
[this, &remaining_nodes, &thread_data_list](
const tbb::blocked_range<std::size_t> &range) {
ContractorThreadData *data = thread_data_list.GetThreadData();
for (int position = range.begin(), end = range.end(); position != end;
++position)
{
const NodeID x = remaining_nodes[position].id;
this->ContractNode<false>(data, x);
}
});
tbb::parallel_for(
tbb::blocked_range<int>(begin_independent_nodes_idx, end_independent_nodes_idx,
DeleteGrainSize),
[this, &remaining_nodes, &thread_data_list](const tbb::blocked_range<int> &range)
{
tbb::blocked_range<int>(
begin_independent_nodes_idx, end_independent_nodes_idx, DeleteGrainSize),
[this, &remaining_nodes, &thread_data_list](const tbb::blocked_range<int> &range) {
ContractorThreadData *data = thread_data_list.GetThreadData();
for (int position = range.begin(), end = range.end(); position != end;
++position)
@ -507,8 +511,7 @@ class GraphContractor
// make sure we really sort each block
tbb::parallel_for(
thread_data_list.data.range(),
[&](const ThreadDataContainer::EnumerableThreadData::range_type &range)
{
[&](const ThreadDataContainer::EnumerableThreadData::range_type &range) {
for (auto &data : range)
tbb::parallel_sort(data->inserted_edges.begin(),
data->inserted_edges.end());
@ -542,11 +545,11 @@ class GraphContractor
if (!use_cached_node_priorities)
{
tbb::parallel_for(
tbb::blocked_range<int>(begin_independent_nodes_idx, end_independent_nodes_idx,
tbb::blocked_range<int>(begin_independent_nodes_idx,
end_independent_nodes_idx,
NeighboursGrainSize),
[this, &node_priorities, &remaining_nodes, &node_depth,
&thread_data_list](const tbb::blocked_range<int> &range)
{
[this, &node_priorities, &remaining_nodes, &node_depth, &thread_data_list](
const tbb::blocked_range<int> &range) {
ContractorThreadData *data = thread_data_list.GetThreadData();
for (int position = range.begin(), end = range.end(); position != end;
++position)
@ -570,8 +573,7 @@ class GraphContractor
if (orig_node_id_from_new_node_id_map.size() > 0)
{
tbb::parallel_for(tbb::blocked_range<int>(0, remaining_nodes.size(), InitGrainSize),
[this, &remaining_nodes](const tbb::blocked_range<int> &range)
{
[this, &remaining_nodes](const tbb::blocked_range<int> &range) {
for (int x = range.begin(), end = range.end(); x != end; ++x)
{
const auto orig_id = remaining_nodes[x].id;
@ -583,8 +585,7 @@ class GraphContractor
else
{
tbb::parallel_for(tbb::blocked_range<int>(0, remaining_nodes.size(), InitGrainSize),
[this, &remaining_nodes](const tbb::blocked_range<int> &range)
{
[this, &remaining_nodes](const tbb::blocked_range<int> &range) {
for (int x = range.begin(), end = range.end(); x != end; ++x)
{
const auto orig_id = remaining_nodes[x].id;
@ -843,15 +844,25 @@ class GraphContractor
// guarantees that source is not connected to another node that is
// contracted
node_weights[source] = path_distance; // make sure to prune better
inserted_edges.emplace_back(
source, target, path_distance,
out_data.originalEdges + in_data.originalEdges, node, SHORTCUT_ARC,
FORWARD_DIRECTION_ENABLED, REVERSE_DIRECTION_DISABLED);
inserted_edges.emplace_back(source,
target,
path_distance,
out_data.originalEdges +
in_data.originalEdges,
node,
SHORTCUT_ARC,
FORWARD_DIRECTION_ENABLED,
REVERSE_DIRECTION_DISABLED);
inserted_edges.emplace_back(
target, source, path_distance,
out_data.originalEdges + in_data.originalEdges, node, SHORTCUT_ARC,
FORWARD_DIRECTION_DISABLED, REVERSE_DIRECTION_ENABLED);
inserted_edges.emplace_back(target,
source,
path_distance,
out_data.originalEdges +
in_data.originalEdges,
node,
SHORTCUT_ARC,
FORWARD_DIRECTION_DISABLED,
REVERSE_DIRECTION_ENABLED);
}
}
continue;
@ -867,8 +878,8 @@ class GraphContractor
if (RUNSIMULATION)
{
const int constexpr SIMULATION_SEARCH_SPACE_SIZE = 1000;
Dijkstra(max_distance, number_of_targets, SIMULATION_SEARCH_SPACE_SIZE, *data,
node);
Dijkstra(
max_distance, number_of_targets, SIMULATION_SEARCH_SPACE_SIZE, *data, node);
}
else
{
@ -898,14 +909,22 @@ class GraphContractor
}
else
{
inserted_edges.emplace_back(source, target, path_distance,
inserted_edges.emplace_back(source,
target,
path_distance,
out_data.originalEdges + in_data.originalEdges,
node, SHORTCUT_ARC, FORWARD_DIRECTION_ENABLED,
node,
SHORTCUT_ARC,
FORWARD_DIRECTION_ENABLED,
REVERSE_DIRECTION_DISABLED);
inserted_edges.emplace_back(target, source, path_distance,
inserted_edges.emplace_back(target,
source,
path_distance,
out_data.originalEdges + in_data.originalEdges,
node, SHORTCUT_ARC, FORWARD_DIRECTION_DISABLED,
node,
SHORTCUT_ARC,
FORWARD_DIRECTION_DISABLED,
REVERSE_DIRECTION_ENABLED);
}
}

View File

@ -37,11 +37,10 @@ class BaseAPI
waypoints.values[0] = MakeWaypoint(segment_end_coordinates.front().source_phantom);
auto out_iter = std::next(waypoints.values.begin());
boost::range::transform(segment_end_coordinates, out_iter,
[this](const PhantomNodes &phantom_pair)
{
return MakeWaypoint(phantom_pair.target_phantom);
});
boost::range::transform(
segment_end_coordinates, out_iter, [this](const PhantomNodes &phantom_pair) {
return MakeWaypoint(phantom_pair.target_phantom);
});
return waypoints;
}
@ -49,7 +48,8 @@ class BaseAPI
// protected:
util::json::Object MakeWaypoint(const PhantomNode &phantom) const
{
return json::makeWaypoint(phantom.location, facade.GetNameForID(phantom.name_id),
return json::makeWaypoint(phantom.location,
facade.GetNameForID(phantom.name_id),
Hint{phantom, facade.GetCheckSum()});
}

View File

@ -28,14 +28,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef ENGINE_API_BASE_PARAMETERS_HPP
#define ENGINE_API_BASE_PARAMETERS_HPP
#include "engine/hint.hpp"
#include "engine/bearing.hpp"
#include "engine/hint.hpp"
#include "util/coordinate.hpp"
#include <boost/optional.hpp>
#include <vector>
#include <algorithm>
#include <vector>
namespace osrm
{
@ -72,9 +72,9 @@ struct BaseParameters
return (hints.empty() || hints.size() == coordinates.size()) &&
(bearings.empty() || bearings.size() == coordinates.size()) &&
(radiuses.empty() || radiuses.size() == coordinates.size()) &&
std::all_of(bearings.begin(), bearings.end(),
[](const boost::optional<Bearing> bearing_and_range)
{
std::all_of(bearings.begin(),
bearings.end(),
[](const boost::optional<Bearing> bearing_and_range) {
if (bearing_and_range)
{
return bearing_and_range->IsValid();

View File

@ -3,12 +3,12 @@
#include "extractor/guidance/turn_instruction.hpp"
#include "extractor/travel_mode.hpp"
#include "engine/polyline_compressor.hpp"
#include "engine/guidance/leg_geometry.hpp"
#include "engine/guidance/route.hpp"
#include "engine/guidance/route_leg.hpp"
#include "engine/guidance/route_step.hpp"
#include "engine/guidance/step_maneuver.hpp"
#include "engine/guidance/route_leg.hpp"
#include "engine/guidance/route.hpp"
#include "engine/guidance/leg_geometry.hpp"
#include "engine/polyline_compressor.hpp"
#include "util/coordinate.hpp"
#include "util/json_container.hpp"
@ -57,7 +57,8 @@ util::json::Object makeGeoJSONGeometry(ForwardIter begin, ForwardIter end)
{
geojson.values["type"] = "LineString";
util::json::Array coordinates;
std::transform(begin, end, std::back_inserter(coordinates.values), &detail::coordinateToLonLat);
std::transform(
begin, end, std::back_inserter(coordinates.values), &detail::coordinateToLonLat);
geojson.values["coordinates"] = std::move(coordinates);
}
else if (num_coordinates > 0)

View File

@ -1,8 +1,8 @@
#ifndef ENGINE_API_MATCH_HPP
#define ENGINE_API_MATCH_HPP
#include "engine/api/route_api.hpp"
#include "engine/api/match_parameters.hpp"
#include "engine/api/route_api.hpp"
#include "engine/datafacade/datafacade_base.hpp"

View File

@ -34,10 +34,10 @@ class NearestAPI final : public BaseAPI
util::json::Array waypoints;
waypoints.values.resize(phantom_nodes.front().size());
std::transform(phantom_nodes.front().begin(), phantom_nodes.front().end(),
std::transform(phantom_nodes.front().begin(),
phantom_nodes.front().end(),
waypoints.values.begin(),
[this](const PhantomNodeWithDistance &phantom_with_distance)
{
[this](const PhantomNodeWithDistance &phantom_with_distance) {
auto waypoint = MakeWaypoint(phantom_with_distance.phantom_node);
waypoint.values["distance"] = phantom_with_distance.distance;
return waypoint;

View File

@ -42,14 +42,16 @@ class RouteAPI : public BaseAPI
auto number_of_routes = raw_route.has_alternative() ? 2UL : 1UL;
util::json::Array routes;
routes.values.resize(number_of_routes);
routes.values[0] =
MakeRoute(raw_route.segment_end_coordinates, raw_route.unpacked_path_segments,
raw_route.source_traversed_in_reverse, raw_route.target_traversed_in_reverse);
routes.values[0] = MakeRoute(raw_route.segment_end_coordinates,
raw_route.unpacked_path_segments,
raw_route.source_traversed_in_reverse,
raw_route.target_traversed_in_reverse);
if (raw_route.has_alternative())
{
std::vector<std::vector<PathData>> wrapped_leg(1);
wrapped_leg.front() = std::move(raw_route.unpacked_alternative);
routes.values[1] = MakeRoute(raw_route.segment_end_coordinates, wrapped_leg,
routes.values[1] = MakeRoute(raw_route.segment_end_coordinates,
wrapped_leg,
raw_route.alt_source_traversed_in_reverse,
raw_route.alt_target_traversed_in_reverse);
}
@ -93,14 +95,23 @@ class RouteAPI : public BaseAPI
auto leg_geometry = guidance::assembleGeometry(
BaseAPI::facade, path_data, phantoms.source_phantom, phantoms.target_phantom);
auto leg = guidance::assembleLeg(facade, path_data, leg_geometry, phantoms.source_phantom,
phantoms.target_phantom, reversed_target, parameters.steps);
auto leg = guidance::assembleLeg(facade,
path_data,
leg_geometry,
phantoms.source_phantom,
phantoms.target_phantom,
reversed_target,
parameters.steps);
if (parameters.steps)
{
auto steps = guidance::assembleSteps(
BaseAPI::facade, path_data, leg_geometry, phantoms.source_phantom,
phantoms.target_phantom, reversed_source, reversed_target);
auto steps = guidance::assembleSteps(BaseAPI::facade,
path_data,
leg_geometry,
phantoms.source_phantom,
phantoms.target_phantom,
reversed_source,
reversed_target);
/* Perform step-based post-processing.
*
@ -133,7 +144,8 @@ class RouteAPI : public BaseAPI
guidance::trimShortSegments(steps, leg_geometry);
leg.steps = guidance::postProcess(std::move(steps));
leg.steps = guidance::collapseTurns(std::move(leg.steps));
leg.steps = guidance::assignRelativeLocations(std::move(leg.steps), leg_geometry,
leg.steps = guidance::assignRelativeLocations(std::move(leg.steps),
leg_geometry,
phantoms.source_phantom,
phantoms.target_phantom);
leg_geometry = guidance::resyncGeometry(std::move(leg_geometry), leg.steps);
@ -161,7 +173,9 @@ class RouteAPI : public BaseAPI
{
auto &leg_geometry = leg_geometries[idx];
std::transform(
legs[idx].steps.begin(), legs[idx].steps.end(), std::back_inserter(step_geometries),
legs[idx].steps.begin(),
legs[idx].steps.end(),
std::back_inserter(step_geometries),
[this, &leg_geometry](const guidance::RouteStep &step) {
if (parameters.geometries == RouteParameters::GeometriesType::Polyline)
{
@ -185,23 +199,25 @@ class RouteAPI : public BaseAPI
util::json::Array durations;
util::json::Array distances;
auto &leg_geometry = leg_geometries[idx];
std::for_each(leg_geometry.annotations.begin(),
leg_geometry.annotations.end(),
[this, &durations, &distances](const guidance::LegGeometry::Annotation &step) {
durations.values.push_back(step.duration);
distances.values.push_back(step.distance);
});
std::for_each(
leg_geometry.annotations.begin(),
leg_geometry.annotations.end(),
[this, &durations, &distances](const guidance::LegGeometry::Annotation &step) {
durations.values.push_back(step.duration);
distances.values.push_back(step.distance);
});
util::json::Object annotation;
annotation.values["distance"] = std::move(distances);
annotation.values["duration"] = std::move(durations);
annotations.push_back(std::move(annotation));
}
}
auto result = json::makeRoute(route,
json::makeRouteLegs(std::move(legs), std::move(step_geometries), std::move(annotations)),
std::move(json_overview));
json::makeRouteLegs(std::move(legs),
std::move(step_geometries),
std::move(annotations)),
std::move(json_overview));
return result;
}

View File

@ -2,15 +2,15 @@
#define ENGINE_API_TABLE_HPP
#include "engine/api/base_api.hpp"
#include "engine/api/table_parameters.hpp"
#include "engine/api/json_factory.hpp"
#include "engine/api/table_parameters.hpp"
#include "engine/datafacade/datafacade_base.hpp"
#include "engine/guidance/assemble_leg.hpp"
#include "engine/guidance/assemble_route.hpp"
#include "engine/guidance/assemble_geometry.hpp"
#include "engine/guidance/assemble_leg.hpp"
#include "engine/guidance/assemble_overview.hpp"
#include "engine/guidance/assemble_route.hpp"
#include "engine/guidance/assemble_steps.hpp"
#include "engine/internal_route_result.hpp"
@ -78,11 +78,10 @@ class TableAPI final : public BaseAPI
json_waypoints.values.reserve(phantoms.size());
BOOST_ASSERT(phantoms.size() == parameters.coordinates.size());
boost::range::transform(phantoms, std::back_inserter(json_waypoints.values),
[this](const PhantomNode &phantom)
{
return BaseAPI::MakeWaypoint(phantom);
});
boost::range::transform(
phantoms,
std::back_inserter(json_waypoints.values),
[this](const PhantomNode &phantom) { return BaseAPI::MakeWaypoint(phantom); });
return json_waypoints;
}
@ -91,9 +90,9 @@ class TableAPI final : public BaseAPI
{
util::json::Array json_waypoints;
json_waypoints.values.reserve(indices.size());
boost::range::transform(indices, std::back_inserter(json_waypoints.values),
[this, phantoms](const std::size_t idx)
{
boost::range::transform(indices,
std::back_inserter(json_waypoints.values),
[this, phantoms](const std::size_t idx) {
BOOST_ASSERT(idx < phantoms.size());
return BaseAPI::MakeWaypoint(phantoms[idx]);
});
@ -111,9 +110,10 @@ class TableAPI final : public BaseAPI
auto row_begin_iterator = values.begin() + (row * number_of_columns);
auto row_end_iterator = values.begin() + ((row + 1) * 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)
{
return util::json::Value(util::json::Null());

View File

@ -89,10 +89,7 @@ struct TableParameters : public BaseParameters
return false;
// 3/ 0 <= index < len(locations)
const auto not_in_range = [this](const std::size_t x)
{
return x >= coordinates.size();
};
const auto not_in_range = [this](const std::size_t x) { return x >= coordinates.size(); };
if (std::any_of(begin(sources), end(sources), not_in_range))
return false;

View File

@ -79,8 +79,7 @@ class TripAPI final : public RouteAPI
std::vector<TripIndex> input_idx_to_trip_idx(parameters.coordinates.size());
for (auto sub_trip_index : util::irange<unsigned>(0u, sub_trips.size()))
{
for (auto point_index :
util::irange<unsigned>(0u, sub_trips[sub_trip_index].size()))
for (auto point_index : util::irange<unsigned>(0u, sub_trips[sub_trip_index].size()))
{
input_idx_to_trip_idx[sub_trips[sub_trip_index][point_index]] =
TripIndex{sub_trip_index, point_index};

View File

@ -1,18 +1,18 @@
#ifndef OSRM_BASE64_HPP
#define OSRM_BASE64_HPP
#include <string>
#include <vector>
#include <iterator>
#include <string>
#include <type_traits>
#include <vector>
#include <cstddef>
#include <climits>
#include <cstddef>
#include <boost/archive/iterators/binary_from_base64.hpp>
#include <boost/archive/iterators/base64_from_binary.hpp>
#include <boost/archive/iterators/transform_width.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/archive/iterators/base64_from_binary.hpp>
#include <boost/archive/iterators/binary_from_base64.hpp>
#include <boost/archive/iterators/transform_width.hpp>
#include <boost/range/algorithm/copy.hpp>
namespace osrm

View File

@ -4,10 +4,10 @@
// Exposes all data access interfaces to the algorithms via base class ptr
#include "contractor/query_edge.hpp"
#include "engine/phantom_node.hpp"
#include "extractor/edge_based_node.hpp"
#include "extractor/external_memory_node.hpp"
#include "extractor/guidance/turn_instruction.hpp"
#include "engine/phantom_node.hpp"
#include "util/exception.hpp"
#include "util/guidance/bearing_class.hpp"
#include "util/guidance/entry_class.hpp"
@ -115,14 +115,15 @@ class BaseDataFacade
const int bearing,
const int bearing_range) const = 0;
virtual std::vector<PhantomNodeWithDistance>
NearestPhantomNodes(const util::Coordinate input_coordinate, const unsigned max_results) const = 0;
NearestPhantomNodes(const util::Coordinate input_coordinate,
const unsigned max_results) const = 0;
virtual std::vector<PhantomNodeWithDistance>
NearestPhantomNodes(const util::Coordinate input_coordinate,
const unsigned max_results,
const double max_distance) const = 0;
virtual std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate) const = 0;
virtual std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
const util::Coordinate input_coordinate) const = 0;
virtual std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const double max_distance) const = 0;
@ -131,8 +132,10 @@ class BaseDataFacade
const double max_distance,
const int bearing,
const int bearing_range) const = 0;
virtual std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
const util::Coordinate input_coordinate, const int bearing, const int bearing_range) const = 0;
virtual std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const int bearing,
const int bearing_range) const = 0;
virtual unsigned GetCheckSum() const = 0;

View File

@ -9,12 +9,12 @@
#include "util/guidance/bearing_class.hpp"
#include "util/guidance/entry_class.hpp"
#include "engine/geospatial_query.hpp"
#include "extractor/compressed_edge_container.hpp"
#include "extractor/original_edge_data.hpp"
#include "extractor/profile_properties.hpp"
#include "extractor/query_node.hpp"
#include "storage/storage_config.hpp"
#include "engine/geospatial_query.hpp"
#include "util/graph_loader.hpp"
#include "util/io.hpp"
#include "util/range_table.hpp"
@ -312,11 +312,12 @@ class InternalDataFacade final : public BaseDataFacade
util::SimpleLogger().Write(logINFO) << "Loading Bearing Class IDs";
std::vector<BearingClassID> bearing_class_id;
if (!util::deserializeVector(intersection_stream, bearing_class_id))
throw util::exception("Reading from " + intersection_class_file.string() + " failed.");
throw util::exception("Reading from " + intersection_class_file.string() +
" failed.");
m_bearing_class_id_table.resize(bearing_class_id.size());
std::copy(bearing_class_id.begin(), bearing_class_id.end(),
&m_bearing_class_id_table[0]);
std::copy(
bearing_class_id.begin(), bearing_class_id.end(), &m_bearing_class_id_table[0]);
}
{
util::SimpleLogger().Write(logINFO) << "Loading Bearing Classes";
@ -330,13 +331,15 @@ class InternalDataFacade final : public BaseDataFacade
intersection_stream.read(reinterpret_cast<char *>(&m_bearing_values_table[0]),
sizeof(m_bearing_values_table[0]) * num_bearings);
if (!static_cast<bool>(intersection_stream))
throw util::exception("Reading from " + intersection_class_file.string() + " failed.");
throw util::exception("Reading from " + intersection_class_file.string() +
" failed.");
}
{
util::SimpleLogger().Write(logINFO) << "Loading Entry Classes";
std::vector<util::guidance::EntryClass> entry_classes;
if (!util::deserializeVector(intersection_stream, entry_classes))
throw util::exception("Reading from " + intersection_class_file.string() + " failed.");
throw util::exception("Reading from " + intersection_class_file.string() +
" failed.");
m_entry_class_table.resize(entry_classes.size());
std::copy(entry_classes.begin(), entry_classes.end(), &m_entry_class_table[0]);
@ -450,8 +453,8 @@ class InternalDataFacade final : public BaseDataFacade
const util::Coordinate north_east) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
const util::RectangleInt2D bbox{south_west.lon, north_east.lon, south_west.lat,
north_east.lat};
const util::RectangleInt2D bbox{
south_west.lon, north_east.lon, south_west.lat, north_east.lat};
return m_geospatial_query->Search(bbox);
}
@ -472,8 +475,8 @@ class InternalDataFacade final : public BaseDataFacade
{
BOOST_ASSERT(m_geospatial_query.get());
return m_geospatial_query->NearestPhantomNodesInRange(input_coordinate, max_distance,
bearing, bearing_range);
return m_geospatial_query->NearestPhantomNodesInRange(
input_coordinate, max_distance, bearing, bearing_range);
}
std::vector<PhantomNodeWithDistance>
@ -503,8 +506,8 @@ class InternalDataFacade final : public BaseDataFacade
{
BOOST_ASSERT(m_geospatial_query.get());
return m_geospatial_query->NearestPhantomNodes(input_coordinate, max_results, bearing,
bearing_range);
return m_geospatial_query->NearestPhantomNodes(
input_coordinate, max_results, bearing, bearing_range);
}
std::vector<PhantomNodeWithDistance>
@ -516,8 +519,8 @@ class InternalDataFacade final : public BaseDataFacade
{
BOOST_ASSERT(m_geospatial_query.get());
return m_geospatial_query->NearestPhantomNodes(input_coordinate, max_results, max_distance,
bearing, bearing_range);
return m_geospatial_query->NearestPhantomNodes(
input_coordinate, max_results, max_distance, bearing, bearing_range);
}
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
@ -582,7 +585,8 @@ class InternalDataFacade final : public BaseDataFacade
{
result.resize(range.back() - range.front() + 1);
std::copy(m_names_char_list.begin() + range.front(),
m_names_char_list.begin() + range.back() + 1, result.begin());
m_names_char_list.begin() + range.back() + 1,
result.begin());
}
return result;
}
@ -614,7 +618,8 @@ class InternalDataFacade final : public BaseDataFacade
result_nodes.clear();
result_nodes.reserve(end - begin);
std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end,
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);
});
@ -629,7 +634,8 @@ class InternalDataFacade final : public BaseDataFacade
result_weights.clear();
result_weights.reserve(end - begin);
std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end,
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);
});
@ -658,7 +664,8 @@ class InternalDataFacade final : public BaseDataFacade
else
{
std::for_each(
m_datasource_list.begin() + begin, m_datasource_list.begin() + end,
m_datasource_list.begin() + begin,
m_datasource_list.begin() + end,
[&](const uint8_t &datasource_id) { result_datasources.push_back(datasource_id); });
}
}
@ -691,7 +698,8 @@ class InternalDataFacade final : public BaseDataFacade
util::guidance::BearingClass result;
for (auto itr = m_bearing_values_table.begin() + range.front();
itr != m_bearing_values_table.begin() + range.back() + 1; ++itr)
itr != m_bearing_values_table.begin() + range.back() + 1;
++itr)
result.add(*itr);
return result;

View File

@ -3,9 +3,9 @@
// implements all data storage when shared memory _IS_ used
#include "engine/datafacade/datafacade_base.hpp"
#include "storage/shared_datatype.hpp"
#include "storage/shared_memory.hpp"
#include "engine/datafacade/datafacade_base.hpp"
#include "extractor/compressed_edge_container.hpp"
#include "extractor/guidance/turn_instruction.hpp"
@ -138,9 +138,11 @@ class SharedDataFacade final : public BaseDataFacade
auto tree_ptr = data_layout->GetBlockPtr<RTreeNode>(
shared_memory, storage::SharedDataLayout::R_SEARCH_TREE);
m_static_rtree.reset(new SharedRTree(
tree_ptr, data_layout->num_entries[storage::SharedDataLayout::R_SEARCH_TREE],
file_index_path, m_coordinate_list));
m_static_rtree.reset(
new SharedRTree(tree_ptr,
data_layout->num_entries[storage::SharedDataLayout::R_SEARCH_TREE],
file_index_path,
m_coordinate_list));
m_geospatial_query.reset(
new SharedGeospatialQuery(*m_static_rtree, m_coordinate_list, *this));
}
@ -164,7 +166,8 @@ class SharedDataFacade final : public BaseDataFacade
{
auto coordinate_list_ptr = data_layout->GetBlockPtr<util::Coordinate>(
shared_memory, storage::SharedDataLayout::COORDINATE_LIST);
m_coordinate_list.reset(coordinate_list_ptr,
m_coordinate_list.reset(
coordinate_list_ptr,
data_layout->num_entries[storage::SharedDataLayout::COORDINATE_LIST]);
auto travel_mode_list_ptr = data_layout->GetBlockPtr<extractor::TravelMode>(
@ -332,8 +335,8 @@ class SharedDataFacade final : public BaseDataFacade
"No shared memory blocks found, have you forgotten to run osrm-datastore?");
}
data_timestamp_ptr = static_cast<storage::SharedDataTimestamp *>(
storage::makeSharedMemory(storage::CURRENT_REGIONS,
sizeof(storage::SharedDataTimestamp), false, false)
storage::makeSharedMemory(
storage::CURRENT_REGIONS, sizeof(storage::SharedDataTimestamp), false, false)
->Ptr());
CURRENT_LAYOUT = storage::LAYOUT_NONE;
CURRENT_DATA = storage::DATA_NONE;
@ -476,7 +479,8 @@ class SharedDataFacade final : public BaseDataFacade
result_nodes.clear();
result_nodes.reserve(end - begin);
std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end,
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);
});
@ -491,7 +495,8 @@ class SharedDataFacade final : public BaseDataFacade
result_weights.clear();
result_weights.reserve(end - begin);
std::for_each(m_geometry_list.begin() + begin, m_geometry_list.begin() + end,
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);
});
@ -517,8 +522,8 @@ class SharedDataFacade final : public BaseDataFacade
const util::Coordinate north_east) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
const util::RectangleInt2D bbox{south_west.lon, north_east.lon, south_west.lat,
north_east.lat};
const util::RectangleInt2D bbox{
south_west.lon, north_east.lon, south_west.lat, north_east.lat};
return m_geospatial_query->Search(bbox);
}
@ -539,8 +544,8 @@ class SharedDataFacade final : public BaseDataFacade
{
BOOST_ASSERT(m_geospatial_query.get());
return m_geospatial_query->NearestPhantomNodesInRange(input_coordinate, max_distance,
bearing, bearing_range);
return m_geospatial_query->NearestPhantomNodesInRange(
input_coordinate, max_distance, bearing, bearing_range);
}
std::vector<PhantomNodeWithDistance>
@ -570,8 +575,8 @@ class SharedDataFacade final : public BaseDataFacade
{
BOOST_ASSERT(m_geospatial_query.get());
return m_geospatial_query->NearestPhantomNodes(input_coordinate, max_results, bearing,
bearing_range);
return m_geospatial_query->NearestPhantomNodes(
input_coordinate, max_results, bearing, bearing_range);
}
std::vector<PhantomNodeWithDistance>
@ -583,8 +588,8 @@ class SharedDataFacade final : public BaseDataFacade
{
BOOST_ASSERT(m_geospatial_query.get());
return m_geospatial_query->NearestPhantomNodes(input_coordinate, max_results, max_distance,
bearing, bearing_range);
return m_geospatial_query->NearestPhantomNodes(
input_coordinate, max_results, max_distance, bearing, bearing_range);
}
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
@ -596,9 +601,8 @@ class SharedDataFacade final : public BaseDataFacade
input_coordinate);
}
std::pair<PhantomNode, PhantomNode>
NearestPhantomNodeWithAlternativeFromBigComponent(const util::Coordinate input_coordinate,
const double max_distance) const override final
std::pair<PhantomNode, PhantomNode> NearestPhantomNodeWithAlternativeFromBigComponent(
const util::Coordinate input_coordinate, const double max_distance) const override final
{
BOOST_ASSERT(m_geospatial_query.get());
@ -650,7 +654,8 @@ class SharedDataFacade final : public BaseDataFacade
{
result.resize(range.back() - range.front() + 1);
std::copy(m_names_char_list.begin() + range.front(),
m_names_char_list.begin() + range.back() + 1, result.begin());
m_names_char_list.begin() + range.back() + 1,
result.begin());
}
return result;
}
@ -690,7 +695,8 @@ class SharedDataFacade final : public BaseDataFacade
else
{
std::for_each(
m_datasource_list.begin() + begin, m_datasource_list.begin() + end,
m_datasource_list.begin() + begin,
m_datasource_list.begin() + end,
[&](const uint8_t &datasource_id) { result_datasources.push_back(datasource_id); });
}
}
@ -729,7 +735,8 @@ class SharedDataFacade final : public BaseDataFacade
auto range = m_bearing_ranges_table->GetRange(bearing_class_id);
util::guidance::BearingClass result;
for (auto itr = m_bearing_values_table.begin() + range.front();
itr != m_bearing_values_table.begin() + range.back() + 1; ++itr)
itr != m_bearing_values_table.begin() + range.back() + 1;
++itr)
result.add(*itr);
return result;
}

View File

@ -3,8 +3,8 @@
#include "util/coordinate.hpp"
#include <vector>
#include <iterator>
#include <vector>
namespace osrm
{

View File

@ -1,13 +1,13 @@
#ifndef ENGINE_HPP
#define ENGINE_HPP
#include "engine/status.hpp"
#include "storage/shared_barriers.hpp"
#include "engine/status.hpp"
#include "util/json_container.hpp"
#include <memory>
#include <unordered_map>
#include <string>
#include <unordered_map>
namespace osrm
{

View File

@ -1,11 +1,11 @@
#ifndef GEOSPATIAL_QUERY_HPP
#define GEOSPATIAL_QUERY_HPP
#include "util/coordinate_calculation.hpp"
#include "util/typedefs.hpp"
#include "engine/phantom_node.hpp"
#include "util/bearing.hpp"
#include "util/coordinate_calculation.hpp"
#include "util/rectangle.hpp"
#include "util/typedefs.hpp"
#include "util/web_mercator.hpp"
#include "osrm/coordinate.hpp"
@ -30,9 +30,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
using CandidateSegment = typename RTreeT::CandidateSegment;
public:
GeospatialQuery(RTreeT &rtree_,
const CoordinateList &coordinates_,
DataFacadeT &datafacade_)
GeospatialQuery(RTreeT &rtree_, const CoordinateList &coordinates_, DataFacadeT &datafacade_)
: rtree(rtree_), coordinates(coordinates_), datafacade(datafacade_)
{
}
@ -45,17 +43,14 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
// Returns nearest PhantomNodes in the given bearing range within max_distance.
// Does not filter by small/big component!
std::vector<PhantomNodeWithDistance>
NearestPhantomNodesInRange(const util::Coordinate input_coordinate, const double max_distance) const
NearestPhantomNodesInRange(const util::Coordinate input_coordinate,
const double max_distance) const
{
auto results =
rtree.Nearest(input_coordinate,
[](const CandidateSegment &)
{
return std::make_pair(true, true);
},
[](const CandidateSegment &) { return std::make_pair(true, true); },
[this, max_distance, input_coordinate](const std::size_t,
const CandidateSegment &segment)
{
const CandidateSegment &segment) {
return CheckSegmentDistance(input_coordinate, segment, max_distance);
});
@ -72,13 +67,11 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
{
auto results = rtree.Nearest(
input_coordinate,
[this, bearing, bearing_range, max_distance](const CandidateSegment &segment)
{
[this, bearing, bearing_range, max_distance](const CandidateSegment &segment) {
return CheckSegmentBearing(segment, bearing, bearing_range);
},
[this, max_distance, input_coordinate](const std::size_t,
const CandidateSegment &segment)
{
const CandidateSegment &segment) {
return CheckSegmentDistance(input_coordinate, segment, max_distance);
});
@ -95,12 +88,10 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
{
auto results =
rtree.Nearest(input_coordinate,
[this, bearing, bearing_range](const CandidateSegment &segment)
{
[this, bearing, bearing_range](const CandidateSegment &segment) {
return CheckSegmentBearing(segment, bearing, bearing_range);
},
[max_results](const std::size_t num_results, const CandidateSegment &)
{
[max_results](const std::size_t num_results, const CandidateSegment &) {
return num_results >= max_results;
});
@ -119,13 +110,11 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
{
auto results =
rtree.Nearest(input_coordinate,
[this, bearing, bearing_range](const CandidateSegment &segment)
{
[this, bearing, bearing_range](const CandidateSegment &segment) {
return CheckSegmentBearing(segment, bearing, bearing_range);
},
[this, max_distance, max_results, input_coordinate](
const std::size_t num_results, const CandidateSegment &segment)
{
const std::size_t num_results, const CandidateSegment &segment) {
return num_results >= max_results ||
CheckSegmentDistance(input_coordinate, segment, max_distance);
});
@ -140,12 +129,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
{
auto results =
rtree.Nearest(input_coordinate,
[](const CandidateSegment &)
{
return std::make_pair(true, true);
},
[max_results](const std::size_t num_results, const CandidateSegment &)
{
[](const CandidateSegment &) { return std::make_pair(true, true); },
[max_results](const std::size_t num_results, const CandidateSegment &) {
return num_results >= max_results;
});
@ -161,13 +146,9 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
{
auto results =
rtree.Nearest(input_coordinate,
[](const CandidateSegment &)
{
return std::make_pair(true, true);
},
[](const CandidateSegment &) { return std::make_pair(true, true); },
[this, max_distance, max_results, input_coordinate](
const std::size_t num_results, const CandidateSegment &segment)
{
const std::size_t num_results, const CandidateSegment &segment) {
return num_results >= max_results ||
CheckSegmentDistance(input_coordinate, segment, max_distance);
});
@ -185,8 +166,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
bool has_big_component = false;
auto results = rtree.Nearest(
input_coordinate,
[&has_big_component, &has_small_component](const CandidateSegment &segment)
{
[&has_big_component, &has_small_component](const CandidateSegment &segment) {
auto use_segment = (!has_small_component ||
(!has_big_component && !segment.data.component.is_tiny));
auto use_directions = std::make_pair(use_segment, use_segment);
@ -196,9 +176,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
return use_directions;
},
[this, &has_big_component, max_distance,
input_coordinate](const std::size_t num_results, const CandidateSegment &segment)
{
[this, &has_big_component, max_distance, input_coordinate](
const std::size_t num_results, const CandidateSegment &segment) {
return (num_results > 0 && has_big_component) ||
CheckSegmentDistance(input_coordinate, segment, max_distance);
});
@ -222,8 +201,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
bool has_big_component = false;
auto results = rtree.Nearest(
input_coordinate,
[&has_big_component, &has_small_component](const CandidateSegment &segment)
{
[&has_big_component, &has_small_component](const CandidateSegment &segment) {
auto use_segment = (!has_small_component ||
(!has_big_component && !segment.data.component.is_tiny));
auto use_directions = std::make_pair(use_segment, use_segment);
@ -233,8 +211,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
return use_directions;
},
[&has_big_component](const std::size_t num_results, const CandidateSegment &)
{
[&has_big_component](const std::size_t num_results, const CandidateSegment &) {
return num_results > 0 && has_big_component;
});
@ -257,9 +234,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
bool has_big_component = false;
auto results = rtree.Nearest(
input_coordinate,
[this, bearing, bearing_range, &has_big_component,
&has_small_component](const CandidateSegment &segment)
{
[this, bearing, bearing_range, &has_big_component, &has_small_component](
const CandidateSegment &segment) {
auto use_segment = (!has_small_component ||
(!has_big_component && !segment.data.component.is_tiny));
auto use_directions = std::make_pair(use_segment, use_segment);
@ -276,8 +252,7 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
return use_directions;
},
[&has_big_component](const std::size_t num_results, const CandidateSegment &)
{
[&has_big_component](const std::size_t num_results, const CandidateSegment &) {
return num_results > 0 && has_big_component;
});
@ -303,9 +278,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
bool has_big_component = false;
auto results = rtree.Nearest(
input_coordinate,
[this, bearing, bearing_range, &has_big_component,
&has_small_component](const CandidateSegment &segment)
{
[this, bearing, bearing_range, &has_big_component, &has_small_component](
const CandidateSegment &segment) {
auto use_segment = (!has_small_component ||
(!has_big_component && !segment.data.component.is_tiny));
auto use_directions = std::make_pair(use_segment, use_segment);
@ -322,9 +296,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
return use_directions;
},
[this, &has_big_component, max_distance,
input_coordinate](const std::size_t num_results, const CandidateSegment &segment)
{
[this, &has_big_component, max_distance, input_coordinate](
const std::size_t num_results, const CandidateSegment &segment) {
return (num_results > 0 && has_big_component) ||
CheckSegmentDistance(input_coordinate, segment, max_distance);
});
@ -345,9 +318,10 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
const std::vector<EdgeData> &results) const
{
std::vector<PhantomNodeWithDistance> distance_and_phantoms(results.size());
std::transform(results.begin(), results.end(), distance_and_phantoms.begin(),
[this, &input_coordinate](const EdgeData &data)
{
std::transform(results.begin(),
results.end(),
distance_and_phantoms.begin(),
[this, &input_coordinate](const EdgeData &data) {
return MakePhantomNode(input_coordinate, data);
});
return distance_and_phantoms;
@ -359,9 +333,11 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
util::Coordinate point_on_segment;
double ratio;
const auto current_perpendicular_distance =
util::coordinate_calculation::perpendicularDistance(
coordinates[data.u], coordinates[data.v], input_coordinate,
point_on_segment, ratio);
util::coordinate_calculation::perpendicularDistance(coordinates[data.u],
coordinates[data.v],
input_coordinate,
point_on_segment,
ratio);
// Find the node-based-edge that this belongs to, and directly
// calculate the forward_weight, forward_offset, reverse_weight, reverse_offset
@ -390,7 +366,8 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
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++)
i < reverse_weight_vector.size() - data.fwd_segment_position - 1;
i++)
{
reverse_offset += reverse_weight_vector[i];
}
@ -408,9 +385,13 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
reverse_weight *= 1.0 - ratio;
}
auto transformed = PhantomNodeWithDistance{PhantomNode{data, forward_weight, forward_offset,
reverse_weight, reverse_offset,
point_on_segment, input_coordinate},
auto transformed = PhantomNodeWithDistance{PhantomNode{data,
forward_weight,
forward_offset,
reverse_weight,
reverse_offset,
point_on_segment,
input_coordinate},
current_perpendicular_distance};
return transformed;
@ -449,12 +430,12 @@ template <typename RTreeT, typename DataFacadeT> class GeospatialQuery
: (forward_edge_bearing + 180);
const bool forward_bearing_valid =
util::bearing::CheckInBounds(std::round(forward_edge_bearing), filter_bearing,
filter_bearing_range) &&
util::bearing::CheckInBounds(
std::round(forward_edge_bearing), filter_bearing, filter_bearing_range) &&
segment.data.forward_segment_id.enabled;
const bool backward_bearing_valid =
util::bearing::CheckInBounds(std::round(backward_edge_bearing), filter_bearing,
filter_bearing_range) &&
util::bearing::CheckInBounds(
std::round(backward_edge_bearing), filter_bearing, filter_bearing_range) &&
segment.data.reverse_segment_id.enabled;
return std::make_pair(forward_bearing_valid, backward_bearing_valid);
}

View File

@ -1,18 +1,18 @@
#ifndef ENGINE_GUIDANCE_ASSEMBLE_GEOMETRY_HPP
#define ENGINE_GUIDANCE_ASSEMBLE_GEOMETRY_HPP
#include "engine/internal_route_result.hpp"
#include "engine/phantom_node.hpp"
#include "engine/guidance/route_step.hpp"
#include "engine/guidance/leg_geometry.hpp"
#include "engine/guidance/toolkit.hpp"
#include "util/coordinate_calculation.hpp"
#include "util/coordinate.hpp"
#include "extractor/guidance/turn_instruction.hpp"
#include "extractor/travel_mode.hpp"
#include "engine/guidance/leg_geometry.hpp"
#include "engine/guidance/route_step.hpp"
#include "engine/guidance/toolkit.hpp"
#include "engine/internal_route_result.hpp"
#include "engine/phantom_node.hpp"
#include "util/coordinate.hpp"
#include "util/coordinate_calculation.hpp"
#include <vector>
#include <utility>
#include <vector>
namespace osrm
{
@ -62,7 +62,8 @@ LegGeometry assembleGeometry(const DataFacadeT &facade,
}
prev_coordinate = coordinate;
geometry.annotations.emplace_back(LegGeometry::Annotation{current_distance, path_point.duration_until_turn / 10.});
geometry.annotations.emplace_back(
LegGeometry::Annotation{current_distance, path_point.duration_until_turn / 10.});
geometry.locations.push_back(std::move(coordinate));
}
current_distance =
@ -70,7 +71,8 @@ LegGeometry assembleGeometry(const DataFacadeT &facade,
cumulative_distance += current_distance;
// segment leading to the target node
geometry.segment_distances.push_back(cumulative_distance);
geometry.annotations.emplace_back(LegGeometry::Annotation{current_distance, target_node.forward_weight / 10.});
geometry.annotations.emplace_back(
LegGeometry::Annotation{current_distance, target_node.forward_weight / 10.});
geometry.segment_offsets.push_back(geometry.locations.size());
geometry.locations.push_back(target_node.location);

View File

@ -38,8 +38,7 @@ template <std::size_t SegmentNumber>
std::array<std::uint32_t, SegmentNumber> summarizeRoute(const std::vector<PathData> &route_data)
{
// merges segments with same name id
const auto collapse_segments = [](std::vector<NamedSegment> &segments)
{
const auto collapse_segments = [](std::vector<NamedSegment> &segments) {
auto out = segments.begin();
auto end = segments.end();
@ -69,47 +68,44 @@ std::array<std::uint32_t, SegmentNumber> summarizeRoute(const std::vector<PathDa
std::vector<NamedSegment> segments(route_data.size());
std::uint32_t index = 0;
std::transform(
route_data.begin(), route_data.end(), segments.begin(), [&index](const PathData &point)
{
route_data.begin(), route_data.end(), segments.begin(), [&index](const PathData &point) {
return NamedSegment{point.duration_until_turn, index++, point.name_id};
});
// this makes sure that the segment with the lowest position comes first
std::sort(segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs)
{
return lhs.name_id < rhs.name_id ||
(lhs.name_id == rhs.name_id && lhs.position < rhs.position);
});
std::sort(
segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs) {
return lhs.name_id < rhs.name_id ||
(lhs.name_id == rhs.name_id && lhs.position < rhs.position);
});
auto new_end = collapse_segments(segments);
segments.resize(new_end - segments.begin());
// Filter out segments with an empty name (name_id == 0)
new_end = std::remove_if(segments.begin(), segments.end(), [](const NamedSegment &segment)
{
return segment.name_id == 0;
});
new_end = std::remove_if(segments.begin(), segments.end(), [](const NamedSegment &segment) {
return segment.name_id == 0;
});
segments.resize(new_end - segments.begin());
// sort descending
std::sort(segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs)
{
return lhs.duration > rhs.duration ||
(lhs.duration == rhs.duration && lhs.position < rhs.position);
});
std::sort(
segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs) {
return lhs.duration > rhs.duration ||
(lhs.duration == rhs.duration && lhs.position < rhs.position);
});
// make sure the segments are sorted by position
segments.resize(std::min(segments.size(), SegmentNumber));
std::sort(segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs)
{
return lhs.position < rhs.position;
});
std::sort(
segments.begin(), segments.end(), [](const NamedSegment &lhs, const NamedSegment &rhs) {
return lhs.position < rhs.position;
});
std::array<std::uint32_t, SegmentNumber> summary;
std::fill(summary.begin(), summary.end(), 0);
std::transform(segments.begin(), segments.end(), summary.begin(),
[](const NamedSegment &segment)
{
return segment.name_id;
});
std::transform(segments.begin(),
segments.end(),
summary.begin(),
[](const NamedSegment &segment) { return segment.name_id; });
return summary;
}
}
@ -126,9 +122,11 @@ inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade,
(target_traversed_in_reverse ? target_node.reverse_weight : target_node.forward_weight) /
10.;
auto distance = std::accumulate(leg_geometry.segment_distances.begin(),
leg_geometry.segment_distances.end(), 0.);
auto duration = std::accumulate(route_data.begin(), route_data.end(), 0.,
auto distance = std::accumulate(
leg_geometry.segment_distances.begin(), leg_geometry.segment_distances.end(), 0.);
auto duration = std::accumulate(route_data.begin(),
route_data.end(),
0.,
[](const double sum, const PathData &data) {
return sum + data.duration_until_turn;
}) /
@ -170,10 +168,10 @@ inline RouteLeg assembleLeg(const datafacade::BaseDataFacade &facade,
BOOST_ASSERT(detail::MAX_USED_SEGMENTS > 0);
BOOST_ASSERT(summary_array.begin() != summary_array.end());
summary = std::accumulate(std::next(summary_array.begin()), summary_array.end(),
summary = std::accumulate(std::next(summary_array.begin()),
summary_array.end(),
facade.GetNameForID(summary_array.front()),
[&facade](std::string previous, const std::uint32_t name_id)
{
[&facade](std::string previous, const std::uint32_t name_id) {
if (name_id != 0)
{
previous += ", " + facade.GetNameForID(name_id);

View File

@ -1,8 +1,8 @@
#ifndef ENGINE_GUIDANCE_ASSEMBLE_ROUTE_HPP
#define ENGINE_GUIDANCE_ASSEMBLE_ROUTE_HPP
#include "engine/guidance/route_leg.hpp"
#include "engine/guidance/route.hpp"
#include "engine/guidance/route_leg.hpp"
#include <vector>

View File

@ -1,14 +1,14 @@
#ifndef ENGINE_GUIDANCE_ASSEMBLE_STEPS_HPP_
#define ENGINE_GUIDANCE_ASSEMBLE_STEPS_HPP_
#include "extractor/guidance/turn_instruction.hpp"
#include "extractor/travel_mode.hpp"
#include "engine/guidance/leg_geometry.hpp"
#include "engine/guidance/route_step.hpp"
#include "engine/guidance/step_maneuver.hpp"
#include "engine/guidance/toolkit.hpp"
#include "engine/internal_route_result.hpp"
#include "engine/phantom_node.hpp"
#include "extractor/guidance/turn_instruction.hpp"
#include "extractor/travel_mode.hpp"
#include "util/bearing.hpp"
#include "util/coordinate.hpp"
#include "util/coordinate_calculation.hpp"
@ -65,11 +65,17 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
auto bearings = detail::getDepartBearings(leg_geometry);
StepManeuver maneuver{source_node.location, bearings.first,
bearings.second, extractor::guidance::TurnInstruction::NO_TURN(),
WaypointType::Depart, 0};
Intersection intersection{source_node.location, std::vector<short>({bearings.second}),
std::vector<bool>({true}), Intersection::NO_INDEX, 0};
StepManeuver maneuver{source_node.location,
bearings.first,
bearings.second,
extractor::guidance::TurnInstruction::NO_TURN(),
WaypointType::Depart,
0};
Intersection intersection{source_node.location,
std::vector<short>({bearings.second}),
std::vector<bool>({true}),
Intersection::NO_INDEX,
0};
if (leg_data.size() > 0)
{
@ -131,8 +137,12 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
{
intersection.entry.push_back(entry_class.allowsEntry(idx));
}
maneuver = {intersection.location, bearings.first, bearings.second,
path_point.turn_instruction, WaypointType::None, 0};
maneuver = {intersection.location,
bearings.first,
bearings.second,
path_point.turn_instruction,
WaypointType::None,
0};
segment_index++;
segment_duration = 0;
}
@ -178,13 +188,18 @@ std::vector<RouteStep> assembleSteps(const DataFacadeT &facade,
BOOST_ASSERT(segment_index == number_of_segments - 1);
bearings = detail::getArriveBearings(leg_geometry);
// This step has length zero, the only reason we need it is the target location
maneuver = {intersection.location, bearings.first,
bearings.second, extractor::guidance::TurnInstruction::NO_TURN(),
WaypointType::Arrive, 0};
maneuver = {intersection.location,
bearings.first,
bearings.second,
extractor::guidance::TurnInstruction::NO_TURN(),
WaypointType::Arrive,
0};
intersection = {
target_node.location,
std::vector<short>({static_cast<short>(util::bearing::reverseBearing(bearings.first))}),
std::vector<bool>({true}), 0, Intersection::NO_INDEX};
std::vector<bool>({true}),
0,
Intersection::NO_INDEX};
BOOST_ASSERT(!leg_geometry.locations.empty());
steps.push_back(RouteStep{target_node.name_id,

View File

@ -8,8 +8,8 @@
#include <cstddef>
#include <vector>
#include <cstdlib>
#include <vector>
namespace osrm
{
@ -32,7 +32,8 @@ struct LegGeometry
std::vector<double> segment_distances;
// Per-coordinate metadata
struct Annotation {
struct Annotation
{
double distance;
double duration;
};

View File

@ -1,9 +1,9 @@
#ifndef ENGINE_GUIDANCE_POST_PROCESSING_HPP
#define ENGINE_GUIDANCE_POST_PROCESSING_HPP
#include "engine/phantom_node.hpp"
#include "engine/guidance/route_step.hpp"
#include "engine/guidance/leg_geometry.hpp"
#include "engine/guidance/route_step.hpp"
#include "engine/phantom_node.hpp"
#include <vector>
@ -37,7 +37,7 @@ std::vector<RouteStep> assignRelativeLocations(std::vector<RouteStep> steps,
const PhantomNode &source_node,
const PhantomNode &target_node);
//remove steps invalidated by post-processing
// remove steps invalidated by post-processing
std::vector<RouteStep> removeNoTurnInstructions(std::vector<RouteStep> steps);
// postProcess will break the connection between the leg geometry

View File

@ -1,8 +1,8 @@
#ifndef ROUTE_STEP_HPP
#define ROUTE_STEP_HPP
#include "engine/guidance/step_maneuver.hpp"
#include "extractor/travel_mode.hpp"
#include "engine/guidance/step_maneuver.hpp"
#include "util/coordinate.hpp"
#include "util/guidance/bearing_class.hpp"
#include "util/guidance/entry_class.hpp"
@ -39,10 +39,10 @@ struct Intersection
inline Intersection getInvalidIntersection()
{
return {util::Coordinate{util::FloatLongitude{0.0}, util::FloatLatitude{0.0}},
{},
{},
Intersection::NO_INDEX,
Intersection::NO_INDEX};
{},
{},
Intersection::NO_INDEX,
Intersection::NO_INDEX};
}
struct RouteStep

View File

@ -32,9 +32,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "util/coordinate.hpp"
#include <string>
#include <cstdint>
#include <iosfwd>
#include <string>
namespace osrm
{
@ -65,7 +65,8 @@ struct Hint
static_assert(sizeof(Hint) == 60 + 4, "Hint is bigger than expected");
constexpr std::size_t ENCODED_HINT_SIZE = 88;
static_assert(ENCODED_HINT_SIZE / 4 * 3 >= sizeof(Hint), "ENCODED_HINT_SIZE does not match size of Hint");
static_assert(ENCODED_HINT_SIZE / 4 * 3 >= sizeof(Hint),
"ENCODED_HINT_SIZE does not match size of Hint");
}
}

View File

@ -1,9 +1,9 @@
#ifndef RAW_ROUTE_DATA_H
#define RAW_ROUTE_DATA_H
#include "engine/phantom_node.hpp"
#include "extractor/guidance/turn_instruction.hpp"
#include "extractor/travel_mode.hpp"
#include "engine/phantom_node.hpp"
#include "util/typedefs.hpp"
#include "osrm/coordinate.hpp"

View File

@ -3,8 +3,8 @@
#include <cmath>
#include <vector>
#include <utility>
#include <vector>
#include <boost/math/constants/constants.hpp>

View File

@ -149,8 +149,8 @@ struct PhantomNode
unsigned reverse_packed_geometry_id;
struct ComponentType
{
std::uint32_t id : 31;
std::uint32_t is_tiny : 1;
std::uint32_t id : 31;
std::uint32_t is_tiny : 1;
} component;
static_assert(sizeof(ComponentType) == 4, "ComponentType needs to be 4 bytes big");

View File

@ -1,8 +1,8 @@
#ifndef MATCH_HPP
#define MATCH_HPP
#include "engine/plugins/plugin_base.hpp"
#include "engine/api/match_parameters.hpp"
#include "engine/plugins/plugin_base.hpp"
#include "engine/map_matching/bayes_classifier.hpp"
#include "engine/routing_algorithms/map_matching.hpp"

View File

@ -1,8 +1,8 @@
#ifndef NEAREST_HPP
#define NEAREST_HPP
#include "engine/plugins/plugin_base.hpp"
#include "engine/api/nearest_parameters.hpp"
#include "engine/plugins/plugin_base.hpp"
#include "osrm/json_container.hpp"
namespace osrm

View File

@ -1,15 +1,15 @@
#ifndef BASE_PLUGIN_HPP
#define BASE_PLUGIN_HPP
#include "engine/datafacade/datafacade_base.hpp"
#include "engine/api/base_parameters.hpp"
#include "engine/datafacade/datafacade_base.hpp"
#include "engine/phantom_node.hpp"
#include "engine/status.hpp"
#include "util/coordinate.hpp"
#include "util/coordinate_calculation.hpp"
#include "util/json_container.hpp"
#include "util/integer_range.hpp"
#include "util/json_container.hpp"
#include <algorithm>
#include <iterator>
@ -31,11 +31,10 @@ class BasePlugin
bool CheckAllCoordinates(const std::vector<util::Coordinate> &coordinates)
{
return !std::any_of(std::begin(coordinates), std::end(coordinates),
[](const util::Coordinate coordinate)
{
return !coordinate.IsValid();
});
return !std::any_of(
std::begin(coordinates), std::end(coordinates), [](const util::Coordinate coordinate) {
return !coordinate.IsValid();
});
}
Status Error(const std::string &code,
@ -53,43 +52,38 @@ class BasePlugin
SnapPhantomNodes(const std::vector<PhantomNodePair> &phantom_node_pair_list) const
{
const auto check_component_id_is_tiny =
[](const std::pair<PhantomNode, PhantomNode> &phantom_pair)
{
return phantom_pair.first.component.is_tiny;
};
[](const std::pair<PhantomNode, PhantomNode> &phantom_pair) {
return phantom_pair.first.component.is_tiny;
};
// are all phantoms from a tiny cc?
const auto check_all_in_same_component =
[](const std::vector<std::pair<PhantomNode, PhantomNode>> &nodes)
{
const auto component_id = nodes.front().first.component.id;
[](const std::vector<std::pair<PhantomNode, PhantomNode>> &nodes) {
const auto component_id = nodes.front().first.component.id;
return std::all_of(std::begin(nodes), std::end(nodes),
[component_id](const PhantomNodePair &phantom_pair)
{
return component_id == phantom_pair.first.component.id;
});
};
return std::all_of(std::begin(nodes),
std::end(nodes),
[component_id](const PhantomNodePair &phantom_pair) {
return component_id == phantom_pair.first.component.id;
});
};
const auto fallback_to_big_component =
[](const std::pair<PhantomNode, PhantomNode> &phantom_pair)
{
if (phantom_pair.first.component.is_tiny && phantom_pair.second.IsValid() &&
!phantom_pair.second.component.is_tiny)
{
return phantom_pair.second;
}
return phantom_pair.first;
};
[](const std::pair<PhantomNode, PhantomNode> &phantom_pair) {
if (phantom_pair.first.component.is_tiny && phantom_pair.second.IsValid() &&
!phantom_pair.second.component.is_tiny)
{
return phantom_pair.second;
}
return phantom_pair.first;
};
const auto use_closed_phantom = [](const std::pair<PhantomNode, PhantomNode> &phantom_pair)
{
return phantom_pair.first;
};
const auto use_closed_phantom = [](
const std::pair<PhantomNode, PhantomNode> &phantom_pair) { return phantom_pair.first; };
const bool every_phantom_is_in_tiny_cc =
std::all_of(std::begin(phantom_node_pair_list), std::end(phantom_node_pair_list),
check_component_id_is_tiny);
const bool every_phantom_is_in_tiny_cc = std::all_of(std::begin(phantom_node_pair_list),
std::end(phantom_node_pair_list),
check_component_id_is_tiny);
auto all_in_same_component = check_all_in_same_component(phantom_node_pair_list);
std::vector<PhantomNode> snapped_phantoms;
@ -99,13 +93,17 @@ class BasePlugin
// component
if (every_phantom_is_in_tiny_cc && all_in_same_component)
{
std::transform(phantom_node_pair_list.begin(), phantom_node_pair_list.end(),
std::back_inserter(snapped_phantoms), use_closed_phantom);
std::transform(phantom_node_pair_list.begin(),
phantom_node_pair_list.end(),
std::back_inserter(snapped_phantoms),
use_closed_phantom);
}
else
{
std::transform(phantom_node_pair_list.begin(), phantom_node_pair_list.end(),
std::back_inserter(snapped_phantoms), fallback_to_big_component);
std::transform(phantom_node_pair_list.begin(),
phantom_node_pair_list.end(),
std::back_inserter(snapped_phantoms),
fallback_to_big_component);
}
return snapped_phantoms;
@ -137,9 +135,11 @@ class BasePlugin
}
if (use_bearings && parameters.bearings[i])
{
phantom_nodes[i] = facade.NearestPhantomNodesInRange(
parameters.coordinates[i], radiuses[i], parameters.bearings[i]->bearing,
parameters.bearings[i]->range);
phantom_nodes[i] =
facade.NearestPhantomNodesInRange(parameters.coordinates[i],
radiuses[i],
parameters.bearings[i]->bearing,
parameters.bearings[i]->range);
}
else
{
@ -179,15 +179,18 @@ class BasePlugin
{
if (use_radiuses && parameters.radiuses[i])
{
phantom_nodes[i] = facade.NearestPhantomNodes(
parameters.coordinates[i], number_of_results, *parameters.radiuses[i],
parameters.bearings[i]->bearing, parameters.bearings[i]->range);
phantom_nodes[i] = facade.NearestPhantomNodes(parameters.coordinates[i],
number_of_results,
*parameters.radiuses[i],
parameters.bearings[i]->bearing,
parameters.bearings[i]->range);
}
else
{
phantom_nodes[i] = facade.NearestPhantomNodes(
parameters.coordinates[i], number_of_results,
parameters.bearings[i]->bearing, parameters.bearings[i]->range);
phantom_nodes[i] = facade.NearestPhantomNodes(parameters.coordinates[i],
number_of_results,
parameters.bearings[i]->bearing,
parameters.bearings[i]->range);
}
}
else
@ -238,14 +241,17 @@ class BasePlugin
{
phantom_node_pairs[i] =
facade.NearestPhantomNodeWithAlternativeFromBigComponent(
parameters.coordinates[i], *parameters.radiuses[i],
parameters.bearings[i]->bearing, parameters.bearings[i]->range);
parameters.coordinates[i],
*parameters.radiuses[i],
parameters.bearings[i]->bearing,
parameters.bearings[i]->range);
}
else
{
phantom_node_pairs[i] =
facade.NearestPhantomNodeWithAlternativeFromBigComponent(
parameters.coordinates[i], parameters.bearings[i]->bearing,
parameters.coordinates[i],
parameters.bearings[i]->bearing,
parameters.bearings[i]->range);
}
}

View File

@ -1,8 +1,8 @@
#ifndef TILEPLUGIN_HPP
#define TILEPLUGIN_HPP
#include "engine/plugins/plugin_base.hpp"
#include "engine/api/tile_parameters.hpp"
#include "engine/plugins/plugin_base.hpp"
#include <string>

View File

@ -4,20 +4,20 @@
#include "engine/plugins/plugin_base.hpp"
#include "engine/api/trip_parameters.hpp"
#include "engine/routing_algorithms/shortest_path.hpp"
#include "engine/routing_algorithms/many_to_many.hpp"
#include "engine/routing_algorithms/shortest_path.hpp"
#include "osrm/json_container.hpp"
#include <boost/assert.hpp>
#include <cstdlib>
#include <algorithm>
#include <cstdlib>
#include <iterator>
#include <memory>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
namespace osrm
{

View File

@ -1,14 +1,14 @@
#ifndef VIA_ROUTE_HPP
#define VIA_ROUTE_HPP
#include "engine/api/route_api.hpp"
#include "engine/datafacade/datafacade_base.hpp"
#include "engine/plugins/plugin_base.hpp"
#include "engine/api/route_api.hpp"
#include "engine/search_engine_data.hpp"
#include "engine/routing_algorithms/shortest_path.hpp"
#include "engine/routing_algorithms/alternative_path.hpp"
#include "engine/routing_algorithms/direct_shortest_path.hpp"
#include "engine/routing_algorithms/shortest_path.hpp"
#include "engine/search_engine_data.hpp"
#include "util/json_container.hpp"
#include <cstdlib>

View File

@ -130,16 +130,22 @@ class AlternativeRouting final
{
if (0 < forward_heap1.Size())
{
AlternativeRoutingStep<true>(forward_heap1, reverse_heap1, &middle_node,
AlternativeRoutingStep<true>(forward_heap1,
reverse_heap1,
&middle_node,
&upper_bound_to_shortest_path_distance,
via_node_candidate_list, forward_search_space,
via_node_candidate_list,
forward_search_space,
min_edge_offset);
}
if (0 < reverse_heap1.Size())
{
AlternativeRoutingStep<false>(forward_heap1, reverse_heap1, &middle_node,
AlternativeRoutingStep<false>(forward_heap1,
reverse_heap1,
&middle_node,
&upper_bound_to_shortest_path_distance,
via_node_candidate_list, reverse_search_space,
via_node_candidate_list,
reverse_search_space,
min_edge_offset);
}
}
@ -168,10 +174,10 @@ class AlternativeRouting final
else
{
super::RetrievePackedPathFromSingleHeap(forward_heap1, middle_node,
packed_forward_path);
super::RetrievePackedPathFromSingleHeap(reverse_heap1, middle_node,
packed_reverse_path);
super::RetrievePackedPathFromSingleHeap(
forward_heap1, middle_node, packed_forward_path);
super::RetrievePackedPathFromSingleHeap(
reverse_heap1, middle_node, packed_reverse_path);
}
// this set is is used as an indicator if a node is on the shortest path
@ -271,8 +277,8 @@ class AlternativeRouting final
{
std::reverse(packed_shortest_path.begin(), packed_shortest_path.end());
packed_shortest_path.emplace_back(middle_node);
packed_shortest_path.insert(packed_shortest_path.end(), packed_reverse_path.begin(),
packed_reverse_path.end());
packed_shortest_path.insert(
packed_shortest_path.end(), packed_reverse_path.begin(), packed_reverse_path.end());
}
std::vector<RankedCandidateNode> ranked_candidates_list;
@ -280,8 +286,11 @@ class AlternativeRouting final
for (const NodeID node : preselected_node_list)
{
int length_of_via_path = 0, sharing_of_via_path = 0;
ComputeLengthAndSharingOfViaPath(node, &length_of_via_path, &sharing_of_via_path,
packed_shortest_path, min_edge_offset);
ComputeLengthAndSharingOfViaPath(node,
&length_of_via_path,
&sharing_of_via_path,
packed_shortest_path,
min_edge_offset);
const int maximum_allowed_sharing =
static_cast<int>(upper_bound_to_shortest_path_distance * VIAPATH_GAMMA);
if (sharing_of_via_path <= maximum_allowed_sharing &&
@ -297,10 +306,16 @@ class AlternativeRouting final
NodeID s_v_middle = SPECIAL_NODEID, v_t_middle = SPECIAL_NODEID;
for (const RankedCandidateNode &candidate : ranked_candidates_list)
{
if (ViaNodeCandidatePassesTTest(
forward_heap1, reverse_heap1, forward_heap2, reverse_heap2, candidate,
upper_bound_to_shortest_path_distance, &length_of_via_path, &s_v_middle,
&v_t_middle, min_edge_offset))
if (ViaNodeCandidatePassesTTest(forward_heap1,
reverse_heap1,
forward_heap2,
reverse_heap2,
candidate,
upper_bound_to_shortest_path_distance,
&length_of_via_path,
&s_v_middle,
&v_t_middle,
min_edge_offset))
{
// select first admissable
selected_via_node = candidate.node;
@ -322,7 +337,8 @@ class AlternativeRouting final
super::UnpackPath(
// -- packed input
packed_shortest_path.begin(), packed_shortest_path.end(),
packed_shortest_path.begin(),
packed_shortest_path.end(),
// -- start of route
phantom_node_pair,
// -- unpacked output
@ -334,8 +350,13 @@ class AlternativeRouting final
{
std::vector<NodeID> packed_alternate_path;
// retrieve alternate path
RetrievePackedAlternatePath(forward_heap1, reverse_heap1, forward_heap2, reverse_heap2,
s_v_middle, v_t_middle, packed_alternate_path);
RetrievePackedAlternatePath(forward_heap1,
reverse_heap1,
forward_heap2,
reverse_heap2,
s_v_middle,
v_t_middle,
packed_alternate_path);
raw_route_data.alt_source_traversed_in_reverse.push_back(
(packed_alternate_path.front() !=
@ -345,8 +366,10 @@ class AlternativeRouting final
phantom_node_pair.target_phantom.forward_segment_id.id));
// unpack the alternate path
super::UnpackPath(packed_alternate_path.begin(), packed_alternate_path.end(),
phantom_node_pair, raw_route_data.unpacked_alternative);
super::UnpackPath(packed_alternate_path.begin(),
packed_alternate_path.end(),
phantom_node_pair,
raw_route_data.unpacked_alternative);
raw_route_data.alternative_path_length = length_of_via_path;
}
@ -372,8 +395,8 @@ class AlternativeRouting final
packed_path.pop_back(); // remove middle node. It's in both half-paths
// fetch patched path [v,t]
super::RetrievePackedPathFromHeap(forward_heap2, reverse_heap1, v_t_middle,
packed_v_t_path);
super::RetrievePackedPathFromHeap(
forward_heap2, reverse_heap1, v_t_middle, packed_v_t_path);
packed_path.insert(packed_path.end(), packed_v_t_path.begin(), packed_v_t_path.end());
}
@ -410,9 +433,15 @@ class AlternativeRouting final
const bool constexpr DO_NOT_FORCE_LOOPS = false;
while (!new_reverse_heap.Empty())
{
super::RoutingStep(new_reverse_heap, existing_forward_heap, s_v_middle,
upper_bound_s_v_path_length, min_edge_offset, false,
STALLING_ENABLED, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS);
super::RoutingStep(new_reverse_heap,
existing_forward_heap,
s_v_middle,
upper_bound_s_v_path_length,
min_edge_offset,
false,
STALLING_ENABLED,
DO_NOT_FORCE_LOOPS,
DO_NOT_FORCE_LOOPS);
}
// compute path <v,..,t> by reusing backward search from node t
NodeID v_t_middle = SPECIAL_NODEID;
@ -420,9 +449,15 @@ class AlternativeRouting final
new_forward_heap.Insert(via_node, 0, via_node);
while (!new_forward_heap.Empty())
{
super::RoutingStep(new_forward_heap, existing_reverse_heap, v_t_middle,
upper_bound_of_v_t_path_length, min_edge_offset, true,
STALLING_ENABLED, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS);
super::RoutingStep(new_forward_heap,
existing_reverse_heap,
v_t_middle,
upper_bound_of_v_t_path_length,
min_edge_offset,
true,
STALLING_ENABLED,
DO_NOT_FORCE_LOOPS,
DO_NOT_FORCE_LOOPS);
}
*real_length_of_via_path = upper_bound_s_v_path_length + upper_bound_of_v_t_path_length;
@ -432,10 +467,10 @@ class AlternativeRouting final
}
// retrieve packed paths
super::RetrievePackedPathFromHeap(existing_forward_heap, new_reverse_heap, s_v_middle,
packed_s_v_path);
super::RetrievePackedPathFromHeap(new_forward_heap, existing_reverse_heap, v_t_middle,
packed_v_t_path);
super::RetrievePackedPathFromHeap(
existing_forward_heap, new_reverse_heap, s_v_middle, packed_s_v_path);
super::RetrievePackedPathFromHeap(
new_forward_heap, existing_reverse_heap, v_t_middle, packed_v_t_path);
// partial unpacking, compute sharing
// First partially unpack s-->v until paths deviate, note length of common path.
@ -501,7 +536,8 @@ class AlternativeRouting final
if (packed_v_t_path[via_path_index] == packed_shortest_path[shortest_path_index])
{
super::UnpackEdge(packed_v_t_path[via_path_index - 1],
packed_v_t_path[via_path_index], partially_unpacked_via_path);
packed_v_t_path[via_path_index],
partially_unpacked_via_path);
super::UnpackEdge(packed_shortest_path[shortest_path_index - 1],
packed_shortest_path[shortest_path_index],
partially_unpacked_shortest_path);
@ -699,9 +735,15 @@ class AlternativeRouting final
const bool constexpr DO_NOT_FORCE_LOOPS = false;
while (new_reverse_heap.Size() > 0)
{
super::RoutingStep(new_reverse_heap, existing_forward_heap, *s_v_middle,
upper_bound_s_v_path_length, min_edge_offset, false,
STALLING_ENABLED, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS);
super::RoutingStep(new_reverse_heap,
existing_forward_heap,
*s_v_middle,
upper_bound_s_v_path_length,
min_edge_offset,
false,
STALLING_ENABLED,
DO_NOT_FORCE_LOOPS,
DO_NOT_FORCE_LOOPS);
}
if (INVALID_EDGE_WEIGHT == upper_bound_s_v_path_length)
@ -715,9 +757,15 @@ class AlternativeRouting final
new_forward_heap.Insert(candidate.node, 0, candidate.node);
while (new_forward_heap.Size() > 0)
{
super::RoutingStep(new_forward_heap, existing_reverse_heap, *v_t_middle,
upper_bound_of_v_t_path_length, min_edge_offset, true,
STALLING_ENABLED, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS);
super::RoutingStep(new_forward_heap,
existing_reverse_heap,
*v_t_middle,
upper_bound_of_v_t_path_length,
min_edge_offset,
true,
STALLING_ENABLED,
DO_NOT_FORCE_LOOPS,
DO_NOT_FORCE_LOOPS);
}
if (INVALID_EDGE_WEIGHT == upper_bound_of_v_t_path_length)
@ -728,11 +776,11 @@ class AlternativeRouting final
*length_of_via_path = upper_bound_s_v_path_length + upper_bound_of_v_t_path_length;
// retrieve packed paths
super::RetrievePackedPathFromHeap(existing_forward_heap, new_reverse_heap, *s_v_middle,
packed_s_v_path);
super::RetrievePackedPathFromHeap(
existing_forward_heap, new_reverse_heap, *s_v_middle, packed_s_v_path);
super::RetrievePackedPathFromHeap(new_forward_heap, existing_reverse_heap, *v_t_middle,
packed_v_t_path);
super::RetrievePackedPathFromHeap(
new_forward_heap, existing_reverse_heap, *v_t_middle, packed_v_t_path);
NodeID s_P = *s_v_middle, t_P = *v_t_middle;
if (SPECIAL_NODEID == s_P)
@ -812,7 +860,8 @@ class AlternativeRouting final
// Traverse path s-->v
BOOST_ASSERT(!packed_v_t_path.empty());
for (unsigned i = 0, packed_path_length = static_cast<unsigned>(packed_v_t_path.size() - 1);
(i < packed_path_length) && unpack_stack.empty(); ++i)
(i < packed_path_length) && unpack_stack.empty();
++i)
{
const EdgeID edgeID =
facade->FindEdgeInEitherDirection(packed_v_t_path[i], packed_v_t_path[i + 1]);
@ -884,14 +933,26 @@ class AlternativeRouting final
{
if (!forward_heap3.Empty())
{
super::RoutingStep(forward_heap3, reverse_heap3, middle, upper_bound,
min_edge_offset, true, STALLING_ENABLED, DO_NOT_FORCE_LOOPS,
super::RoutingStep(forward_heap3,
reverse_heap3,
middle,
upper_bound,
min_edge_offset,
true,
STALLING_ENABLED,
DO_NOT_FORCE_LOOPS,
DO_NOT_FORCE_LOOPS);
}
if (!reverse_heap3.Empty())
{
super::RoutingStep(reverse_heap3, forward_heap3, middle, upper_bound,
min_edge_offset, false, STALLING_ENABLED, DO_NOT_FORCE_LOOPS,
super::RoutingStep(reverse_heap3,
forward_heap3,
middle,
upper_bound,
min_edge_offset,
false,
STALLING_ENABLED,
DO_NOT_FORCE_LOOPS,
DO_NOT_FORCE_LOOPS);
}
}

View File

@ -102,12 +102,22 @@ class DirectShortestPathRouting final
forward_core_heap.Clear();
reverse_core_heap.Clear();
super::SearchWithCore(forward_heap, reverse_heap, forward_core_heap, reverse_core_heap,
distance, packed_leg, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS);
super::SearchWithCore(forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
distance,
packed_leg,
DO_NOT_FORCE_LOOPS,
DO_NOT_FORCE_LOOPS);
}
else
{
super::Search(forward_heap, reverse_heap, distance, packed_leg, DO_NOT_FORCE_LOOPS,
super::Search(forward_heap,
reverse_heap,
distance,
packed_leg,
DO_NOT_FORCE_LOOPS,
DO_NOT_FORCE_LOOPS);
}
@ -128,7 +138,9 @@ class DirectShortestPathRouting final
raw_route_data.target_traversed_in_reverse.push_back(
(packed_leg.back() != phantom_node_pair.target_phantom.forward_segment_id.id));
super::UnpackPath(packed_leg.begin(), packed_leg.end(), phantom_node_pair,
super::UnpackPath(packed_leg.begin(),
packed_leg.end(),
phantom_node_pair,
raw_route_data.unpacked_path_segments.front());
}
};

View File

@ -66,8 +66,7 @@ class ManyToManyRouting final
SearchSpaceWithBuckets search_space_with_buckets;
unsigned column_idx = 0;
const auto search_target_phantom = [&](const PhantomNode &phantom)
{
const auto search_target_phantom = [&](const PhantomNode &phantom) {
query_heap.Clear();
// insert target(s) at distance 0
@ -94,8 +93,7 @@ class ManyToManyRouting final
// for each source do forward search
unsigned row_idx = 0;
const auto search_source_phantom = [&](const PhantomNode &phantom)
{
const auto search_source_phantom = [&](const PhantomNode &phantom) {
query_heap.Clear();
// insert target(s) at distance 0
@ -115,8 +113,11 @@ class ManyToManyRouting final
// explore search space
while (!query_heap.Empty())
{
ForwardRoutingStep(row_idx, number_of_targets, query_heap,
search_space_with_buckets, result_table);
ForwardRoutingStep(row_idx,
number_of_targets,
query_heap,
search_space_with_buckets,
result_table);
}
++row_idx;
};

View File

@ -4,12 +4,12 @@
#include "engine/routing_algorithms/routing_base.hpp"
#include "engine/map_matching/hidden_markov_model.hpp"
#include "engine/map_matching/sub_matching.hpp"
#include "engine/map_matching/matching_confidence.hpp"
#include "engine/map_matching/sub_matching.hpp"
#include "util/coordinate_calculation.hpp"
#include "util/json_logger.hpp"
#include "util/for_each_pair.hpp"
#include "util/json_logger.hpp"
#include <cstddef>
@ -86,8 +86,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
const bool use_timestamps = trace_timestamps.size() > 1;
const auto median_sample_time = [&]
{
const auto median_sample_time = [&] {
if (use_timestamps)
{
return std::max(1u, GetMedianSampleTime(trace_timestamps));
@ -98,8 +97,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
}
}();
const auto max_broken_time = median_sample_time * MAX_BROKEN_STATES;
const auto max_distance_delta = [&]
{
const auto max_distance_delta = [&] {
if (use_timestamps)
{
return median_sample_time * MAX_SPEED;
@ -116,10 +114,10 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
for (auto t = 0UL; t < candidates_list.size(); ++t)
{
emission_log_probabilities[t].resize(candidates_list[t].size());
std::transform(candidates_list[t].begin(), candidates_list[t].end(),
std::transform(candidates_list[t].begin(),
candidates_list[t].end(),
emission_log_probabilities[t].begin(),
[this](const PhantomNodeWithDistance &candidate)
{
[this](const PhantomNodeWithDistance &candidate) {
return default_emission_log_probability(candidate.distance);
});
}
@ -134,19 +132,19 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
map_matching::EmissionLogProbability emission_log_probability(
*trace_gps_precision[t]);
std::transform(
candidates_list[t].begin(), candidates_list[t].end(),
candidates_list[t].begin(),
candidates_list[t].end(),
emission_log_probabilities[t].begin(),
[&emission_log_probability](const PhantomNodeWithDistance &candidate)
{
[&emission_log_probability](const PhantomNodeWithDistance &candidate) {
return emission_log_probability(candidate.distance);
});
}
else
{
std::transform(candidates_list[t].begin(), candidates_list[t].end(),
std::transform(candidates_list[t].begin(),
candidates_list[t].end(),
emission_log_probabilities[t].begin(),
[this](const PhantomNodeWithDistance &candidate)
{
[this](const PhantomNodeWithDistance &candidate) {
return default_emission_log_probability(candidate.distance);
});
}
@ -269,14 +267,19 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
forward_core_heap.Clear();
reverse_core_heap.Clear();
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,
current_timestamps_list[s_prime].phantom_node, duration_uppder_bound);
current_timestamps_list[s_prime].phantom_node,
duration_uppder_bound);
}
else
{
network_distance = super::GetNetworkDistance(
forward_heap, reverse_heap,
forward_heap,
reverse_heap,
prev_unbroken_timestamps_list[s].phantom_node,
current_timestamps_list[s_prime].phantom_node);
}
@ -398,10 +401,10 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
matching_distance += model.path_distances[timestamp_index][location_index];
}
util::for_each_pair(
reconstructed_indices, [&trace_distance, &trace_coordinates](
const std::pair<std::size_t, std::size_t> &prev,
const std::pair<std::size_t, std::size_t> &curr)
{
reconstructed_indices,
[&trace_distance,
&trace_coordinates](const std::pair<std::size_t, std::size_t> &prev,
const std::pair<std::size_t, std::size_t> &curr) {
trace_distance += util::coordinate_calculation::haversineDistance(
trace_coordinates[prev.first], trace_coordinates[curr.first]);
});

View File

@ -1,9 +1,9 @@
#ifndef ROUTING_BASE_HPP
#define ROUTING_BASE_HPP
#include "extractor/guidance/turn_instruction.hpp"
#include "engine/internal_route_result.hpp"
#include "engine/search_engine_data.hpp"
#include "extractor/guidance/turn_instruction.hpp"
#include "util/coordinate_calculation.hpp"
#include "util/typedefs.hpp"
@ -228,8 +228,9 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
BOOST_ASSERT(*packed_path_begin == phantom_node_pair.source_phantom.forward_segment_id.id ||
*packed_path_begin == phantom_node_pair.source_phantom.reverse_segment_id.id);
BOOST_ASSERT(*std::prev(packed_path_end) == phantom_node_pair.target_phantom.forward_segment_id.id ||
*std::prev(packed_path_end) == phantom_node_pair.target_phantom.reverse_segment_id.id);
BOOST_ASSERT(
*std::prev(packed_path_end) == phantom_node_pair.target_phantom.forward_segment_id.id ||
*std::prev(packed_path_end) == phantom_node_pair.target_phantom.reverse_segment_id.id);
std::pair<NodeID, NodeID> edge;
while (!recursion_stack.empty())
@ -322,8 +323,11 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
for (std::size_t i = start_index; i < end_index; ++i)
{
unpacked_path.push_back(
PathData{id_vector[i], name_index, weight_vector[i],
extractor::guidance::TurnInstruction::NO_TURN(), travel_mode,
PathData{id_vector[i],
name_index,
weight_vector[i],
extractor::guidance::TurnInstruction::NO_TURN(),
travel_mode,
INVALID_ENTRY_CLASSID});
}
BOOST_ASSERT(unpacked_path.size() > 0);
@ -381,7 +385,9 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
BOOST_ASSERT(i < id_vector.size());
BOOST_ASSERT(phantom_node_pair.target_phantom.forward_travel_mode > 0);
unpacked_path.push_back(PathData{
id_vector[i], phantom_node_pair.target_phantom.name_id, weight_vector[i],
id_vector[i],
phantom_node_pair.target_phantom.name_id,
weight_vector[i],
extractor::guidance::TurnInstruction::NO_TURN(),
target_traversed_in_reverse ? phantom_node_pair.target_phantom.backward_travel_mode
: phantom_node_pair.target_phantom.forward_travel_mode,
@ -544,13 +550,27 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
{
if (!forward_heap.Empty())
{
RoutingStep(forward_heap, reverse_heap, middle, distance, min_edge_offset, true,
STALLING_ENABLED, force_loop_forward, force_loop_reverse);
RoutingStep(forward_heap,
reverse_heap,
middle,
distance,
min_edge_offset,
true,
STALLING_ENABLED,
force_loop_forward,
force_loop_reverse);
}
if (!reverse_heap.Empty())
{
RoutingStep(reverse_heap, forward_heap, middle, distance, min_edge_offset, false,
STALLING_ENABLED, force_loop_reverse, force_loop_forward);
RoutingStep(reverse_heap,
forward_heap,
middle,
distance,
min_edge_offset,
false,
STALLING_ENABLED,
force_loop_reverse,
force_loop_forward);
}
}
@ -622,8 +642,15 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
}
else
{
RoutingStep(forward_heap, reverse_heap, middle, distance, min_edge_offset, true,
STALLING_ENABLED, force_loop_forward, force_loop_reverse);
RoutingStep(forward_heap,
reverse_heap,
middle,
distance,
min_edge_offset,
true,
STALLING_ENABLED,
force_loop_forward,
force_loop_reverse);
}
}
if (!reverse_heap.Empty())
@ -636,8 +663,15 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
}
else
{
RoutingStep(reverse_heap, forward_heap, middle, distance, min_edge_offset,
false, STALLING_ENABLED, force_loop_reverse, force_loop_forward);
RoutingStep(reverse_heap,
forward_heap,
middle,
distance,
min_edge_offset,
false,
STALLING_ENABLED,
force_loop_reverse,
force_loop_forward);
}
}
}
@ -690,12 +724,24 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
while (0 < forward_core_heap.Size() && 0 < reverse_core_heap.Size() &&
distance > (forward_core_heap.MinKey() + reverse_core_heap.MinKey()))
{
RoutingStep(forward_core_heap, reverse_core_heap, middle, distance,
min_core_edge_offset, true, STALLING_DISABLED, force_loop_forward,
RoutingStep(forward_core_heap,
reverse_core_heap,
middle,
distance,
min_core_edge_offset,
true,
STALLING_DISABLED,
force_loop_forward,
force_loop_reverse);
RoutingStep(reverse_core_heap, forward_core_heap, middle, distance,
min_core_edge_offset, false, STALLING_DISABLED, force_loop_reverse,
RoutingStep(reverse_core_heap,
forward_core_heap,
middle,
distance,
min_core_edge_offset,
false,
STALLING_DISABLED,
force_loop_reverse,
force_loop_forward);
}
@ -724,8 +770,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
else
{
std::vector<NodeID> packed_core_leg;
RetrievePackedPathFromHeap(forward_core_heap, reverse_core_heap, middle,
packed_core_leg);
RetrievePackedPathFromHeap(
forward_core_heap, reverse_core_heap, middle, packed_core_leg);
BOOST_ASSERT(packed_core_leg.size() > 0);
RetrievePackedPathFromSingleHeap(forward_heap, packed_core_leg.front(), packed_leg);
std::reverse(packed_leg.begin(), packed_leg.end());
@ -872,8 +918,15 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
int duration = INVALID_EDGE_WEIGHT;
std::vector<NodeID> packed_path;
SearchWithCore(forward_heap, reverse_heap, forward_core_heap, reverse_core_heap, duration,
packed_path, DO_NOT_FORCE_LOOPS, DO_NOT_FORCE_LOOPS, duration_upper_bound);
SearchWithCore(forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
duration,
packed_path,
DO_NOT_FORCE_LOOPS,
DO_NOT_FORCE_LOOPS,
duration_upper_bound);
double distance = std::numeric_limits<double>::max();
if (duration != INVALID_EDGE_WEIGHT)
@ -926,8 +979,13 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
int duration = INVALID_EDGE_WEIGHT;
std::vector<NodeID> packed_path;
Search(forward_heap, reverse_heap, duration, packed_path, DO_NOT_FORCE_LOOPS,
DO_NOT_FORCE_LOOPS, duration_upper_bound);
Search(forward_heap,
reverse_heap,
duration,
packed_path,
DO_NOT_FORCE_LOOPS,
DO_NOT_FORCE_LOOPS,
duration_upper_bound);
if (duration == INVALID_EDGE_WEIGHT)
{

View File

@ -57,13 +57,13 @@ class ShortestPathRouting final
if (search_from_forward_node)
{
forward_heap.Insert(source_phantom.forward_segment_id.id,
-source_phantom.GetForwardWeightPlusOffset(),
-source_phantom.GetForwardWeightPlusOffset(),
source_phantom.forward_segment_id.id);
}
if (search_from_reverse_node)
{
forward_heap.Insert(source_phantom.reverse_segment_id.id,
-source_phantom.GetReverseWeightPlusOffset(),
-source_phantom.GetReverseWeightPlusOffset(),
source_phantom.reverse_segment_id.id);
}
if (search_to_forward_node)
@ -96,16 +96,25 @@ class ShortestPathRouting final
reverse_core_heap.Clear();
BOOST_ASSERT(forward_core_heap.Size() == 0);
BOOST_ASSERT(reverse_core_heap.Size() == 0);
super::SearchWithCore(forward_heap, reverse_heap, forward_core_heap, reverse_core_heap,
new_total_distance, leg_packed_path, needs_loop_forwad,
super::SearchWithCore(forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
new_total_distance,
leg_packed_path,
needs_loop_forwad,
needs_loop_backwards);
}
else
{
super::Search(forward_heap, reverse_heap, new_total_distance, leg_packed_path,
needs_loop_forwad, needs_loop_backwards);
super::Search(forward_heap,
reverse_heap,
new_total_distance,
leg_packed_path,
needs_loop_forwad,
needs_loop_backwards);
}
new_total_distance += std::min(total_distance_to_forward,total_distance_to_reverse);
new_total_distance += std::min(total_distance_to_forward, total_distance_to_reverse);
}
// searches shortest path between:
@ -159,14 +168,20 @@ class ShortestPathRouting final
reverse_core_heap.Clear();
BOOST_ASSERT(forward_core_heap.Size() == 0);
BOOST_ASSERT(reverse_core_heap.Size() == 0);
super::SearchWithCore(
forward_heap, reverse_heap, forward_core_heap, reverse_core_heap,
new_total_distance_to_forward, leg_packed_path_forward,
super::NeedsLoopForward(source_phantom, target_phantom), DO_NOT_FORCE_LOOP);
super::SearchWithCore(forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
new_total_distance_to_forward,
leg_packed_path_forward,
super::NeedsLoopForward(source_phantom, target_phantom),
DO_NOT_FORCE_LOOP);
}
else
{
super::Search(forward_heap, reverse_heap, new_total_distance_to_forward,
super::Search(forward_heap,
reverse_heap,
new_total_distance_to_forward,
leg_packed_path_forward,
super::NeedsLoopForward(source_phantom, target_phantom),
DO_NOT_FORCE_LOOP);
@ -202,15 +217,22 @@ class ShortestPathRouting final
reverse_core_heap.Clear();
BOOST_ASSERT(forward_core_heap.Size() == 0);
BOOST_ASSERT(reverse_core_heap.Size() == 0);
super::SearchWithCore(forward_heap, reverse_heap, forward_core_heap,
reverse_core_heap, new_total_distance_to_reverse,
leg_packed_path_reverse, DO_NOT_FORCE_LOOP,
super::SearchWithCore(forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
new_total_distance_to_reverse,
leg_packed_path_reverse,
DO_NOT_FORCE_LOOP,
super::NeedsLoopBackwards(source_phantom, target_phantom));
}
else
{
super::Search(forward_heap, reverse_heap, new_total_distance_to_reverse,
leg_packed_path_reverse, DO_NOT_FORCE_LOOP,
super::Search(forward_heap,
reverse_heap,
new_total_distance_to_reverse,
leg_packed_path_reverse,
DO_NOT_FORCE_LOOP,
super::NeedsLoopBackwards(source_phantom, target_phantom));
}
}
@ -231,7 +253,9 @@ class ShortestPathRouting final
auto leg_begin = total_packed_path.begin() + packed_leg_begin[current_leg];
auto leg_end = total_packed_path.begin() + packed_leg_begin[current_leg + 1];
const auto &unpack_phantom_node_pair = phantom_nodes_vector[current_leg];
super::UnpackPath(leg_begin, leg_end, unpack_phantom_node_pair,
super::UnpackPath(leg_begin,
leg_end,
unpack_phantom_node_pair,
raw_route_data.unpacked_path_segments[current_leg]);
raw_route_data.source_traversed_in_reverse.push_back(
@ -247,7 +271,9 @@ class ShortestPathRouting final
const boost::optional<bool> continue_straight_at_waypoint,
InternalRouteResult &raw_route_data) const
{
const bool allow_uturn_at_waypoint = !(continue_straight_at_waypoint ? *continue_straight_at_waypoint : super::facade->GetContinueStraightDefault());
const bool allow_uturn_at_waypoint =
!(continue_straight_at_waypoint ? *continue_straight_at_waypoint
: super::facade->GetContinueStraightDefault());
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
super::facade->GetNumberOfNodes());
@ -300,12 +326,20 @@ class ShortestPathRouting final
{
if (allow_uturn_at_waypoint)
{
SearchWithUTurn(forward_heap, reverse_heap, forward_core_heap,
reverse_core_heap, search_from_forward_node,
search_from_reverse_node, search_to_forward_node,
search_to_reverse_node, source_phantom, target_phantom,
total_distance_to_forward, total_distance_to_reverse,
new_total_distance_to_forward, packed_leg_to_forward);
SearchWithUTurn(forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
search_from_forward_node,
search_from_reverse_node,
search_to_forward_node,
search_to_reverse_node,
source_phantom,
target_phantom,
total_distance_to_forward,
total_distance_to_reverse,
new_total_distance_to_forward,
packed_leg_to_forward);
// if only the reverse node is valid (e.g. when using the match plugin) we
// actually need to move
if (!target_phantom.forward_segment_id.enabled)
@ -323,12 +357,22 @@ class ShortestPathRouting final
}
else
{
Search(forward_heap, reverse_heap, forward_core_heap, reverse_core_heap,
search_from_forward_node, search_from_reverse_node,
search_to_forward_node, search_to_reverse_node, source_phantom,
target_phantom, total_distance_to_forward, total_distance_to_reverse,
new_total_distance_to_forward, new_total_distance_to_reverse,
packed_leg_to_forward, packed_leg_to_reverse);
Search(forward_heap,
reverse_heap,
forward_core_heap,
reverse_core_heap,
search_from_forward_node,
search_from_reverse_node,
search_to_forward_node,
search_to_reverse_node,
source_phantom,
target_phantom,
total_distance_to_forward,
total_distance_to_reverse,
new_total_distance_to_forward,
new_total_distance_to_reverse,
packed_leg_to_forward,
packed_leg_to_reverse);
}
}
@ -441,8 +485,11 @@ class ShortestPathRouting final
packed_leg_to_reverse_begin.push_back(total_packed_path_to_reverse.size());
BOOST_ASSERT(packed_leg_to_reverse_begin.size() == phantom_nodes_vector.size() + 1);
UnpackLegs(phantom_nodes_vector, total_packed_path_to_reverse,
packed_leg_to_reverse_begin, total_distance_to_reverse, raw_route_data);
UnpackLegs(phantom_nodes_vector,
total_packed_path_to_reverse,
packed_leg_to_reverse_begin,
total_distance_to_reverse,
raw_route_data);
}
else
{
@ -450,8 +497,11 @@ class ShortestPathRouting final
packed_leg_to_forward_begin.push_back(total_packed_path_to_forward.size());
BOOST_ASSERT(packed_leg_to_forward_begin.size() == phantom_nodes_vector.size() + 1);
UnpackLegs(phantom_nodes_vector, total_packed_path_to_forward,
packed_leg_to_forward_begin, total_distance_to_forward, raw_route_data);
UnpackLegs(phantom_nodes_vector,
total_packed_path_to_forward,
packed_leg_to_forward_begin,
total_distance_to_forward,
raw_route_data);
}
}
};

View File

@ -3,8 +3,8 @@
#include <boost/thread/tss.hpp>
#include "util/typedefs.hpp"
#include "util/binary_heap.hpp"
#include "util/typedefs.hpp"
namespace osrm
{

View File

@ -1,18 +1,18 @@
#ifndef TRIP_BRUTE_FORCE_HPP
#define TRIP_BRUTE_FORCE_HPP
#include "util/typedefs.hpp"
#include "util/dist_table_wrapper.hpp"
#include "util/simple_logger.hpp"
#include "util/typedefs.hpp"
#include "osrm/json_container.hpp"
#include <cstdlib>
#include <algorithm>
#include <string>
#include <cstdlib>
#include <iterator>
#include <vector>
#include <limits>
#include <string>
#include <vector>
namespace osrm
{

View File

@ -1,18 +1,18 @@
#ifndef TRIP_FARTHEST_INSERTION_HPP
#define TRIP_FARTHEST_INSERTION_HPP
#include "util/typedefs.hpp"
#include "util/dist_table_wrapper.hpp"
#include "util/typedefs.hpp"
#include "util/typedefs.hpp"
#include "osrm/json_container.hpp"
#include <boost/assert.hpp>
#include <cstdlib>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <string>
#include <vector>
#include <limits>
namespace osrm
{
@ -153,7 +153,6 @@ std::vector<NodeID> FarthestInsertionTrip(const NodeIDIterator &start,
// 5. DONE!
//////////////////////////////////////////////////////////////////////////////////////////////////
// Guard against division-by-zero in the code path below.
BOOST_ASSERT(number_of_locations > 0);

View File

@ -1,17 +1,17 @@
#ifndef TRIP_NEAREST_NEIGHBOUR_HPP
#define TRIP_NEAREST_NEIGHBOUR_HPP
#include "util/typedefs.hpp"
#include "util/simple_logger.hpp"
#include "util/dist_table_wrapper.hpp"
#include "util/simple_logger.hpp"
#include "util/typedefs.hpp"
#include "osrm/json_container.hpp"
#include <cstdlib>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <string>
#include <vector>
#include <limits>
namespace osrm
{

View File

@ -11,10 +11,10 @@
#include "extractor/query_node.hpp"
#include "extractor/restriction_map.hpp"
#include "util/guidance/bearing_class.hpp"
#include "util/guidance/entry_class.hpp"
#include "extractor/guidance/turn_analysis.hpp"
#include "extractor/guidance/turn_instruction.hpp"
#include "util/guidance/bearing_class.hpp"
#include "util/guidance/entry_class.hpp"
#include "util/deallocating_vector.hpp"
#include "util/name_table.hpp"

View File

@ -21,8 +21,8 @@ struct EdgeBasedNode
{
EdgeBasedNode()
: forward_segment_id{SPECIAL_SEGMENTID, false},
reverse_segment_id{SPECIAL_SEGMENTID, false}, u(SPECIAL_NODEID),
v(SPECIAL_NODEID), name_id(0), forward_packed_geometry_id(SPECIAL_EDGEID),
reverse_segment_id{SPECIAL_SEGMENTID, false}, u(SPECIAL_NODEID), v(SPECIAL_NODEID),
name_id(0), forward_packed_geometry_id(SPECIAL_EDGEID),
reverse_packed_geometry_id(SPECIAL_EDGEID), component{INVALID_COMPONENTID, false},
fwd_segment_position(std::numeric_limits<unsigned short>::max()),
forward_travel_mode(TRAVEL_MODE_INACCESSIBLE),
@ -42,15 +42,13 @@ struct EdgeBasedNode
unsigned short fwd_segment_position,
TravelMode forward_travel_mode,
TravelMode backward_travel_mode)
: forward_segment_id(forward_segment_id_),
reverse_segment_id(reverse_segment_id_), u(u), v(v), name_id(name_id),
forward_packed_geometry_id(forward_geometry_id_),
: forward_segment_id(forward_segment_id_), reverse_segment_id(reverse_segment_id_), u(u),
v(v), name_id(name_id), forward_packed_geometry_id(forward_geometry_id_),
reverse_packed_geometry_id(reverse_geometry_id_),
component{component_id, is_tiny_component}, fwd_segment_position(fwd_segment_position),
forward_travel_mode(forward_travel_mode), backward_travel_mode(backward_travel_mode)
{
BOOST_ASSERT(forward_segment_id.enabled ||
reverse_segment_id.enabled);
BOOST_ASSERT(forward_segment_id.enabled || reverse_segment_id.enabled);
}
SegmentID forward_segment_id; // needed for edge-expanded graph

View File

@ -25,15 +25,17 @@ struct ExternalMemoryNode : QueryNode
static ExternalMemoryNode min_value()
{
return ExternalMemoryNode(util::FixedLongitude(0), util::FixedLatitude(0), MIN_OSM_NODEID,
false, false);
return ExternalMemoryNode(
util::FixedLongitude(0), util::FixedLatitude(0), MIN_OSM_NODEID, false, false);
}
static ExternalMemoryNode max_value()
{
return ExternalMemoryNode(util::FixedLongitude(std::numeric_limits<int>::max()),
util::FixedLatitude(std::numeric_limits<int>::max()),
MAX_OSM_NODEID, false, false);
MAX_OSM_NODEID,
false,
false);
}
bool barrier;

View File

@ -1,11 +1,11 @@
#ifndef EXTRACTION_CONTAINERS_HPP
#define EXTRACTION_CONTAINERS_HPP
#include "extractor/internal_extractor_edge.hpp"
#include "extractor/first_and_last_segment_of_way.hpp"
#include "extractor/scripting_environment.hpp"
#include "extractor/external_memory_node.hpp"
#include "extractor/first_and_last_segment_of_way.hpp"
#include "extractor/internal_extractor_edge.hpp"
#include "extractor/restriction.hpp"
#include "extractor/scripting_environment.hpp"
#include <stxxl/vector>
#include <unordered_map>

View File

@ -1,8 +1,8 @@
#ifndef EXTRACTION_HELPER_FUNCTIONS_HPP
#define EXTRACTION_HELPER_FUNCTIONS_HPP
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/qi.hpp>
#include <limits>
#include <string>
@ -19,8 +19,7 @@ namespace qi = boost::spirit::qi;
template <typename Iterator> struct iso_8601_grammar : qi::grammar<Iterator, unsigned()>
{
iso_8601_grammar()
: iso_8601_grammar::base_type(root)
iso_8601_grammar() : iso_8601_grammar::base_type(root)
{
using qi::_1;
@ -38,50 +37,38 @@ template <typename Iterator> struct iso_8601_grammar : qi::grammar<Iterator, uns
mm = uint2_p[_pass = bind([](unsigned x) { return x < 60; }, _1), _val = _1];
ss = uint2_p[_pass = bind([](unsigned x) { return x < 60; }, _1), _val = _1];
osm_time
= (uint_p[_a = _1] >> eoi) [_val = _a * 60]
| (uint_p[_a = _1] >> ':' >> uint_p[_b = _1] >> eoi) [_val = _a * 3600 + _b * 60]
| (uint_p[_a = _1] >> ':' >> uint_p[_b = _1] >> ':' >> uint_p[_c = _1] >> eoi) [_val = _a * 3600 + _b * 60 + _c]
;
osm_time = (uint_p[_a = _1] >> eoi)[_val = _a * 60] |
(uint_p[_a = _1] >> ':' >> uint_p[_b = _1] >> eoi)[_val = _a * 3600 + _b * 60] |
(uint_p[_a = _1] >> ':' >> uint_p[_b = _1] >> ':' >> uint_p[_c = _1] >>
eoi)[_val = _a * 3600 + _b * 60 + _c];
alternative_time
= ('T' >> hh[_a = _1] >> mm[_b = _1] >> ss[_c = _1]) [_val = _a * 3600 + _b * 60 + _c]
;
alternative_time =
('T' >> hh[_a = _1] >> mm[_b = _1] >> ss[_c = _1])[_val = _a * 3600 + _b * 60 + _c];
extended_time
= ('T' >> hh[_a = _1] >> ':' >> mm[_b = _1] >> ':' >> ss[_c = _1]) [_val = _a * 3600 + _b * 60 + _c]
;
extended_time = ('T' >> hh[_a = _1] >> ':' >> mm[_b = _1] >> ':' >>
ss[_c = _1])[_val = _a * 3600 + _b * 60 + _c];
standard_time
= ('T'
>> -(uint_ >> char_("Hh"))[_a = _1]
>> -(uint_ >> char_("Mm"))[_b = _1]
>> -(uint_ >> char_("Ss"))[_c = _1]) [_val = _a * 3600 + _b * 60 + _c]
;
standard_time =
('T' >> -(uint_ >> char_("Hh"))[_a = _1] >> -(uint_ >> char_("Mm"))[_b = _1] >>
-(uint_ >> char_("Ss"))[_c = _1])[_val = _a * 3600 + _b * 60 + _c];
standard_date
= (uint_ >> char_("Dd")) [_val = _1 * 86400]
;
standard_date = (uint_ >> char_("Dd"))[_val = _1 * 86400];
standard_week
= (uint_ >> char_("Ww")) [_val = _1 * 604800]
;
standard_week = (uint_ >> char_("Ww"))[_val = _1 * 604800];
iso_period
= osm_time [_val = _1]
| ('P' >> standard_week >> eoi) [_val = _1]
| ('P' >> ( alternative_time[_a = 0, _b = _1]
| extended_time[_a = 0, _b = _1]
| (eps[_a = 0, _b = 0] >> -standard_date[_a = _1] >> -standard_time[_b = _1] ) )
>> eoi) [_val = _a + _b]
;
iso_period =
osm_time[_val = _1] | ('P' >> standard_week >> eoi)[_val = _1] |
('P' >> (alternative_time[_a = 0, _b = _1] | extended_time[_a = 0, _b = _1] |
(eps[_a = 0, _b = 0] >> -standard_date[_a = _1] >> -standard_time[_b = _1])) >>
eoi)[_val = _a + _b];
root = iso_period;
}
qi::rule<Iterator, unsigned()> root;
qi::rule<Iterator, unsigned(), qi::locals<unsigned, unsigned>> iso_period;
qi::rule<Iterator, unsigned(), qi::locals<unsigned, unsigned, unsigned>> osm_time, standard_time, alternative_time, extended_time;
qi::rule<Iterator, unsigned(), qi::locals<unsigned, unsigned, unsigned>> osm_time,
standard_time, alternative_time, extended_time;
qi::rule<Iterator, unsigned()> standard_date, standard_week;
qi::rule<Iterator, unsigned()> hh, mm, ss;
@ -111,7 +98,6 @@ inline unsigned parseDuration(const std::string &s)
return !s.empty() && iter == s.end() ? duration : std::numeric_limits<unsigned>::max();
}
}
}

View File

@ -30,8 +30,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/filesystem/path.hpp>
#include <string>
#include <array>
#include <string>
namespace osrm
{
@ -72,7 +72,7 @@ struct ExtractorConfig
edge_penalty_path = basepath + ".osrm.edge_penalties";
edge_based_node_weights_output_path = basepath + ".osrm.enw";
profile_properties_output_path = basepath + ".osrm.properties";
intersection_class_data_output_path = basepath + ".osrm.icd";
intersection_class_data_output_path = basepath + ".osrm.icd";
}
boost::filesystem::path config_file_path;

View File

@ -9,10 +9,10 @@ namespace guidance
{
enum class RoundaboutType
{
None, // not a roundabout
Roundabout, // standard roundabout
Rotary, // traffic circle (large roundabout) with dedicated name
RoundaboutIntersection // small roundabout with distinct turns, handled as intersection
None, // not a roundabout
Roundabout, // standard roundabout
Rotary, // traffic circle (large roundabout) with dedicated name
RoundaboutIntersection // small roundabout with distinct turns, handled as intersection
};
} /* namespace guidance */
} /* namespace extractor */

View File

@ -70,7 +70,8 @@ getCoordinateFromCompressedRange(util::Coordinate current_coordinate,
};
for (auto compressed_geometry_itr = compressed_geometry_begin;
compressed_geometry_itr != compressed_geometry_end; ++compressed_geometry_itr)
compressed_geometry_itr != compressed_geometry_end;
++compressed_geometry_itr)
{
const auto next_coordinate =
extractCoordinateFromNode(query_nodes[compressed_geometry_itr->node_id]);
@ -82,7 +83,8 @@ getCoordinateFromCompressedRange(util::Coordinate current_coordinate,
if (distance_to_next_coordinate >= detail::DESIRED_SEGMENT_LENGTH)
return util::coordinate_calculation::interpolateLinear(
getFactor(distance_to_current_coordinate, distance_to_next_coordinate),
current_coordinate, next_coordinate);
current_coordinate,
next_coordinate);
// prepare for next iteration
current_coordinate = next_coordinate;
@ -98,7 +100,8 @@ getCoordinateFromCompressedRange(util::Coordinate current_coordinate,
distance_to_next_coordinate >= detail::DESIRED_SEGMENT_LENGTH)
return util::coordinate_calculation::interpolateLinear(
getFactor(distance_to_current_coordinate, distance_to_next_coordinate),
current_coordinate, final_coordinate);
current_coordinate,
final_coordinate);
else
return final_coordinate;
}
@ -280,10 +283,14 @@ inline double getTurnConfidence(const double angle, TurnInstruction instruction)
// swaps left <-> right modifier types
inline DirectionModifier::Enum mirrorDirectionModifier(const DirectionModifier::Enum modifier)
{
const constexpr DirectionModifier::Enum results[] = {
DirectionModifier::UTurn, DirectionModifier::SharpLeft, DirectionModifier::Left,
DirectionModifier::SlightLeft, DirectionModifier::Straight, DirectionModifier::SlightRight,
DirectionModifier::Right, DirectionModifier::SharpRight};
const constexpr DirectionModifier::Enum results[] = {DirectionModifier::UTurn,
DirectionModifier::SharpLeft,
DirectionModifier::Left,
DirectionModifier::SlightLeft,
DirectionModifier::Straight,
DirectionModifier::SlightRight,
DirectionModifier::Right,
DirectionModifier::SharpRight};
return results[modifier];
}
@ -380,8 +387,10 @@ inline bool requiresNameAnnounced(const std::string &from,
return false;
if (!checkTable(first_prefix_and_suffixes.first))
return false;
return !first.compare(first_prefix_and_suffixes.first.length(), std::string::npos,
second, second_prefix_and_suffixes.first.length(),
return !first.compare(first_prefix_and_suffixes.first.length(),
std::string::npos,
second,
second_prefix_and_suffixes.first.length(),
std::string::npos);
}();
@ -390,8 +399,10 @@ inline bool requiresNameAnnounced(const std::string &from,
return false;
if (!checkTable(first_prefix_and_suffixes.second))
return false;
return !first.compare(0, first.length() - first_prefix_and_suffixes.second.length(),
second, 0,
return !first.compare(0,
first.length() - first_prefix_and_suffixes.second.length(),
second,
0,
second.length() - second_prefix_and_suffixes.second.length());
}();
@ -421,8 +432,8 @@ inline int getPriority(const FunctionalRoadClass road_class)
// The road priorities indicate which roads can bee seen as more or less equal.
// They are used in Fork-Discovery. Possibly should be moved to profiles post v5?
// A fork can happen between road types that are at most 1 priority apart from each other
const constexpr int road_priority[] = {10, 0, 10, 2, 10, 4, 10, 6,
10, 8, 10, 11, 10, 12, 10, 14};
const constexpr int road_priority[] = {
10, 0, 10, 2, 10, 4, 10, 6, 10, 8, 10, 11, 10, 12, 10, 14};
return road_priority[static_cast<int>(road_class)];
}
@ -441,10 +452,14 @@ inline bool canBeSeenAsFork(const FunctionalRoadClass first, const FunctionalRoa
// turn and vice versa.
inline ConnectedRoad mirror(ConnectedRoad road)
{
const constexpr DirectionModifier::Enum mirrored_modifiers[] = {
DirectionModifier::UTurn, DirectionModifier::SharpLeft, DirectionModifier::Left,
DirectionModifier::SlightLeft, DirectionModifier::Straight, DirectionModifier::SlightRight,
DirectionModifier::Right, DirectionModifier::SharpRight};
const constexpr DirectionModifier::Enum mirrored_modifiers[] = {DirectionModifier::UTurn,
DirectionModifier::SharpLeft,
DirectionModifier::Left,
DirectionModifier::SlightLeft,
DirectionModifier::Straight,
DirectionModifier::SlightRight,
DirectionModifier::Right,
DirectionModifier::SharpRight};
if (angularDeviation(road.turn.angle, 0) > std::numeric_limits<double>::epsilon())
{

View File

@ -1,23 +1,21 @@
#ifndef OSRM_GUIDANCE_TURN_CLASSIFICATION_HPP_
#define OSRM_GUIDANCE_TURN_CLASSIFICATION_HPP_
#include "extractor/compressed_edge_container.hpp"
#include "extractor/guidance/intersection.hpp"
#include "extractor/guidance/toolkit.hpp"
#include "extractor/compressed_edge_container.hpp"
#include "extractor/query_node.hpp"
#include "util/guidance/entry_class.hpp"
#include "util/guidance/bearing_class.hpp"
#include "util/coordinate.hpp"
#include "util/guidance/bearing_class.hpp"
#include "util/guidance/entry_class.hpp"
#include "util/node_based_graph.hpp"
#include "util/typedefs.hpp"
#include <algorithm>
#include <cstddef>
#include <vector>
#include <utility>
#include <vector>
namespace osrm
{
@ -26,7 +24,7 @@ namespace extractor
namespace guidance
{
std::pair<util::guidance::EntryClass,util::guidance::BearingClass>
std::pair<util::guidance::EntryClass, util::guidance::BearingClass>
classifyIntersection(NodeID nid,
const Intersection &intersection,
const util::NodeBasedDynamicGraph &node_based_graph,

View File

@ -101,7 +101,9 @@ struct TurnInstruction
const DirectionModifier::Enum modifier)
{
const constexpr TurnType::Enum enter_instruction[] = {
TurnType::Invalid, TurnType::EnterRoundabout, TurnType::EnterRotary,
TurnType::Invalid,
TurnType::EnterRoundabout,
TurnType::EnterRotary,
TurnType::EnterRoundaboutIntersection};
return {enter_instruction[static_cast<int>(roundabout_type)], modifier};
}
@ -109,9 +111,10 @@ struct TurnInstruction
static TurnInstruction EXIT_ROUNDABOUT(const RoundaboutType roundabout_type,
const DirectionModifier::Enum modifier)
{
const constexpr TurnType::Enum exit_instruction[] = {
TurnType::Invalid, TurnType::ExitRoundabout, TurnType::ExitRotary,
TurnType::ExitRoundaboutIntersection};
const constexpr TurnType::Enum exit_instruction[] = {TurnType::Invalid,
TurnType::ExitRoundabout,
TurnType::ExitRotary,
TurnType::ExitRoundaboutIntersection};
return {exit_instruction[static_cast<int>(roundabout_type)], modifier};
}
@ -119,7 +122,9 @@ struct TurnInstruction
const DirectionModifier::Enum modifier)
{
const constexpr TurnType::Enum exit_instruction[] = {
TurnType::Invalid, TurnType::EnterAndExitRoundabout, TurnType::EnterAndExitRotary,
TurnType::Invalid,
TurnType::EnterAndExitRoundabout,
TurnType::EnterAndExitRotary,
TurnType::EnterAndExitRoundaboutIntersection};
return {exit_instruction[static_cast<int>(roundabout_type)], modifier};
}
@ -128,7 +133,9 @@ struct TurnInstruction
const DirectionModifier::Enum modifier)
{
const constexpr TurnType::Enum enter_instruction[] = {
TurnType::Invalid, TurnType::EnterRoundaboutAtExit, TurnType::EnterRotaryAtExit,
TurnType::Invalid,
TurnType::EnterRoundaboutAtExit,
TurnType::EnterRotaryAtExit,
TurnType::EnterRoundaboutIntersectionAtExit};
return {enter_instruction[static_cast<int>(roundabout_type)], modifier};
}

View File

@ -1,15 +1,15 @@
#ifndef INTERNAL_EXTRACTOR_EDGE_HPP
#define INTERNAL_EXTRACTOR_EDGE_HPP
#include "util/typedefs.hpp"
#include "extractor/travel_mode.hpp"
#include "extractor/node_based_edge.hpp"
#include "extractor/travel_mode.hpp"
#include "util/typedefs.hpp"
#include <boost/assert.hpp>
#include "extractor/guidance/classification_data.hpp"
#include "osrm/coordinate.hpp"
#include <utility>
#include "extractor/guidance/classification_data.hpp"
namespace osrm
{
@ -32,8 +32,7 @@ struct InternalExtractorEdge
WeightData() : duration(0.0), type(WeightType::INVALID) {}
union
{
union {
double duration;
double speed;
};
@ -94,14 +93,32 @@ struct InternalExtractorEdge
// necessary static util functions for stxxl's sorting
static InternalExtractorEdge min_osm_value()
{
return InternalExtractorEdge(MIN_OSM_NODEID, MIN_OSM_NODEID, 0, WeightData(), false, false,
false, false, true, TRAVEL_MODE_INACCESSIBLE, false,
return InternalExtractorEdge(MIN_OSM_NODEID,
MIN_OSM_NODEID,
0,
WeightData(),
false,
false,
false,
false,
true,
TRAVEL_MODE_INACCESSIBLE,
false,
guidance::RoadClassificationData());
}
static InternalExtractorEdge max_osm_value()
{
return InternalExtractorEdge(MAX_OSM_NODEID, MAX_OSM_NODEID, 0, WeightData(), false, false,
false, false, true, TRAVEL_MODE_INACCESSIBLE, false,
return InternalExtractorEdge(MAX_OSM_NODEID,
MAX_OSM_NODEID,
0,
WeightData(),
false,
false,
false,
false,
true,
TRAVEL_MODE_INACCESSIBLE,
false,
guidance::RoadClassificationData());
}

View File

@ -27,8 +27,7 @@ struct OriginalEdgeData
OriginalEdgeData()
: via_node(std::numeric_limits<unsigned>::max()),
name_id(std::numeric_limits<unsigned>::max()),
entry_classid(INVALID_ENTRY_CLASSID),
name_id(std::numeric_limits<unsigned>::max()), entry_classid(INVALID_ENTRY_CLASSID),
turn_instruction(guidance::TurnInstruction::INVALID()),
travel_mode(TRAVEL_MODE_INACCESSIBLE)
{

View File

@ -11,24 +11,19 @@ namespace extractor
struct ProfileProperties
{
ProfileProperties()
: traffic_signal_penalty(0), u_turn_penalty(0), continue_straight_at_waypoint(true), use_turn_restrictions(false)
: traffic_signal_penalty(0), u_turn_penalty(0), continue_straight_at_waypoint(true),
use_turn_restrictions(false)
{
}
double GetUturnPenalty() const
{
return u_turn_penalty / 10.;
}
double GetUturnPenalty() const { return u_turn_penalty / 10.; }
void SetUturnPenalty(const double u_turn_penalty_)
{
u_turn_penalty = boost::numeric_cast<int>(u_turn_penalty_ * 10.);
}
double GetTrafficSignalPenalty() const
{
return traffic_signal_penalty / 10.;
}
double GetTrafficSignalPenalty() const { return traffic_signal_penalty / 10.; }
void SetTrafficSignalPenalty(const double traffic_signal_penalty_)
{

View File

@ -36,13 +36,15 @@ struct QueryNode
static QueryNode min_value()
{
return QueryNode(util::FixedLongitude(-180 * COORDINATE_PRECISION),
util::FixedLatitude(-90 * COORDINATE_PRECISION), MIN_OSM_NODEID);
util::FixedLatitude(-90 * COORDINATE_PRECISION),
MIN_OSM_NODEID);
}
static QueryNode max_value()
{
return QueryNode(util::FixedLongitude(180 * COORDINATE_PRECISION),
util::FixedLatitude(90 * COORDINATE_PRECISION), MAX_OSM_NODEID);
util::FixedLatitude(90 * COORDINATE_PRECISION),
MAX_OSM_NODEID);
}
};
}

View File

@ -1,18 +1,18 @@
#ifndef RASTER_SOURCE_HPP
#define RASTER_SOURCE_HPP
#include "util/exception.hpp"
#include "util/coordinate.hpp"
#include "util/exception.hpp"
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/spirit/include/qi_int.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <boost/assert.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_int.hpp>
#include <unordered_map>
#include <iterator>
#include <unordered_map>
namespace osrm
{

View File

@ -12,8 +12,7 @@ namespace extractor
struct TurnRestriction
{
union WayOrNode
{
union WayOrNode {
OSMNodeID_weak node;
OSMEdgeID_weak way;
};

View File

@ -76,7 +76,7 @@ namespace extractor
class RestrictionMap
{
public:
RestrictionMap() : m_count(0){}
RestrictionMap() : m_count(0) {}
RestrictionMap(const std::vector<TurnRestriction> &restriction_list);
// Replace end v with w in each turn restriction containing u as via node

View File

@ -42,7 +42,7 @@ struct ProfileProperties;
class RestrictionParser
{
public:
RestrictionParser(lua_State *lua_state, const ProfileProperties& properties);
RestrictionParser(lua_State *lua_state, const ProfileProperties &properties);
boost::optional<InputRestrictionContainer> TryParse(const osmium::Relation &relation) const;
private:

View File

@ -6,9 +6,9 @@
#include "util/lua_util.hpp"
#include <string>
#include <memory>
#include <mutex>
#include <string>
#include <tbb/enumerable_thread_specific.h>
struct lua_State;

View File

@ -1,11 +1,11 @@
#ifndef TARJAN_SCC_HPP
#define TARJAN_SCC_HPP
#include "util/typedefs.hpp"
#include "util/deallocating_vector.hpp"
#include "extractor/node_based_edge.hpp"
#include "extractor/query_node.hpp"
#include "util/deallocating_vector.hpp"
#include "util/percent.hpp"
#include "util/typedefs.hpp"
#include "util/integer_range.hpp"
#include "util/simple_logger.hpp"
@ -16,9 +16,9 @@
#include <boost/assert.hpp>
#include <cstdint>
#include <memory>
#include <algorithm>
#include <climits>
#include <memory>
#include <stack>
#include <vector>
@ -160,11 +160,9 @@ template <typename GraphT> class TarjanSCC
TIMER_STOP(SCC_RUN);
util::SimpleLogger().Write() << "SCC run took: " << TIMER_MSEC(SCC_RUN) / 1000. << "s";
size_one_counter = std::count_if(component_size_vector.begin(), component_size_vector.end(),
[](unsigned value)
{
return 1 == value;
});
size_one_counter = std::count_if(component_size_vector.begin(),
component_size_vector.end(),
[](unsigned value) { return 1 == value; });
}
std::size_t GetNumberOfComponents() const { return component_size_vector.size(); }

View File

@ -32,7 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
namespace osrm
{
using engine::Bearing;
using engine::Bearing;
}
#endif

View File

@ -75,8 +75,8 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
BaseParametersGrammar(qi::rule<Iterator, Signature> &root_rule)
: BaseParametersGrammar::base_type(root_rule)
{
const auto add_hint = [](engine::api::BaseParameters &base_parameters, const boost::optional<std::string> &hint_string)
{
const auto add_hint = [](engine::api::BaseParameters &base_parameters,
const boost::optional<std::string> &hint_string) {
if (hint_string)
{
base_parameters.hints.emplace_back(engine::Hint::FromBase64(hint_string.get()));
@ -87,64 +87,63 @@ struct BaseParametersGrammar : boost::spirit::qi::grammar<Iterator, Signature>
}
};
const auto add_bearing = [](engine::api::BaseParameters &base_parameters,
boost::optional<boost::fusion::vector2<short, short>> bearing_range)
{
boost::optional<engine::Bearing> bearing;
if (bearing_range)
{
bearing = engine::Bearing{boost::fusion::at_c<0>(*bearing_range),
boost::fusion::at_c<1>(*bearing_range)};
}
base_parameters.bearings.push_back(std::move(bearing));
};
const auto add_bearing =
[](engine::api::BaseParameters &base_parameters,
boost::optional<boost::fusion::vector2<short, short>> bearing_range) {
boost::optional<engine::Bearing> bearing;
if (bearing_range)
{
bearing = engine::Bearing{boost::fusion::at_c<0>(*bearing_range),
boost::fusion::at_c<1>(*bearing_range)};
}
base_parameters.bearings.push_back(std::move(bearing));
};
polyline_chars = qi::char_("a-zA-Z0-9_.--[]{}@?|\\%~`^");
base64_char = qi::char_("a-zA-Z0-9--_=");
unlimited_rule = qi::lit("unlimited")[qi::_val = std::numeric_limits<double>::infinity()];
bearing_rule
= (qi::short_ > ',' > qi::short_)
[qi::_val = ph::bind([](short bearing, short range) {
return osrm::engine::Bearing{bearing, range};
}, qi::_1, qi::_2)]
;
bearing_rule =
(qi::short_ > ',' > qi::short_)[qi::_val = ph::bind(
[](short bearing, short range) {
return osrm::engine::Bearing{bearing, range};
},
qi::_1,
qi::_2)];
location_rule
= (double_ > qi::lit(',') > double_)
[qi::_val = ph::bind([](double lon, double lat) {
return util::Coordinate(util::FixedLongitude(lon * COORDINATE_PRECISION),
util::FixedLatitude(lat * COORDINATE_PRECISION));
}, qi::_1, qi::_2)]
;
location_rule = (double_ > qi::lit(',') >
double_)[qi::_val = ph::bind(
[](double lon, double lat) {
return util::Coordinate(
util::FixedLongitude(lon * COORDINATE_PRECISION),
util::FixedLatitude(lat * COORDINATE_PRECISION));
},
qi::_1,
qi::_2)];
polyline_rule
= qi::as_string[qi::lit("polyline(") > +polyline_chars > ')']
[qi::_val = ph::bind([](const std::string &polyline) {
return engine::decodePolyline(polyline);
}, qi::_1)]
;
polyline_rule = qi::as_string[qi::lit("polyline(") > +polyline_chars > ')']
[qi::_val = ph::bind(
[](const std::string &polyline) {
return engine::decodePolyline(polyline);
},
qi::_1)];
query_rule
= ((location_rule % ';') | polyline_rule)
[ph::bind(&engine::api::BaseParameters::coordinates, qi::_r1) = qi::_1]
;
query_rule =
((location_rule % ';') |
polyline_rule)[ph::bind(&engine::api::BaseParameters::coordinates, qi::_r1) = qi::_1];
radiuses_rule
= qi::lit("radiuses=")
> (-(qi::double_ | unlimited_rule) % ';')
[ph::bind(&engine::api::BaseParameters::radiuses, qi::_r1) = qi::_1]
;
radiuses_rule = qi::lit("radiuses=") >
(-(qi::double_ | unlimited_rule) %
';')[ph::bind(&engine::api::BaseParameters::radiuses, qi::_r1) = qi::_1];
hints_rule
= qi::lit("hints=")
> (-qi::as_string[qi::repeat(engine::ENCODED_HINT_SIZE)[base64_char]])[ph::bind(add_hint, qi::_r1, qi::_1)] % ';'
;
hints_rule = qi::lit("hints=") >
(-qi::as_string[qi::repeat(engine::ENCODED_HINT_SIZE)[base64_char]])[ph::bind(
add_hint, qi::_r1, qi::_1)] %
';';
bearings_rule
= qi::lit("bearings=") >
(-(qi::short_ > ',' > qi::short_))[ph::bind(add_bearing, qi::_r1, qi::_1)] % ';'
;
bearings_rule =
qi::lit("bearings=") >
(-(qi::short_ > ',' > qi::short_))[ph::bind(add_bearing, qi::_r1, qi::_1)] % ';';
base_rule = radiuses_rule(qi::_r1) | hints_rule(qi::_r1) | bearings_rule(qi::_r1);
}

View File

@ -1,8 +1,8 @@
#ifndef MATCH_PARAMETERS_GRAMMAR_HPP
#define MATCH_PARAMETERS_GRAMMAR_HPP
#include "engine/api/match_parameters.hpp"
#include "server/api/route_parameters_grammar.hpp"
#include "engine/api/match_parameters.hpp"
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/qi.hpp>
@ -28,15 +28,13 @@ struct MatchParametersGrammar final : public RouteParametersGrammar<Iterator, Si
MatchParametersGrammar() : BaseGrammar(root_rule)
{
timestamps_rule
= qi::lit("timestamps=")
> (qi::uint_ % ';')[ph::bind(&engine::api::MatchParameters::timestamps, qi::_r1) = qi::_1]
;
timestamps_rule =
qi::lit("timestamps=") >
(qi::uint_ %
';')[ph::bind(&engine::api::MatchParameters::timestamps, qi::_r1) = qi::_1];
root_rule
= BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json")
> -('?' > (timestamps_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1)) % '&')
;
root_rule = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") >
-('?' > (timestamps_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1)) % '&');
}
private:

View File

@ -1,8 +1,8 @@
#ifndef NEAREST_PARAMETERS_GRAMMAR_HPP
#define NEAREST_PARAMETERS_GRAMMAR_HPP
#include "engine/api/nearest_parameters.hpp"
#include "server/api/base_parameters_grammar.hpp"
#include "engine/api/nearest_parameters.hpp"
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/qi.hpp>
@ -28,15 +28,12 @@ struct NearestParametersGrammar final : public BaseParametersGrammar<Iterator, S
NearestParametersGrammar() : BaseGrammar(root_rule)
{
nearest_rule
= (qi::lit("number=") > qi::uint_)
[ph::bind(&engine::api::NearestParameters::number_of_results, qi::_r1) = qi::_1]
;
nearest_rule = (qi::lit("number=") >
qi::uint_)[ph::bind(&engine::api::NearestParameters::number_of_results,
qi::_r1) = qi::_1];
root_rule
= BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json")
> -('?' > (nearest_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1)) % '&')
;
root_rule = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") >
-('?' > (nearest_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1)) % '&');
}
private:

View File

@ -1,8 +1,8 @@
#ifndef ROUTE_PARAMETERS_GRAMMAR_HPP
#define ROUTE_PARAMETERS_GRAMMAR_HPP
#include "engine/api/route_parameters.hpp"
#include "server/api/base_parameters_grammar.hpp"
#include "engine/api/route_parameters.hpp"
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/qi.hpp>
@ -28,39 +28,38 @@ struct RouteParametersGrammar : public BaseParametersGrammar<Iterator, Signature
RouteParametersGrammar() : RouteParametersGrammar(root_rule)
{
route_rule
= (qi::lit("alternatives=") > qi::bool_[ph::bind(&engine::api::RouteParameters::alternatives, qi::_r1) = qi::_1])
| (qi::lit("continue_straight=")
> (qi::lit("default")
| qi::bool_[ph::bind(&engine::api::RouteParameters::continue_straight, qi::_r1) = qi::_1]))
;
route_rule =
(qi::lit("alternatives=") >
qi::bool_[ph::bind(&engine::api::RouteParameters::alternatives, qi::_r1) = qi::_1]) |
(qi::lit("continue_straight=") >
(qi::lit("default") |
qi::bool_[ph::bind(&engine::api::RouteParameters::continue_straight, qi::_r1) =
qi::_1]));
root_rule
= query_rule(qi::_r1) > -qi::lit(".json")
> -('?' > (route_rule(qi::_r1) | base_rule(qi::_r1)) % '&')
;
root_rule = query_rule(qi::_r1) > -qi::lit(".json") >
-('?' > (route_rule(qi::_r1) | base_rule(qi::_r1)) % '&');
}
RouteParametersGrammar(qi::rule<Iterator, Signature> &root_rule_) : BaseGrammar(root_rule_)
{
geometries_type.add
("geojson", engine::api::RouteParameters::GeometriesType::GeoJSON)
("polyline", engine::api::RouteParameters::GeometriesType::Polyline)
;
geometries_type.add("geojson", engine::api::RouteParameters::GeometriesType::GeoJSON)(
"polyline", engine::api::RouteParameters::GeometriesType::Polyline);
overview_type.add
("simplified", engine::api::RouteParameters::OverviewType::Simplified)
("full", engine::api::RouteParameters::OverviewType::Full)
("false", engine::api::RouteParameters::OverviewType::False)
;
overview_type.add("simplified", engine::api::RouteParameters::OverviewType::Simplified)(
"full", engine::api::RouteParameters::OverviewType::Full)(
"false", engine::api::RouteParameters::OverviewType::False);
base_rule =
BaseGrammar::base_rule(qi::_r1)
| (qi::lit("steps=") > qi::bool_[ph::bind(&engine::api::RouteParameters::steps, qi::_r1) = qi::_1])
| (qi::lit("annotations=") > qi::bool_[ph::bind(&engine::api::RouteParameters::annotations, qi::_r1) = qi::_1])
| (qi::lit("geometries=") > geometries_type[ph::bind(&engine::api::RouteParameters::geometries, qi::_r1) = qi::_1])
| (qi::lit("overview=") > overview_type[ph::bind(&engine::api::RouteParameters::overview, qi::_r1) = qi::_1])
;
BaseGrammar::base_rule(qi::_r1) |
(qi::lit("steps=") >
qi::bool_[ph::bind(&engine::api::RouteParameters::steps, qi::_r1) = qi::_1]) |
(qi::lit("annotations=") >
qi::bool_[ph::bind(&engine::api::RouteParameters::annotations, qi::_r1) = qi::_1]) |
(qi::lit("geometries=") >
geometries_type[ph::bind(&engine::api::RouteParameters::geometries, qi::_r1) =
qi::_1]) |
(qi::lit("overview=") >
overview_type[ph::bind(&engine::api::RouteParameters::overview, qi::_r1) = qi::_1]);
query_rule = BaseGrammar::query_rule(qi::_r1);
}

View File

@ -1,8 +1,8 @@
#ifndef TABLE_PARAMETERS_GRAMMAR_HPP
#define TABLE_PARAMETERS_GRAMMAR_HPP
#include "engine/api/table_parameters.hpp"
#include "server/api/base_parameters_grammar.hpp"
#include "engine/api/table_parameters.hpp"
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/qi.hpp>
@ -37,22 +37,21 @@ struct TableParametersGrammar final : public BaseParametersGrammar<Iterator, Sig
size_t_ = qi::ulong_;
#endif
destinations_rule
= qi::lit("destinations=")
> (qi::lit("all") | (size_t_ % ';')[ph::bind(&engine::api::TableParameters::destinations, qi::_r1) = qi::_1])
;
destinations_rule =
qi::lit("destinations=") >
(qi::lit("all") |
(size_t_ %
';')[ph::bind(&engine::api::TableParameters::destinations, qi::_r1) = qi::_1]);
sources_rule
= qi::lit("sources=")
> (qi::lit("all") | (size_t_ % ';')[ph::bind(&engine::api::TableParameters::sources, qi::_r1) = qi::_1])
;
sources_rule =
qi::lit("sources=") >
(qi::lit("all") |
(size_t_ % ';')[ph::bind(&engine::api::TableParameters::sources, qi::_r1) = qi::_1]);
table_rule = destinations_rule(qi::_r1) | sources_rule(qi::_r1);
root_rule
= BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json")
> -('?' > (table_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1)) % '&')
;
root_rule = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") >
-('?' > (table_rule(qi::_r1) | BaseGrammar::base_rule(qi::_r1)) % '&');
}
private:

View File

@ -30,13 +30,11 @@ struct TileParametersGrammar final : boost::spirit::qi::grammar<Iterator, Signat
{
TileParametersGrammar() : TileParametersGrammar::base_type(root_rule)
{
root_rule
= qi::lit("tile(")
> qi::uint_[ph::bind(&engine::api::TileParameters::x, qi::_r1) = qi::_1] > ','
> qi::uint_[ph::bind(&engine::api::TileParameters::y, qi::_r1) = qi::_1] > ','
> qi::uint_[ph::bind(&engine::api::TileParameters::z, qi::_r1) = qi::_1]
> qi::lit(").mvt")
;
root_rule = qi::lit("tile(") >
qi::uint_[ph::bind(&engine::api::TileParameters::x, qi::_r1) = qi::_1] > ',' >
qi::uint_[ph::bind(&engine::api::TileParameters::y, qi::_r1) = qi::_1] > ',' >
qi::uint_[ph::bind(&engine::api::TileParameters::z, qi::_r1) = qi::_1] >
qi::lit(").mvt");
}
private:

View File

@ -1,8 +1,8 @@
#ifndef TRIP_PARAMETERS_GRAMMAR_HPP
#define TRIP_PARAMETERS_GRAMMAR_HPP
#include "engine/api/trip_parameters.hpp"
#include "server/api/route_parameters_grammar.hpp"
#include "engine/api/trip_parameters.hpp"
#include <boost/spirit/include/qi.hpp>
@ -26,10 +26,8 @@ struct TripParametersGrammar final : public RouteParametersGrammar<Iterator, Sig
TripParametersGrammar() : BaseGrammar(root_rule)
{
root_rule
= BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json")
> -('?' > (BaseGrammar::base_rule(qi::_r1)) % '&')
;
root_rule = BaseGrammar::query_rule(qi::_r1) > -qi::lit(".json") >
-('?' > (BaseGrammar::base_rule(qi::_r1)) % '&');
}
private:

View File

@ -1,8 +1,8 @@
#ifndef HEADER_HPP
#define HEADER_HPP
#include <string>
#include <algorithm>
#include <string>
namespace osrm
{

View File

@ -14,15 +14,15 @@
#include <zlib.h>
#ifndef _WIN32
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/types.h>
#endif
#include <functional>
#include <memory>
#include <string>
#include <thread>
#include <vector>
#include <string>
namespace osrm
{

View File

@ -2,8 +2,8 @@
#define SERVER_SERVICE_BASE_SERVICE_HPP
#include "engine/status.hpp"
#include "util/coordinate.hpp"
#include "osrm/osrm.hpp"
#include "util/coordinate.hpp"
#include <variant/variant.hpp>
@ -25,7 +25,8 @@ class BaseService
BaseService(OSRM &routing_machine) : routing_machine(routing_machine) {}
virtual ~BaseService() = default;
virtual engine::Status RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) = 0;
virtual engine::Status
RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) = 0;
virtual unsigned GetVersion() = 0;

View File

@ -4,8 +4,8 @@
#include "server/service/base_service.hpp"
#include "engine/status.hpp"
#include "util/coordinate.hpp"
#include "osrm/osrm.hpp"
#include "util/coordinate.hpp"
#include <string>
#include <vector>
@ -22,7 +22,8 @@ class MatchService final : public BaseService
public:
MatchService(OSRM &routing_machine) : BaseService(routing_machine) {}
engine::Status RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override;
engine::Status
RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override;
unsigned GetVersion() final override { return 1; }
};

View File

@ -4,8 +4,8 @@
#include "server/service/base_service.hpp"
#include "engine/status.hpp"
#include "util/coordinate.hpp"
#include "osrm/osrm.hpp"
#include "util/coordinate.hpp"
#include <string>
#include <vector>
@ -22,7 +22,8 @@ class NearestService final : public BaseService
public:
NearestService(OSRM &routing_machine) : BaseService(routing_machine) {}
engine::Status RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override;
engine::Status
RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override;
unsigned GetVersion() final override { return 1; }
};

View File

@ -4,8 +4,8 @@
#include "server/service/base_service.hpp"
#include "engine/status.hpp"
#include "util/coordinate.hpp"
#include "osrm/osrm.hpp"
#include "util/coordinate.hpp"
#include <string>
#include <vector>
@ -22,7 +22,8 @@ class RouteService final : public BaseService
public:
RouteService(OSRM &routing_machine) : BaseService(routing_machine) {}
engine::Status RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override;
engine::Status
RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override;
unsigned GetVersion() final override { return 1; }
};

View File

@ -4,8 +4,8 @@
#include "server/service/base_service.hpp"
#include "engine/status.hpp"
#include "util/coordinate.hpp"
#include "osrm/osrm.hpp"
#include "util/coordinate.hpp"
#include <string>
#include <vector>
@ -22,7 +22,8 @@ class TableService final : public BaseService
public:
TableService(OSRM &routing_machine) : BaseService(routing_machine) {}
engine::Status RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override;
engine::Status
RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override;
unsigned GetVersion() final override { return 1; }
};

View File

@ -4,8 +4,8 @@
#include "server/service/base_service.hpp"
#include "engine/status.hpp"
#include "util/coordinate.hpp"
#include "osrm/osrm.hpp"
#include "util/coordinate.hpp"
#include <string>
#include <vector>
@ -22,7 +22,8 @@ class TileService final : public BaseService
public:
TileService(OSRM &routing_machine) : BaseService(routing_machine) {}
engine::Status RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override;
engine::Status
RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override;
unsigned GetVersion() final override { return 1; }
};

View File

@ -4,8 +4,8 @@
#include "server/service/base_service.hpp"
#include "engine/status.hpp"
#include "util/coordinate.hpp"
#include "osrm/osrm.hpp"
#include "util/coordinate.hpp"
#include <string>
#include <vector>
@ -22,7 +22,8 @@ class TripService final : public BaseService
public:
TripService(OSRM &routing_machine) : BaseService(routing_machine) {}
engine::Status RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override;
engine::Status
RunQuery(std::size_t prefix_length, std::string &query, ResultT &result) final override;
unsigned GetVersion() final override { return 1; }
};

View File

@ -1,8 +1,8 @@
#ifndef SHARED_BARRIERS_HPP
#define SHARED_BARRIERS_HPP
#include <boost/interprocess/sync/named_mutex.hpp>
#include <boost/interprocess/sync/named_condition.hpp>
#include <boost/interprocess/sync/named_mutex.hpp>
namespace osrm
{

View File

@ -104,8 +104,8 @@ class SharedMemory
{
Remove(key);
}
shm = boost::interprocess::xsi_shared_memory(boost::interprocess::open_or_create, key,
size);
shm = boost::interprocess::xsi_shared_memory(
boost::interprocess::open_or_create, key, size);
#ifdef __linux__
if (-1 == shmctl(shm.get_shmid(), SHM_LOCK, nullptr))
{
@ -236,7 +236,8 @@ class SharedMemory
if (0 == size)
{ // read_only
shm = boost::interprocess::shared_memory_object(
boost::interprocess::open_only, key,
boost::interprocess::open_only,
key,
read_write ? boost::interprocess::read_write : boost::interprocess::read_only);
region = boost::interprocess::mapped_region(
shm, read_write ? boost::interprocess::read_write : boost::interprocess::read_only);
@ -248,8 +249,8 @@ class SharedMemory
{
Remove(key);
}
shm = boost::interprocess::shared_memory_object(boost::interprocess::open_or_create,
key, boost::interprocess::read_write);
shm = boost::interprocess::shared_memory_object(
boost::interprocess::open_or_create, key, boost::interprocess::read_write);
shm.truncate(size);
region = boost::interprocess::mapped_region(shm, boost::interprocess::read_write);
@ -290,8 +291,8 @@ class SharedMemory
bool result = true;
try
{
boost::interprocess::shared_memory_object shm(boost::interprocess::open_only, key,
boost::interprocess::read_write);
boost::interprocess::shared_memory_object shm(
boost::interprocess::open_only, key, boost::interprocess::read_write);
}
catch (...)
{

View File

@ -96,7 +96,6 @@ inline double reverseBearing(const double bearing)
return bearing - 180.;
return bearing + 180;
}
}
}
}

View File

@ -1,9 +1,9 @@
#ifndef CAST_HPP
#define CAST_HPP
#include <string>
#include <sstream>
#include <iomanip>
#include <sstream>
#include <string>
#include <type_traits>
#include <boost/algorithm/string/classification.hpp>

View File

@ -32,10 +32,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <boost/numeric/conversion/cast.hpp>
#include <cstddef>
#include <iosfwd> //for std::ostream
#include <string>
#include <type_traits>
#include <cstddef>
namespace osrm
{
@ -200,8 +200,10 @@ bool operator==(const FloatCoordinate lhs, const FloatCoordinate rhs);
std::ostream &operator<<(std::ostream &out, const Coordinate coordinate);
std::ostream &operator<<(std::ostream &out, const FloatCoordinate coordinate);
inline Coordinate::Coordinate(const FloatCoordinate &other) : Coordinate(toFixed(other.lon), toFixed(other.lat)) {}
inline Coordinate::Coordinate(const FloatCoordinate &other)
: Coordinate(toFixed(other.lon), toFixed(other.lat))
{
}
}
}

View File

@ -23,7 +23,6 @@ const constexpr long double RAD_TO_DEGREE = 1. / DEGREE_TO_RAD;
const constexpr long double EARTH_RADIUS = 6372797.560856;
}
//! Takes the squared euclidean distance of the input coordinates. Does not return meters!
std::uint64_t squaredEuclideanDistance(const Coordinate lhs, const Coordinate rhs);
@ -32,8 +31,8 @@ double haversineDistance(const Coordinate first_coordinate, const Coordinate sec
double greatCircleDistance(const Coordinate first_coordinate, const Coordinate second_coordinate);
inline std::pair<double, FloatCoordinate> projectPointOnSegment(const FloatCoordinate &source,
const FloatCoordinate &target,
const FloatCoordinate &coordinate)
const FloatCoordinate &target,
const FloatCoordinate &coordinate)
{
const FloatCoordinate slope_vector{target.lon - source.lon, target.lat - source.lat};
const FloatCoordinate rel_coordinate{coordinate.lon - source.lon, coordinate.lat - source.lat};

View File

@ -1,11 +1,11 @@
#ifndef DIST_TABLE_WRAPPER_H
#define DIST_TABLE_WRAPPER_H
#include <vector>
#include <utility>
#include <algorithm>
#include <boost/assert.hpp>
#include <cstddef>
#include <algorithm>
#include <utility>
#include <vector>
namespace osrm
{

View File

@ -1,8 +1,8 @@
#ifndef FOR_EACH_PAIR_HPP
#define FOR_EACH_PAIR_HPP
#include <numeric>
#include <iterator>
#include <numeric>
namespace osrm
{

View File

@ -1,13 +1,13 @@
#ifndef GRAPH_LOADER_HPP
#define GRAPH_LOADER_HPP
#include "util/fingerprint.hpp"
#include "util/exception.hpp"
#include "util/simple_logger.hpp"
#include "extractor/external_memory_node.hpp"
#include "extractor/node_based_edge.hpp"
#include "extractor/query_node.hpp"
#include "extractor/restriction.hpp"
#include "util/exception.hpp"
#include "util/fingerprint.hpp"
#include "util/simple_logger.hpp"
#include "util/typedefs.hpp"
#include <boost/assert.hpp>
@ -121,12 +121,13 @@ NodeID loadEdgesFromFile(std::istream &input_stream,
#ifndef NDEBUG
SimpleLogger().Write() << "Validating loaded edges...";
tbb::parallel_sort(edge_list.begin(), edge_list.end(),
[](const extractor::NodeBasedEdge &lhs, const extractor::NodeBasedEdge &rhs)
{
return (lhs.source < rhs.source) ||
(lhs.source == rhs.source && lhs.target < rhs.target);
});
tbb::parallel_sort(
edge_list.begin(),
edge_list.end(),
[](const extractor::NodeBasedEdge &lhs, const extractor::NodeBasedEdge &rhs) {
return (lhs.source < rhs.source) ||
(lhs.source == rhs.source && lhs.target < rhs.target);
});
for (auto i = 1u; i < edge_list.size(); ++i)
{
const auto &edge = edge_list[i];

View File

@ -3,9 +3,9 @@
/* A set of tools required for guidance in both pre and post-processing */
#include "extractor/guidance/turn_instruction.hpp"
#include "engine/guidance/route_step.hpp"
#include "engine/phantom_node.hpp"
#include "extractor/guidance/turn_instruction.hpp"
#include "util/guidance/bearing_class.hpp"
#include "util/guidance/entry_class.hpp"
#include "util/simple_logger.hpp"

View File

@ -33,10 +33,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <variant/variant.hpp>
#include <vector>
#include <string>
#include <utility>
#include <unordered_map>
#include <utility>
#include <vector>
namespace osrm
{

View File

@ -1,8 +1,8 @@
#ifndef UTIL_JSON_DEEP_COMPARE_HPP
#define UTIL_JSON_DEEP_COMPARE_HPP
#include "util/json_container.hpp"
#include "util/integer_range.hpp"
#include "util/json_container.hpp"
#include <boost/assert.hpp>
@ -24,22 +24,26 @@ struct Comparator : mapbox::util::static_visitor<bool>
{
}
bool operator()(const String &lhs, const String &rhs) const {
bool is_same = lhs.value == rhs.value;
if (!is_same)
{
reason = lhs_path + " (= \"" + lhs.value + "\") != " + rhs_path + " (= \"" + rhs.value + "\")";
}
return is_same;
bool operator()(const String &lhs, const String &rhs) const
{
bool is_same = lhs.value == rhs.value;
if (!is_same)
{
reason = lhs_path + " (= \"" + lhs.value + "\") != " + rhs_path + " (= \"" + rhs.value +
"\")";
}
return is_same;
}
bool operator()(const Number &lhs, const Number &rhs) const {
bool is_same = lhs.value == rhs.value;
if (!is_same)
{
reason = lhs_path + " (= " + std::to_string(lhs.value) + ") != " + rhs_path + " (= " + std::to_string(rhs.value) + ")";
}
return is_same;
bool operator()(const Number &lhs, const Number &rhs) const
{
bool is_same = lhs.value == rhs.value;
if (!is_same)
{
reason = lhs_path + " (= " + std::to_string(lhs.value) + ") != " + rhs_path + " (= " +
std::to_string(rhs.value) + ")";
}
return is_same;
}
bool operator()(const Object &lhs, const Object &rhs) const
@ -82,7 +86,8 @@ struct Comparator : mapbox::util::static_visitor<bool>
const auto &rhs_child = rhs.values.find(key)->second;
const auto &lhs_child = lhs.values.find(key)->second;
auto is_same = mapbox::util::apply_visitor(
Comparator(reason, lhs_path + "." + key, rhs_path + "." + key), lhs_child,
Comparator(reason, lhs_path + "." + key, rhs_path + "." + key),
lhs_child,
rhs_child);
if (!is_same)
{
@ -103,10 +108,12 @@ struct Comparator : mapbox::util::static_visitor<bool>
for (auto i = 0UL; i < lhs.values.size(); ++i)
{
auto is_same = mapbox::util::apply_visitor(
Comparator(reason, lhs_path + "[" + std::to_string(i) + "]",
rhs_path + "[" + std::to_string(i) + "]"),
lhs.values[i], rhs.values[i]);
auto is_same =
mapbox::util::apply_visitor(Comparator(reason,
lhs_path + "[" + std::to_string(i) + "]",
rhs_path + "[" + std::to_string(i) + "]"),
lhs.values[i],
rhs.values[i]);
if (!is_same)
{
return false;
@ -148,8 +155,8 @@ struct Comparator : mapbox::util::static_visitor<bool>
inline bool compare(const Value &reference, const Value &result, std::string &reason)
{
return mapbox::util::apply_visitor(Comparator(reason, "reference", "result"), reference,
result);
return mapbox::util::apply_visitor(
Comparator(reason, "reference", "result"), reference, result);
}
}
}

View File

@ -9,10 +9,10 @@
#include "osrm/json_container.hpp"
#include <ostream>
#include <vector>
#include <iterator>
#include <ostream>
#include <string>
#include <vector>
namespace osrm
{

View File

@ -2,8 +2,8 @@
#define LUA_UTIL_HPP
extern "C" {
#include <lua.h>
#include <lauxlib.h>
#include <lua.h>
#include <lualib.h>
}

View File

@ -1,9 +1,9 @@
#ifndef MATRIX_GRAPH_WRAPPER_H
#define MATRIX_GRAPH_WRAPPER_H
#include <vector>
#include <cstddef>
#include <iterator>
#include <vector>
#include "util/typedefs.hpp"
@ -20,7 +20,9 @@ template <typename T> class MatrixGraphWrapper
{
public:
MatrixGraphWrapper(std::vector<T> table, const std::size_t number_of_nodes)
: table_(std::move(table)), number_of_nodes_(number_of_nodes){}
: table_(std::move(table)), number_of_nodes_(number_of_nodes)
{
}
std::size_t GetNumberOfNodes() const { return number_of_nodes_; }

View File

@ -1,10 +1,10 @@
#ifndef NODE_BASED_GRAPH_HPP
#define NODE_BASED_GRAPH_HPP
#include "util/dynamic_graph.hpp"
#include "extractor/node_based_edge.hpp"
#include "util/graph_utils.hpp"
#include "extractor/guidance/classification_data.hpp"
#include "extractor/node_based_edge.hpp"
#include "util/dynamic_graph.hpp"
#include "util/graph_utils.hpp"
#include <tbb/parallel_sort.h>
@ -68,9 +68,9 @@ NodeBasedDynamicGraphFromEdges(std::size_t number_of_nodes,
const std::vector<extractor::NodeBasedEdge> &input_edge_list)
{
auto edges_list = directedEdgesFromCompressed<NodeBasedDynamicGraph::InputEdge>(
input_edge_list, [](NodeBasedDynamicGraph::InputEdge &output_edge,
const extractor::NodeBasedEdge &input_edge)
{
input_edge_list,
[](NodeBasedDynamicGraph::InputEdge &output_edge,
const extractor::NodeBasedEdge &input_edge) {
output_edge.data.distance = static_cast<int>(input_edge.weight);
BOOST_ASSERT(output_edge.data.distance > 0);

View File

@ -1,8 +1,8 @@
#ifndef PERCENT_HPP
#define PERCENT_HPP
#include <iostream>
#include <atomic>
#include <iostream>
namespace osrm
{

Some files were not shown because too many files have changed in this diff Show More