#5325 CLang format

This commit is contained in:
Vsevolod Novikov 2021-02-15 19:46:06 +03:00
parent d69d0c2fe6
commit 44bc0a521e
10 changed files with 122 additions and 109 deletions

View File

@ -1,8 +1,8 @@
#ifndef GEOMETRY_COMPRESSOR_HPP_
#define GEOMETRY_COMPRESSOR_HPP_
#include "extractor/segment_data_container.hpp"
#include "extractor/node_based_edge.hpp"
#include "extractor/segment_data_container.hpp"
#include "util/typedefs.hpp"
@ -49,7 +49,8 @@ class CompressedEdgeContainer
const SegmentWeight duration);
void InitializeBothwayVector();
unsigned ZipEdges(const unsigned f_edge_pos, const unsigned r_edge_pos, OSMWayIDMap &osm_way_id_map);
unsigned
ZipEdges(const unsigned f_edge_pos, const unsigned r_edge_pos, OSMWayIDMap &osm_way_id_map);
bool HasEntryForID(const EdgeID edge_id) const;
bool HasZippedEntryForForwardID(const EdgeID edge_id) const;

View File

@ -2,8 +2,8 @@
#define NODE_BASED_EDGE_HPP
#include <cstdint>
#include <tuple>
#include <map>
#include <tuple>
#include "extractor/class_data.hpp"
#include "extractor/travel_mode.hpp"

View File

@ -73,10 +73,8 @@ struct RouteParametersGrammar : public BaseParametersGrammar<Iterator, Signature
"full", engine::api::RouteParameters::OverviewType::Full)(
"false", engine::api::RouteParameters::OverviewType::False);
annotations_type.add(
"duration", AnnotationsType::Duration)(
"nodes", AnnotationsType::Nodes)(
"ways", AnnotationsType::Ways)(
annotations_type.add("duration", AnnotationsType::Duration)(
"nodes", AnnotationsType::Nodes)("ways", AnnotationsType::Ways)(
"distance", AnnotationsType::Distance)("weight", AnnotationsType::Weight)(
"datasources", AnnotationsType::Datasources)("speed", AnnotationsType::Speed);

View File

@ -262,7 +262,9 @@ void CompressedEdgeContainer::InitializeBothwayVector()
segment_data->rev_datasources.reserve(m_compressed_oneway_geometries.size());
}
unsigned CompressedEdgeContainer::ZipEdges(const EdgeID f_edge_id, const EdgeID r_edge_id, OSMWayIDMap &osm_way_id_map)
unsigned CompressedEdgeContainer::ZipEdges(const EdgeID f_edge_id,
const EdgeID r_edge_id,
OSMWayIDMap &osm_way_id_map)
{
if (!segment_data)
InitializeBothwayVector();
@ -299,18 +301,27 @@ unsigned CompressedEdgeContainer::ZipEdges(const EdgeID f_edge_id, const EdgeID
BOOST_ASSERT(fwd_node.node_id == rev_node.node_id);
auto node_id = fwd_node.node_id;
if( node_id != prev_node_id ) {
if (node_id != prev_node_id)
{
auto find_way_id = osm_way_id_map.find(OSMWayIDMapKey(prev_node_id, node_id));
if( find_way_id == osm_way_id_map.cend() ) {
if (find_way_id == osm_way_id_map.cend())
{
find_way_id = osm_way_id_map.find(OSMWayIDMapKey(node_id, prev_node_id));
}
if( find_way_id == osm_way_id_map.cend() ) {
util::Log(logERROR) << "OSM Way ID not found for (nbg) nodes, it should never be happened: " << prev_node_id << "<-x->" << node_id;
if (find_way_id == osm_way_id_map.cend())
{
util::Log(logERROR)
<< "OSM Way ID not found for (nbg) nodes, it should never be happened: "
<< prev_node_id << "<-x->" << node_id;
segment_data->osm_ways.emplace_back(osm_way_id);
} else {
}
else
{
segment_data->osm_ways.emplace_back(osm_way_id = find_way_id->second);
}
} else {
}
else
{
// Special case (artificial lighting signal edge)
segment_data->osm_ways.emplace_back(osm_way_id);
}
@ -327,18 +338,27 @@ unsigned CompressedEdgeContainer::ZipEdges(const EdgeID f_edge_id, const EdgeID
const auto &last_node = forward_bucket.back();
auto node_id = last_node.node_id;
if( node_id != prev_node_id ) {
if (node_id != prev_node_id)
{
auto find_way_id = osm_way_id_map.find(OSMWayIDMapKey(prev_node_id, node_id));
if( find_way_id == osm_way_id_map.cend() ) {
if (find_way_id == osm_way_id_map.cend())
{
find_way_id = osm_way_id_map.find(OSMWayIDMapKey(node_id, prev_node_id));
}
if( find_way_id == osm_way_id_map.cend() ) {
util::Log(logERROR) << "OSM Way ID not found for (nbg) nodes, it should never be happened: " << prev_node_id << "<-x->" << node_id;
if (find_way_id == osm_way_id_map.cend())
{
util::Log(logERROR)
<< "OSM Way ID not found for (nbg) nodes, it should never be happened: "
<< prev_node_id << "<-x->" << node_id;
segment_data->osm_ways.emplace_back(osm_way_id);
} else {
}
else
{
segment_data->osm_ways.emplace_back(osm_way_id = find_way_id->second);
}
} else {
}
else
{
// Special case (artificial lighting signal edge)
segment_data->osm_ways.emplace_back(osm_way_id);
}

View File

@ -370,8 +370,10 @@ int Extractor::run(ScriptingEnvironment &scripting_environment)
return 0;
}
std::
tuple<LaneDescriptionMap, OSMWayIDMap, std::vector<TurnRestriction>, std::vector<UnresolvedManeuverOverride>>
std::tuple<LaneDescriptionMap,
OSMWayIDMap,
std::vector<TurnRestriction>,
std::vector<UnresolvedManeuverOverride>>
Extractor::ParseOSMData(ScriptingEnvironment &scripting_environment,
const unsigned number_of_threads)
{
@ -631,10 +633,10 @@ std::
files::writeProfileProperties(config.GetPath(".osrm.properties").string(), profile_properties);
// Fill OSM Way ID Lookup Map to use it later
for(auto edge: extraction_containers.all_edges_list) {
osm_way_id_map[
OSMWayIDMapKey(edge.result.source, edge.result.target)
] = edge.result.osm_way_id;
for (auto edge : extraction_containers.all_edges_list)
{
osm_way_id_map[OSMWayIDMapKey(edge.result.source, edge.result.target)] =
edge.result.osm_way_id;
}
TIMER_STOP(extracting);

View File

@ -32,8 +32,7 @@ ExtractorCallbacks::ExtractorCallbacks(ExtractionContainers &extraction_containe
OSMWayIDMap &osm_way_id_map,
const ProfileProperties &properties)
: external_memory(extraction_containers_), classes_map(classes_map),
lane_description_map(lane_description_map),
osm_way_id_map(osm_way_id_map),
lane_description_map(lane_description_map), osm_way_id_map(osm_way_id_map),
fallback_to_duration(properties.fallback_to_duration),
force_split_edges(properties.force_split_edges)
{

View File

@ -127,7 +127,8 @@ void NodeBasedGraphFactory::CompressGeometry(OSMWayIDMap &osm_way_id_map)
const EdgeID edge_id_2 = compressed_output_graph.FindEdge(to, from);
BOOST_ASSERT(edge_id_2 != SPECIAL_EDGEID);
auto packed_geometry_id = compressed_edge_container.ZipEdges(edge_id_1, edge_id_2, osm_way_id_map);
auto packed_geometry_id =
compressed_edge_container.ZipEdges(edge_id_1, edge_id_2, osm_way_id_map);
// remember the geometry ID for both edges in the node-based graph
compressed_output_graph.GetEdgeData(edge_id_1).geometry_id = {packed_geometry_id, true};

View File

@ -14,9 +14,9 @@
#include "osrm/osrm.hpp"
#include "osrm/route_parameters.hpp"
#include "osrm/status.hpp"
#include <osmium/io/reader.hpp>
#include <osmium/io/pbf_input.hpp>
#include <osmium/handler.hpp>
#include <osmium/io/pbf_input.hpp>
#include <osmium/io/reader.hpp>
#include <osmium/osm/node.hpp>
#include <osmium/osm/way.hpp>
#include <osmium/visitor.hpp>
@ -604,14 +604,19 @@ BOOST_AUTO_TEST_CASE(test_manual_setting_of_annotations_property_new_api)
using NodePair = std::pair<osmium::unsigned_object_id_type, osmium::unsigned_object_id_type>;
using NodePairToWayIDMap = std::map<NodePair, osmium::unsigned_object_id_type>;
NodePairToWayIDMap read_node_pair_to_way_id_map(osmium::io::Reader &osm) {
struct H: public osmium::handler::Handler {
NodePairToWayIDMap read_node_pair_to_way_id_map(osmium::io::Reader &osm)
{
struct H : public osmium::handler::Handler
{
NodePairToWayIDMap ret;
void way(const osmium::Way &way) {
void way(const osmium::Way &way)
{
auto first = osmium::unsigned_object_id_type(-1);
for( const auto &n: way.nodes() ) {
for (const auto &n : way.nodes())
{
const auto second = n.positive_ref();
if( first != osmium::unsigned_object_id_type(-1) ) {
if (first != osmium::unsigned_object_id_type(-1))
{
ret[{first, second}] = way.id();
}
first = second;
@ -625,19 +630,17 @@ NodePairToWayIDMap read_node_pair_to_way_id_map(osmium::io::Reader &osm) {
using LonLat = std::pair<float, float>;
using LonLatVector = std::vector<LonLat>;
LonLatVector check_route_annotated_ways(
std::vector<osrm::util::Coordinate> &coordinates,
LonLatVector check_route_annotated_ways(std::vector<osrm::util::Coordinate> &coordinates,
osrm::OSRM &osrm,
NodePairToWayIDMap &node_pair_to_way_id_map,
bool use_steps
) {
bool use_steps)
{
LonLatVector ret;
using namespace osrm;
(void)node_pair_to_way_id_map;
RouteParameters params{};
params.annotations_type =
RouteParameters::AnnotationsType::Nodes |
RouteParameters::AnnotationsType::Ways;
RouteParameters::AnnotationsType::Nodes | RouteParameters::AnnotationsType::Ways;
params.steps = use_steps;
params.geometries = engine::api::RouteParameters::GeometriesType::GeoJSON;
params.coordinates = coordinates;
@ -649,9 +652,7 @@ LonLatVector check_route_annotated_ways(
const auto code = json_result.values.at("code").get<json::String>().value;
BOOST_CHECK_EQUAL(code, "Ok");
auto routes = json_result.values["routes"]
.get<json::Array>()
.values;
auto routes = json_result.values["routes"].get<json::Array>().values;
BOOST_CHECK_EQUAL(routes.size(), 1);
auto route = routes[0];
@ -662,24 +663,22 @@ LonLatVector check_route_annotated_ways(
.get<json::Array>()
.values;
auto legs = route.get<json::Object>()
.values["legs"]
.get<json::Array>()
.values;
for(auto leg: legs) {
if( use_steps ) {
auto steps = leg.get<json::Object>()
.values["steps"]
.get<json::Array>()
.values;
for(auto step: steps) {
auto legs = route.get<json::Object>().values["legs"].get<json::Array>().values;
for (auto leg : legs)
{
if (use_steps)
{
auto steps = leg.get<json::Object>().values["steps"].get<json::Array>().values;
for (auto step : steps)
{
auto geom = step.get<json::Object>()
.values["geometry"]
.get<json::Object>()
.values["coordinates"]
.get<json::Array>()
.values;
for(auto gleg: geom) {
for (auto gleg : geom)
{
auto p = gleg.get<json::Array>().values;
auto lon = p[0].get<json::Number>().value;
auto lat = p[1].get<json::Number>().value;
@ -687,38 +686,30 @@ LonLatVector check_route_annotated_ways(
}
}
}
auto annotations = leg.get<json::Object>()
.values["annotation"]
.get<json::Object>()
.values;
auto annotations = leg.get<json::Object>().values["annotation"].get<json::Object>().values;
BOOST_CHECK_EQUAL(annotations.size(), 2);
auto nodes = annotations["nodes"]
.get<json::Array>()
.values;
auto ways = annotations["ways"]
.get<json::Array>()
.values;
auto nodes = annotations["nodes"].get<json::Array>().values;
auto ways = annotations["ways"].get<json::Array>().values;
BOOST_CHECK_GT(nodes.size(), 1);
BOOST_CHECK_EQUAL(nodes.size() - 1, ways.size());
auto nodes_it = nodes.cbegin();
auto ways_it = ways.cbegin();
osmium::unsigned_object_id_type first = nodes_it->get<json::Number>().value;
for(nodes_it++; nodes_it != nodes.cend(); nodes_it++, ways_it++) {
for (nodes_it++; nodes_it != nodes.cend(); nodes_it++, ways_it++)
{
osmium::unsigned_object_id_type second = nodes_it->get<json::Number>().value;
osmium::unsigned_object_id_type way_id = ways_it->get<json::Number>().value;
auto found = node_pair_to_way_id_map.find(NodePair(first, second));
if (found == node_pair_to_way_id_map.end())
found = node_pair_to_way_id_map.find(NodePair(second, first));
BOOST_CHECK_MESSAGE(
found != node_pair_to_way_id_map.end(),
"The node pair not found: " << first << "<->" << second
);
BOOST_CHECK_MESSAGE(
found->second == way_id,
"The node pair way doesn't correspond: " << first << "<->" << second << "=" << found->second << "=?=" << way_id
);
BOOST_CHECK_MESSAGE(found != node_pair_to_way_id_map.end(),
"The node pair not found: " << first << "<->" << second);
BOOST_CHECK_MESSAGE(found->second == way_id,
"The node pair way doesn't correspond: " << first << "<->" << second
<< "=" << found->second
<< "=?=" << way_id);
first = second;
}
}
@ -743,15 +734,16 @@ BOOST_AUTO_TEST_CASE(test_route_annotated_ways)
BOOST_TEST_MESSAGE("locations_in_big_component with steps");
auto coords = check_route_annotated_ways(coordinates, osrm, node_pair_to_way_id_map, true);
auto c1 = coords.cbegin(), c2 = coords.cend();
for( c1++, c2--; c1 != coords.cend() && c2 != coords.cbegin(); c1++, c2--) {
for (c1++, c2--; c1 != coords.cend() && c2 != coords.cbegin(); c1++, c2--)
{
if (c1 == c2)
continue;
coordinates = Locations{{Longitude{c1->first},Latitude{c1->second}},{Longitude{c2->first},Latitude{c2->second}}};
BOOST_TEST_MESSAGE(
"Checking: <" <<
osrm::util::toFloating(coordinates[0].lat) << ":" << osrm::util::toFloating(coordinates[0].lon) << "> -> <" <<
osrm::util::toFloating(coordinates[1].lat) << ":" << osrm::util::toFloating(coordinates[1].lon) << ">"
);
coordinates = Locations{{Longitude{c1->first}, Latitude{c1->second}},
{Longitude{c2->first}, Latitude{c2->second}}};
BOOST_TEST_MESSAGE("Checking: <" << osrm::util::toFloating(coordinates[0].lat) << ":"
<< osrm::util::toFloating(coordinates[0].lon) << "> -> <"
<< osrm::util::toFloating(coordinates[1].lat) << ":"
<< osrm::util::toFloating(coordinates[1].lon) << ">");
check_route_annotated_ways(coordinates, osrm, node_pair_to_way_id_map, false);
check_route_annotated_ways(coordinates, osrm, node_pair_to_way_id_map, true);
}