Format with clang-format 3.8
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
#include "engine/plugins/plugin_base.hpp"
|
||||
#include "engine/plugins/match.hpp"
|
||||
#include "engine/plugins/plugin_base.hpp"
|
||||
|
||||
#include "engine/map_matching/bayes_classifier.hpp"
|
||||
#include "engine/api/match_parameters.hpp"
|
||||
#include "engine/api/match_api.hpp"
|
||||
#include "engine/api/match_parameters.hpp"
|
||||
#include "engine/map_matching/bayes_classifier.hpp"
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
#include "util/integer_range.hpp"
|
||||
#include "util/json_logger.hpp"
|
||||
@@ -34,9 +34,10 @@ void filterCandidates(const std::vector<util::Coordinate> &coordinates,
|
||||
|
||||
if (coordinates.size() - 1 > current_coordinate && 0 < current_coordinate)
|
||||
{
|
||||
double turn_angle = util::coordinate_calculation::computeAngle(
|
||||
coordinates[current_coordinate - 1], coordinates[current_coordinate],
|
||||
coordinates[current_coordinate + 1]);
|
||||
double turn_angle =
|
||||
util::coordinate_calculation::computeAngle(coordinates[current_coordinate - 1],
|
||||
coordinates[current_coordinate],
|
||||
coordinates[current_coordinate + 1]);
|
||||
|
||||
// sharp turns indicate a possible uturn
|
||||
if (turn_angle <= 90.0 || turn_angle >= 270.0)
|
||||
@@ -52,24 +53,29 @@ void filterCandidates(const std::vector<util::Coordinate> &coordinates,
|
||||
}
|
||||
|
||||
// sort by forward id, then by reverse id and then by distance
|
||||
std::sort(
|
||||
candidates.begin(), candidates.end(),
|
||||
[](const PhantomNodeWithDistance &lhs, const PhantomNodeWithDistance &rhs)
|
||||
{
|
||||
return lhs.phantom_node.forward_segment_id.id < rhs.phantom_node.forward_segment_id.id ||
|
||||
(lhs.phantom_node.forward_segment_id.id == rhs.phantom_node.forward_segment_id.id &&
|
||||
(lhs.phantom_node.reverse_segment_id.id < rhs.phantom_node.reverse_segment_id.id ||
|
||||
(lhs.phantom_node.reverse_segment_id.id == rhs.phantom_node.reverse_segment_id.id &&
|
||||
lhs.distance < rhs.distance)));
|
||||
});
|
||||
std::sort(candidates.begin(),
|
||||
candidates.end(),
|
||||
[](const PhantomNodeWithDistance &lhs, const PhantomNodeWithDistance &rhs) {
|
||||
return lhs.phantom_node.forward_segment_id.id <
|
||||
rhs.phantom_node.forward_segment_id.id ||
|
||||
(lhs.phantom_node.forward_segment_id.id ==
|
||||
rhs.phantom_node.forward_segment_id.id &&
|
||||
(lhs.phantom_node.reverse_segment_id.id <
|
||||
rhs.phantom_node.reverse_segment_id.id ||
|
||||
(lhs.phantom_node.reverse_segment_id.id ==
|
||||
rhs.phantom_node.reverse_segment_id.id &&
|
||||
lhs.distance < rhs.distance)));
|
||||
});
|
||||
|
||||
auto new_end = std::unique(
|
||||
candidates.begin(), candidates.end(),
|
||||
[](const PhantomNodeWithDistance &lhs, const PhantomNodeWithDistance &rhs)
|
||||
{
|
||||
return lhs.phantom_node.forward_segment_id.id == rhs.phantom_node.forward_segment_id.id &&
|
||||
lhs.phantom_node.reverse_segment_id.id == rhs.phantom_node.reverse_segment_id.id;
|
||||
});
|
||||
auto new_end =
|
||||
std::unique(candidates.begin(),
|
||||
candidates.end(),
|
||||
[](const PhantomNodeWithDistance &lhs, const PhantomNodeWithDistance &rhs) {
|
||||
return lhs.phantom_node.forward_segment_id.id ==
|
||||
rhs.phantom_node.forward_segment_id.id &&
|
||||
lhs.phantom_node.reverse_segment_id.id ==
|
||||
rhs.phantom_node.reverse_segment_id.id;
|
||||
});
|
||||
candidates.resize(new_end - candidates.begin());
|
||||
|
||||
if (!allow_uturn)
|
||||
@@ -92,9 +98,9 @@ void filterCandidates(const std::vector<util::Coordinate> &coordinates,
|
||||
}
|
||||
|
||||
// sort by distance to make pruning effective
|
||||
std::sort(candidates.begin(), candidates.end(),
|
||||
[](const PhantomNodeWithDistance &lhs, const PhantomNodeWithDistance &rhs)
|
||||
{
|
||||
std::sort(candidates.begin(),
|
||||
candidates.end(),
|
||||
[](const PhantomNodeWithDistance &lhs, const PhantomNodeWithDistance &rhs) {
|
||||
return lhs.distance < rhs.distance;
|
||||
});
|
||||
}
|
||||
@@ -129,9 +135,10 @@ Status MatchPlugin::HandleRequest(const api::MatchParameters ¶meters,
|
||||
else
|
||||
{
|
||||
search_radiuses.resize(parameters.coordinates.size());
|
||||
std::transform(parameters.radiuses.begin(), parameters.radiuses.end(),
|
||||
search_radiuses.begin(), [](const boost::optional<double> &maybe_radius)
|
||||
{
|
||||
std::transform(parameters.radiuses.begin(),
|
||||
parameters.radiuses.end(),
|
||||
search_radiuses.begin(),
|
||||
[](const boost::optional<double> &maybe_radius) {
|
||||
if (maybe_radius)
|
||||
{
|
||||
return *maybe_radius * RADIUS_MULTIPLIER;
|
||||
@@ -147,9 +154,9 @@ Status MatchPlugin::HandleRequest(const api::MatchParameters ¶meters,
|
||||
auto candidates_lists = GetPhantomNodesInRange(parameters, search_radiuses);
|
||||
|
||||
filterCandidates(parameters.coordinates, candidates_lists);
|
||||
if (std::all_of(candidates_lists.begin(), candidates_lists.end(),
|
||||
[](const std::vector<PhantomNodeWithDistance> &candidates)
|
||||
{
|
||||
if (std::all_of(candidates_lists.begin(),
|
||||
candidates_lists.end(),
|
||||
[](const std::vector<PhantomNodeWithDistance> &candidates) {
|
||||
return candidates.empty();
|
||||
}))
|
||||
{
|
||||
@@ -159,8 +166,8 @@ Status MatchPlugin::HandleRequest(const api::MatchParameters ¶meters,
|
||||
}
|
||||
|
||||
// call the actual map matching
|
||||
SubMatchingList sub_matchings = map_matching(candidates_lists, parameters.coordinates,
|
||||
parameters.timestamps, parameters.radiuses);
|
||||
SubMatchingList sub_matchings = map_matching(
|
||||
candidates_lists, parameters.coordinates, parameters.timestamps, parameters.radiuses);
|
||||
|
||||
if (sub_matchings.size() == 0)
|
||||
{
|
||||
@@ -183,7 +190,8 @@ Status MatchPlugin::HandleRequest(const api::MatchParameters ¶meters,
|
||||
BOOST_ASSERT(current_phantom_node_pair.target_phantom.IsValid());
|
||||
sub_routes[index].segment_end_coordinates.emplace_back(current_phantom_node_pair);
|
||||
}
|
||||
// force uturns to be on, since we split the phantom nodes anyway and only have bi-directional
|
||||
// force uturns to be on, since we split the phantom nodes anyway and only have
|
||||
// bi-directional
|
||||
// phantom nodes for possible uturns
|
||||
shortest_path(sub_routes[index].segment_end_coordinates, {false}, sub_routes[index]);
|
||||
BOOST_ASSERT(sub_routes[index].shortest_path_length != INVALID_EDGE_WEIGHT);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "engine/plugins/nearest.hpp"
|
||||
#include "engine/api/nearest_parameters.hpp"
|
||||
#include "engine/api/nearest_api.hpp"
|
||||
#include "engine/api/nearest_parameters.hpp"
|
||||
#include "engine/phantom_node.hpp"
|
||||
#include "util/integer_range.hpp"
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "engine/plugins/table.hpp"
|
||||
|
||||
#include "engine/api/table_parameters.hpp"
|
||||
#include "engine/api/table_api.hpp"
|
||||
#include "engine/api/table_parameters.hpp"
|
||||
#include "engine/routing_algorithms/many_to_many.hpp"
|
||||
#include "engine/search_engine_data.hpp"
|
||||
#include "util/string_util.hpp"
|
||||
#include "util/json_container.hpp"
|
||||
#include "util/string_util.hpp"
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
@@ -40,8 +40,8 @@ Status TablePlugin::HandleRequest(const api::TableParameters ¶ms, util::json
|
||||
|
||||
if (params.bearings.size() > 0 && params.coordinates.size() != params.bearings.size())
|
||||
{
|
||||
return Error("InvalidOptions", "Number of bearings does not match number of coordinates",
|
||||
result);
|
||||
return Error(
|
||||
"InvalidOptions", "Number of bearings does not match number of coordinates", result);
|
||||
}
|
||||
|
||||
// Empty sources or destinations means the user wants all of them included, respectively
|
||||
|
||||
+27
-17
@@ -1,21 +1,21 @@
|
||||
#include "engine/plugins/plugin_base.hpp"
|
||||
#include "engine/plugins/tile.hpp"
|
||||
#include "engine/plugins/plugin_base.hpp"
|
||||
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
#include "util/web_mercator.hpp"
|
||||
#include "util/vector_tile.hpp"
|
||||
#include "util/web_mercator.hpp"
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/geometries.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/multi/geometries/multi_linestring.hpp>
|
||||
|
||||
#include <protozero/varint.hpp>
|
||||
#include <protozero/pbf_writer.hpp>
|
||||
#include <protozero/varint.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
@@ -171,8 +171,8 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
double min_lon, min_lat, max_lon, max_lat;
|
||||
|
||||
// Convert the z,x,y mercator tile coordinates into WGS84 lon/lat values
|
||||
util::web_mercator::xyzToWGS84(parameters.x, parameters.y, parameters.z, min_lon, min_lat,
|
||||
max_lon, max_lat);
|
||||
util::web_mercator::xyzToWGS84(
|
||||
parameters.x, parameters.y, parameters.z, min_lon, min_lat, max_lon, max_lat);
|
||||
|
||||
util::Coordinate southwest{util::FloatLongitude(min_lon), util::FloatLatitude(min_lat)};
|
||||
util::Coordinate northeast{util::FloatLongitude(max_lon), util::FloatLatitude(max_lat)};
|
||||
@@ -242,8 +242,8 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
// TODO: extract speed values for compressed and uncompressed geometries
|
||||
|
||||
// Convert tile coordinates into mercator coordinates
|
||||
util::web_mercator::xyzToMercator(parameters.x, parameters.y, parameters.z, min_lon, min_lat,
|
||||
max_lon, max_lat);
|
||||
util::web_mercator::xyzToMercator(
|
||||
parameters.x, parameters.y, parameters.z, min_lon, min_lat, max_lon, max_lat);
|
||||
const detail::BBox tile_bbox{min_lon, min_lat, max_lon, max_lat};
|
||||
|
||||
// Protobuf serialized blocks when objects go out of scope, hence
|
||||
@@ -317,10 +317,12 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
max_datasource_id = std::max(max_datasource_id, reverse_datasource);
|
||||
|
||||
const auto encode_tile_line = [&layer_writer, &edge, &id, &max_datasource_id](
|
||||
const detail::FixedLine &tile_line, const std::uint32_t speed_kmh,
|
||||
const std::size_t duration, const std::uint8_t datasource,
|
||||
std::int32_t &start_x, std::int32_t &start_y)
|
||||
{
|
||||
const detail::FixedLine &tile_line,
|
||||
const std::uint32_t speed_kmh,
|
||||
const std::size_t duration,
|
||||
const std::uint8_t datasource,
|
||||
std::int32_t &start_x,
|
||||
std::int32_t &start_y) {
|
||||
// Here, we save the two attributes for our feature: the speed and the
|
||||
// is_small
|
||||
// boolean. We onl serve up speeds from 0-139, so all we do is save the
|
||||
@@ -377,8 +379,12 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
auto tile_line = coordinatesToTileLine(a, b, tile_bbox);
|
||||
if (!tile_line.empty())
|
||||
{
|
||||
encode_tile_line(tile_line, speed_kmh, weight_offsets[forward_weight],
|
||||
forward_datasource, start_x, start_y);
|
||||
encode_tile_line(tile_line,
|
||||
speed_kmh,
|
||||
weight_offsets[forward_weight],
|
||||
forward_datasource,
|
||||
start_x,
|
||||
start_y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,8 +402,12 @@ Status TilePlugin::HandleRequest(const api::TileParameters ¶meters, std::str
|
||||
auto tile_line = coordinatesToTileLine(b, a, tile_bbox);
|
||||
if (!tile_line.empty())
|
||||
{
|
||||
encode_tile_line(tile_line, speed_kmh, weight_offsets[reverse_weight],
|
||||
reverse_datasource, start_x, start_y);
|
||||
encode_tile_line(tile_line,
|
||||
speed_kmh,
|
||||
weight_offsets[reverse_weight],
|
||||
reverse_datasource,
|
||||
start_x,
|
||||
start_y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,22 +4,22 @@
|
||||
|
||||
#include "engine/api/trip_api.hpp"
|
||||
#include "engine/api/trip_parameters.hpp"
|
||||
#include "engine/trip/trip_nearest_neighbour.hpp"
|
||||
#include "engine/trip/trip_farthest_insertion.hpp"
|
||||
#include "engine/trip/trip_brute_force.hpp"
|
||||
#include "util/dist_table_wrapper.hpp" // to access the dist table more easily
|
||||
#include "util/matrix_graph_wrapper.hpp" // wrapper to use tarjan scc on dist table
|
||||
#include "engine/trip/trip_farthest_insertion.hpp"
|
||||
#include "engine/trip/trip_nearest_neighbour.hpp"
|
||||
#include "util/dist_table_wrapper.hpp" // to access the dist table more easily
|
||||
#include "util/json_container.hpp"
|
||||
#include "util/matrix_graph_wrapper.hpp" // wrapper to use tarjan scc on dist table
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <cstdlib>
|
||||
#include <algorithm>
|
||||
#include <cstdlib>
|
||||
#include <iterator>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <iterator>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -210,8 +210,8 @@ Status TripPlugin::HandleRequest(const api::TripParameters ¶meters,
|
||||
}
|
||||
else
|
||||
{
|
||||
scc_route = trip::FarthestInsertionTrip(route_begin, route_end, number_of_locations,
|
||||
result_table);
|
||||
scc_route = trip::FarthestInsertionTrip(
|
||||
route_begin, route_end, number_of_locations, result_table);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "engine/plugins/viaroute.hpp"
|
||||
#include "engine/datafacade/datafacade_base.hpp"
|
||||
#include "engine/api/route_api.hpp"
|
||||
#include "engine/datafacade/datafacade_base.hpp"
|
||||
#include "engine/status.hpp"
|
||||
|
||||
#include "util/for_each_pair.hpp"
|
||||
@@ -50,8 +50,9 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter
|
||||
auto phantom_node_pairs = GetPhantomNodes(route_parameters);
|
||||
if (phantom_node_pairs.size() != route_parameters.coordinates.size())
|
||||
{
|
||||
return Error("NoSegment", std::string("Could not find a matching segment for coordinate ") +
|
||||
std::to_string(phantom_node_pairs.size()),
|
||||
return Error("NoSegment",
|
||||
std::string("Could not find a matching segment for coordinate ") +
|
||||
std::to_string(phantom_node_pairs.size()),
|
||||
json_result);
|
||||
}
|
||||
BOOST_ASSERT(phantom_node_pairs.size() == route_parameters.coordinates.size());
|
||||
@@ -64,8 +65,7 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter
|
||||
|
||||
InternalRouteResult raw_route;
|
||||
auto build_phantom_pairs = [&raw_route, continue_straight_at_waypoint](
|
||||
const PhantomNode &first_node, const PhantomNode &second_node)
|
||||
{
|
||||
const PhantomNode &first_node, const PhantomNode &second_node) {
|
||||
raw_route.segment_end_coordinates.push_back(PhantomNodes{first_node, second_node});
|
||||
auto &last_inserted = raw_route.segment_end_coordinates.back();
|
||||
// enable forward direction if possible
|
||||
@@ -77,7 +77,8 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter
|
||||
// enable reverse direction if possible
|
||||
if (last_inserted.source_phantom.reverse_segment_id.id != SPECIAL_SEGMENTID)
|
||||
{
|
||||
last_inserted.source_phantom.reverse_segment_id.enabled |= !continue_straight_at_waypoint;
|
||||
last_inserted.source_phantom.reverse_segment_id.enabled |=
|
||||
!continue_straight_at_waypoint;
|
||||
}
|
||||
};
|
||||
util::for_each_pair(snapped_phantoms, build_phantom_pairs);
|
||||
@@ -95,7 +96,8 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter
|
||||
}
|
||||
else
|
||||
{
|
||||
shortest_path(raw_route.segment_end_coordinates, route_parameters.continue_straight, raw_route);
|
||||
shortest_path(
|
||||
raw_route.segment_end_coordinates, route_parameters.continue_straight, raw_route);
|
||||
}
|
||||
|
||||
// we can only know this after the fact, different SCC ids still
|
||||
@@ -108,9 +110,9 @@ Status ViaRoutePlugin::HandleRequest(const api::RouteParameters &route_parameter
|
||||
else
|
||||
{
|
||||
auto first_component_id = snapped_phantoms.front().component.id;
|
||||
auto not_in_same_component = std::any_of(snapped_phantoms.begin(), snapped_phantoms.end(),
|
||||
[first_component_id](const PhantomNode &node)
|
||||
{
|
||||
auto not_in_same_component = std::any_of(snapped_phantoms.begin(),
|
||||
snapped_phantoms.end(),
|
||||
[first_component_id](const PhantomNode &node) {
|
||||
return node.component.id != first_component_id;
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user