Format with clang-format 3.8
This commit is contained in:
@@ -32,8 +32,14 @@ namespace json
|
||||
namespace detail
|
||||
{
|
||||
|
||||
const constexpr char *modifier_names[] = {"uturn", "sharp right", "right", "slight right",
|
||||
"straight", "slight left", "left", "sharp left"};
|
||||
const constexpr char *modifier_names[] = {"uturn",
|
||||
"sharp right",
|
||||
"right",
|
||||
"slight right",
|
||||
"straight",
|
||||
"slight left",
|
||||
"left",
|
||||
"sharp left"};
|
||||
|
||||
// translations of TurnTypes. Not all types are exposed to the outside world.
|
||||
// invalid types should never be returned as part of the API
|
||||
@@ -158,12 +164,15 @@ util::json::Object makeIntersection(const guidance::Intersection &intersection)
|
||||
util::json::Array entry;
|
||||
|
||||
bearings.values.reserve(intersection.bearings.size());
|
||||
std::copy(intersection.bearings.begin(), intersection.bearings.end(),
|
||||
std::copy(intersection.bearings.begin(),
|
||||
intersection.bearings.end(),
|
||||
std::back_inserter(bearings.values));
|
||||
|
||||
entry.values.reserve(intersection.entry.size());
|
||||
std::transform(intersection.entry.begin(), intersection.entry.end(),
|
||||
std::back_inserter(entry.values), [](const bool has_entry) -> util::json::Value {
|
||||
std::transform(intersection.entry.begin(),
|
||||
intersection.entry.end(),
|
||||
std::back_inserter(entry.values),
|
||||
[](const bool has_entry) -> util::json::Value {
|
||||
if (has_entry)
|
||||
return util::json::True();
|
||||
else
|
||||
@@ -196,8 +205,10 @@ util::json::Object makeRouteStep(guidance::RouteStep step, util::json::Value geo
|
||||
|
||||
util::json::Array intersections;
|
||||
intersections.values.reserve(step.intersections.size());
|
||||
std::transform(step.intersections.begin(), step.intersections.end(),
|
||||
std::back_inserter(intersections.values), makeIntersection);
|
||||
std::transform(step.intersections.begin(),
|
||||
step.intersections.end(),
|
||||
std::back_inserter(intersections.values),
|
||||
makeIntersection);
|
||||
route_step.values["intersections"] = std::move(intersections);
|
||||
|
||||
return route_step;
|
||||
@@ -237,7 +248,8 @@ util::json::Object makeRouteLeg(guidance::RouteLeg leg, util::json::Array steps)
|
||||
return route_leg;
|
||||
}
|
||||
|
||||
util::json::Object makeRouteLeg(guidance::RouteLeg leg, util::json::Array steps, util::json::Object annotation)
|
||||
util::json::Object
|
||||
makeRouteLeg(guidance::RouteLeg leg, util::json::Array steps, util::json::Object annotation)
|
||||
{
|
||||
util::json::Object route_leg = makeRouteLeg(std::move(leg), std::move(steps));
|
||||
route_leg.values["annotation"] = std::move(annotation);
|
||||
@@ -255,14 +267,16 @@ util::json::Array makeRouteLegs(std::vector<guidance::RouteLeg> legs,
|
||||
auto leg = std::move(legs[idx]);
|
||||
util::json::Array json_steps;
|
||||
json_steps.values.reserve(leg.steps.size());
|
||||
std::transform(
|
||||
std::make_move_iterator(leg.steps.begin()), std::make_move_iterator(leg.steps.end()),
|
||||
std::back_inserter(json_steps.values), [&step_geometry_iter](guidance::RouteStep step) {
|
||||
return makeRouteStep(std::move(step), std::move(*step_geometry_iter++));
|
||||
});
|
||||
std::transform(std::make_move_iterator(leg.steps.begin()),
|
||||
std::make_move_iterator(leg.steps.end()),
|
||||
std::back_inserter(json_steps.values),
|
||||
[&step_geometry_iter](guidance::RouteStep step) {
|
||||
return makeRouteStep(std::move(step), std::move(*step_geometry_iter++));
|
||||
});
|
||||
if (annotations.size() > 0)
|
||||
{
|
||||
json_legs.values.push_back(makeRouteLeg(std::move(leg), std::move(json_steps), annotations[idx]));
|
||||
json_legs.values.push_back(
|
||||
makeRouteLeg(std::move(leg), std::move(json_steps), annotations[idx]));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <iterator>
|
||||
#include <stack>
|
||||
#include <utility>
|
||||
@@ -24,8 +24,8 @@ std::uint64_t fastPerpendicularDistance(const util::FloatCoordinate &projected_s
|
||||
{
|
||||
util::FloatCoordinate projected_point_on_segment;
|
||||
std::tie(std::ignore, projected_point_on_segment) =
|
||||
util::coordinate_calculation::projectPointOnSegment(projected_start, projected_target,
|
||||
projected);
|
||||
util::coordinate_calculation::projectPointOnSegment(
|
||||
projected_start, projected_target, projected);
|
||||
auto squared_distance = util::coordinate_calculation::squaredEuclideanDistance(
|
||||
projected, projected_point_on_segment);
|
||||
return squared_distance;
|
||||
@@ -45,10 +45,9 @@ std::vector<util::Coordinate> douglasPeucker(std::vector<util::Coordinate>::cons
|
||||
}
|
||||
|
||||
std::vector<util::FloatCoordinate> projected_coordinates(size);
|
||||
std::transform(begin, end, projected_coordinates.begin(), [](const util::Coordinate coord)
|
||||
{
|
||||
return util::web_mercator::fromWGS84(coord);
|
||||
});
|
||||
std::transform(begin, end, projected_coordinates.begin(), [](const util::Coordinate coord) {
|
||||
return util::web_mercator::fromWGS84(coord);
|
||||
});
|
||||
|
||||
std::vector<bool> is_necessary(size, false);
|
||||
BOOST_ASSERT(is_necessary.size() >= 2);
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#include "engine/engine.hpp"
|
||||
#include "engine/engine_config.hpp"
|
||||
#include "engine/api/route_parameters.hpp"
|
||||
#include "engine/engine_config.hpp"
|
||||
#include "engine/status.hpp"
|
||||
|
||||
#include "engine/plugins/table.hpp"
|
||||
#include "engine/plugins/match.hpp"
|
||||
#include "engine/plugins/nearest.hpp"
|
||||
#include "engine/plugins/table.hpp"
|
||||
#include "engine/plugins/tile.hpp"
|
||||
#include "engine/plugins/trip.hpp"
|
||||
#include "engine/plugins/viaroute.hpp"
|
||||
#include "engine/plugins/tile.hpp"
|
||||
#include "engine/plugins/match.hpp"
|
||||
|
||||
#include "engine/datafacade/datafacade_base.hpp"
|
||||
#include "engine/datafacade/internal_datafacade.hpp"
|
||||
@@ -137,7 +137,8 @@ Engine::Engine(EngineConfig &config)
|
||||
{
|
||||
throw util::exception("Invalid file paths given!");
|
||||
}
|
||||
query_data_facade = util::make_unique<datafacade::InternalDataFacade>(config.storage_config);
|
||||
query_data_facade =
|
||||
util::make_unique<datafacade::InternalDataFacade>(config.storage_config);
|
||||
}
|
||||
|
||||
// Register plugins
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#ifndef ENGINE_GUIDANCE_ASSEMBLE_OVERVIEW_HPP
|
||||
#define ENGINE_GUIDANCE_ASSEMBLE_OVERVIEW_HPP
|
||||
|
||||
#include "engine/guidance/leg_geometry.hpp"
|
||||
#include "engine/douglas_peucker.hpp"
|
||||
#include "engine/guidance/leg_geometry.hpp"
|
||||
#include "util/viewport.hpp"
|
||||
|
||||
#include <vector>
|
||||
#include <tuple>
|
||||
#include <numeric>
|
||||
#include <utility>
|
||||
#include <iterator>
|
||||
#include <limits>
|
||||
#include <numeric>
|
||||
#include <tuple>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -23,8 +23,10 @@ namespace
|
||||
|
||||
unsigned calculateOverviewZoomLevel(const std::vector<LegGeometry> &leg_geometries)
|
||||
{
|
||||
util::Coordinate south_west{util::FixedLongitude{std::numeric_limits<int>::max()}, util::FixedLatitude{std::numeric_limits<int>::max()}};
|
||||
util::Coordinate north_east{util::FixedLongitude{std::numeric_limits<int>::min()}, util::FixedLatitude{std::numeric_limits<int>::min()}};
|
||||
util::Coordinate south_west{util::FixedLongitude{std::numeric_limits<int>::max()},
|
||||
util::FixedLatitude{std::numeric_limits<int>::max()}};
|
||||
util::Coordinate north_east{util::FixedLongitude{std::numeric_limits<int>::min()},
|
||||
util::FixedLatitude{std::numeric_limits<int>::min()}};
|
||||
|
||||
for (const auto &leg_geometry : leg_geometries)
|
||||
{
|
||||
@@ -46,7 +48,7 @@ std::vector<util::Coordinate> simplifyGeometry(const std::vector<LegGeometry> &l
|
||||
{
|
||||
std::vector<util::Coordinate> overview_geometry;
|
||||
auto leg_index = 0UL;
|
||||
for (const auto& geometry : leg_geometries)
|
||||
for (const auto &geometry : leg_geometries)
|
||||
{
|
||||
auto simplified_geometry =
|
||||
douglasPeucker(geometry.locations.begin(), geometry.locations.end(), zoom_level);
|
||||
@@ -55,8 +57,8 @@ std::vector<util::Coordinate> simplifyGeometry(const std::vector<LegGeometry> &l
|
||||
{
|
||||
simplified_geometry.pop_back();
|
||||
}
|
||||
overview_geometry.insert(overview_geometry.end(), simplified_geometry.begin(),
|
||||
simplified_geometry.end());
|
||||
overview_geometry.insert(
|
||||
overview_geometry.end(), simplified_geometry.begin(), simplified_geometry.end());
|
||||
}
|
||||
return overview_geometry;
|
||||
}
|
||||
@@ -72,17 +74,19 @@ std::vector<util::Coordinate> assembleOverview(const std::vector<LegGeometry> &l
|
||||
}
|
||||
BOOST_ASSERT(!use_simplification);
|
||||
|
||||
auto overview_size = std::accumulate(leg_geometries.begin(), leg_geometries.end(), 0,
|
||||
[](const std::size_t sum, const LegGeometry &leg_geometry)
|
||||
{
|
||||
return sum + leg_geometry.locations.size();
|
||||
}) -
|
||||
leg_geometries.size() + 1;
|
||||
auto overview_size =
|
||||
std::accumulate(leg_geometries.begin(),
|
||||
leg_geometries.end(),
|
||||
0,
|
||||
[](const std::size_t sum, const LegGeometry &leg_geometry) {
|
||||
return sum + leg_geometry.locations.size();
|
||||
}) -
|
||||
leg_geometries.size() + 1;
|
||||
std::vector<util::Coordinate> overview_geometry;
|
||||
overview_geometry.reserve(overview_size);
|
||||
|
||||
auto leg_index = 0UL;
|
||||
for (const auto& geometry : leg_geometries)
|
||||
for (const auto &geometry : leg_geometries)
|
||||
{
|
||||
auto begin = geometry.locations.begin();
|
||||
auto end = geometry.locations.end();
|
||||
|
||||
@@ -11,16 +11,14 @@ namespace guidance
|
||||
|
||||
Route assembleRoute(const std::vector<RouteLeg> &route_legs)
|
||||
{
|
||||
auto distance = std::accumulate(route_legs.begin(), route_legs.end(), 0.,
|
||||
[](const double sum, const RouteLeg &leg)
|
||||
{
|
||||
return sum + leg.distance;
|
||||
});
|
||||
auto duration = std::accumulate(route_legs.begin(), route_legs.end(), 0.,
|
||||
[](const double sum, const RouteLeg &leg)
|
||||
{
|
||||
return sum + leg.duration;
|
||||
});
|
||||
auto distance = std::accumulate(
|
||||
route_legs.begin(), route_legs.end(), 0., [](const double sum, const RouteLeg &leg) {
|
||||
return sum + leg.distance;
|
||||
});
|
||||
auto duration = std::accumulate(
|
||||
route_legs.begin(), route_legs.end(), 0., [](const double sum, const RouteLeg &leg) {
|
||||
return sum + leg.duration;
|
||||
});
|
||||
|
||||
return Route{duration, distance};
|
||||
}
|
||||
|
||||
@@ -36,7 +36,8 @@ std::pair<short, short> getDepartBearings(const LegGeometry &leg_geometry)
|
||||
const auto turn_coordinate = leg_geometry.locations.front();
|
||||
const auto post_turn_coordinate = *(leg_geometry.locations.begin() + 1);
|
||||
return std::make_pair<short, short>(
|
||||
0, std::round(util::coordinate_calculation::bearing(turn_coordinate, post_turn_coordinate)));
|
||||
0,
|
||||
std::round(util::coordinate_calculation::bearing(turn_coordinate, post_turn_coordinate)));
|
||||
}
|
||||
|
||||
std::pair<short, short> getArriveBearings(const LegGeometry &leg_geometry)
|
||||
|
||||
@@ -104,12 +104,14 @@ RouteStep forwardInto(RouteStep destination, const RouteStep &source)
|
||||
if (destination.geometry_begin < source.geometry_begin)
|
||||
{
|
||||
destination.intersections.insert(destination.intersections.end(),
|
||||
source.intersections.begin(), source.intersections.end());
|
||||
source.intersections.begin(),
|
||||
source.intersections.end());
|
||||
}
|
||||
else
|
||||
{
|
||||
destination.intersections.insert(destination.intersections.begin(),
|
||||
source.intersections.begin(), source.intersections.end());
|
||||
source.intersections.begin(),
|
||||
source.intersections.end());
|
||||
}
|
||||
|
||||
destination.geometry_begin = std::min(destination.geometry_begin, source.geometry_begin);
|
||||
@@ -305,8 +307,8 @@ RouteStep elongate(RouteStep step, const RouteStep &by_step)
|
||||
|
||||
// if we elongate in the back, we only need to copy the intersections to the beginning.
|
||||
// the bearings remain the same, as the location of the turn doesn't change
|
||||
step.intersections.insert(step.intersections.end(), by_step.intersections.begin(),
|
||||
by_step.intersections.end());
|
||||
step.intersections.insert(
|
||||
step.intersections.end(), by_step.intersections.begin(), by_step.intersections.end());
|
||||
}
|
||||
// by_step comes before step -> we append at the front
|
||||
else
|
||||
@@ -319,8 +321,8 @@ RouteStep elongate(RouteStep step, const RouteStep &by_step)
|
||||
// elongating in the front changes the location of the maneuver
|
||||
step.maneuver = by_step.maneuver;
|
||||
|
||||
step.intersections.insert(step.intersections.begin(), by_step.intersections.begin(),
|
||||
by_step.intersections.end());
|
||||
step.intersections.insert(
|
||||
step.intersections.begin(), by_step.intersections.begin(), by_step.intersections.end());
|
||||
}
|
||||
return step;
|
||||
}
|
||||
@@ -738,7 +740,8 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
|
||||
BOOST_ASSERT(geometry.segment_offsets[1] == 1);
|
||||
// geometry offsets have to be adjusted. Move all offsets to the front and reduce by
|
||||
// one. (This is an inplace forward one and reduce by one)
|
||||
std::transform(geometry.segment_offsets.begin() + 1, geometry.segment_offsets.end(),
|
||||
std::transform(geometry.segment_offsets.begin() + 1,
|
||||
geometry.segment_offsets.end(),
|
||||
geometry.segment_offsets.begin(),
|
||||
[](const std::size_t val) { return val - 1; });
|
||||
|
||||
@@ -772,7 +775,8 @@ void trimShortSegments(std::vector<RouteStep> &steps, LegGeometry &geometry)
|
||||
steps.front().geometry_begin = 1;
|
||||
|
||||
// reduce all offsets by one (inplace)
|
||||
std::transform(geometry.segment_offsets.begin(), geometry.segment_offsets.end(),
|
||||
std::transform(geometry.segment_offsets.begin(),
|
||||
geometry.segment_offsets.end(),
|
||||
geometry.segment_offsets.begin(),
|
||||
[](const std::size_t val) { return val - 1; });
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,8 +4,8 @@
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <ostream>
|
||||
#include <tuple>
|
||||
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "engine/polyline_compressor.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <boost/assert.hpp>
|
||||
#include <cmath>
|
||||
#include <cstddef>
|
||||
#include <cstdlib>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -70,20 +70,19 @@ std::string encodePolyline(CoordVectorForwardIter begin, CoordVectorForwardIter
|
||||
delta_numbers.reserve((size - 1) * 2);
|
||||
int current_lat = 0;
|
||||
int current_lon = 0;
|
||||
std::for_each(begin, end,
|
||||
[&delta_numbers, ¤t_lat, ¤t_lon](const util::Coordinate loc)
|
||||
{
|
||||
const int lat_diff =
|
||||
std::round(static_cast<int>(loc.lat) * detail::COORDINATE_TO_POLYLINE) -
|
||||
current_lat;
|
||||
const int lon_diff =
|
||||
std::round(static_cast<int>(loc.lon) * detail::COORDINATE_TO_POLYLINE) -
|
||||
current_lon;
|
||||
delta_numbers.emplace_back(lat_diff);
|
||||
delta_numbers.emplace_back(lon_diff);
|
||||
current_lat += lat_diff;
|
||||
current_lon += lon_diff;
|
||||
});
|
||||
std::for_each(
|
||||
begin, end, [&delta_numbers, ¤t_lat, ¤t_lon](const util::Coordinate loc) {
|
||||
const int lat_diff =
|
||||
std::round(static_cast<int>(loc.lat) * detail::COORDINATE_TO_POLYLINE) -
|
||||
current_lat;
|
||||
const int lon_diff =
|
||||
std::round(static_cast<int>(loc.lon) * detail::COORDINATE_TO_POLYLINE) -
|
||||
current_lon;
|
||||
delta_numbers.emplace_back(lat_diff);
|
||||
delta_numbers.emplace_back(lon_diff);
|
||||
current_lat += lat_diff;
|
||||
current_lon += lon_diff;
|
||||
});
|
||||
return encode(delta_numbers);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user