Format with clang-format 3.8
This commit is contained in:
@@ -6,15 +6,15 @@
|
||||
#include "osrm/engine_config.hpp"
|
||||
#include "osrm/json_container.hpp"
|
||||
|
||||
#include "osrm/status.hpp"
|
||||
#include "osrm/osrm.hpp"
|
||||
#include "osrm/status.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
||||
#include <cstdlib>
|
||||
|
||||
@@ -222,8 +222,10 @@ int main(int argc, const char *argv[]) try
|
||||
}
|
||||
}
|
||||
TIMER_STOP(routes);
|
||||
std::cout << (TIMER_MSEC(routes) / NUM) << "ms/req at " << params.coordinates.size() << " coordinate" << std::endl;
|
||||
std::cout << (TIMER_MSEC(routes) / NUM / params.coordinates.size()) << "ms/coordinate" << std::endl;
|
||||
std::cout << (TIMER_MSEC(routes) / NUM) << "ms/req at " << params.coordinates.size()
|
||||
<< " coordinate" << std::endl;
|
||||
std::cout << (TIMER_MSEC(routes) / NUM / params.coordinates.size()) << "ms/coordinate"
|
||||
<< std::endl;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "engine/geospatial_query.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "extractor/edge_based_node.hpp"
|
||||
#include "util/static_rtree.hpp"
|
||||
#include "util/timing_util.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
#include "extractor/edge_based_node.hpp"
|
||||
#include "extractor/query_node.hpp"
|
||||
#include "mocks/mock_datafacade.hpp"
|
||||
#include "engine/geospatial_query.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
#include "util/timing_util.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <random>
|
||||
@@ -79,14 +79,12 @@ void benchmark(BenchStaticRTree &rtree, unsigned num_queries)
|
||||
util::FixedLatitude{lat_udist(mt_rand)});
|
||||
}
|
||||
|
||||
benchmarkQuery(queries, "raw RTree queries (1 result)", [&rtree](const util::Coordinate &q)
|
||||
{
|
||||
return rtree.Nearest(q, 1);
|
||||
});
|
||||
benchmarkQuery(queries, "raw RTree queries (10 results)", [&rtree](const util::Coordinate &q)
|
||||
{
|
||||
return rtree.Nearest(q, 10);
|
||||
});
|
||||
benchmarkQuery(queries, "raw RTree queries (1 result)", [&rtree](const util::Coordinate &q) {
|
||||
return rtree.Nearest(q, 1);
|
||||
});
|
||||
benchmarkQuery(queries, "raw RTree queries (10 results)", [&rtree](const util::Coordinate &q) {
|
||||
return rtree.Nearest(q, 10);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,11 +93,17 @@ int Contractor::Run()
|
||||
|
||||
util::DeallocatingVector<extractor::EdgeBasedEdge> edge_based_edge_list;
|
||||
|
||||
std::size_t max_edge_id = LoadEdgeExpandedGraph(
|
||||
config.edge_based_graph_path, edge_based_edge_list, config.edge_segment_lookup_path,
|
||||
config.edge_penalty_path, config.segment_speed_lookup_paths,
|
||||
config.turn_penalty_lookup_paths, config.node_based_graph_path, config.geometry_path,
|
||||
config.datasource_names_path, config.datasource_indexes_path, config.rtree_leaf_path);
|
||||
std::size_t max_edge_id = LoadEdgeExpandedGraph(config.edge_based_graph_path,
|
||||
edge_based_edge_list,
|
||||
config.edge_segment_lookup_path,
|
||||
config.edge_penalty_path,
|
||||
config.segment_speed_lookup_paths,
|
||||
config.turn_penalty_lookup_paths,
|
||||
config.node_based_graph_path,
|
||||
config.geometry_path,
|
||||
config.datasource_names_path,
|
||||
config.datasource_indexes_path,
|
||||
config.rtree_leaf_path);
|
||||
|
||||
// Contracting the edge-expanded graph
|
||||
|
||||
@@ -122,8 +128,12 @@ int Contractor::Run()
|
||||
}
|
||||
|
||||
util::DeallocatingVector<QueryEdge> contracted_edge_list;
|
||||
ContractGraph(max_edge_id, edge_based_edge_list, contracted_edge_list, std::move(node_weights),
|
||||
is_core_node, node_levels);
|
||||
ContractGraph(max_edge_id,
|
||||
edge_based_edge_list,
|
||||
contracted_edge_list,
|
||||
std::move(node_weights),
|
||||
is_core_node,
|
||||
node_levels);
|
||||
TIMER_STOP(contraction);
|
||||
|
||||
util::SimpleLogger().Write() << "Contraction took " << TIMER_SEC(contraction) << " sec";
|
||||
@@ -231,9 +241,12 @@ parse_segment_lookup_from_csv_files(const std::vector<std::string> &segment_spee
|
||||
const auto last = end(line);
|
||||
|
||||
// The ulong_long -> uint64_t will likely break on 32bit platforms
|
||||
const auto ok = parse(it, last, //
|
||||
const auto ok = parse(it,
|
||||
last, //
|
||||
(ulong_long >> ',' >> ulong_long >> ',' >> uint_), //
|
||||
from_node_id, to_node_id, speed); //
|
||||
from_node_id,
|
||||
to_node_id,
|
||||
speed); //
|
||||
|
||||
if (!ok || it != last)
|
||||
throw util::exception{"Segment speed file " + filename + " malformed"};
|
||||
@@ -251,7 +264,8 @@ parse_segment_lookup_from_csv_files(const std::vector<std::string> &segment_spee
|
||||
{
|
||||
Mutex::scoped_lock _{flatten_mutex};
|
||||
|
||||
flatten.insert(end(flatten), std::make_move_iterator(begin(local)),
|
||||
flatten.insert(end(flatten),
|
||||
std::make_move_iterator(begin(local)),
|
||||
std::make_move_iterator(end(local)));
|
||||
}
|
||||
};
|
||||
@@ -312,15 +326,20 @@ parse_turn_penalty_lookup_from_csv_files(const std::vector<std::string> &turn_pe
|
||||
|
||||
// The ulong_long -> uint64_t will likely break on 32bit platforms
|
||||
const auto ok =
|
||||
parse(it, last, //
|
||||
parse(it,
|
||||
last, //
|
||||
(ulong_long >> ',' >> ulong_long >> ',' >> ulong_long >> ',' >> double_), //
|
||||
from_node_id, via_node_id, to_node_id, penalty); //
|
||||
from_node_id,
|
||||
via_node_id,
|
||||
to_node_id,
|
||||
penalty); //
|
||||
|
||||
if (!ok || it != last)
|
||||
throw util::exception{"Turn penalty file " + filename + " malformed"};
|
||||
|
||||
map[std::make_tuple(OSMNodeID(from_node_id), OSMNodeID(via_node_id),
|
||||
OSMNodeID(to_node_id))] = std::make_pair(penalty, file_id);
|
||||
map[std::make_tuple(
|
||||
OSMNodeID(from_node_id), OSMNodeID(via_node_id), OSMNodeID(to_node_id))] =
|
||||
std::make_pair(penalty, file_id);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -460,8 +479,10 @@ std::size_t Contractor::LoadEdgeExpandedGraph(
|
||||
};
|
||||
|
||||
// Folds all our actions into independently concurrently executing lambdas
|
||||
tbb::parallel_invoke(parse_segment_speeds, parse_turn_penalties, //
|
||||
maybe_load_internal_to_external_node_map, maybe_load_geometries);
|
||||
tbb::parallel_invoke(parse_segment_speeds,
|
||||
parse_turn_penalties, //
|
||||
maybe_load_internal_to_external_node_map,
|
||||
maybe_load_geometries);
|
||||
|
||||
if (update_edge_weights || update_turn_penalties)
|
||||
{
|
||||
@@ -537,10 +558,11 @@ std::size_t Contractor::LoadEdgeExpandedGraph(
|
||||
if (forward_speed_iter != segment_speed_lookup.end())
|
||||
{
|
||||
int new_segment_weight =
|
||||
std::max(1, static_cast<int>(std::floor(
|
||||
(segment_length * 10.) /
|
||||
(forward_speed_iter->speed_source.speed / 3.6) +
|
||||
.5)));
|
||||
std::max(1,
|
||||
static_cast<int>(std::floor(
|
||||
(segment_length * 10.) /
|
||||
(forward_speed_iter->speed_source.speed / 3.6) +
|
||||
.5)));
|
||||
m_geometry_list[forward_begin + leaf_object.fwd_segment_position].weight =
|
||||
new_segment_weight;
|
||||
m_geometry_datasource[forward_begin + leaf_object.fwd_segment_position] =
|
||||
@@ -587,10 +609,11 @@ std::size_t Contractor::LoadEdgeExpandedGraph(
|
||||
if (reverse_speed_iter != segment_speed_lookup.end())
|
||||
{
|
||||
int new_segment_weight =
|
||||
std::max(1, static_cast<int>(std::floor(
|
||||
(segment_length * 10.) /
|
||||
(reverse_speed_iter->speed_source.speed / 3.6) +
|
||||
.5)));
|
||||
std::max(1,
|
||||
static_cast<int>(std::floor(
|
||||
(segment_length * 10.) /
|
||||
(reverse_speed_iter->speed_source.speed / 3.6) +
|
||||
.5)));
|
||||
m_geometry_list[reverse_begin + rev_segment_position].weight =
|
||||
new_segment_weight;
|
||||
m_geometry_datasource[reverse_begin + rev_segment_position] =
|
||||
@@ -947,8 +970,8 @@ void Contractor::ContractGraph(
|
||||
std::vector<float> node_levels;
|
||||
node_levels.swap(inout_node_levels);
|
||||
|
||||
GraphContractor graph_contractor(max_edge_id + 1, edge_based_edge_list, std::move(node_levels),
|
||||
std::move(node_weights));
|
||||
GraphContractor graph_contractor(
|
||||
max_edge_id + 1, edge_based_edge_list, std::move(node_levels), std::move(node_weights));
|
||||
graph_contractor.Run(config.core_factor);
|
||||
graph_contractor.GetEdges(contracted_edge_list);
|
||||
graph_contractor.GetCoreMarker(is_core_node);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -159,8 +159,8 @@ void CompressedEdgeContainer::CompressEdge(const EdgeID edge_id_1,
|
||||
m_compressed_geometries[list_to_remove_index];
|
||||
|
||||
// found an existing list, append it to the list of edge_id_1
|
||||
edge_bucket_list1.insert(edge_bucket_list1.end(), edge_bucket_list2.begin(),
|
||||
edge_bucket_list2.end());
|
||||
edge_bucket_list1.insert(
|
||||
edge_bucket_list1.end(), edge_bucket_list2.begin(), edge_bucket_list2.end());
|
||||
|
||||
// remove the list of edge_id_2
|
||||
m_edge_id_to_list_index_map.erase(edge_id_2);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "extractor/edge_based_edge.hpp"
|
||||
#include "extractor/edge_based_graph_factory.hpp"
|
||||
#include "extractor/edge_based_edge.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
#include "util/exception.hpp"
|
||||
@@ -9,9 +9,9 @@
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/timing_util.hpp"
|
||||
|
||||
#include "extractor/suffix_table.hpp"
|
||||
#include "extractor/guidance/toolkit.hpp"
|
||||
#include "extractor/guidance/turn_analysis.hpp"
|
||||
#include "extractor/suffix_table.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/numeric/conversion/cast.hpp>
|
||||
@@ -125,8 +125,7 @@ void EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeI
|
||||
|
||||
NodeID current_edge_source_coordinate_id = node_u;
|
||||
|
||||
const auto edge_id_to_segment_id = [](const NodeID edge_based_node_id)
|
||||
{
|
||||
const auto edge_id_to_segment_id = [](const NodeID edge_based_node_id) {
|
||||
if (edge_based_node_id == SPECIAL_NODEID)
|
||||
{
|
||||
return SegmentID{SPECIAL_SEGMENTID, false};
|
||||
@@ -146,13 +145,18 @@ void EdgeBasedGraphFactory::InsertEdgeBasedNode(const NodeID node_u, const NodeI
|
||||
BOOST_ASSERT(current_edge_target_coordinate_id != current_edge_source_coordinate_id);
|
||||
|
||||
// build edges
|
||||
m_edge_based_node_list.emplace_back(
|
||||
edge_id_to_segment_id(forward_data.edge_id),
|
||||
edge_id_to_segment_id(reverse_data.edge_id), current_edge_source_coordinate_id,
|
||||
current_edge_target_coordinate_id, forward_data.name_id,
|
||||
m_compressed_edge_container.GetPositionForID(edge_id_1),
|
||||
m_compressed_edge_container.GetPositionForID(edge_id_2), false, INVALID_COMPONENTID, i,
|
||||
forward_data.travel_mode, reverse_data.travel_mode);
|
||||
m_edge_based_node_list.emplace_back(edge_id_to_segment_id(forward_data.edge_id),
|
||||
edge_id_to_segment_id(reverse_data.edge_id),
|
||||
current_edge_source_coordinate_id,
|
||||
current_edge_target_coordinate_id,
|
||||
forward_data.name_id,
|
||||
m_compressed_edge_container.GetPositionForID(edge_id_1),
|
||||
m_compressed_edge_container.GetPositionForID(edge_id_2),
|
||||
false,
|
||||
INVALID_COMPONENTID,
|
||||
i,
|
||||
forward_data.travel_mode,
|
||||
reverse_data.travel_mode);
|
||||
|
||||
m_edge_based_node_is_startpoint.push_back(forward_data.startpoint ||
|
||||
reverse_data.startpoint);
|
||||
@@ -190,8 +194,11 @@ void EdgeBasedGraphFactory::Run(const std::string &original_edge_data_filename,
|
||||
TIMER_STOP(generate_nodes);
|
||||
|
||||
TIMER_START(generate_edges);
|
||||
GenerateEdgeExpandedEdges(original_edge_data_filename, lua_state, edge_segment_lookup_filename,
|
||||
edge_penalty_filename, generate_edge_lookup);
|
||||
GenerateEdgeExpandedEdges(original_edge_data_filename,
|
||||
lua_state,
|
||||
edge_segment_lookup_filename,
|
||||
edge_penalty_filename,
|
||||
generate_edge_lookup);
|
||||
|
||||
TIMER_STOP(generate_edges);
|
||||
|
||||
@@ -325,8 +332,12 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
// linear number of turns only.
|
||||
util::Percent progress(m_node_based_graph->GetNumberOfNodes());
|
||||
SuffixTable street_name_suffix_table(lua_state);
|
||||
guidance::TurnAnalysis turn_analysis(*m_node_based_graph, m_node_info_list, *m_restriction_map,
|
||||
m_barrier_nodes, m_compressed_edge_container, name_table,
|
||||
guidance::TurnAnalysis turn_analysis(*m_node_based_graph,
|
||||
m_node_info_list,
|
||||
*m_restriction_map,
|
||||
m_barrier_nodes,
|
||||
m_compressed_edge_container,
|
||||
name_table,
|
||||
street_name_suffix_table);
|
||||
|
||||
bearing_class_by_node_based_node.resize(m_node_based_graph->GetNumberOfNodes(),
|
||||
@@ -349,9 +360,12 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
|
||||
// the entry class depends on the turn, so we have to classify the interesction for
|
||||
// every edge
|
||||
const auto turn_classification = classifyIntersection(
|
||||
node_v, turn_analysis.getIntersection(node_u, edge_from_u), *m_node_based_graph,
|
||||
m_compressed_edge_container, m_node_info_list);
|
||||
const auto turn_classification =
|
||||
classifyIntersection(node_v,
|
||||
turn_analysis.getIntersection(node_u, edge_from_u),
|
||||
*m_node_based_graph,
|
||||
m_compressed_edge_container,
|
||||
m_node_info_list);
|
||||
|
||||
const auto entry_class_id = [&](const util::guidance::EntryClass entry_class) {
|
||||
if (0 == entry_class_hash.count(entry_class))
|
||||
@@ -412,8 +426,11 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
|
||||
BOOST_ASSERT(m_compressed_edge_container.HasEntryForID(edge_from_u));
|
||||
original_edge_data_vector.emplace_back(
|
||||
m_compressed_edge_container.GetPositionForID(edge_from_u), edge_data1.name_id,
|
||||
turn_instruction, entry_class_id, edge_data1.travel_mode);
|
||||
m_compressed_edge_container.GetPositionForID(edge_from_u),
|
||||
edge_data1.name_id,
|
||||
turn_instruction,
|
||||
entry_class_id,
|
||||
edge_data1.travel_mode);
|
||||
|
||||
++original_edges_counter;
|
||||
|
||||
@@ -427,8 +444,11 @@ void EdgeBasedGraphFactory::GenerateEdgeExpandedEdges(
|
||||
|
||||
// NOTE: potential overflow here if we hit 2^32 routable edges
|
||||
BOOST_ASSERT(m_edge_based_edge_list.size() <= std::numeric_limits<NodeID>::max());
|
||||
m_edge_based_edge_list.emplace_back(edge_data1.edge_id, edge_data2.edge_id,
|
||||
m_edge_based_edge_list.size(), distance, true,
|
||||
m_edge_based_edge_list.emplace_back(edge_data1.edge_id,
|
||||
edge_data2.edge_id,
|
||||
m_edge_based_edge_list.size(),
|
||||
distance,
|
||||
true,
|
||||
false);
|
||||
|
||||
// Here is where we write out the mapping between the edge-expanded edges, and
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
#include "util/range_table.hpp"
|
||||
|
||||
#include "util/exception.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/timing_util.hpp"
|
||||
#include "util/fingerprint.hpp"
|
||||
#include "util/lua_util.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/timing_util.hpp"
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
@@ -133,8 +133,8 @@ void ExtractionContainers::PrepareNodes()
|
||||
{
|
||||
std::cout << "[extractor] Sorting used nodes ... " << std::flush;
|
||||
TIMER_START(sorting_used_nodes);
|
||||
stxxl::sort(used_node_id_list.begin(), used_node_id_list.end(), OSMNodeIDSTXXLLess(),
|
||||
stxxl_memory);
|
||||
stxxl::sort(
|
||||
used_node_id_list.begin(), used_node_id_list.end(), OSMNodeIDSTXXLLess(), stxxl_memory);
|
||||
TIMER_STOP(sorting_used_nodes);
|
||||
std::cout << "ok, after " << TIMER_SEC(sorting_used_nodes) << "s" << std::endl;
|
||||
|
||||
@@ -147,7 +147,9 @@ void ExtractionContainers::PrepareNodes()
|
||||
|
||||
std::cout << "[extractor] Sorting all nodes ... " << std::flush;
|
||||
TIMER_START(sorting_nodes);
|
||||
stxxl::sort(all_nodes_list.begin(), all_nodes_list.end(), ExternalMemoryNodeSTXXLCompare(),
|
||||
stxxl::sort(all_nodes_list.begin(),
|
||||
all_nodes_list.end(),
|
||||
ExternalMemoryNodeSTXXLCompare(),
|
||||
stxxl_memory);
|
||||
TIMER_STOP(sorting_nodes);
|
||||
std::cout << "ok, after " << TIMER_SEC(sorting_nodes) << "s" << std::endl;
|
||||
@@ -250,8 +252,7 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state)
|
||||
|
||||
// Remove all remaining edges. They are invalid because there are no corresponding nodes for
|
||||
// them. This happens when using osmosis with bbox or polygon to extract smaller areas.
|
||||
auto markSourcesInvalid = [](InternalExtractorEdge &edge)
|
||||
{
|
||||
auto markSourcesInvalid = [](InternalExtractorEdge &edge) {
|
||||
util::SimpleLogger().Write(LogLevel::logWARNING) << "Found invalid node reference "
|
||||
<< edge.result.source;
|
||||
edge.result.source = SPECIAL_NODEID;
|
||||
@@ -315,13 +316,15 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state)
|
||||
|
||||
if (has_segment_function)
|
||||
{
|
||||
luabind::call_function<void>(
|
||||
segment_state, "segment_function", boost::cref(edge_iterator->source_coordinate),
|
||||
boost::cref(*node_iterator), distance, boost::ref(edge_iterator->weight_data));
|
||||
luabind::call_function<void>(segment_state,
|
||||
"segment_function",
|
||||
boost::cref(edge_iterator->source_coordinate),
|
||||
boost::cref(*node_iterator),
|
||||
distance,
|
||||
boost::ref(edge_iterator->weight_data));
|
||||
}
|
||||
|
||||
const double weight = [distance](const InternalExtractorEdge::WeightData &data)
|
||||
{
|
||||
const double weight = [distance](const InternalExtractorEdge::WeightData &data) {
|
||||
switch (data.type)
|
||||
{
|
||||
case InternalExtractorEdge::WeightType::EDGE_DURATION:
|
||||
@@ -361,8 +364,7 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state)
|
||||
|
||||
// Remove all remaining edges. They are invalid because there are no corresponding nodes for
|
||||
// them. This happens when using osmosis with bbox or polygon to extract smaller areas.
|
||||
auto markTargetsInvalid = [](InternalExtractorEdge &edge)
|
||||
{
|
||||
auto markTargetsInvalid = [](InternalExtractorEdge &edge) {
|
||||
util::SimpleLogger().Write(LogLevel::logWARNING) << "Found invalid node reference "
|
||||
<< edge.result.target;
|
||||
edge.result.target = SPECIAL_NODEID;
|
||||
@@ -374,8 +376,10 @@ void ExtractionContainers::PrepareEdges(lua_State *segment_state)
|
||||
// Sort edges by start.
|
||||
std::cout << "[extractor] Sorting edges by renumbered start ... " << std::flush;
|
||||
TIMER_START(sort_edges_by_renumbered_start);
|
||||
stxxl::sort(all_edges_list.begin(), all_edges_list.end(),
|
||||
CmpEdgeByInternalStartThenInternalTargetID(), stxxl_memory);
|
||||
stxxl::sort(all_edges_list.begin(),
|
||||
all_edges_list.end(),
|
||||
CmpEdgeByInternalStartThenInternalTargetID(),
|
||||
stxxl_memory);
|
||||
TIMER_STOP(sort_edges_by_renumbered_start);
|
||||
std::cout << "ok, after " << TIMER_SEC(sort_edges_by_renumbered_start) << "s" << std::endl;
|
||||
|
||||
@@ -582,15 +586,19 @@ void ExtractionContainers::PrepareRestrictions()
|
||||
{
|
||||
std::cout << "[extractor] Sorting used ways ... " << std::flush;
|
||||
TIMER_START(sort_ways);
|
||||
stxxl::sort(way_start_end_id_list.begin(), way_start_end_id_list.end(),
|
||||
FirstAndLastSegmentOfWayStxxlCompare(), stxxl_memory);
|
||||
stxxl::sort(way_start_end_id_list.begin(),
|
||||
way_start_end_id_list.end(),
|
||||
FirstAndLastSegmentOfWayStxxlCompare(),
|
||||
stxxl_memory);
|
||||
TIMER_STOP(sort_ways);
|
||||
std::cout << "ok, after " << TIMER_SEC(sort_ways) << "s" << std::endl;
|
||||
|
||||
std::cout << "[extractor] Sorting " << restrictions_list.size() << " restriction. by from... "
|
||||
<< std::flush;
|
||||
TIMER_START(sort_restrictions);
|
||||
stxxl::sort(restrictions_list.begin(), restrictions_list.end(), CmpRestrictionContainerByFrom(),
|
||||
stxxl::sort(restrictions_list.begin(),
|
||||
restrictions_list.end(),
|
||||
CmpRestrictionContainerByFrom(),
|
||||
stxxl_memory);
|
||||
TIMER_STOP(sort_restrictions);
|
||||
std::cout << "ok, after " << TIMER_SEC(sort_restrictions) << "s" << std::endl;
|
||||
@@ -682,7 +690,9 @@ void ExtractionContainers::PrepareRestrictions()
|
||||
|
||||
std::cout << "[extractor] Sorting restrictions. by to ... " << std::flush;
|
||||
TIMER_START(sort_restrictions_to);
|
||||
stxxl::sort(restrictions_list.begin(), restrictions_list.end(), CmpRestrictionContainerByTo(),
|
||||
stxxl::sort(restrictions_list.begin(),
|
||||
restrictions_list.end(),
|
||||
CmpRestrictionContainerByTo(),
|
||||
stxxl_memory);
|
||||
TIMER_STOP(sort_restrictions_to);
|
||||
std::cout << "ok, after " << TIMER_SEC(sort_restrictions_to) << "s" << std::endl;
|
||||
|
||||
+49
-25
@@ -46,9 +46,9 @@
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
#include <type_traits>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
#include <type_traits>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
@@ -174,7 +174,8 @@ int Extractor::run()
|
||||
result_node.clear();
|
||||
++number_of_nodes;
|
||||
luabind::call_function<void>(
|
||||
local_context.state, "node_function",
|
||||
local_context.state,
|
||||
"node_function",
|
||||
boost::cref(static_cast<const osmium::Node &>(*entity)),
|
||||
boost::ref(result_node));
|
||||
resulting_nodes.push_back(std::make_pair(x, std::move(result_node)));
|
||||
@@ -183,7 +184,8 @@ int Extractor::run()
|
||||
result_way.clear();
|
||||
++number_of_ways;
|
||||
luabind::call_function<void>(
|
||||
local_context.state, "way_function",
|
||||
local_context.state,
|
||||
"way_function",
|
||||
boost::cref(static_cast<const osmium::Way &>(*entity)),
|
||||
boost::ref(result_way));
|
||||
resulting_ways.push_back(std::make_pair(x, std::move(result_way)));
|
||||
@@ -234,8 +236,10 @@ int Extractor::run()
|
||||
return 1;
|
||||
}
|
||||
|
||||
extraction_containers.PrepareData(config.output_file_name, config.restriction_file_name,
|
||||
config.names_file_name, main_context.state);
|
||||
extraction_containers.PrepareData(config.output_file_name,
|
||||
config.restriction_file_name,
|
||||
config.names_file_name,
|
||||
main_context.state);
|
||||
|
||||
WriteProfileProperties(config.profile_properties_output_path, main_context.properties);
|
||||
|
||||
@@ -268,10 +272,14 @@ int Extractor::run()
|
||||
std::vector<bool> node_is_startpoint;
|
||||
std::vector<EdgeWeight> edge_based_node_weights;
|
||||
std::vector<QueryNode> internal_to_external_node_map;
|
||||
auto graph_size = BuildEdgeExpandedGraph(
|
||||
main_context.state, main_context.properties, internal_to_external_node_map,
|
||||
edge_based_node_list, node_is_startpoint, edge_based_node_weights, edge_based_edge_list,
|
||||
config.intersection_class_data_output_path);
|
||||
auto graph_size = BuildEdgeExpandedGraph(main_context.state,
|
||||
main_context.properties,
|
||||
internal_to_external_node_map,
|
||||
edge_based_node_list,
|
||||
node_is_startpoint,
|
||||
edge_based_node_weights,
|
||||
edge_based_edge_list,
|
||||
config.intersection_class_data_output_path);
|
||||
|
||||
auto number_of_node_based_nodes = graph_size.first;
|
||||
auto max_edge_id = graph_size.second;
|
||||
@@ -290,7 +298,8 @@ int Extractor::run()
|
||||
|
||||
FindComponents(max_edge_id, edge_based_edge_list, edge_based_node_list);
|
||||
|
||||
BuildRTree(std::move(edge_based_node_list), std::move(node_is_startpoint),
|
||||
BuildRTree(std::move(edge_based_node_list),
|
||||
std::move(node_is_startpoint),
|
||||
internal_to_external_node_map);
|
||||
|
||||
TIMER_STOP(rtree);
|
||||
@@ -485,7 +494,10 @@ Extractor::BuildEdgeExpandedGraph(lua_State *lua_state,
|
||||
|
||||
CompressedEdgeContainer compressed_edge_container;
|
||||
GraphCompressor graph_compressor;
|
||||
graph_compressor.Compress(barrier_nodes, traffic_lights, *restriction_map, *node_based_graph,
|
||||
graph_compressor.Compress(barrier_nodes,
|
||||
traffic_lights,
|
||||
*restriction_map,
|
||||
*node_based_graph,
|
||||
compressed_edge_container);
|
||||
|
||||
compressed_edge_container.SerializeInternalVector(config.geometry_output_path);
|
||||
@@ -493,12 +505,19 @@ Extractor::BuildEdgeExpandedGraph(lua_State *lua_state,
|
||||
util::NameTable name_table(config.names_file_name);
|
||||
|
||||
EdgeBasedGraphFactory edge_based_graph_factory(
|
||||
node_based_graph, compressed_edge_container, barrier_nodes, traffic_lights,
|
||||
node_based_graph,
|
||||
compressed_edge_container,
|
||||
barrier_nodes,
|
||||
traffic_lights,
|
||||
std::const_pointer_cast<RestrictionMap const>(restriction_map),
|
||||
internal_to_external_node_map, profile_properties, name_table);
|
||||
internal_to_external_node_map,
|
||||
profile_properties,
|
||||
name_table);
|
||||
|
||||
edge_based_graph_factory.Run(config.edge_output_path, lua_state,
|
||||
config.edge_segment_lookup_path, config.edge_penalty_path,
|
||||
edge_based_graph_factory.Run(config.edge_output_path,
|
||||
lua_state,
|
||||
config.edge_segment_lookup_path,
|
||||
config.edge_penalty_path,
|
||||
config.generate_edge_lookup);
|
||||
|
||||
edge_based_graph_factory.GetEdgeBasedEdges(edge_based_edge_list);
|
||||
@@ -509,9 +528,10 @@ Extractor::BuildEdgeExpandedGraph(lua_State *lua_state,
|
||||
|
||||
const std::size_t number_of_node_based_nodes = node_based_graph->GetNumberOfNodes();
|
||||
|
||||
WriteIntersectionClassificationData(
|
||||
intersection_class_output_file, edge_based_graph_factory.GetBearingClassIds(),
|
||||
edge_based_graph_factory.GetBearingClasses(), edge_based_graph_factory.GetEntryClasses());
|
||||
WriteIntersectionClassificationData(intersection_class_output_file,
|
||||
edge_based_graph_factory.GetBearingClassIds(),
|
||||
edge_based_graph_factory.GetBearingClasses(),
|
||||
edge_based_graph_factory.GetEntryClasses());
|
||||
|
||||
return std::make_pair(number_of_node_based_nodes, max_edge_id);
|
||||
}
|
||||
@@ -568,9 +588,10 @@ void Extractor::BuildRTree(std::vector<EdgeBasedNode> node_based_edge_list,
|
||||
node_based_edge_list.resize(new_size);
|
||||
|
||||
TIMER_START(construction);
|
||||
util::StaticRTree<EdgeBasedNode, std::vector<QueryNode>> rtree(
|
||||
node_based_edge_list, config.rtree_nodes_output_path, config.rtree_leafs_output_path,
|
||||
internal_to_external_node_map);
|
||||
util::StaticRTree<EdgeBasedNode, std::vector<QueryNode>> rtree(node_based_edge_list,
|
||||
config.rtree_nodes_output_path,
|
||||
config.rtree_leafs_output_path,
|
||||
internal_to_external_node_map);
|
||||
|
||||
TIMER_STOP(construction);
|
||||
util::SimpleLogger().Write() << "finished r-tree construction in " << TIMER_SEC(construction)
|
||||
@@ -630,8 +651,10 @@ void Extractor::WriteIntersectionClassificationData(
|
||||
std::vector<unsigned> bearing_counts;
|
||||
bearing_counts.reserve(bearing_classes.size());
|
||||
std::uint64_t total_bearings = 0;
|
||||
for (const auto &bearing_class : bearing_classes){
|
||||
bearing_counts.push_back(static_cast<unsigned>(bearing_class.getAvailableBearings().size()));
|
||||
for (const auto &bearing_class : bearing_classes)
|
||||
{
|
||||
bearing_counts.push_back(
|
||||
static_cast<unsigned>(bearing_class.getAvailableBearings().size()));
|
||||
total_bearings += bearing_class.getAvailableBearings().size();
|
||||
}
|
||||
|
||||
@@ -639,10 +662,11 @@ void Extractor::WriteIntersectionClassificationData(
|
||||
file_out_stream << bearing_class_range_table;
|
||||
|
||||
file_out_stream << total_bearings;
|
||||
for( const auto &bearing_class : bearing_classes)
|
||||
for (const auto &bearing_class : bearing_classes)
|
||||
{
|
||||
const auto &bearings = bearing_class.getAvailableBearings();
|
||||
file_out_stream.write( reinterpret_cast<const char*>(&bearings[0]), sizeof(bearings[0]) * bearings.size() );
|
||||
file_out_stream.write(reinterpret_cast<const char *>(&bearings[0]),
|
||||
sizeof(bearings[0]) * bearings.size());
|
||||
}
|
||||
|
||||
// FIXME
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "util/for_each_pair.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
|
||||
#include <boost/optional/optional.hpp>
|
||||
#include "extractor/extractor_callbacks.hpp"
|
||||
#include <boost/optional/optional.hpp>
|
||||
|
||||
#include <osmium/osm.hpp>
|
||||
|
||||
@@ -42,7 +42,9 @@ void ExtractorCallbacks::ProcessNode(const osmium::Node &input_node,
|
||||
external_memory.all_nodes_list.push_back(
|
||||
{util::toFixed(util::FloatLongitude(input_node.location().lon())),
|
||||
util::toFixed(util::FloatLatitude(input_node.location().lat())),
|
||||
OSMNodeID(input_node.id()), result_node.barrier, result_node.traffic_lights});
|
||||
OSMNodeID(input_node.id()),
|
||||
result_node.barrier,
|
||||
result_node.traffic_lights});
|
||||
}
|
||||
|
||||
void ExtractorCallbacks::ProcessRestriction(
|
||||
@@ -151,7 +153,8 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
|
||||
auto name_length = std::min<unsigned>(MAX_STRING_LENGTH, parsed_way.name.size());
|
||||
|
||||
external_memory.name_char_data.reserve(name_id + name_length);
|
||||
std::copy(parsed_way.name.c_str(), parsed_way.name.c_str() + name_length,
|
||||
std::copy(parsed_way.name.c_str(),
|
||||
parsed_way.name.c_str() + name_length,
|
||||
std::back_inserter(external_memory.name_char_data));
|
||||
|
||||
external_memory.name_lengths.push_back(name_length);
|
||||
@@ -169,7 +172,8 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
|
||||
((parsed_way.forward_speed != parsed_way.backward_speed) ||
|
||||
(parsed_way.forward_travel_mode != parsed_way.backward_travel_mode));
|
||||
|
||||
std::transform(input_way.nodes().begin(), input_way.nodes().end(),
|
||||
std::transform(input_way.nodes().begin(),
|
||||
input_way.nodes().end(),
|
||||
std::back_inserter(external_memory.used_node_id_list),
|
||||
[](const osmium::NodeRef &ref) { return OSMNodeID(ref.ref()); });
|
||||
|
||||
@@ -181,51 +185,82 @@ void ExtractorCallbacks::ProcessWay(const osmium::Way &input_way, const Extracti
|
||||
BOOST_ASSERT(split_edge == false);
|
||||
BOOST_ASSERT(parsed_way.backward_travel_mode != TRAVEL_MODE_INACCESSIBLE);
|
||||
util::for_each_pair(
|
||||
input_way.nodes().crbegin(), input_way.nodes().crend(),
|
||||
input_way.nodes().crbegin(),
|
||||
input_way.nodes().crend(),
|
||||
[&](const osmium::NodeRef &first_node, const osmium::NodeRef &last_node) {
|
||||
external_memory.all_edges_list.push_back(InternalExtractorEdge(
|
||||
OSMNodeID(first_node.ref()), OSMNodeID(last_node.ref()), name_id,
|
||||
backward_weight_data, true, false, parsed_way.roundabout,
|
||||
parsed_way.is_access_restricted, parsed_way.is_startpoint,
|
||||
parsed_way.backward_travel_mode, false, road_classification));
|
||||
external_memory.all_edges_list.push_back(
|
||||
InternalExtractorEdge(OSMNodeID(first_node.ref()),
|
||||
OSMNodeID(last_node.ref()),
|
||||
name_id,
|
||||
backward_weight_data,
|
||||
true,
|
||||
false,
|
||||
parsed_way.roundabout,
|
||||
parsed_way.is_access_restricted,
|
||||
parsed_way.is_startpoint,
|
||||
parsed_way.backward_travel_mode,
|
||||
false,
|
||||
road_classification));
|
||||
});
|
||||
|
||||
external_memory.way_start_end_id_list.push_back(
|
||||
{OSMWayID(input_way.id()), OSMNodeID(input_way.nodes().back().ref()),
|
||||
{OSMWayID(input_way.id()),
|
||||
OSMNodeID(input_way.nodes().back().ref()),
|
||||
OSMNodeID(input_way.nodes()[input_way.nodes().size() - 2].ref()),
|
||||
OSMNodeID(input_way.nodes()[1].ref()), OSMNodeID(input_way.nodes()[0].ref())});
|
||||
OSMNodeID(input_way.nodes()[1].ref()),
|
||||
OSMNodeID(input_way.nodes()[0].ref())});
|
||||
}
|
||||
else
|
||||
{
|
||||
const bool forward_only =
|
||||
split_edge || TRAVEL_MODE_INACCESSIBLE == parsed_way.backward_travel_mode;
|
||||
util::for_each_pair(
|
||||
input_way.nodes().cbegin(), input_way.nodes().cend(),
|
||||
input_way.nodes().cbegin(),
|
||||
input_way.nodes().cend(),
|
||||
[&](const osmium::NodeRef &first_node, const osmium::NodeRef &last_node) {
|
||||
external_memory.all_edges_list.push_back(InternalExtractorEdge(
|
||||
OSMNodeID(first_node.ref()), OSMNodeID(last_node.ref()), name_id,
|
||||
forward_weight_data, true, !forward_only, parsed_way.roundabout,
|
||||
parsed_way.is_access_restricted, parsed_way.is_startpoint,
|
||||
parsed_way.forward_travel_mode, split_edge, road_classification));
|
||||
external_memory.all_edges_list.push_back(
|
||||
InternalExtractorEdge(OSMNodeID(first_node.ref()),
|
||||
OSMNodeID(last_node.ref()),
|
||||
name_id,
|
||||
forward_weight_data,
|
||||
true,
|
||||
!forward_only,
|
||||
parsed_way.roundabout,
|
||||
parsed_way.is_access_restricted,
|
||||
parsed_way.is_startpoint,
|
||||
parsed_way.forward_travel_mode,
|
||||
split_edge,
|
||||
road_classification));
|
||||
});
|
||||
if (split_edge)
|
||||
{
|
||||
BOOST_ASSERT(parsed_way.backward_travel_mode != TRAVEL_MODE_INACCESSIBLE);
|
||||
util::for_each_pair(
|
||||
input_way.nodes().cbegin(), input_way.nodes().cend(),
|
||||
input_way.nodes().cbegin(),
|
||||
input_way.nodes().cend(),
|
||||
[&](const osmium::NodeRef &first_node, const osmium::NodeRef &last_node) {
|
||||
external_memory.all_edges_list.push_back(InternalExtractorEdge(
|
||||
OSMNodeID(first_node.ref()), OSMNodeID(last_node.ref()), name_id,
|
||||
backward_weight_data, false, true, parsed_way.roundabout,
|
||||
parsed_way.is_access_restricted, parsed_way.is_startpoint,
|
||||
parsed_way.backward_travel_mode, true, road_classification));
|
||||
external_memory.all_edges_list.push_back(
|
||||
InternalExtractorEdge(OSMNodeID(first_node.ref()),
|
||||
OSMNodeID(last_node.ref()),
|
||||
name_id,
|
||||
backward_weight_data,
|
||||
false,
|
||||
true,
|
||||
parsed_way.roundabout,
|
||||
parsed_way.is_access_restricted,
|
||||
parsed_way.is_startpoint,
|
||||
parsed_way.backward_travel_mode,
|
||||
true,
|
||||
road_classification));
|
||||
});
|
||||
}
|
||||
|
||||
external_memory.way_start_end_id_list.push_back(
|
||||
{OSMWayID(input_way.id()), OSMNodeID(input_way.nodes().back().ref()),
|
||||
{OSMWayID(input_way.id()),
|
||||
OSMNodeID(input_way.nodes().back().ref()),
|
||||
OSMNodeID(input_way.nodes()[input_way.nodes().size() - 2].ref()),
|
||||
OSMNodeID(input_way.nodes()[1].ref()), OSMNodeID(input_way.nodes()[0].ref())});
|
||||
OSMNodeID(input_way.nodes()[1].ref()),
|
||||
OSMNodeID(input_way.nodes()[0].ref())});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,10 +151,10 @@ void GraphCompressor::Compress(const std::unordered_set<NodeID> &barrier_nodes,
|
||||
restriction_map.FixupArrivingTurnRestriction(node_w, node_v, node_u, graph);
|
||||
|
||||
// store compressed geometry in container
|
||||
geometry_compressor.CompressEdge(forward_e1, forward_e2, node_v, node_w,
|
||||
forward_weight1, forward_weight2);
|
||||
geometry_compressor.CompressEdge(reverse_e1, reverse_e2, node_v, node_u,
|
||||
reverse_weight1, reverse_weight2);
|
||||
geometry_compressor.CompressEdge(
|
||||
forward_e1, forward_e2, node_v, node_w, forward_weight1, forward_weight2);
|
||||
geometry_compressor.CompressEdge(
|
||||
reverse_e1, reverse_e2, node_v, node_u, reverse_weight1, reverse_weight2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "extractor/guidance/constants.hpp"
|
||||
#include "extractor/guidance/intersection_generator.hpp"
|
||||
#include "extractor/guidance/constants.hpp"
|
||||
#include "extractor/guidance/toolkit.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "extractor/guidance/constants.hpp"
|
||||
#include "extractor/guidance/intersection_handler.hpp"
|
||||
#include "extractor/guidance/constants.hpp"
|
||||
#include "extractor/guidance/toolkit.hpp"
|
||||
|
||||
#include "util/guidance/toolkit.hpp"
|
||||
@@ -38,12 +38,13 @@ IntersectionHandler::~IntersectionHandler() {}
|
||||
|
||||
std::size_t IntersectionHandler::countValid(const Intersection &intersection) const
|
||||
{
|
||||
return std::count_if(intersection.begin(), intersection.end(),
|
||||
[](const ConnectedRoad &road) { return road.entry_allowed; });
|
||||
return std::count_if(intersection.begin(), intersection.end(), [](const ConnectedRoad &road) {
|
||||
return road.entry_allowed;
|
||||
});
|
||||
}
|
||||
|
||||
TurnType::Enum IntersectionHandler::findBasicTurnType(const EdgeID via_edge,
|
||||
const ConnectedRoad &road) const
|
||||
const ConnectedRoad &road) const
|
||||
{
|
||||
|
||||
const auto &in_data = node_based_graph.GetEdgeData(via_edge);
|
||||
@@ -94,9 +95,9 @@ TurnInstruction IntersectionHandler::getInstructionForObvious(const std::size_t
|
||||
// obvious turn onto a through street is a merge
|
||||
if (through_street)
|
||||
{
|
||||
return {TurnType::Merge, road.turn.angle > STRAIGHT_ANGLE
|
||||
? DirectionModifier::SlightRight
|
||||
: DirectionModifier::SlightLeft};
|
||||
return {TurnType::Merge,
|
||||
road.turn.angle > STRAIGHT_ANGLE ? DirectionModifier::SlightRight
|
||||
: DirectionModifier::SlightLeft};
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "extractor/guidance/constants.hpp"
|
||||
#include "extractor/guidance/intersection_scenario_three_way.hpp"
|
||||
#include "extractor/guidance/constants.hpp"
|
||||
#include "extractor/guidance/toolkit.hpp"
|
||||
|
||||
#include "util/guidance/toolkit.hpp"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "extractor/guidance/constants.hpp"
|
||||
#include "extractor/guidance/motorway_handler.hpp"
|
||||
#include "extractor/guidance/constants.hpp"
|
||||
#include "extractor/guidance/toolkit.hpp"
|
||||
|
||||
#include "util/guidance/toolkit.hpp"
|
||||
@@ -233,8 +233,10 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in
|
||||
BOOST_ASSERT(!detail::isRampClass(intersection[1].turn.eid, node_based_graph));
|
||||
|
||||
intersection[1].turn.instruction =
|
||||
getInstructionForObvious(intersection.size(), via_eid,
|
||||
isThroughStreet(1, intersection), intersection[1]);
|
||||
getInstructionForObvious(intersection.size(),
|
||||
via_eid,
|
||||
isThroughStreet(1, intersection),
|
||||
intersection[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -275,8 +277,10 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in
|
||||
if (exiting_motorways == 2 && intersection.size() == 2)
|
||||
{
|
||||
intersection[1].turn.instruction =
|
||||
getInstructionForObvious(intersection.size(), via_eid,
|
||||
isThroughStreet(1, intersection), intersection[1]);
|
||||
getInstructionForObvious(intersection.size(),
|
||||
via_eid,
|
||||
isThroughStreet(1, intersection),
|
||||
intersection[1]);
|
||||
util::SimpleLogger().Write(logDEBUG) << "Disabled U-Turn on a freeway";
|
||||
intersection[0].entry_allowed = false; // UTURN on the freeway
|
||||
}
|
||||
@@ -329,7 +333,9 @@ Intersection MotorwayHandler::fromMotorway(const EdgeID via_eid, Intersection in
|
||||
}
|
||||
}
|
||||
}
|
||||
assignFork(via_eid, intersection[third_valid], intersection[second_valid],
|
||||
assignFork(via_eid,
|
||||
intersection[third_valid],
|
||||
intersection[second_valid],
|
||||
intersection[first_valid]);
|
||||
}
|
||||
else
|
||||
@@ -389,8 +395,10 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
|
||||
else // passing by the end of a motorway
|
||||
{
|
||||
intersection[1].turn.instruction =
|
||||
getInstructionForObvious(intersection.size(), via_eid,
|
||||
isThroughStreet(1, intersection), intersection[1]);
|
||||
getInstructionForObvious(intersection.size(),
|
||||
via_eid,
|
||||
isThroughStreet(1, intersection),
|
||||
intersection[1]);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -414,8 +422,10 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
|
||||
else // passing the end of a highway
|
||||
{
|
||||
intersection[2].turn.instruction =
|
||||
getInstructionForObvious(intersection.size(), via_eid,
|
||||
isThroughStreet(2, intersection), intersection[2]);
|
||||
getInstructionForObvious(intersection.size(),
|
||||
via_eid,
|
||||
isThroughStreet(2, intersection),
|
||||
intersection[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -472,8 +482,8 @@ Intersection MotorwayHandler::fromRamp(const EdgeID via_eid, Intersection inters
|
||||
}
|
||||
else if (detail::isMotorwayClass(edge_data.road_classification.road_class))
|
||||
{
|
||||
road.turn.instruction = {TurnType::Merge, passed_highway_entry
|
||||
? DirectionModifier::SlightRight
|
||||
road.turn.instruction = {TurnType::Merge,
|
||||
passed_highway_entry ? DirectionModifier::SlightRight
|
||||
: DirectionModifier::SlightLeft};
|
||||
}
|
||||
else
|
||||
@@ -516,16 +526,18 @@ Intersection MotorwayHandler::fallback(Intersection intersection) const
|
||||
road.turn.instruction = {type, DirectionModifier::Straight};
|
||||
else
|
||||
{
|
||||
road.turn.instruction = {type, road.turn.angle > STRAIGHT_ANGLE
|
||||
? DirectionModifier::SlightLeft
|
||||
: DirectionModifier::SlightRight};
|
||||
road.turn.instruction = {type,
|
||||
road.turn.angle > STRAIGHT_ANGLE
|
||||
? DirectionModifier::SlightLeft
|
||||
: DirectionModifier::SlightRight};
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
road.turn.instruction = {type, road.turn.angle < STRAIGHT_ANGLE
|
||||
? DirectionModifier::SlightLeft
|
||||
: DirectionModifier::SlightRight};
|
||||
road.turn.instruction = {type,
|
||||
road.turn.angle < STRAIGHT_ANGLE
|
||||
? DirectionModifier::SlightLeft
|
||||
: DirectionModifier::SlightRight};
|
||||
}
|
||||
}
|
||||
return intersection;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "extractor/guidance/constants.hpp"
|
||||
#include "extractor/guidance/roundabout_handler.hpp"
|
||||
#include "extractor/guidance/constants.hpp"
|
||||
#include "extractor/guidance/toolkit.hpp"
|
||||
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
@@ -52,8 +52,11 @@ operator()(const NodeID from_nid, const EdgeID via_eid, Intersection intersectio
|
||||
const auto flags = getRoundaboutFlags(from_nid, via_eid, intersection);
|
||||
const auto roundabout_type = getRoundaboutType(node_based_graph.GetTarget(via_eid));
|
||||
// find the radius of the roundabout
|
||||
return handleRoundabouts(roundabout_type, via_eid, flags.on_roundabout,
|
||||
flags.can_exit_separately, std::move(intersection));
|
||||
return handleRoundabouts(roundabout_type,
|
||||
via_eid,
|
||||
flags.on_roundabout,
|
||||
flags.can_exit_separately,
|
||||
std::move(intersection));
|
||||
}
|
||||
|
||||
detail::RoundaboutFlags RoundaboutHandler::getRoundaboutFlags(
|
||||
@@ -169,9 +172,13 @@ bool RoundaboutHandler::qualifiesAsRoundaboutIntersection(
|
||||
|
||||
// there is a single non-roundabout edge
|
||||
const auto src_coordinate = getCoordinate(node);
|
||||
const auto next_coordinate = getRepresentativeCoordinate(
|
||||
node, node_based_graph.GetTarget(edge), edge, edge_data.reversed,
|
||||
compressed_edge_container, node_info_list);
|
||||
const auto next_coordinate =
|
||||
getRepresentativeCoordinate(node,
|
||||
node_based_graph.GetTarget(edge),
|
||||
edge,
|
||||
edge_data.reversed,
|
||||
compressed_edge_container,
|
||||
node_info_list);
|
||||
result.push_back(
|
||||
util::coordinate_calculation::bearing(src_coordinate, next_coordinate));
|
||||
break;
|
||||
@@ -206,40 +213,40 @@ RoundaboutType RoundaboutHandler::getRoundaboutType(const NodeID nid) const
|
||||
unsigned roundabout_name_id = 0;
|
||||
std::unordered_set<unsigned> connected_names;
|
||||
|
||||
const auto getNextOnRoundabout = [this, &roundabout_name_id,
|
||||
&connected_names](const NodeID node) {
|
||||
EdgeID continue_edge = SPECIAL_EDGEID;
|
||||
for (const auto edge : node_based_graph.GetAdjacentEdgeRange(node))
|
||||
{
|
||||
const auto &edge_data = node_based_graph.GetEdgeData(edge);
|
||||
if (!edge_data.reversed && edge_data.roundabout)
|
||||
const auto getNextOnRoundabout =
|
||||
[this, &roundabout_name_id, &connected_names](const NodeID node) {
|
||||
EdgeID continue_edge = SPECIAL_EDGEID;
|
||||
for (const auto edge : node_based_graph.GetAdjacentEdgeRange(node))
|
||||
{
|
||||
if (SPECIAL_EDGEID != continue_edge)
|
||||
const auto &edge_data = node_based_graph.GetEdgeData(edge);
|
||||
if (!edge_data.reversed && edge_data.roundabout)
|
||||
{
|
||||
// fork in roundabout
|
||||
return SPECIAL_EDGEID;
|
||||
if (SPECIAL_EDGEID != continue_edge)
|
||||
{
|
||||
// fork in roundabout
|
||||
return SPECIAL_EDGEID;
|
||||
}
|
||||
// roundabout does not keep its name
|
||||
if (roundabout_name_id != 0 && roundabout_name_id != edge_data.name_id &&
|
||||
requiresNameAnnounced(name_table.GetNameForID(roundabout_name_id),
|
||||
name_table.GetNameForID(edge_data.name_id),
|
||||
street_name_suffix_table))
|
||||
{
|
||||
return SPECIAL_EDGEID;
|
||||
}
|
||||
|
||||
roundabout_name_id = edge_data.name_id;
|
||||
|
||||
continue_edge = edge;
|
||||
}
|
||||
// roundabout does not keep its name
|
||||
if (roundabout_name_id != 0 && roundabout_name_id != edge_data.name_id &&
|
||||
requiresNameAnnounced(name_table.GetNameForID(roundabout_name_id),
|
||||
name_table.GetNameForID(edge_data.name_id),
|
||||
street_name_suffix_table))
|
||||
else if (!edge_data.roundabout)
|
||||
{
|
||||
return SPECIAL_EDGEID;
|
||||
// remember all connected road names
|
||||
connected_names.insert(edge_data.name_id);
|
||||
}
|
||||
|
||||
roundabout_name_id = edge_data.name_id;
|
||||
|
||||
continue_edge = edge;
|
||||
}
|
||||
else if (!edge_data.roundabout)
|
||||
{
|
||||
// remember all connected road names
|
||||
connected_names.insert(edge_data.name_id);
|
||||
}
|
||||
}
|
||||
return continue_edge;
|
||||
};
|
||||
return continue_edge;
|
||||
};
|
||||
// the roundabout radius has to be the same for all locations we look at it from
|
||||
// to guarantee this, we search the full roundabout for its vertices
|
||||
// and select the three smalles ids
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "extractor/guidance/constants.hpp"
|
||||
#include "extractor/guidance/turn_analysis.hpp"
|
||||
#include "extractor/guidance/constants.hpp"
|
||||
|
||||
#include "util/coordinate.hpp"
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
@@ -109,9 +109,9 @@ TurnAnalysis::setTurnTypes(const NodeID from_nid, const EdgeID, Intersection int
|
||||
const EdgeID onto_edge = road.turn.eid;
|
||||
const NodeID to_nid = node_based_graph.GetTarget(onto_edge);
|
||||
|
||||
road.turn.instruction = {TurnType::Turn, (from_nid == to_nid)
|
||||
? DirectionModifier::UTurn
|
||||
: getTurnDirection(road.turn.angle)};
|
||||
road.turn.instruction = {TurnType::Turn,
|
||||
(from_nid == to_nid) ? DirectionModifier::UTurn
|
||||
: getTurnDirection(road.turn.angle)};
|
||||
}
|
||||
return intersection;
|
||||
}
|
||||
@@ -142,7 +142,8 @@ Intersection TurnAnalysis::handleSliproads(const EdgeID source_edge_id,
|
||||
|
||||
// Find the continuation of the intersection we're on
|
||||
auto next_road = std::find_if(
|
||||
intersection.begin(), intersection.end(),
|
||||
intersection.begin(),
|
||||
intersection.end(),
|
||||
[this, source_edge_data](const ConnectedRoad &road) {
|
||||
const auto road_edge_data = node_based_graph.GetEdgeData(road.turn.eid);
|
||||
// Test to see if the source edge and the one we're looking at are the same road
|
||||
|
||||
@@ -52,10 +52,10 @@ classifyIntersection(NodeID nid,
|
||||
turns.push_back({road.entry_allowed, bearing});
|
||||
}
|
||||
|
||||
std::sort(turns.begin(), turns.end(),
|
||||
[](const TurnPossibility left, const TurnPossibility right) {
|
||||
return left.bearing < right.bearing;
|
||||
});
|
||||
std::sort(
|
||||
turns.begin(), turns.end(), [](const TurnPossibility left, const TurnPossibility right) {
|
||||
return left.bearing < right.bearing;
|
||||
});
|
||||
|
||||
util::guidance::EntryClass entry_class;
|
||||
util::guidance::BearingClass bearing_class;
|
||||
@@ -81,7 +81,7 @@ classifyIntersection(NodeID nid,
|
||||
std::size_t number = 0;
|
||||
if (canBeDiscretized)
|
||||
{
|
||||
if(util::guidance::BearingClass::getDiscreteBearing(turns.back().bearing) <
|
||||
if (util::guidance::BearingClass::getDiscreteBearing(turns.back().bearing) <
|
||||
util::guidance::BearingClass::getDiscreteBearing(turns.front().bearing))
|
||||
{
|
||||
turns.insert(turns.begin(), turns.back());
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "extractor/guidance/turn_handler.hpp"
|
||||
#include "extractor/guidance/constants.hpp"
|
||||
#include "extractor/guidance/intersection_scenario_three_way.hpp"
|
||||
#include "extractor/guidance/toolkit.hpp"
|
||||
#include "extractor/guidance/turn_handler.hpp"
|
||||
|
||||
#include "util/guidance/toolkit.hpp"
|
||||
|
||||
@@ -257,9 +257,11 @@ Intersection TurnHandler::handleComplexTurn(const EdgeID via_edge, Intersection
|
||||
// check whether the obvious choice is actually a through street
|
||||
if (obvious_index != 0)
|
||||
{
|
||||
intersection[obvious_index].turn.instruction = getInstructionForObvious(
|
||||
intersection.size(), via_edge, isThroughStreet(obvious_index, intersection),
|
||||
intersection[obvious_index]);
|
||||
intersection[obvious_index].turn.instruction =
|
||||
getInstructionForObvious(intersection.size(),
|
||||
via_edge,
|
||||
isThroughStreet(obvious_index, intersection),
|
||||
intersection[obvious_index]);
|
||||
if (has_same_name_turn &&
|
||||
node_based_graph.GetEdgeData(intersection[obvious_index].turn.eid).name_id !=
|
||||
in_data.name_id &&
|
||||
@@ -314,8 +316,10 @@ Intersection TurnHandler::handleComplexTurn(const EdgeID via_edge, Intersection
|
||||
}
|
||||
else if (fork_range.second - fork_range.first == 2)
|
||||
{
|
||||
assignFork(via_edge, intersection[fork_range.second],
|
||||
intersection[fork_range.first + 1], intersection[fork_range.first]);
|
||||
assignFork(via_edge,
|
||||
intersection[fork_range.second],
|
||||
intersection[fork_range.first + 1],
|
||||
intersection[fork_range.first]);
|
||||
}
|
||||
// assign left/right turns
|
||||
intersection = assignLeftTurns(via_edge, std::move(intersection), fork_range.second + 1);
|
||||
|
||||
@@ -48,8 +48,8 @@ RestrictionMap::RestrictionMap(const std::vector<TurnRestriction> &restriction_l
|
||||
}
|
||||
++m_count;
|
||||
BOOST_ASSERT(restriction.to.node < std::numeric_limits<NodeID>::max());
|
||||
m_restriction_bucket_list.at(index)
|
||||
.emplace_back(restriction.to.node, restriction.flags.is_only);
|
||||
m_restriction_bucket_list.at(index).emplace_back(restriction.to.node,
|
||||
restriction.flags.is_only);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
#include "extractor/profile_properties.hpp"
|
||||
|
||||
#include "extractor/external_memory_node.hpp"
|
||||
#include "util/lua_util.hpp"
|
||||
#include "util/exception.hpp"
|
||||
#include "util/lua_util.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/regex.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/algorithm/string/regex.hpp>
|
||||
#include <boost/optional/optional.hpp>
|
||||
#include <boost/ref.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
@@ -48,8 +48,8 @@ void RestrictionParser::ReadRestrictionExceptions(lua_State *lua_state)
|
||||
{
|
||||
luabind::set_pcall_callback(&luaErrorCallback);
|
||||
// get list of turn restriction exceptions
|
||||
luabind::call_function<void>(lua_state, "get_exceptions",
|
||||
boost::ref(restriction_exceptions));
|
||||
luabind::call_function<void>(
|
||||
lua_state, "get_exceptions", boost::ref(restriction_exceptions));
|
||||
const unsigned exception_count = restriction_exceptions.size();
|
||||
util::SimpleLogger().Write() << "Found " << exception_count
|
||||
<< " exceptions to turn restrictions:";
|
||||
@@ -117,8 +117,7 @@ RestrictionParser::TryParse(const osmium::Relation &relation) const
|
||||
// "restriction:<transportation_type>")
|
||||
if (key.size() > 11)
|
||||
{
|
||||
const auto ex_suffix = [&](const std::string &exception)
|
||||
{
|
||||
const auto ex_suffix = [&](const std::string &exception) {
|
||||
return boost::algorithm::ends_with(key, exception);
|
||||
};
|
||||
bool is_actually_restricted =
|
||||
@@ -201,13 +200,12 @@ bool RestrictionParser::ShouldIgnoreRestriction(const std::string &except_tag_st
|
||||
std::vector<std::string> exceptions;
|
||||
boost::algorithm::split_regex(exceptions, except_tag_string, boost::regex("[;][ ]*"));
|
||||
|
||||
return std::any_of(std::begin(exceptions), std::end(exceptions),
|
||||
[&](const std::string ¤t_string)
|
||||
{
|
||||
return std::end(restriction_exceptions) !=
|
||||
std::find(std::begin(restriction_exceptions),
|
||||
std::end(restriction_exceptions), current_string);
|
||||
});
|
||||
return std::any_of(
|
||||
std::begin(exceptions), std::end(exceptions), [&](const std::string ¤t_string) {
|
||||
return std::end(restriction_exceptions) != std::find(std::begin(restriction_exceptions),
|
||||
std::end(restriction_exceptions),
|
||||
current_string);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
#include "extractor/scripting_environment.hpp"
|
||||
|
||||
#include "extractor/external_memory_node.hpp"
|
||||
#include "extractor/extraction_helper_functions.hpp"
|
||||
#include "extractor/extraction_node.hpp"
|
||||
#include "extractor/extraction_way.hpp"
|
||||
#include "extractor/internal_extractor_edge.hpp"
|
||||
#include "extractor/external_memory_node.hpp"
|
||||
#include "extractor/raster_source.hpp"
|
||||
#include "extractor/profile_properties.hpp"
|
||||
#include "extractor/raster_source.hpp"
|
||||
#include "util/exception.hpp"
|
||||
#include "util/lua_util.hpp"
|
||||
#include "util/make_unique.hpp"
|
||||
#include "util/exception.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <luabind/tag_function.hpp>
|
||||
#include <luabind/iterator_policy.hpp>
|
||||
#include <luabind/operator.hpp>
|
||||
#include <luabind/tag_function.hpp>
|
||||
|
||||
#include <osmium/osm.hpp>
|
||||
|
||||
@@ -44,10 +44,9 @@ template <class T> double lonToDouble(T const &object)
|
||||
return static_cast<double>(util::toFloating(object.lon));
|
||||
}
|
||||
|
||||
// Luabind does not like memr funs: instead of casting to the function's signature (mem fun ptr) we simply wrap it
|
||||
auto get_nodes_for_way(const osmium::Way& way) -> decltype(way.nodes()) {
|
||||
return way.nodes();
|
||||
}
|
||||
// Luabind does not like memr funs: instead of casting to the function's signature (mem fun ptr) we
|
||||
// simply wrap it
|
||||
auto get_nodes_for_way(const osmium::Way &way) -> decltype(way.nodes()) { return way.nodes(); }
|
||||
|
||||
// Error handler
|
||||
int luaErrorCallback(lua_State *state)
|
||||
@@ -78,19 +77,19 @@ void ScriptingEnvironment::InitContext(ScriptingEnvironment::Context &context)
|
||||
luabind::module(context.state)
|
||||
[luabind::def("durationIsValid", durationIsValid),
|
||||
luabind::def("parseDuration", parseDuration),
|
||||
luabind::class_<TravelMode>("mode")
|
||||
.enum_("enums")[luabind::value("inaccessible", TRAVEL_MODE_INACCESSIBLE),
|
||||
luabind::value("driving", TRAVEL_MODE_DRIVING),
|
||||
luabind::value("cycling", TRAVEL_MODE_CYCLING),
|
||||
luabind::value("walking", TRAVEL_MODE_WALKING),
|
||||
luabind::value("ferry", TRAVEL_MODE_FERRY),
|
||||
luabind::value("train", TRAVEL_MODE_TRAIN),
|
||||
luabind::value("pushing_bike", TRAVEL_MODE_PUSHING_BIKE),
|
||||
luabind::value("steps_up", TRAVEL_MODE_STEPS_UP),
|
||||
luabind::value("steps_down", TRAVEL_MODE_STEPS_DOWN),
|
||||
luabind::value("river_up", TRAVEL_MODE_RIVER_UP),
|
||||
luabind::value("river_down", TRAVEL_MODE_RIVER_DOWN),
|
||||
luabind::value("route", TRAVEL_MODE_ROUTE)],
|
||||
luabind::class_<TravelMode>("mode").enum_(
|
||||
"enums")[luabind::value("inaccessible", TRAVEL_MODE_INACCESSIBLE),
|
||||
luabind::value("driving", TRAVEL_MODE_DRIVING),
|
||||
luabind::value("cycling", TRAVEL_MODE_CYCLING),
|
||||
luabind::value("walking", TRAVEL_MODE_WALKING),
|
||||
luabind::value("ferry", TRAVEL_MODE_FERRY),
|
||||
luabind::value("train", TRAVEL_MODE_TRAIN),
|
||||
luabind::value("pushing_bike", TRAVEL_MODE_PUSHING_BIKE),
|
||||
luabind::value("steps_up", TRAVEL_MODE_STEPS_UP),
|
||||
luabind::value("steps_down", TRAVEL_MODE_STEPS_DOWN),
|
||||
luabind::value("river_up", TRAVEL_MODE_RIVER_UP),
|
||||
luabind::value("river_down", TRAVEL_MODE_RIVER_DOWN),
|
||||
luabind::value("route", TRAVEL_MODE_ROUTE)],
|
||||
luabind::class_<SourceContainer>("sources")
|
||||
.def(luabind::constructor<>())
|
||||
.def("load", &SourceContainer::LoadRasterSource)
|
||||
@@ -101,16 +100,20 @@ void ScriptingEnvironment::InitContext(ScriptingEnvironment::Context &context)
|
||||
|
||||
luabind::class_<ProfileProperties>("ProfileProperties")
|
||||
.def(luabind::constructor<>())
|
||||
.property("traffic_signal_penalty", &ProfileProperties::GetTrafficSignalPenalty,
|
||||
.property("traffic_signal_penalty",
|
||||
&ProfileProperties::GetTrafficSignalPenalty,
|
||||
&ProfileProperties::SetTrafficSignalPenalty)
|
||||
.property("u_turn_penalty", &ProfileProperties::GetUturnPenalty,
|
||||
.property("u_turn_penalty",
|
||||
&ProfileProperties::GetUturnPenalty,
|
||||
&ProfileProperties::SetUturnPenalty)
|
||||
.def_readwrite("use_turn_restrictions", &ProfileProperties::use_turn_restrictions)
|
||||
.def_readwrite("continue_straight_at_waypoint", &ProfileProperties::continue_straight_at_waypoint),
|
||||
.def_readwrite("continue_straight_at_waypoint",
|
||||
&ProfileProperties::continue_straight_at_waypoint),
|
||||
|
||||
luabind::class_<std::vector<std::string>>("vector")
|
||||
.def("Add", static_cast<void (std::vector<std::string>::*)(const std::string &)>(
|
||||
&std::vector<std::string>::push_back)),
|
||||
luabind::class_<std::vector<std::string>>("vector").def(
|
||||
"Add",
|
||||
static_cast<void (std::vector<std::string>::*)(const std::string &)>(
|
||||
&std::vector<std::string>::push_back)),
|
||||
|
||||
luabind::class_<osmium::Location>("Location")
|
||||
.def<location_member_ptr_type>("lat", &osmium::Location::lat)
|
||||
@@ -136,18 +139,19 @@ void ScriptingEnvironment::InitContext(ScriptingEnvironment::Context &context)
|
||||
.def_readwrite("is_access_restricted", &ExtractionWay::is_access_restricted)
|
||||
.def_readwrite("is_startpoint", &ExtractionWay::is_startpoint)
|
||||
.def_readwrite("duration", &ExtractionWay::duration)
|
||||
.property("forward_mode", &ExtractionWay::get_forward_mode,
|
||||
&ExtractionWay::set_forward_mode)
|
||||
.property("backward_mode", &ExtractionWay::get_backward_mode,
|
||||
.property(
|
||||
"forward_mode", &ExtractionWay::get_forward_mode, &ExtractionWay::set_forward_mode)
|
||||
.property("backward_mode",
|
||||
&ExtractionWay::get_backward_mode,
|
||||
&ExtractionWay::set_backward_mode),
|
||||
luabind::class_<osmium::WayNodeList>("WayNodeList")
|
||||
.def(luabind::constructor<>()),
|
||||
luabind::class_<osmium::WayNodeList>("WayNodeList").def(luabind::constructor<>()),
|
||||
luabind::class_<osmium::NodeRef>("NodeRef")
|
||||
.def(luabind::constructor<>())
|
||||
// Dear ambitious reader: registering .location() as in:
|
||||
// .def("location", +[](const osmium::NodeRef& nref){ return nref.location(); })
|
||||
// will crash at runtime, since we're not (yet?) using libosnmium's NodeLocationsForWays cache
|
||||
.def("id", &osmium::NodeRef::ref),
|
||||
.def(luabind::constructor<>())
|
||||
// Dear ambitious reader: registering .location() as in:
|
||||
// .def("location", +[](const osmium::NodeRef& nref){ return nref.location(); })
|
||||
// will crash at runtime, since we're not (yet?) using libosnmium's
|
||||
// NodeLocationsForWays cache
|
||||
.def("id", &osmium::NodeRef::ref),
|
||||
luabind::class_<osmium::Way>("Way")
|
||||
.def("get_value_by_key", &osmium::Way::get_value_by_key)
|
||||
.def("get_value_by_key", &get_value_by_key<osmium::Way>)
|
||||
|
||||
@@ -26,8 +26,8 @@ SuffixTable::SuffixTable(lua_State *lua_state)
|
||||
try
|
||||
{
|
||||
// call lua profile to compute turn penalty
|
||||
luabind::call_function<void>(lua_state, "get_name_suffix_list",
|
||||
boost::ref(suffixes_vector));
|
||||
luabind::call_function<void>(
|
||||
lua_state, "get_name_suffix_list", boost::ref(suffixes_vector));
|
||||
}
|
||||
catch (const luabind::error &er)
|
||||
{
|
||||
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
#include "osrm/osrm.hpp"
|
||||
#include "engine/api/match_parameters.hpp"
|
||||
#include "engine/api/nearest_parameters.hpp"
|
||||
#include "engine/api/route_parameters.hpp"
|
||||
#include "engine/api/table_parameters.hpp"
|
||||
#include "engine/api/nearest_parameters.hpp"
|
||||
#include "engine/api/trip_parameters.hpp"
|
||||
#include "engine/api/match_parameters.hpp"
|
||||
#include "engine/engine.hpp"
|
||||
#include "engine/status.hpp"
|
||||
#include "engine/engine_config.hpp"
|
||||
#include "engine/status.hpp"
|
||||
#include "util/make_unique.hpp"
|
||||
|
||||
namespace osrm
|
||||
|
||||
@@ -19,15 +19,21 @@ namespace api
|
||||
namespace detail
|
||||
{
|
||||
template <typename T>
|
||||
using is_grammar_t = std::integral_constant<bool, std::is_same<RouteParametersGrammar<>, T>::value ||
|
||||
std::is_same<TableParametersGrammar<>, T>::value || std::is_same<NearestParametersGrammar<>, T>::value ||
|
||||
std::is_same<TripParametersGrammar<>, T>::value || std::is_same<MatchParametersGrammar<>, T>::value ||
|
||||
std::is_same<TileParametersGrammar<>, T>::value>;
|
||||
using is_grammar_t =
|
||||
std::integral_constant<bool,
|
||||
std::is_same<RouteParametersGrammar<>, T>::value ||
|
||||
std::is_same<TableParametersGrammar<>, T>::value ||
|
||||
std::is_same<NearestParametersGrammar<>, T>::value ||
|
||||
std::is_same<TripParametersGrammar<>, T>::value ||
|
||||
std::is_same<MatchParametersGrammar<>, T>::value ||
|
||||
std::is_same<TileParametersGrammar<>, T>::value>;
|
||||
|
||||
template <typename ParameterT, typename GrammarT,
|
||||
template <typename ParameterT,
|
||||
typename GrammarT,
|
||||
typename std::enable_if<detail::is_parameter_t<ParameterT>::value, int>::type = 0,
|
||||
typename std::enable_if<detail::is_grammar_t<GrammarT>::value, int>::type = 0>
|
||||
boost::optional<ParameterT> parseParameters(std::string::iterator &iter, const std::string::iterator end)
|
||||
boost::optional<ParameterT> parseParameters(std::string::iterator &iter,
|
||||
const std::string::iterator end)
|
||||
{
|
||||
using It = std::decay<decltype(iter)>::type;
|
||||
|
||||
@@ -36,7 +42,8 @@ boost::optional<ParameterT> parseParameters(std::string::iterator &iter, const s
|
||||
try
|
||||
{
|
||||
ParameterT parameters;
|
||||
const auto ok = boost::spirit::qi::parse(iter, end, grammar(boost::phoenix::ref(parameters)));
|
||||
const auto ok =
|
||||
boost::spirit::qi::parse(iter, end, grammar(boost::phoenix::ref(parameters)));
|
||||
|
||||
// return move(a.b) is needed to move b out of a and then return the rvalue by implicit move
|
||||
if (ok && iter == end)
|
||||
@@ -54,37 +61,47 @@ boost::optional<ParameterT> parseParameters(std::string::iterator &iter, const s
|
||||
} // ns detail
|
||||
|
||||
template <>
|
||||
boost::optional<engine::api::RouteParameters> parseParameters(std::string::iterator &iter, const std::string::iterator end)
|
||||
boost::optional<engine::api::RouteParameters> parseParameters(std::string::iterator &iter,
|
||||
const std::string::iterator end)
|
||||
{
|
||||
return detail::parseParameters<engine::api::RouteParameters, RouteParametersGrammar<>>(iter, end);
|
||||
return detail::parseParameters<engine::api::RouteParameters, RouteParametersGrammar<>>(iter,
|
||||
end);
|
||||
}
|
||||
|
||||
template <>
|
||||
boost::optional<engine::api::TableParameters> parseParameters(std::string::iterator &iter, const std::string::iterator end)
|
||||
boost::optional<engine::api::TableParameters> parseParameters(std::string::iterator &iter,
|
||||
const std::string::iterator end)
|
||||
{
|
||||
return detail::parseParameters<engine::api::TableParameters, TableParametersGrammar<>>(iter, end);
|
||||
return detail::parseParameters<engine::api::TableParameters, TableParametersGrammar<>>(iter,
|
||||
end);
|
||||
}
|
||||
|
||||
template <>
|
||||
boost::optional<engine::api::NearestParameters> parseParameters(std::string::iterator &iter, const std::string::iterator end)
|
||||
boost::optional<engine::api::NearestParameters> parseParameters(std::string::iterator &iter,
|
||||
const std::string::iterator end)
|
||||
{
|
||||
return detail::parseParameters<engine::api::NearestParameters, NearestParametersGrammar<>>(iter, end);
|
||||
return detail::parseParameters<engine::api::NearestParameters, NearestParametersGrammar<>>(iter,
|
||||
end);
|
||||
}
|
||||
|
||||
template <>
|
||||
boost::optional<engine::api::TripParameters> parseParameters(std::string::iterator &iter, const std::string::iterator end)
|
||||
boost::optional<engine::api::TripParameters> parseParameters(std::string::iterator &iter,
|
||||
const std::string::iterator end)
|
||||
{
|
||||
return detail::parseParameters<engine::api::TripParameters, TripParametersGrammar<>>(iter, end);
|
||||
}
|
||||
|
||||
template <>
|
||||
boost::optional<engine::api::MatchParameters> parseParameters(std::string::iterator &iter, const std::string::iterator end)
|
||||
boost::optional<engine::api::MatchParameters> parseParameters(std::string::iterator &iter,
|
||||
const std::string::iterator end)
|
||||
{
|
||||
return detail::parseParameters<engine::api::MatchParameters, MatchParametersGrammar<>>(iter, end);
|
||||
return detail::parseParameters<engine::api::MatchParameters, MatchParametersGrammar<>>(iter,
|
||||
end);
|
||||
}
|
||||
|
||||
template <>
|
||||
boost::optional<engine::api::TileParameters> parseParameters(std::string::iterator &iter, const std::string::iterator end)
|
||||
boost::optional<engine::api::TileParameters> parseParameters(std::string::iterator &iter,
|
||||
const std::string::iterator end)
|
||||
{
|
||||
return detail::parseParameters<engine::api::TileParameters, TileParametersGrammar<>>(iter, end);
|
||||
}
|
||||
|
||||
@@ -10,11 +10,8 @@
|
||||
#include <type_traits>
|
||||
|
||||
BOOST_FUSION_ADAPT_STRUCT(osrm::server::api::ParsedURL,
|
||||
(std::string, service)
|
||||
(unsigned, version)
|
||||
(std::string, profile)
|
||||
(std::string, query)
|
||||
)
|
||||
(std::string, service)(unsigned, version)(std::string,
|
||||
profile)(std::string, query))
|
||||
|
||||
// Keep impl. TU local
|
||||
namespace
|
||||
@@ -40,14 +37,10 @@ struct URLParser final : qi::grammar<Iterator, Into>
|
||||
|
||||
// Example input: /route/v1/driving/7.416351,43.731205;7.420363,43.736189
|
||||
|
||||
start
|
||||
= qi::lit('/') > service
|
||||
> qi::lit('/') > qi::lit('v') > version
|
||||
> qi::lit('/') > profile
|
||||
> qi::lit('/')
|
||||
> qi::omit[iter_pos[ph::bind(&osrm::server::api::ParsedURL::prefix_length, qi::_val) = qi::_1 - qi::_r1]]
|
||||
> query
|
||||
;
|
||||
start = qi::lit('/') > service > qi::lit('/') > qi::lit('v') > version > qi::lit('/') >
|
||||
profile > qi::lit('/') >
|
||||
qi::omit[iter_pos[ph::bind(&osrm::server::api::ParsedURL::prefix_length, qi::_val) =
|
||||
qi::_1 - qi::_r1]] > query;
|
||||
|
||||
BOOST_SPIRIT_DEBUG_NODES((start)(service)(version)(profile)(query))
|
||||
}
|
||||
|
||||
+17
-12
@@ -4,8 +4,8 @@
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/iostreams/filtering_stream.hpp>
|
||||
#include <boost/iostreams/filter/gzip.hpp>
|
||||
#include <boost/iostreams/filtering_stream.hpp>
|
||||
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
@@ -28,7 +28,8 @@ void Connection::start()
|
||||
{
|
||||
TCP_socket.async_read_some(
|
||||
boost::asio::buffer(incoming_data_buffer),
|
||||
strand.wrap(boost::bind(&Connection::handle_read, this->shared_from_this(),
|
||||
strand.wrap(boost::bind(&Connection::handle_read,
|
||||
this->shared_from_this(),
|
||||
boost::asio::placeholders::error,
|
||||
boost::asio::placeholders::bytes_transferred)));
|
||||
}
|
||||
@@ -44,7 +45,8 @@ void Connection::handle_read(const boost::system::error_code &error, std::size_t
|
||||
http::compression_type compression_type(http::no_compression);
|
||||
RequestParser::RequestStatus result;
|
||||
std::tie(result, compression_type) =
|
||||
request_parser.parse(current_request, incoming_data_buffer.data(),
|
||||
request_parser.parse(current_request,
|
||||
incoming_data_buffer.data(),
|
||||
incoming_data_buffer.data() + bytes_transferred);
|
||||
|
||||
// the request has been parsed
|
||||
@@ -81,26 +83,29 @@ void Connection::handle_read(const boost::system::error_code &error, std::size_t
|
||||
break;
|
||||
}
|
||||
// write result to stream
|
||||
boost::asio::async_write(
|
||||
TCP_socket, output_buffer,
|
||||
strand.wrap(boost::bind(&Connection::handle_write, this->shared_from_this(),
|
||||
boost::asio::placeholders::error)));
|
||||
boost::asio::async_write(TCP_socket,
|
||||
output_buffer,
|
||||
strand.wrap(boost::bind(&Connection::handle_write,
|
||||
this->shared_from_this(),
|
||||
boost::asio::placeholders::error)));
|
||||
}
|
||||
else if (result == RequestParser::RequestStatus::invalid)
|
||||
{ // request is not parseable
|
||||
current_reply = http::reply::stock_reply(http::reply::bad_request);
|
||||
|
||||
boost::asio::async_write(
|
||||
TCP_socket, current_reply.to_buffers(),
|
||||
strand.wrap(boost::bind(&Connection::handle_write, this->shared_from_this(),
|
||||
boost::asio::placeholders::error)));
|
||||
boost::asio::async_write(TCP_socket,
|
||||
current_reply.to_buffers(),
|
||||
strand.wrap(boost::bind(&Connection::handle_write,
|
||||
this->shared_from_this(),
|
||||
boost::asio::placeholders::error)));
|
||||
}
|
||||
else
|
||||
{
|
||||
// we don't have a result yet, so continue reading
|
||||
TCP_socket.async_read_some(
|
||||
boost::asio::buffer(incoming_data_buffer),
|
||||
strand.wrap(boost::bind(&Connection::handle_read, this->shared_from_this(),
|
||||
strand.wrap(boost::bind(&Connection::handle_read,
|
||||
this->shared_from_this(),
|
||||
boost::asio::placeholders::error,
|
||||
boost::asio::placeholders::bytes_transferred)));
|
||||
}
|
||||
|
||||
@@ -11,18 +11,18 @@
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include "engine/status.hpp"
|
||||
#include "util/json_container.hpp"
|
||||
#include "osrm/osrm.hpp"
|
||||
#include "util/json_container.hpp"
|
||||
|
||||
#include <boost/iostreams/filtering_streambuf.hpp>
|
||||
#include <boost/iostreams/copy.hpp>
|
||||
#include <boost/iostreams/filter/gzip.hpp>
|
||||
#include <boost/iostreams/filtering_streambuf.hpp>
|
||||
|
||||
#include <ctime>
|
||||
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
|
||||
namespace osrm
|
||||
@@ -103,10 +103,11 @@ void RequestHandler::HandleRequest(const http::request ¤t_request, http::r
|
||||
{
|
||||
const auto position = std::distance(request_string.begin(), api_iterator);
|
||||
BOOST_ASSERT(position >= 0);
|
||||
const auto context_begin = request_string.begin() + ((position < 3) ? 0 : (position - 3UL));
|
||||
const auto context_begin =
|
||||
request_string.begin() + ((position < 3) ? 0 : (position - 3UL));
|
||||
BOOST_ASSERT(context_begin >= request_string.begin());
|
||||
const auto context_end =
|
||||
request_string.begin() + std::min<std::size_t>(position + 3UL, request_string.size());
|
||||
const auto context_end = request_string.begin() +
|
||||
std::min<std::size_t>(position + 3UL, request_string.size());
|
||||
BOOST_ASSERT(context_end <= request_string.end());
|
||||
std::string context(context_begin, context_end);
|
||||
|
||||
@@ -133,7 +134,8 @@ void RequestHandler::HandleRequest(const http::request ¤t_request, http::r
|
||||
else
|
||||
{
|
||||
BOOST_ASSERT(result.is<std::string>());
|
||||
std::copy(result.get<std::string>().cbegin(), result.get<std::string>().cend(),
|
||||
std::copy(result.get<std::string>().cbegin(),
|
||||
result.get<std::string>().cend(),
|
||||
std::back_inserter(current_reply.content));
|
||||
|
||||
current_reply.headers.emplace_back("Content-Type", "application/x-protobuf");
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "server/service/match_service.hpp"
|
||||
|
||||
#include "engine/api/match_parameters.hpp"
|
||||
#include "server/api/parameters_parser.hpp"
|
||||
#include "server/service/utils.hpp"
|
||||
#include "engine/api/match_parameters.hpp"
|
||||
|
||||
#include "util/json_container.hpp"
|
||||
|
||||
@@ -22,14 +22,15 @@ std::string getWrongOptionHelp(const engine::api::MatchParameters ¶meters)
|
||||
|
||||
const auto coord_size = parameters.coordinates.size();
|
||||
|
||||
const bool param_size_mismatch = constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "hints",
|
||||
parameters.hints, coord_size, help) ||
|
||||
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "bearings",
|
||||
parameters.bearings, coord_size, help) ||
|
||||
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "radiuses",
|
||||
parameters.radiuses, coord_size, help) ||
|
||||
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "timestamps",
|
||||
parameters.timestamps, coord_size, help);
|
||||
const bool param_size_mismatch =
|
||||
constrainParamSize(
|
||||
PARAMETER_SIZE_MISMATCH_MSG, "hints", parameters.hints, coord_size, help) ||
|
||||
constrainParamSize(
|
||||
PARAMETER_SIZE_MISMATCH_MSG, "bearings", parameters.bearings, coord_size, help) ||
|
||||
constrainParamSize(
|
||||
PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help) ||
|
||||
constrainParamSize(
|
||||
PARAMETER_SIZE_MISMATCH_MSG, "timestamps", parameters.timestamps, coord_size, help);
|
||||
|
||||
if (!param_size_mismatch && parameters.coordinates.size() < 2)
|
||||
{
|
||||
@@ -40,7 +41,8 @@ std::string getWrongOptionHelp(const engine::api::MatchParameters ¶meters)
|
||||
}
|
||||
} // anon. ns
|
||||
|
||||
engine::Status MatchService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
|
||||
engine::Status
|
||||
MatchService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
|
||||
{
|
||||
result = util::json::Object();
|
||||
auto &json_result = result.get<util::json::Object>();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "server/service/nearest_service.hpp"
|
||||
#include "server/service/utils.hpp"
|
||||
|
||||
#include "engine/api/nearest_parameters.hpp"
|
||||
#include "server/api/parameters_parser.hpp"
|
||||
#include "engine/api/nearest_parameters.hpp"
|
||||
|
||||
#include "util/json_container.hpp"
|
||||
|
||||
@@ -23,12 +23,13 @@ std::string getWrongOptionHelp(const engine::api::NearestParameters ¶meters)
|
||||
|
||||
const auto coord_size = parameters.coordinates.size();
|
||||
|
||||
const bool param_size_mismatch = constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "hints",
|
||||
parameters.hints, coord_size, help) ||
|
||||
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "bearings",
|
||||
parameters.bearings, coord_size, help) ||
|
||||
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "radiuses",
|
||||
parameters.radiuses, coord_size, help);
|
||||
const bool param_size_mismatch =
|
||||
constrainParamSize(
|
||||
PARAMETER_SIZE_MISMATCH_MSG, "hints", parameters.hints, coord_size, help) ||
|
||||
constrainParamSize(
|
||||
PARAMETER_SIZE_MISMATCH_MSG, "bearings", parameters.bearings, coord_size, help) ||
|
||||
constrainParamSize(
|
||||
PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help);
|
||||
|
||||
if (!param_size_mismatch && parameters.coordinates.size() < 2)
|
||||
{
|
||||
@@ -39,7 +40,8 @@ std::string getWrongOptionHelp(const engine::api::NearestParameters ¶meters)
|
||||
}
|
||||
} // anon. ns
|
||||
|
||||
engine::Status NearestService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
|
||||
engine::Status
|
||||
NearestService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
|
||||
{
|
||||
result = util::json::Object();
|
||||
auto &json_result = result.get<util::json::Object>();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "server/service/route_service.hpp"
|
||||
#include "server/service/utils.hpp"
|
||||
|
||||
#include "engine/api/route_parameters.hpp"
|
||||
#include "server/api/parameters_parser.hpp"
|
||||
#include "engine/api/route_parameters.hpp"
|
||||
|
||||
#include "util/json_container.hpp"
|
||||
|
||||
@@ -20,12 +20,13 @@ std::string getWrongOptionHelp(const engine::api::RouteParameters ¶meters)
|
||||
|
||||
const auto coord_size = parameters.coordinates.size();
|
||||
|
||||
const bool param_size_mismatch = constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "hints",
|
||||
parameters.hints, coord_size, help) ||
|
||||
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "bearings",
|
||||
parameters.bearings, coord_size, help) ||
|
||||
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "radiuses",
|
||||
parameters.radiuses, coord_size, help);
|
||||
const bool param_size_mismatch =
|
||||
constrainParamSize(
|
||||
PARAMETER_SIZE_MISMATCH_MSG, "hints", parameters.hints, coord_size, help) ||
|
||||
constrainParamSize(
|
||||
PARAMETER_SIZE_MISMATCH_MSG, "bearings", parameters.bearings, coord_size, help) ||
|
||||
constrainParamSize(
|
||||
PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help);
|
||||
|
||||
if (!param_size_mismatch && parameters.coordinates.size() < 2)
|
||||
{
|
||||
@@ -36,7 +37,8 @@ std::string getWrongOptionHelp(const engine::api::RouteParameters ¶meters)
|
||||
}
|
||||
} // anon. ns
|
||||
|
||||
engine::Status RouteService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
|
||||
engine::Status
|
||||
RouteService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
|
||||
{
|
||||
result = util::json::Object();
|
||||
auto &json_result = result.get<util::json::Object>();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "server/service/table_service.hpp"
|
||||
|
||||
#include "engine/api/table_parameters.hpp"
|
||||
#include "server/api/parameters_parser.hpp"
|
||||
#include "engine/api/table_parameters.hpp"
|
||||
|
||||
#include "util/json_container.hpp"
|
||||
|
||||
@@ -41,12 +41,13 @@ std::string getWrongOptionHelp(const engine::api::TableParameters ¶meters)
|
||||
|
||||
const auto coord_size = parameters.coordinates.size();
|
||||
|
||||
const bool param_size_mismatch = constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "hints",
|
||||
parameters.hints, coord_size, help) ||
|
||||
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "bearings",
|
||||
parameters.bearings, coord_size, help) ||
|
||||
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "radiuses",
|
||||
parameters.radiuses, coord_size, help);
|
||||
const bool param_size_mismatch =
|
||||
constrainParamSize(
|
||||
PARAMETER_SIZE_MISMATCH_MSG, "hints", parameters.hints, coord_size, help) ||
|
||||
constrainParamSize(
|
||||
PARAMETER_SIZE_MISMATCH_MSG, "bearings", parameters.bearings, coord_size, help) ||
|
||||
constrainParamSize(
|
||||
PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help);
|
||||
|
||||
if (!param_size_mismatch && parameters.coordinates.size() < 2)
|
||||
{
|
||||
@@ -57,7 +58,8 @@ std::string getWrongOptionHelp(const engine::api::TableParameters ¶meters)
|
||||
}
|
||||
} // anon. ns
|
||||
|
||||
engine::Status TableService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
|
||||
engine::Status
|
||||
TableService::RunQuery(std::size_t prefix_length, std::string &query, ResultT &result)
|
||||
{
|
||||
result = util::json::Object();
|
||||
auto &json_result = result.get<util::json::Object>();
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "server/service/tile_service.hpp"
|
||||
#include "server/service/utils.hpp"
|
||||
|
||||
#include "engine/api/tile_parameters.hpp"
|
||||
#include "server/api/parameters_parser.hpp"
|
||||
#include "engine/api/tile_parameters.hpp"
|
||||
|
||||
#include "util/json_container.hpp"
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#include "server/service/trip_service.hpp"
|
||||
#include "server/service/utils.hpp"
|
||||
|
||||
#include "engine/api/trip_parameters.hpp"
|
||||
#include "server/api/parameters_parser.hpp"
|
||||
#include "engine/api/trip_parameters.hpp"
|
||||
|
||||
#include "util/json_container.hpp"
|
||||
|
||||
@@ -22,12 +22,13 @@ std::string getWrongOptionHelp(const engine::api::TripParameters ¶meters)
|
||||
|
||||
const auto coord_size = parameters.coordinates.size();
|
||||
|
||||
const bool param_size_mismatch = constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "hints",
|
||||
parameters.hints, coord_size, help) ||
|
||||
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "bearings",
|
||||
parameters.bearings, coord_size, help) ||
|
||||
constrainParamSize(PARAMETER_SIZE_MISMATCH_MSG, "radiuses",
|
||||
parameters.radiuses, coord_size, help);
|
||||
const bool param_size_mismatch =
|
||||
constrainParamSize(
|
||||
PARAMETER_SIZE_MISMATCH_MSG, "hints", parameters.hints, coord_size, help) ||
|
||||
constrainParamSize(
|
||||
PARAMETER_SIZE_MISMATCH_MSG, "bearings", parameters.bearings, coord_size, help) ||
|
||||
constrainParamSize(
|
||||
PARAMETER_SIZE_MISMATCH_MSG, "radiuses", parameters.radiuses, coord_size, help);
|
||||
|
||||
if (!param_size_mismatch && parameters.coordinates.size() < 2)
|
||||
{
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "server/service_handler.hpp"
|
||||
|
||||
#include "server/service/match_service.hpp"
|
||||
#include "server/service/nearest_service.hpp"
|
||||
#include "server/service/route_service.hpp"
|
||||
#include "server/service/table_service.hpp"
|
||||
#include "server/service/nearest_service.hpp"
|
||||
#include "server/service/trip_service.hpp"
|
||||
#include "server/service/match_service.hpp"
|
||||
#include "server/service/tile_service.hpp"
|
||||
#include "server/service/trip_service.hpp"
|
||||
|
||||
#include "server/api/parsed_url.hpp"
|
||||
#include "util/json_util.hpp"
|
||||
|
||||
+14
-10
@@ -1,5 +1,5 @@
|
||||
#include "storage/storage.hpp"
|
||||
#include "contractor/query_edge.hpp"
|
||||
#include "engine/datafacade/datafacade_base.hpp"
|
||||
#include "extractor/compressed_edge_container.hpp"
|
||||
#include "extractor/guidance/turn_instruction.hpp"
|
||||
#include "extractor/original_edge_data.hpp"
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "storage/shared_barriers.hpp"
|
||||
#include "storage/shared_datatype.hpp"
|
||||
#include "storage/shared_memory.hpp"
|
||||
#include "storage/storage.hpp"
|
||||
#include "engine/datafacade/datafacade_base.hpp"
|
||||
#include "util/coordinate.hpp"
|
||||
#include "util/exception.hpp"
|
||||
#include "util/fingerprint.hpp"
|
||||
@@ -258,8 +258,8 @@ int Storage::Run()
|
||||
geometry_input_stream.read((char *)&number_of_geometries_indices, sizeof(unsigned));
|
||||
shared_layout_ptr->SetBlockSize<unsigned>(SharedDataLayout::GEOMETRIES_INDEX,
|
||||
number_of_geometries_indices);
|
||||
boost::iostreams::seek(geometry_input_stream, number_of_geometries_indices * sizeof(unsigned),
|
||||
BOOST_IOS::cur);
|
||||
boost::iostreams::seek(
|
||||
geometry_input_stream, number_of_geometries_indices * sizeof(unsigned), BOOST_IOS::cur);
|
||||
geometry_input_stream.read((char *)&number_of_compressed_geometries, sizeof(unsigned));
|
||||
shared_layout_ptr->SetBlockSize<extractor::CompressedEdgeContainer::CompressedEdge>(
|
||||
SharedDataLayout::GEOMETRIES_LIST, number_of_compressed_geometries);
|
||||
@@ -300,7 +300,8 @@ int Storage::Run()
|
||||
while (std::getline(datasource_names_input_stream, name))
|
||||
{
|
||||
m_datasource_name_offsets.push_back(m_datasource_name_data.size());
|
||||
std::copy(name.c_str(), name.c_str() + name.size(),
|
||||
std::copy(name.c_str(),
|
||||
name.c_str() + name.size(),
|
||||
std::back_inserter(m_datasource_name_data));
|
||||
m_datasource_name_lengths.push_back(name.size());
|
||||
}
|
||||
@@ -394,7 +395,8 @@ int Storage::Run()
|
||||
file_index_path_ptr +
|
||||
shared_layout_ptr->GetBlockSize(SharedDataLayout::FILE_INDEX_PATH),
|
||||
0);
|
||||
std::copy(absolute_file_index_path.string().begin(), absolute_file_index_path.string().end(),
|
||||
std::copy(absolute_file_index_path.string().begin(),
|
||||
absolute_file_index_path.string().end(),
|
||||
file_index_path_ptr);
|
||||
|
||||
// Loading street names
|
||||
@@ -508,15 +510,16 @@ int Storage::Run()
|
||||
{
|
||||
std::cout << "Copying " << (m_datasource_name_data.end() - m_datasource_name_data.begin())
|
||||
<< " chars into name data ptr\n";
|
||||
std::copy(m_datasource_name_data.begin(), m_datasource_name_data.end(),
|
||||
datasource_name_data_ptr);
|
||||
std::copy(
|
||||
m_datasource_name_data.begin(), m_datasource_name_data.end(), datasource_name_data_ptr);
|
||||
}
|
||||
|
||||
auto datasource_name_offsets_ptr = shared_layout_ptr->GetBlockPtr<std::size_t, true>(
|
||||
shared_memory_ptr, SharedDataLayout::DATASOURCE_NAME_OFFSETS);
|
||||
if (shared_layout_ptr->GetBlockSize(SharedDataLayout::DATASOURCE_NAME_OFFSETS) > 0)
|
||||
{
|
||||
std::copy(m_datasource_name_offsets.begin(), m_datasource_name_offsets.end(),
|
||||
std::copy(m_datasource_name_offsets.begin(),
|
||||
m_datasource_name_offsets.end(),
|
||||
datasource_name_offsets_ptr);
|
||||
}
|
||||
|
||||
@@ -524,7 +527,8 @@ int Storage::Run()
|
||||
shared_memory_ptr, SharedDataLayout::DATASOURCE_NAME_LENGTHS);
|
||||
if (shared_layout_ptr->GetBlockSize(SharedDataLayout::DATASOURCE_NAME_LENGTHS) > 0)
|
||||
{
|
||||
std::copy(m_datasource_name_lengths.begin(), m_datasource_name_lengths.end(),
|
||||
std::copy(m_datasource_name_lengths.begin(),
|
||||
m_datasource_name_lengths.end(),
|
||||
datasource_name_lengths_ptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,19 @@ StorageConfig::StorageConfig(const boost::filesystem::path &base)
|
||||
bool StorageConfig::IsValid() const
|
||||
{
|
||||
const constexpr auto num_files = 13;
|
||||
const boost::filesystem::path paths[num_files] = {
|
||||
ram_index_path, file_index_path, hsgr_data_path, nodes_data_path,
|
||||
edges_data_path, core_data_path, geometries_path, timestamp_path,
|
||||
datasource_indexes_path, datasource_indexes_path, names_data_path, properties_path,
|
||||
intersection_class_path};
|
||||
const boost::filesystem::path paths[num_files] = {ram_index_path,
|
||||
file_index_path,
|
||||
hsgr_data_path,
|
||||
nodes_data_path,
|
||||
edges_data_path,
|
||||
core_data_path,
|
||||
geometries_path,
|
||||
timestamp_path,
|
||||
datasource_indexes_path,
|
||||
datasource_indexes_path,
|
||||
names_data_path,
|
||||
properties_path,
|
||||
intersection_class_path};
|
||||
|
||||
bool success = true;
|
||||
for (auto path = paths; path != paths + num_files; ++path)
|
||||
|
||||
+13
-10
@@ -1,13 +1,13 @@
|
||||
#include "util/typedefs.hpp"
|
||||
#include "extractor/tarjan_scc.hpp"
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
#include "util/dynamic_graph.hpp"
|
||||
#include "util/static_graph.hpp"
|
||||
#include "util/exception.hpp"
|
||||
#include "util/fingerprint.hpp"
|
||||
#include "util/graph_loader.hpp"
|
||||
#include "util/make_unique.hpp"
|
||||
#include "util/exception.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/static_graph.hpp"
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
@@ -65,8 +65,8 @@ std::size_t loadGraph(const char *path,
|
||||
std::vector<NodeID> traffic_light_node_list;
|
||||
std::vector<NodeID> barrier_node_list;
|
||||
|
||||
auto number_of_nodes = util::loadNodesFromFile(input_stream, barrier_node_list,
|
||||
traffic_light_node_list, coordinate_list);
|
||||
auto number_of_nodes = util::loadNodesFromFile(
|
||||
input_stream, barrier_node_list, traffic_light_node_list, coordinate_list);
|
||||
|
||||
util::loadEdgesFromFile(input_stream, edge_list);
|
||||
|
||||
@@ -83,13 +83,17 @@ std::size_t loadGraph(const char *path,
|
||||
|
||||
if (input_edge.forward)
|
||||
{
|
||||
graph_edge_list.emplace_back(input_edge.source, input_edge.target,
|
||||
(std::max)(input_edge.weight, 1), input_edge.name_id);
|
||||
graph_edge_list.emplace_back(input_edge.source,
|
||||
input_edge.target,
|
||||
(std::max)(input_edge.weight, 1),
|
||||
input_edge.name_id);
|
||||
}
|
||||
if (input_edge.backward)
|
||||
{
|
||||
graph_edge_list.emplace_back(input_edge.target, input_edge.source,
|
||||
(std::max)(input_edge.weight, 1), input_edge.name_id);
|
||||
graph_edge_list.emplace_back(input_edge.target,
|
||||
input_edge.source,
|
||||
(std::max)(input_edge.weight, 1),
|
||||
input_edge.name_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +140,6 @@ int main(int argc, char *argv[]) try
|
||||
osrm::tools::deleteFileIfExists("component.shx");
|
||||
osrm::tools::deleteFileIfExists("component.shp");
|
||||
|
||||
|
||||
OGRRegisterAll();
|
||||
|
||||
const char *psz_driver_name = "ESRI Shapefile";
|
||||
|
||||
+18
-13
@@ -39,23 +39,27 @@ return_code parseArguments(int argc, char *argv[], contractor::ContractorConfig
|
||||
"core,k",
|
||||
boost::program_options::value<double>(&contractor_config.core_factor)->default_value(1.0),
|
||||
"Percentage of the graph (in vertices) to contract [0..1]")(
|
||||
"segment-speed-file", boost::program_options::value<std::vector<std::string>>(
|
||||
&contractor_config.segment_speed_lookup_paths)
|
||||
->composing(),
|
||||
"segment-speed-file",
|
||||
boost::program_options::value<std::vector<std::string>>(
|
||||
&contractor_config.segment_speed_lookup_paths)
|
||||
->composing(),
|
||||
"Lookup files containing nodeA, nodeB, speed data to adjust edge weights")(
|
||||
"turn-penalty-file", boost::program_options::value<std::vector<std::string>>(
|
||||
&contractor_config.turn_penalty_lookup_paths)
|
||||
->composing(),
|
||||
"turn-penalty-file",
|
||||
boost::program_options::value<std::vector<std::string>>(
|
||||
&contractor_config.turn_penalty_lookup_paths)
|
||||
->composing(),
|
||||
"Lookup files containing from_, to_, via_nodes, and turn penalties to adjust turn weights")(
|
||||
"level-cache,o", boost::program_options::value<bool>(&contractor_config.use_cached_priority)
|
||||
->default_value(false),
|
||||
"level-cache,o",
|
||||
boost::program_options::value<bool>(&contractor_config.use_cached_priority)
|
||||
->default_value(false),
|
||||
"Use .level file to retain the contaction level for each node from the last run.");
|
||||
|
||||
// hidden options, will be allowed on command line, but will not be shown to the user
|
||||
boost::program_options::options_description hidden_options("Hidden options");
|
||||
hidden_options.add_options()("input,i", boost::program_options::value<boost::filesystem::path>(
|
||||
&contractor_config.osrm_input_path),
|
||||
"Input file in .osm, .osm.bz2 or .osm.pbf format");
|
||||
hidden_options.add_options()(
|
||||
"input,i",
|
||||
boost::program_options::value<boost::filesystem::path>(&contractor_config.osrm_input_path),
|
||||
"Input file in .osm, .osm.bz2 or .osm.pbf format");
|
||||
|
||||
// positional option
|
||||
boost::program_options::positional_options_description positional_options;
|
||||
@@ -65,9 +69,10 @@ return_code parseArguments(int argc, char *argv[], contractor::ContractorConfig
|
||||
boost::program_options::options_description cmdline_options;
|
||||
cmdline_options.add(generic_options).add(config_options).add(hidden_options);
|
||||
|
||||
const auto* executable = argv[0];
|
||||
const auto *executable = argv[0];
|
||||
boost::program_options::options_description visible_options(
|
||||
"Usage: " + boost::filesystem::path(executable).filename().string() + " <input.osrm> [options]");
|
||||
"Usage: " + boost::filesystem::path(executable).filename().string() +
|
||||
" <input.osrm> [options]");
|
||||
visible_options.add(generic_options).add(config_options);
|
||||
|
||||
// parse command line options
|
||||
|
||||
@@ -52,9 +52,10 @@ return_code parseArguments(int argc, char *argv[], extractor::ExtractorConfig &e
|
||||
// hidden options, will be allowed on command line, but will not be
|
||||
// shown to the user
|
||||
boost::program_options::options_description hidden_options("Hidden options");
|
||||
hidden_options.add_options()("input,i", boost::program_options::value<boost::filesystem::path>(
|
||||
&extractor_config.input_path),
|
||||
"Input file in .osm, .osm.bz2 or .osm.pbf format");
|
||||
hidden_options.add_options()(
|
||||
"input,i",
|
||||
boost::program_options::value<boost::filesystem::path>(&extractor_config.input_path),
|
||||
"Input file in .osm, .osm.bz2 or .osm.pbf format");
|
||||
|
||||
// positional option
|
||||
boost::program_options::positional_options_description positional_options;
|
||||
@@ -64,9 +65,10 @@ return_code parseArguments(int argc, char *argv[], extractor::ExtractorConfig &e
|
||||
boost::program_options::options_description cmdline_options;
|
||||
cmdline_options.add(generic_options).add(config_options).add(hidden_options);
|
||||
|
||||
const auto* executable = argv[0];
|
||||
const auto *executable = argv[0];
|
||||
boost::program_options::options_description visible_options(
|
||||
boost::filesystem::path(executable).filename().string() + " <input.osm/.osm.bz2/.osm.pbf> [options]");
|
||||
boost::filesystem::path(executable).filename().string() +
|
||||
" <input.osm/.osm.bz2/.osm.pbf> [options]");
|
||||
visible_options.add(generic_options).add(config_options);
|
||||
|
||||
// parse command line options
|
||||
|
||||
@@ -40,8 +40,8 @@ void runStatistics(std::vector<double> &timings_vector, Statistics &stats)
|
||||
double primary_sum = std::accumulate(timings_vector.begin(), timings_vector.end(), 0.0);
|
||||
stats.mean = primary_sum / timings_vector.size();
|
||||
|
||||
double primary_sq_sum = std::inner_product(timings_vector.begin(), timings_vector.end(),
|
||||
timings_vector.begin(), 0.0);
|
||||
double primary_sq_sum = std::inner_product(
|
||||
timings_vector.begin(), timings_vector.end(), timings_vector.begin(), 0.0);
|
||||
stats.dev = std::sqrt(primary_sq_sum / timings_vector.size() - (stats.mean * stats.mean));
|
||||
}
|
||||
}
|
||||
|
||||
+89
-63
@@ -3,8 +3,8 @@
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "util/version.hpp"
|
||||
|
||||
#include "osrm/osrm.hpp"
|
||||
#include "osrm/engine_config.hpp"
|
||||
#include "osrm/osrm.hpp"
|
||||
#include "osrm/storage_config.hpp"
|
||||
|
||||
#include <boost/any.hpp>
|
||||
@@ -23,8 +23,8 @@
|
||||
#include <future>
|
||||
#include <iostream>
|
||||
#include <new>
|
||||
#include <thread>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
#ifdef _WIN32
|
||||
boost::function0<void> console_ctrl_function;
|
||||
@@ -52,19 +52,18 @@ const static unsigned INIT_OK_DO_NOT_START_ENGINE = 1;
|
||||
const static unsigned INIT_FAILED = -1;
|
||||
|
||||
// generate boost::program_options object for the routing part
|
||||
inline unsigned
|
||||
generateServerProgramOptions(const int argc,
|
||||
const char *argv[],
|
||||
boost::filesystem::path &base_path,
|
||||
std::string &ip_address,
|
||||
int &ip_port,
|
||||
int &requested_num_threads,
|
||||
bool &use_shared_memory,
|
||||
bool &trial,
|
||||
int &max_locations_trip,
|
||||
int &max_locations_viaroute,
|
||||
int &max_locations_distance_table,
|
||||
int &max_locations_map_matching)
|
||||
inline unsigned generateServerProgramOptions(const int argc,
|
||||
const char *argv[],
|
||||
boost::filesystem::path &base_path,
|
||||
std::string &ip_address,
|
||||
int &ip_port,
|
||||
int &requested_num_threads,
|
||||
bool &use_shared_memory,
|
||||
bool &trial,
|
||||
int &max_locations_trip,
|
||||
int &max_locations_viaroute,
|
||||
int &max_locations_distance_table,
|
||||
int &max_locations_map_matching)
|
||||
{
|
||||
using boost::program_options::value;
|
||||
using boost::filesystem::path;
|
||||
@@ -77,29 +76,36 @@ generateServerProgramOptions(const int argc,
|
||||
|
||||
// declare a group of options that will be allowed on command line
|
||||
boost::program_options::options_description config_options("Configuration");
|
||||
config_options.add_options() //
|
||||
("ip,i", value<std::string>(&ip_address)->default_value("0.0.0.0"),
|
||||
config_options.add_options() //
|
||||
("ip,i",
|
||||
value<std::string>(&ip_address)->default_value("0.0.0.0"),
|
||||
"IP address") //
|
||||
("port,p", value<int>(&ip_port)->default_value(5000),
|
||||
("port,p",
|
||||
value<int>(&ip_port)->default_value(5000),
|
||||
"TCP/IP port") //
|
||||
("threads,t", value<int>(&requested_num_threads)->default_value(8),
|
||||
("threads,t",
|
||||
value<int>(&requested_num_threads)->default_value(8),
|
||||
"Number of threads to use") //
|
||||
("shared-memory,s",
|
||||
value<bool>(&use_shared_memory)->implicit_value(true)->default_value(false),
|
||||
"Load data from shared memory") //
|
||||
("max-viaroute-size", value<int>(&max_locations_viaroute)->default_value(500),
|
||||
("max-viaroute-size",
|
||||
value<int>(&max_locations_viaroute)->default_value(500),
|
||||
"Max. locations supported in viaroute query") //
|
||||
("max-trip-size", value<int>(&max_locations_trip)->default_value(100),
|
||||
("max-trip-size",
|
||||
value<int>(&max_locations_trip)->default_value(100),
|
||||
"Max. locations supported in trip query") //
|
||||
("max-table-size", value<int>(&max_locations_distance_table)->default_value(100),
|
||||
("max-table-size",
|
||||
value<int>(&max_locations_distance_table)->default_value(100),
|
||||
"Max. locations supported in distance table query") //
|
||||
("max-matching-size", value<int>(&max_locations_map_matching)->default_value(100),
|
||||
("max-matching-size",
|
||||
value<int>(&max_locations_map_matching)->default_value(100),
|
||||
"Max. locations supported in map matching query");
|
||||
|
||||
// hidden options, will be allowed on command line, but will not be shown to the user
|
||||
boost::program_options::options_description hidden_options("Hidden options");
|
||||
hidden_options.add_options()("base,b", value<boost::filesystem::path>(&base_path),
|
||||
"base path to .osrm file");
|
||||
hidden_options.add_options()(
|
||||
"base,b", value<boost::filesystem::path>(&base_path), "base path to .osrm file");
|
||||
|
||||
// positional option
|
||||
boost::program_options::positional_options_description positional_options;
|
||||
@@ -109,7 +115,7 @@ generateServerProgramOptions(const int argc,
|
||||
boost::program_options::options_description cmdline_options;
|
||||
cmdline_options.add(generic_options).add(config_options).add(hidden_options);
|
||||
|
||||
const auto* executable = argv[0];
|
||||
const auto *executable = argv[0];
|
||||
boost::program_options::options_description visible_options(
|
||||
boost::filesystem::path(executable).filename().string() + " <base.osrm> [<options>]");
|
||||
visible_options.add(generic_options).add(config_options);
|
||||
@@ -146,7 +152,8 @@ generateServerProgramOptions(const int argc,
|
||||
}
|
||||
else if (use_shared_memory && option_variables.count("base"))
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << "Shared memory settings conflict with path settings.";
|
||||
util::SimpleLogger().Write(logWARNING)
|
||||
<< "Shared memory settings conflict with path settings.";
|
||||
}
|
||||
|
||||
util::SimpleLogger().Write() << visible_options;
|
||||
@@ -163,11 +170,18 @@ int main(int argc, const char *argv[]) try
|
||||
|
||||
EngineConfig config;
|
||||
boost::filesystem::path base_path;
|
||||
const unsigned init_result = generateServerProgramOptions(
|
||||
argc, argv, base_path, ip_address, ip_port, requested_thread_num,
|
||||
config.use_shared_memory, trial_run, config.max_locations_trip,
|
||||
config.max_locations_viaroute, config.max_locations_distance_table,
|
||||
config.max_locations_map_matching);
|
||||
const unsigned init_result = generateServerProgramOptions(argc,
|
||||
argv,
|
||||
base_path,
|
||||
ip_address,
|
||||
ip_port,
|
||||
requested_thread_num,
|
||||
config.use_shared_memory,
|
||||
trial_run,
|
||||
config.max_locations_trip,
|
||||
config.max_locations_viaroute,
|
||||
config.max_locations_distance_table,
|
||||
config.max_locations_map_matching);
|
||||
if (init_result == INIT_OK_DO_NOT_START_ENGINE)
|
||||
{
|
||||
return EXIT_SUCCESS;
|
||||
@@ -180,7 +194,7 @@ int main(int argc, const char *argv[]) try
|
||||
{
|
||||
config.storage_config = storage::StorageConfig(base_path);
|
||||
}
|
||||
if(!config.IsValid())
|
||||
if (!config.IsValid())
|
||||
{
|
||||
if (base_path.empty() != config.use_shared_memory)
|
||||
{
|
||||
@@ -188,53 +202,65 @@ int main(int argc, const char *argv[]) try
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!boost::filesystem::is_regular_file(config.storage_config.ram_index_path))
|
||||
if (!boost::filesystem::is_regular_file(config.storage_config.ram_index_path))
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.ram_index_path << " is not found";
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.ram_index_path
|
||||
<< " is not found";
|
||||
}
|
||||
if(!boost::filesystem::is_regular_file(config.storage_config.file_index_path))
|
||||
if (!boost::filesystem::is_regular_file(config.storage_config.file_index_path))
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.file_index_path << " is not found";
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.file_index_path
|
||||
<< " is not found";
|
||||
}
|
||||
if(!boost::filesystem::is_regular_file(config.storage_config.hsgr_data_path))
|
||||
if (!boost::filesystem::is_regular_file(config.storage_config.hsgr_data_path))
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.hsgr_data_path << " is not found";
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.hsgr_data_path
|
||||
<< " is not found";
|
||||
}
|
||||
if(!boost::filesystem::is_regular_file(config.storage_config.nodes_data_path))
|
||||
if (!boost::filesystem::is_regular_file(config.storage_config.nodes_data_path))
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.nodes_data_path << " is not found";
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.nodes_data_path
|
||||
<< " is not found";
|
||||
}
|
||||
if(!boost::filesystem::is_regular_file(config.storage_config.edges_data_path))
|
||||
if (!boost::filesystem::is_regular_file(config.storage_config.edges_data_path))
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.edges_data_path << " is not found";
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.edges_data_path
|
||||
<< " is not found";
|
||||
}
|
||||
if(!boost::filesystem::is_regular_file(config.storage_config.core_data_path))
|
||||
if (!boost::filesystem::is_regular_file(config.storage_config.core_data_path))
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.core_data_path << " is not found";
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.core_data_path
|
||||
<< " is not found";
|
||||
}
|
||||
if(!boost::filesystem::is_regular_file(config.storage_config.geometries_path))
|
||||
if (!boost::filesystem::is_regular_file(config.storage_config.geometries_path))
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.geometries_path << " is not found";
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.geometries_path
|
||||
<< " is not found";
|
||||
}
|
||||
if(!boost::filesystem::is_regular_file(config.storage_config.timestamp_path))
|
||||
if (!boost::filesystem::is_regular_file(config.storage_config.timestamp_path))
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.timestamp_path << " is not found";
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.timestamp_path
|
||||
<< " is not found";
|
||||
}
|
||||
if(!boost::filesystem::is_regular_file(config.storage_config.datasource_names_path))
|
||||
if (!boost::filesystem::is_regular_file(config.storage_config.datasource_names_path))
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.datasource_names_path << " is not found";
|
||||
util::SimpleLogger().Write(logWARNING)
|
||||
<< config.storage_config.datasource_names_path << " is not found";
|
||||
}
|
||||
if(!boost::filesystem::is_regular_file(config.storage_config.datasource_indexes_path))
|
||||
if (!boost::filesystem::is_regular_file(config.storage_config.datasource_indexes_path))
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.datasource_indexes_path << " is not found";
|
||||
util::SimpleLogger().Write(logWARNING)
|
||||
<< config.storage_config.datasource_indexes_path << " is not found";
|
||||
}
|
||||
if(!boost::filesystem::is_regular_file(config.storage_config.names_data_path))
|
||||
if (!boost::filesystem::is_regular_file(config.storage_config.names_data_path))
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.names_data_path << " is not found";
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.names_data_path
|
||||
<< " is not found";
|
||||
}
|
||||
if(!boost::filesystem::is_regular_file(config.storage_config.properties_path))
|
||||
if (!boost::filesystem::is_regular_file(config.storage_config.properties_path))
|
||||
{
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.properties_path << " is not found";
|
||||
util::SimpleLogger().Write(logWARNING) << config.storage_config.properties_path
|
||||
<< " is not found";
|
||||
}
|
||||
}
|
||||
return EXIT_FAILURE;
|
||||
@@ -289,11 +315,10 @@ int main(int argc, const char *argv[]) try
|
||||
}
|
||||
else
|
||||
{
|
||||
std::packaged_task<int()> server_task([&]
|
||||
{
|
||||
routing_server->Run();
|
||||
return 0;
|
||||
});
|
||||
std::packaged_task<int()> server_task([&] {
|
||||
routing_server->Run();
|
||||
return 0;
|
||||
});
|
||||
auto future = server_task.get_future();
|
||||
std::thread server_thread(std::move(server_task));
|
||||
|
||||
@@ -306,7 +331,8 @@ int main(int argc, const char *argv[]) try
|
||||
sigaddset(&wait_mask, SIGTERM);
|
||||
pthread_sigmask(SIG_BLOCK, &wait_mask, nullptr);
|
||||
util::SimpleLogger().Write() << "running and waiting for requests";
|
||||
if(std::getenv("SIGNAL_PARENT_WHEN_READY")) {
|
||||
if (std::getenv("SIGNAL_PARENT_WHEN_READY"))
|
||||
{
|
||||
kill(getppid(), SIGUSR1);
|
||||
}
|
||||
sigwait(&wait_mask, &sig);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <cstdio>
|
||||
|
||||
#include "storage/shared_memory.hpp"
|
||||
#include "storage/shared_datatype.hpp"
|
||||
#include "storage/shared_memory.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
|
||||
namespace osrm
|
||||
@@ -16,8 +16,7 @@ void deleteRegion(const SharedDataType region)
|
||||
{
|
||||
if (SharedMemory::RegionExists(region) && !SharedMemory::Remove(region))
|
||||
{
|
||||
const std::string name = [&]
|
||||
{
|
||||
const std::string name = [&] {
|
||||
switch (region)
|
||||
{
|
||||
case CURRENT_REGIONS:
|
||||
|
||||
+7
-5
@@ -10,7 +10,9 @@
|
||||
using namespace osrm;
|
||||
|
||||
// generate boost::program_options object for the routing part
|
||||
bool generateDataStoreOptions(const int argc, const char *argv[], boost::filesystem::path& base_path)
|
||||
bool generateDataStoreOptions(const int argc,
|
||||
const char *argv[],
|
||||
boost::filesystem::path &base_path)
|
||||
{
|
||||
// declare a group of options that will be allowed only on command line
|
||||
boost::program_options::options_description generic_options("Options");
|
||||
@@ -23,9 +25,9 @@ bool generateDataStoreOptions(const int argc, const char *argv[], boost::filesys
|
||||
|
||||
// hidden options, will be allowed on command line but will not be shown to the user
|
||||
boost::program_options::options_description hidden_options("Hidden options");
|
||||
hidden_options.add_options()(
|
||||
"base,b", boost::program_options::value<boost::filesystem::path>(&base_path),
|
||||
"base path to .osrm file");
|
||||
hidden_options.add_options()("base,b",
|
||||
boost::program_options::value<boost::filesystem::path>(&base_path),
|
||||
"base path to .osrm file");
|
||||
|
||||
// positional option
|
||||
boost::program_options::positional_options_description positional_options;
|
||||
@@ -35,7 +37,7 @@ bool generateDataStoreOptions(const int argc, const char *argv[], boost::filesys
|
||||
boost::program_options::options_description cmdline_options;
|
||||
cmdline_options.add(generic_options).add(config_options).add(hidden_options);
|
||||
|
||||
const auto* executable = argv[0];
|
||||
const auto *executable = argv[0];
|
||||
boost::program_options::options_description visible_options(
|
||||
boost::filesystem::path(executable).filename().string() + " [<options>] <configuration>");
|
||||
visible_options.add(generic_options).add(config_options);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "util/simple_logger.hpp"
|
||||
#include "storage/shared_barriers.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@
|
||||
#ifndef NDEBUG
|
||||
#include <bitset>
|
||||
#endif
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
namespace osrm
|
||||
@@ -17,7 +17,6 @@ namespace osrm
|
||||
namespace util
|
||||
{
|
||||
|
||||
|
||||
bool Coordinate::IsValid() const
|
||||
{
|
||||
return !(lat > FixedLatitude(90 * COORDINATE_PRECISION) ||
|
||||
@@ -26,16 +25,12 @@ bool Coordinate::IsValid() const
|
||||
lon < FixedLongitude(-180 * COORDINATE_PRECISION));
|
||||
}
|
||||
|
||||
|
||||
bool FloatCoordinate::IsValid() const
|
||||
{
|
||||
return !(lat > FloatLatitude(90) ||
|
||||
lat < FloatLatitude(-90) ||
|
||||
lon > FloatLongitude(180) ||
|
||||
return !(lat > FloatLatitude(90) || lat < FloatLatitude(-90) || lon > FloatLongitude(180) ||
|
||||
lon < FloatLongitude(-180));
|
||||
}
|
||||
|
||||
|
||||
bool operator==(const Coordinate lhs, const Coordinate rhs)
|
||||
{
|
||||
return lhs.lat == rhs.lat && lhs.lon == rhs.lon;
|
||||
@@ -56,8 +51,7 @@ std::ostream &operator<<(std::ostream &out, const Coordinate coordinate)
|
||||
}
|
||||
std::ostream &operator<<(std::ostream &out, const FloatCoordinate coordinate)
|
||||
{
|
||||
out << std::setprecision(12) << "(lon:" << coordinate.lon
|
||||
<< ", lat:" << coordinate.lat << ")";
|
||||
out << std::setprecision(12) << "(lon:" << coordinate.lon << ", lat:" << coordinate.lat << ")";
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,7 +77,6 @@ double greatCircleDistance(const Coordinate coordinate_1, const Coordinate coord
|
||||
return std::hypot(x_value, y_value) * detail::EARTH_RADIUS;
|
||||
}
|
||||
|
||||
|
||||
double perpendicularDistance(const Coordinate segment_source,
|
||||
const Coordinate segment_target,
|
||||
const Coordinate query_location,
|
||||
@@ -89,9 +88,10 @@ double perpendicularDistance(const Coordinate segment_source,
|
||||
BOOST_ASSERT(query_location.IsValid());
|
||||
|
||||
FloatCoordinate projected_nearest;
|
||||
std::tie(ratio, projected_nearest) = projectPointOnSegment(
|
||||
web_mercator::fromWGS84(segment_source), web_mercator::fromWGS84(segment_target),
|
||||
web_mercator::fromWGS84(query_location));
|
||||
std::tie(ratio, projected_nearest) =
|
||||
projectPointOnSegment(web_mercator::fromWGS84(segment_source),
|
||||
web_mercator::fromWGS84(segment_target),
|
||||
web_mercator::fromWGS84(query_location));
|
||||
nearest_location = web_mercator::toWGS84(projected_nearest);
|
||||
|
||||
const double approximate_distance = greatCircleDistance(query_location, nearest_location);
|
||||
@@ -106,8 +106,8 @@ double perpendicularDistance(const Coordinate source_coordinate,
|
||||
double ratio;
|
||||
Coordinate nearest_location;
|
||||
|
||||
return perpendicularDistance(source_coordinate, target_coordinate, query_location,
|
||||
nearest_location, ratio);
|
||||
return perpendicularDistance(
|
||||
source_coordinate, target_coordinate, query_location, nearest_location, ratio);
|
||||
}
|
||||
|
||||
Coordinate centroid(const Coordinate lhs, const Coordinate rhs)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "extractor/guidance/discrete_angle.hpp"
|
||||
#include "util/guidance/bearing_class.hpp"
|
||||
#include "extractor/guidance/discrete_angle.hpp"
|
||||
#include "util/guidance/toolkit.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -44,10 +44,7 @@ bool BearingClass::operator<(const BearingClass &other) const
|
||||
return false;
|
||||
}
|
||||
|
||||
void BearingClass::add(const DiscreteBearing bearing)
|
||||
{
|
||||
available_bearings.push_back(bearing);
|
||||
}
|
||||
void BearingClass::add(const DiscreteBearing bearing) { available_bearings.push_back(bearing); }
|
||||
|
||||
const std::vector<DiscreteBearing> &BearingClass::getAvailableBearings() const
|
||||
{
|
||||
@@ -69,7 +66,8 @@ std::size_t BearingClass::findMatchingBearing(const double bearing) const
|
||||
// the small size of the intersections allows a linear compare
|
||||
auto discrete_bearing = static_cast<DiscreteBearing>(bearing);
|
||||
auto max_element =
|
||||
std::max_element(available_bearings.begin(), available_bearings.end(),
|
||||
std::max_element(available_bearings.begin(),
|
||||
available_bearings.end(),
|
||||
[&](const DiscreteBearing first, const DiscreteBearing second) {
|
||||
return angularDeviation(first, discrete_bearing) >
|
||||
angularDeviation(second, discrete_bearing);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#include "util/exception.hpp"
|
||||
#include "util/name_table.hpp"
|
||||
#include "util/exception.hpp"
|
||||
#include "util/simple_logger.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
@@ -57,7 +57,8 @@ std::string NameTable::GetNameForID(const unsigned name_id) const
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user