Add namespace around all files

This commit is contained in:
Patrick Niklaus
2016-01-05 16:51:13 +01:00
parent efc9007cbf
commit 6b18e4f7e9
194 changed files with 2648 additions and 1245 deletions
@@ -8,6 +8,11 @@
#include <string>
#include <vector>
namespace osrm
{
namespace extractor
{
class CompressedEdgeContainer
{
public:
@@ -39,4 +44,7 @@ class CompressedEdgeContainer
std::unordered_map<EdgeID, unsigned> m_edge_id_to_list_index_map;
};
}
}
#endif // GEOMETRY_COMPRESSOR_HPP_
+13 -5
View File
@@ -27,13 +27,18 @@
struct lua_State;
namespace osrm
{
namespace extractor
{
class EdgeBasedGraphFactory
{
public:
EdgeBasedGraphFactory() = delete;
EdgeBasedGraphFactory(const EdgeBasedGraphFactory &) = delete;
explicit EdgeBasedGraphFactory(std::shared_ptr<NodeBasedDynamicGraph> node_based_graph,
explicit EdgeBasedGraphFactory(std::shared_ptr<util::NodeBasedDynamicGraph> node_based_graph,
const CompressedEdgeContainer &compressed_edge_container,
const std::unordered_set<NodeID> &barrier_nodes,
const std::unordered_set<NodeID> &traffic_lights,
@@ -56,7 +61,7 @@ class EdgeBasedGraphFactory
const bool generate_edge_lookup);
#endif
void GetEdgeBasedEdges(DeallocatingVector<EdgeBasedEdge> &edges);
void GetEdgeBasedEdges(util::DeallocatingVector<EdgeBasedEdge> &edges);
void GetEdgeBasedNodes(std::vector<EdgeBasedNode> &nodes);
void GetStartPointMarkers(std::vector<bool> &node_is_startpoint);
@@ -69,18 +74,18 @@ class EdgeBasedGraphFactory
int GetTurnPenalty(double angle, lua_State *lua_state) const;
private:
using EdgeData = NodeBasedDynamicGraph::EdgeData;
using EdgeData = util::NodeBasedDynamicGraph::EdgeData;
//! maps index from m_edge_based_node_list to ture/false if the node is an entry point to the
//! graph
std::vector<bool> m_edge_based_node_is_startpoint;
//! list of edge based nodes (compressed segments)
std::vector<EdgeBasedNode> m_edge_based_node_list;
DeallocatingVector<EdgeBasedEdge> m_edge_based_edge_list;
util::DeallocatingVector<EdgeBasedEdge> m_edge_based_edge_list;
unsigned m_max_edge_id;
const std::vector<QueryNode> &m_node_info_list;
std::shared_ptr<NodeBasedDynamicGraph> m_node_based_graph;
std::shared_ptr<util::NodeBasedDynamicGraph> m_node_based_graph;
std::shared_ptr<RestrictionMap const> m_restriction_map;
const std::unordered_set<NodeID> &m_barrier_nodes;
@@ -113,4 +118,7 @@ class EdgeBasedGraphFactory
std::vector<OriginalEdgeData> &original_edge_data_vector) const;
};
}
}
#endif /* EDGE_BASED_GRAPH_FACTORY_HPP_ */
+12 -4
View File
@@ -10,7 +10,12 @@
#include <limits>
/// This is what StaticRTree serialized and stores on disk
namespace osrm
{
namespace extractor
{
/// This is what util::StaticRTree serialized and stores on disk
/// It is generated in EdgeBasedGraphFactory.
struct EdgeBasedNode
{
@@ -53,10 +58,10 @@ struct EdgeBasedNode
(reverse_edge_based_node_id != SPECIAL_NODEID));
}
static inline FixedPointCoordinate Centroid(const FixedPointCoordinate &a,
const FixedPointCoordinate &b)
static inline util::FixedPointCoordinate Centroid(const util::FixedPointCoordinate &a,
const util::FixedPointCoordinate &b)
{
FixedPointCoordinate centroid;
util::FixedPointCoordinate centroid;
// The coordinates of the midpoint are given by:
centroid.lat = (a.lat + b.lat) / 2;
centroid.lon = (a.lon + b.lon) / 2;
@@ -85,4 +90,7 @@ struct EdgeBasedNode
TravelMode backward_travel_mode : 4;
};
}
}
#endif // EDGE_BASED_NODE_HPP
@@ -5,6 +5,11 @@
#include "util/typedefs.hpp"
namespace osrm
{
namespace extractor
{
struct ExternalMemoryNode : QueryNode
{
ExternalMemoryNode(int lat, int lon, OSMNodeID id, bool barrier, bool traffic_light);
@@ -27,4 +32,7 @@ struct ExternalMemoryNodeSTXXLCompare
value_type min_value();
};
}
}
#endif /* EXTERNAL_MEMORY_NODE_HPP_ */
@@ -10,6 +10,11 @@
#include <stxxl/vector>
#include <unordered_map>
namespace osrm
{
namespace extractor
{
/**
* Uses external memory containers from stxxl to store all the data that
* is collected by the extractor callbacks.
@@ -61,4 +66,7 @@ class ExtractionContainers
lua_State *segment_state);
};
}
}
#endif /* EXTRACTION_CONTAINERS_HPP */
@@ -12,6 +12,11 @@
#include <limits>
#include <string>
namespace osrm
{
namespace extractor
{
bool simple_duration_is_valid(const std::string &s)
{
boost::regex simple_format(
@@ -29,8 +34,8 @@ bool simple_duration_is_valid(const std::string &s)
bool iso_8601_duration_is_valid(const std::string &s)
{
iso_8601_grammar<std::string::const_iterator> iso_parser;
const bool result = qi::parse(s.begin(), s.end(), iso_parser);
util::iso_8601_grammar<std::string::const_iterator> iso_parser;
const bool result = boost::spirit::qi::parse(s.begin(), s.end(), iso_parser);
// check if the was an error with the request
if (result && (0 != iso_parser.get_duration()))
@@ -81,8 +86,8 @@ unsigned parseDuration(const std::string &s)
}
else if (iso_8601_duration_is_valid(s))
{
iso_8601_grammar<std::string::const_iterator> iso_parser;
qi::parse(s.begin(), s.end(), iso_parser);
util::iso_8601_grammar<std::string::const_iterator> iso_parser;
boost::spirit::qi::parse(s.begin(), s.end(), iso_parser);
return iso_parser.get_duration();
}
@@ -90,4 +95,7 @@ unsigned parseDuration(const std::string &s)
return std::numeric_limits<unsigned>::max();
}
}
}
#endif // EXTRACTION_HELPER_FUNCTIONS_HPP
+9
View File
@@ -1,6 +1,11 @@
#ifndef EXTRACTION_NODE_HPP
#define EXTRACTION_NODE_HPP
namespace osrm
{
namespace extractor
{
struct ExtractionNode
{
ExtractionNode() : traffic_lights(false), barrier(false) {}
@@ -8,4 +13,8 @@ struct ExtractionNode
bool traffic_lights;
bool barrier;
};
}
}
#endif // EXTRACTION_NODE_HPP
+8
View File
@@ -7,6 +7,11 @@
#include <string>
#include <vector>
namespace osrm
{
namespace extractor
{
/**
* This struct is the direct result of the call to ```way_function```
* in the lua based profile.
@@ -99,4 +104,7 @@ struct ExtractionWay
TravelMode backward_travel_mode : 4;
};
}
}
#endif // EXTRACTION_WAY_HPP
+12 -4
View File
@@ -5,6 +5,11 @@
#include "extractor/edge_based_graph_factory.hpp"
#include "extractor/graph_compressor.hpp"
namespace osrm
{
namespace extractor
{
class extractor
{
public:
@@ -18,22 +23,25 @@ class extractor
BuildEdgeExpandedGraph(std::vector<QueryNode> &internal_to_external_node_map,
std::vector<EdgeBasedNode> &node_based_edge_list,
std::vector<bool> &node_is_startpoint,
DeallocatingVector<EdgeBasedEdge> &edge_based_edge_list);
util::DeallocatingVector<EdgeBasedEdge> &edge_based_edge_list);
void WriteNodeMapping(const std::vector<QueryNode> &internal_to_external_node_map);
void FindComponents(unsigned max_edge_id,
const DeallocatingVector<EdgeBasedEdge> &edges,
const util::DeallocatingVector<EdgeBasedEdge> &edges,
std::vector<EdgeBasedNode> &nodes) const;
void BuildRTree(std::vector<EdgeBasedNode> node_based_edge_list,
std::vector<bool> node_is_startpoint,
const std::vector<QueryNode> &internal_to_external_node_map);
std::shared_ptr<RestrictionMap> LoadRestrictionMap();
std::shared_ptr<NodeBasedDynamicGraph>
std::shared_ptr<util::NodeBasedDynamicGraph>
LoadNodeBasedGraph(std::unordered_set<NodeID> &barrier_nodes,
std::unordered_set<NodeID> &traffic_lights,
std::vector<QueryNode> &internal_to_external_node_map);
void WriteEdgeBasedGraph(std::string const &output_file_filename,
size_t const max_edge_id,
DeallocatingVector<EdgeBasedEdge> const &edge_based_edge_list);
util::DeallocatingVector<EdgeBasedEdge> const &edge_based_edge_list);
};
}
}
#endif /* EXTRACTOR_HPP */
+13 -5
View File
@@ -7,17 +7,22 @@
#include <string>
#include <unordered_map>
struct ExternalMemoryNode;
class ExtractionContainers;
struct InputRestrictionContainer;
struct ExtractionNode;
struct ExtractionWay;
namespace osmium
{
class Node;
class Way;
}
namespace osrm
{
namespace extractor
{
class ExtractionContainers;
struct InputRestrictionContainer;
struct ExtractionNode;
struct ExtractionWay;
/**
* This class is uses by the extractor with the results of the
* osmium based parsing and the customization through the lua profile.
@@ -47,4 +52,7 @@ class ExtractorCallbacks
void ProcessWay(const osmium::Way &current_way, const ExtractionWay &result_way);
};
}
}
#endif /* EXTRACTOR_CALLBACKS_HPP */
+8
View File
@@ -5,6 +5,11 @@
#include <string>
namespace osrm
{
namespace extractor
{
enum class return_code : unsigned
{
ok,
@@ -48,4 +53,7 @@ struct ExtractorOptions
static void GenerateOutputFilesNames(ExtractorConfig &extractor_config);
};
}
}
#endif // EXTRACTOR_OPTIONS_HPP
@@ -7,6 +7,11 @@
#include <limits>
#include <string>
namespace osrm
{
namespace extractor
{
struct FirstAndLastSegmentOfWay
{
OSMWayID way_id;
@@ -49,4 +54,7 @@ struct FirstAndLastSegmentOfWayStxxlCompare
value_type min_value() { return FirstAndLastSegmentOfWay::min_value(); }
};
}
}
#endif /* FIRST_AND_LAST_SEGMENT_OF_WAY_HPP */
+11 -3
View File
@@ -9,12 +9,17 @@
#include <memory>
#include <unordered_set>
namespace osrm
{
namespace extractor
{
class CompressedEdgeContainer;
class RestrictionMap;
class GraphCompressor
{
using EdgeData = NodeBasedDynamicGraph::EdgeData;
using EdgeData = util::NodeBasedDynamicGraph::EdgeData;
public:
GraphCompressor(SpeedProfileProperties speed_profile);
@@ -22,15 +27,18 @@ class GraphCompressor
void Compress(const std::unordered_set<NodeID> &barrier_nodes,
const std::unordered_set<NodeID> &traffic_lights,
RestrictionMap &restriction_map,
NodeBasedDynamicGraph &graph,
util::NodeBasedDynamicGraph &graph,
CompressedEdgeContainer &geometry_compressor);
private:
void PrintStatistics(unsigned original_number_of_nodes,
unsigned original_number_of_edges,
const NodeBasedDynamicGraph &graph) const;
const util::NodeBasedDynamicGraph &graph) const;
SpeedProfileProperties speed_profile;
};
}
}
#endif
+8
View File
@@ -4,6 +4,11 @@
#include "extractor/travel_mode.hpp"
#include "util/typedefs.hpp"
namespace osrm
{
namespace extractor
{
struct NodeBasedEdge
{
bool operator<(const NodeBasedEdge &e) const;
@@ -90,4 +95,7 @@ struct EdgeBasedEdge
bool backward : 1;
};
}
}
#endif /* IMPORT_EDGE_HPP */
@@ -10,6 +10,11 @@
#include "osrm/coordinate.hpp"
#include <utility>
namespace osrm
{
namespace extractor
{
struct InternalExtractorEdge
{
// specify the type of the weight data
@@ -80,7 +85,7 @@ struct InternalExtractorEdge
// intermediate edge weight
WeightData weight_data;
// coordinate of the source node
FixedPointCoordinate source_coordinate;
util::FixedPointCoordinate source_coordinate;
// necessary static util functions for stxxl's sorting
static InternalExtractorEdge min_osm_value()
@@ -148,4 +153,7 @@ struct CmpEdgeByOSMTargetID
value_type min_value() { return InternalExtractorEdge::min_osm_value(); }
};
}
}
#endif // INTERNAL_EXTRACTOR_EDGE_HPP
+8
View File
@@ -3,6 +3,11 @@
#include "util/typedefs.hpp"
namespace osrm
{
namespace extractor
{
struct Cmp
{
using value_type = OSMNodeID;
@@ -11,4 +16,7 @@ struct Cmp
value_type min_value() { return MIN_OSM_NODEID; }
};
}
}
#endif // NODE_ID_HPP
+8
View File
@@ -7,6 +7,11 @@
#include <limits>
namespace osrm
{
namespace extractor
{
struct OriginalEdgeData
{
explicit OriginalEdgeData(NodeID via_node,
@@ -33,4 +38,7 @@ struct OriginalEdgeData
TravelMode travel_mode;
};
}
}
#endif // ORIGINAL_EDGE_DATA_HPP
+8
View File
@@ -9,6 +9,11 @@
#include <limits>
namespace osrm
{
namespace extractor
{
struct QueryNode
{
using key_type = OSMNodeID; // type of NodeID
@@ -55,4 +60,7 @@ struct QueryNode
}
};
}
}
#endif // QUERY_NODE_HPP
+11 -3
View File
@@ -13,6 +13,11 @@
#include <unordered_map>
#include <iterator>
namespace osrm
{
namespace extractor
{
/**
\brief Small wrapper around raster source queries to optionally provide results
gracefully, depending on source bounds
@@ -40,7 +45,7 @@ class RasterGrid
boost::filesystem::ifstream stream(filepath);
if (!stream)
{
throw osrm::exception("Unable to open raster file.");
throw util::exception("Unable to open raster file.");
}
stream.seekg(0, std::ios_base::end);
@@ -65,13 +70,13 @@ class RasterGrid
}
catch (std::exception const &ex)
{
throw osrm::exception(
throw util::exception(
std::string("Failed to read from raster source with exception: ") + ex.what());
}
if (!r || itr != end)
{
throw osrm::exception("Failed to parse raster source correctly.");
throw util::exception("Failed to parse raster source correctly.");
}
}
@@ -145,4 +150,7 @@ class SourceContainer
std::unordered_map<std::string, int> LoadedSourcePaths;
};
}
}
#endif /* RASTER_SOURCE_HPP */
+8
View File
@@ -5,6 +5,11 @@
#include <limits>
namespace osrm
{
namespace extractor
{
struct TurnRestriction
{
union WayOrNode
@@ -104,4 +109,7 @@ struct CmpRestrictionContainerByTo
value_type min_value() const { return InputRestrictionContainer::min_value(); }
};
}
}
#endif // RESTRICTION_HPP
+19 -4
View File
@@ -12,6 +12,11 @@
#include <unordered_set>
#include <vector>
namespace osrm
{
namespace extractor
{
struct RestrictionSource
{
NodeID start_node;
@@ -37,26 +42,33 @@ struct RestrictionTarget
return (lhs.target_node == rhs.target_node && lhs.is_only == rhs.is_only);
}
};
}
}
namespace std
{
template <> struct hash<RestrictionSource>
template <> struct hash<osrm::extractor::RestrictionSource>
{
size_t operator()(const RestrictionSource &r_source) const
size_t operator()(const osrm::extractor::RestrictionSource &r_source) const
{
return hash_val(r_source.start_node, r_source.via_node);
}
};
template <> struct hash<RestrictionTarget>
template <> struct hash<osrm::extractor::RestrictionTarget>
{
size_t operator()(const RestrictionTarget &r_target) const
size_t operator()(const osrm::extractor::RestrictionTarget &r_target) const
{
return hash_val(r_target.target_node, r_target.is_only);
}
};
}
namespace osrm
{
namespace extractor
{
/**
\brief Efficent look up if an edge is the start + via node of a TurnRestriction
EdgeBasedEdgeFactory decides by it if edges are inserted or geometry is compressed
@@ -146,4 +158,7 @@ class RestrictionMap
std::unordered_set<NodeID> m_no_turn_via_node_set;
};
}
}
#endif // RESTRICTION_MAP_HPP
+9
View File
@@ -14,6 +14,12 @@ namespace osmium
class Relation;
}
namespace osrm
{
namespace extractor
{
/**
* Parses the relations that represents turn restrictions.
*
@@ -47,4 +53,7 @@ class RestrictionParser
bool use_turn_restrictions;
};
}
}
#endif /* RESTRICTION_PARSER_HPP */
@@ -8,6 +8,11 @@
struct lua_State;
namespace osrm
{
namespace extractor
{
/**
* Creates a lua context and binds osmium way, node and relation objects and
* ExtractionWay and ExtractionNode to lua objects.
@@ -30,4 +35,7 @@ class ScriptingEnvironment
tbb::enumerable_thread_specific<std::shared_ptr<lua_State>> script_contexts;
};
}
}
#endif /* SCRIPTING_ENVIRONMENT_HPP */
+8
View File
@@ -1,6 +1,11 @@
#ifndef SPEED_PROFILE_PROPERTIES_HPP
#define SPEED_PROFILE_PROPERTIES_HPP
namespace osrm
{
namespace extractor
{
struct SpeedProfileProperties
{
SpeedProfileProperties()
@@ -13,4 +18,7 @@ struct SpeedProfileProperties
bool has_turn_penalty_function;
};
}
}
#endif
+11 -3
View File
@@ -22,6 +22,11 @@
#include <stack>
#include <vector>
namespace osrm
{
namespace extractor
{
template <typename GraphT> class TarjanSCC
{
struct TarjanStackFrame
@@ -66,7 +71,7 @@ template <typename GraphT> class TarjanSCC
unsigned component_index = 0, size_of_current_component = 0;
unsigned index = 0;
std::vector<bool> processing_node_before_recursion(max_node_id, true);
for (const NodeID node : osrm::irange(0u, max_node_id))
for (const NodeID node : util::irange(0u, max_node_id))
{
if (SPECIAL_NODEID == components_index[node])
{
@@ -141,7 +146,7 @@ template <typename GraphT> class TarjanSCC
if (size_of_current_component > 1000)
{
SimpleLogger().Write() << "large component [" << component_index
util::SimpleLogger().Write() << "large component [" << component_index
<< "]=" << size_of_current_component;
}
@@ -153,7 +158,7 @@ template <typename GraphT> class TarjanSCC
}
TIMER_STOP(SCC_RUN);
SimpleLogger().Write() << "SCC run took: " << TIMER_MSEC(SCC_RUN) / 1000. << "s";
util::SimpleLogger().Write() << "SCC run took: " << TIMER_MSEC(SCC_RUN) / 1000. << "s";
size_one_counter = std::count_if(component_size_vector.begin(), component_size_vector.end(),
[](unsigned value)
@@ -174,4 +179,7 @@ template <typename GraphT> class TarjanSCC
unsigned get_component_id(const NodeID node) const { return components_index[node]; }
};
}
}
#endif /* TARJAN_SCC_HPP */
+11 -3
View File
@@ -1,10 +1,18 @@
#ifndef TRAVEL_MODE_HPP
#define TRAVEL_MODE_HPP
namespace
namespace osrm
{
namespace extractor
{
using TravelMode = unsigned char;
static const TravelMode TRAVEL_MODE_INACCESSIBLE = 0;
static const TravelMode TRAVEL_MODE_DEFAULT = 1;
}
}
namespace {
static const osrm::extractor::TravelMode TRAVEL_MODE_INACCESSIBLE = 0;
static const osrm::extractor::TravelMode TRAVEL_MODE_DEFAULT = 1;
}
#endif /* TRAVEL_MODE_HPP */
+8
View File
@@ -1,6 +1,11 @@
#ifndef TURN_INSTRUCTIONS_HPP
#define TURN_INSTRUCTIONS_HPP
namespace osrm
{
namespace extractor
{
enum class TurnInstruction : unsigned char
{
NoTurn = 0,
@@ -75,4 +80,7 @@ struct TurnInstructionsClass
}
};
}
}
#endif /* TURN_INSTRUCTIONS_HPP */