Fix formating

This commit is contained in:
Patrick Niklaus 2017-03-02 21:16:48 +00:00 committed by Patrick Niklaus
parent e737700c7b
commit c2a5cc034a
7 changed files with 37 additions and 29 deletions

View File

@ -19,9 +19,9 @@ struct CoreCH final
{ {
}; };
template<typename AlgorithmT> const char* name(); template <typename AlgorithmT> const char *name();
template<> inline const char* name<CH>() { return "CH"; } template <> inline const char *name<CH>() { return "CH"; }
template<> inline const char* name<CoreCH>() { return "CoreCH"; } template <> inline const char *name<CoreCH>() { return "CoreCH"; }
} }
namespace algorithm_trais namespace algorithm_trais

View File

@ -63,12 +63,14 @@ template <typename AlgorithmT> class Engine final : public EngineInterface
{ {
if (config.use_shared_memory) if (config.use_shared_memory)
{ {
util::Log(logDEBUG) << "Using shared memory with algorithm " << algorithm::name<AlgorithmT>(); util::Log(logDEBUG) << "Using shared memory with algorithm "
<< algorithm::name<AlgorithmT>();
facade_provider = std::make_unique<WatchingProvider<AlgorithmT>>(); facade_provider = std::make_unique<WatchingProvider<AlgorithmT>>();
} }
else else
{ {
util::Log(logDEBUG) << "Using internal memory with algorithm " << algorithm::name<AlgorithmT>(); util::Log(logDEBUG) << "Using internal memory with algorithm "
<< algorithm::name<AlgorithmT>();
facade_provider = facade_provider =
std::make_unique<ImmutableProvider<AlgorithmT>>(config.storage_config); std::make_unique<ImmutableProvider<AlgorithmT>>(config.storage_config);
} }
@ -157,7 +159,8 @@ template <> bool Engine<algorithm::CH>::CheckCompability(const EngineConfig &con
else else
{ {
std::ifstream in(config.storage_config.hsgr_data_path.string().c_str()); std::ifstream in(config.storage_config.hsgr_data_path.string().c_str());
if (!in) return false; if (!in)
return false;
in.seekg(0, std::ios::end); in.seekg(0, std::ios::end);
auto size = in.tellg(); auto size = in.tellg();
@ -185,7 +188,8 @@ template <> bool Engine<algorithm::CoreCH>::CheckCompability(const EngineConfig
else else
{ {
std::ifstream in(config.storage_config.core_data_path.string().c_str()); std::ifstream in(config.storage_config.core_data_path.string().c_str());
if (!in) return false; if (!in)
return false;
in.seekg(0, std::ios::end); in.seekg(0, std::ios::end);
std::size_t size = in.tellg(); std::size_t size = in.tellg();

View File

@ -57,7 +57,8 @@ namespace engine
* *
* You can chose between three algorithms: * You can chose between three algorithms:
* - Algorithm::CH * - Algorithm::CH
* Contraction Hierarchies, extremely fast queries but slow pre-processing. The default right now. * Contraction Hierarchies, extremely fast queries but slow pre-processing. The default right
* now.
* - Algorithm::CoreCH * - Algorithm::CoreCH
* Contractoin Hierachies with partial contraction for faster pre-processing but slower queries. * Contractoin Hierachies with partial contraction for faster pre-processing but slower queries.
* *
@ -72,8 +73,8 @@ struct EngineConfig final
enum class Algorithm enum class Algorithm
{ {
CH, // will upgrade to CoreCH if it finds core data CH, // will upgrade to CoreCH if it finds core data
CoreCH // will fail hard if there is no core data CoreCH // will fail hard if there is no core data
}; };
storage::StorageConfig storage_config; storage::StorageConfig storage_config;

View File

@ -15,7 +15,6 @@ namespace engine
namespace routing_algorithms namespace routing_algorithms
{ {
using CandidateList = std::vector<PhantomNodeWithDistance>; using CandidateList = std::vector<PhantomNodeWithDistance>;
using CandidateLists = std::vector<CandidateList>; using CandidateLists = std::vector<CandidateList>;
using SubMatchingList = std::vector<map_matching::SubMatching>; using SubMatchingList = std::vector<map_matching::SubMatching>;

View File

@ -259,7 +259,8 @@ std::vector<std::size_t> getEdgeIndex(const std::vector<RTreeLeaf> &edges)
// GetEdgesInBox is marked `const`, so we can't sort the array itself, // GetEdgesInBox is marked `const`, so we can't sort the array itself,
// instead we create an array of indexes and sort that instead. // instead we create an array of indexes and sort that instead.
std::vector<std::size_t> sorted_edge_indexes(edges.size(), 0); std::vector<std::size_t> sorted_edge_indexes(edges.size(), 0);
std::iota(sorted_edge_indexes.begin(), sorted_edge_indexes.end(), 0); // fill with 0,1,2,3,...N-1 std::iota(
sorted_edge_indexes.begin(), sorted_edge_indexes.end(), 0); // fill with 0,1,2,3,...N-1
// Now, sort that array based on the edges list, using the u/v node IDs // Now, sort that array based on the edges list, using the u/v node IDs
// as the sort condition // as the sort condition
@ -653,17 +654,19 @@ void encodeVectorTile(const datafacade::ContiguousInternalMemoryDataFacadeBase &
{ {
// we need to pre-encode all values here because we need the full offsets later // we need to pre-encode all values here because we need the full offsets later
// for encoding the actual features. // for encoding the actual features.
std::vector<std::tuple<util::Coordinate, unsigned, unsigned, unsigned>> encoded_turn_data(all_turn_data.size()); std::vector<std::tuple<util::Coordinate, unsigned, unsigned, unsigned>>
std::transform(all_turn_data.begin(), encoded_turn_data(all_turn_data.size());
all_turn_data.end(), std::transform(
encoded_turn_data.begin(), all_turn_data.begin(),
[&](const routing_algorithms::TurnData &t) { all_turn_data.end(),
auto angle_idx = use_point_int_value(t.in_angle); encoded_turn_data.begin(),
auto turn_idx = use_point_int_value(t.turn_angle); [&](const routing_algorithms::TurnData &t) {
auto weight_idx = use_point_float_value(t.weight / auto angle_idx = use_point_int_value(t.in_angle);
10.0); // Note conversion to float here auto turn_idx = use_point_int_value(t.turn_angle);
return std::make_tuple(t.coordinate, angle_idx, turn_idx, weight_idx); auto weight_idx =
}); use_point_float_value(t.weight / 10.0); // Note conversion to float here
return std::make_tuple(t.coordinate, angle_idx, turn_idx, weight_idx);
});
// Now write the points layer for turn penalty data: // Now write the points layer for turn penalty data:
// Add a layer object to the PBF stream. 3=='layer' from the vector tile spec // Add a layer object to the PBF stream. 3=='layer' from the vector tile spec
@ -680,9 +683,8 @@ void encodeVectorTile(const datafacade::ContiguousInternalMemoryDataFacadeBase &
int id = 1; int id = 1;
// Helper function to encode a new point feature on a vector tile. // Helper function to encode a new point feature on a vector tile.
const auto encode_tile_point = [&]( const auto encode_tile_point = [&](const FixedPoint &tile_point,
const FixedPoint &tile_point, const auto &point_turn_data) {
const auto &point_turn_data) {
protozero::pbf_writer feature_writer(point_layer_writer, protozero::pbf_writer feature_writer(point_layer_writer,
util::vector_tile::FEATURE_TAG); util::vector_tile::FEATURE_TAG);
// Field 3 is the "geometry type" field. Value 1 is "point" // Field 3 is the "geometry type" field. Value 1 is "point"
@ -714,7 +716,8 @@ void encodeVectorTile(const datafacade::ContiguousInternalMemoryDataFacadeBase &
// Loop over all the turns we found and add them as features to the layer // Loop over all the turns we found and add them as features to the layer
for (const auto &turndata : encoded_turn_data) for (const auto &turndata : encoded_turn_data)
{ {
const auto tile_point = coordinatesToTilePoint(std::get<0>(turndata), tile_bbox); const auto tile_point =
coordinatesToTilePoint(std::get<0>(turndata), tile_bbox);
if (!boost::geometry::within(point_t(tile_point.x, tile_point.y), clip_box)) if (!boost::geometry::within(point_t(tile_point.x, tile_point.y), clip_box))
{ {
continue; continue;

View File

@ -21,7 +21,8 @@ OSRM::OSRM(engine::EngineConfig &config)
if (config.algorithm == EngineConfig::Algorithm::CoreCH || if (config.algorithm == EngineConfig::Algorithm::CoreCH ||
config.algorithm == EngineConfig::Algorithm::CH) config.algorithm == EngineConfig::Algorithm::CH)
{ {
bool corech_compatible = engine::Engine<engine::algorithm::CoreCH>::CheckCompability(config); bool corech_compatible =
engine::Engine<engine::algorithm::CoreCH>::CheckCompability(config);
// Activate CoreCH if we can because it is faster // Activate CoreCH if we can because it is faster
if (config.algorithm == EngineConfig::Algorithm::CH && corech_compatible) if (config.algorithm == EngineConfig::Algorithm::CH && corech_compatible)

View File

@ -1,6 +1,6 @@
#include "server/server.hpp" #include "server/server.hpp"
#include "util/log.hpp"
#include "util/exception.hpp" #include "util/exception.hpp"
#include "util/log.hpp"
#include "util/version.hpp" #include "util/version.hpp"
#include "osrm/engine_config.hpp" #include "osrm/engine_config.hpp"