Add namespace around all files
This commit is contained in:
@@ -4,6 +4,11 @@
|
||||
#include <boost/assert.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
namespace bearing
|
||||
{
|
||||
inline std::string get(const double heading)
|
||||
@@ -86,4 +91,7 @@ inline bool CheckInBounds(const int A, const int B, const int range)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // BEARING_HPP
|
||||
|
||||
@@ -10,6 +10,11 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
template <typename NodeID, typename Key> class ArrayStorage
|
||||
{
|
||||
public:
|
||||
@@ -286,4 +291,7 @@ class BinaryHeap
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // BINARY_HEAP_H
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
namespace cast
|
||||
{
|
||||
template <typename Enumeration>
|
||||
@@ -39,4 +44,7 @@ template <typename T, int Precision = 6> inline std::string to_string_with_preci
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // CAST_HPP
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
#ifndef COMPUTE_ANGLE_HPP
|
||||
#define COMPUTE_ANGLE_HPP
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
struct FixedPointCoordinate;
|
||||
|
||||
struct ComputeAngle
|
||||
@@ -12,4 +17,7 @@ struct ComputeAngle
|
||||
const FixedPointCoordinate &third) noexcept;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // COMPUTE_ANGLE_HPP
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
// Culled by SFINAE if reserve does not exist or is not accessible
|
||||
@@ -81,4 +84,6 @@ void append_to_container(Container &&container, T value, Args &&... args)
|
||||
}
|
||||
|
||||
} // namespace osrm
|
||||
}
|
||||
|
||||
#endif /* CONTAINER_HPP */
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
#ifndef COORDINATE_CALCULATION
|
||||
#define COORDINATE_CALCULATION
|
||||
|
||||
struct FixedPointCoordinate;
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
struct FixedPointCoordinate;
|
||||
|
||||
namespace coordinate_calculation
|
||||
{
|
||||
double haversineDistance(const int lat1, const int lon1, const int lat2, const int lon2);
|
||||
@@ -49,4 +54,7 @@ double bearing(const FixedPointCoordinate &first_coordinate,
|
||||
const FixedPointCoordinate &second_coordinate);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // COORDINATE_CALCULATION
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
// generate boost::program_options object for the routing part
|
||||
bool GenerateDataStoreOptions(const int argc,
|
||||
const char *argv[],
|
||||
@@ -199,59 +204,62 @@ bool GenerateDataStoreOptions(const int argc,
|
||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw osrm::exception("valid .hsgr file must be specified");
|
||||
throw exception("valid .hsgr file must be specified");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("nodesdata");
|
||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw osrm::exception("valid .nodes file must be specified");
|
||||
throw exception("valid .nodes file must be specified");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("edgesdata");
|
||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw osrm::exception("valid .edges file must be specified");
|
||||
throw exception("valid .edges file must be specified");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("geometry");
|
||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw osrm::exception("valid .geometry file must be specified");
|
||||
throw exception("valid .geometry file must be specified");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("ramindex");
|
||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw osrm::exception("valid .ramindex file must be specified");
|
||||
throw exception("valid .ramindex file must be specified");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("fileindex");
|
||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw osrm::exception("valid .fileindex file must be specified");
|
||||
throw exception("valid .fileindex file must be specified");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("namesdata");
|
||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw osrm::exception("valid .names file must be specified");
|
||||
throw exception("valid .names file must be specified");
|
||||
}
|
||||
|
||||
path_iterator = paths.find("timestamp");
|
||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw osrm::exception("valid .timestamp file must be specified");
|
||||
throw exception("valid .timestamp file must be specified");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* DATASTORE_OPTIONS_HPP */
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
template <typename ElementT> struct ConstDeallocatingVectorIteratorState
|
||||
{
|
||||
ConstDeallocatingVectorIteratorState()
|
||||
@@ -302,7 +307,7 @@ class DeallocatingVector
|
||||
{ // down-size
|
||||
const std::size_t number_of_necessary_buckets = 1 + (new_size / ELEMENTS_PER_BLOCK);
|
||||
for (const auto bucket_index :
|
||||
osrm::irange(number_of_necessary_buckets, bucket_list.size()))
|
||||
irange(number_of_necessary_buckets, bucket_list.size()))
|
||||
{
|
||||
if (nullptr != bucket_list[bucket_index])
|
||||
{
|
||||
@@ -374,4 +379,7 @@ void swap(DeallocatingVector<T, S> &lhs, DeallocatingVector<T, S> &rhs)
|
||||
lhs.swap(rhs);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* DEALLOCATING_VECTOR_HPP */
|
||||
|
||||
@@ -6,7 +6,12 @@
|
||||
|
||||
#ifndef DEBUG_GEOMETRY
|
||||
|
||||
inline void DEBUG_GEOMETRY_START(ContractorConfig & /* config */) {}
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
inline void DEBUG_GEOMETRY_START(const contractor::ContractorConfig & /* config */) {}
|
||||
inline void DEBUG_GEOMETRY_EDGE(int /* new_segment_weight */,
|
||||
double /* segment_length */,
|
||||
OSMNodeID /* previous_osm_node_id */,
|
||||
@@ -17,25 +22,28 @@ inline void DEBUG_GEOMETRY_STOP() {}
|
||||
|
||||
inline void DEBUG_TURNS_START(const std::string & /* debug_turns_filename */) {}
|
||||
inline void DEBUG_TURN(const NodeID /* node */,
|
||||
const std::vector<QueryNode> & /* m_node_info_list */,
|
||||
const std::vector<extractor::QueryNode> & /* m_node_info_list */,
|
||||
const FixedPointCoordinate & /* first_coordinate */,
|
||||
const int /* turn_angle */,
|
||||
const int /* turn_penalty */)
|
||||
{
|
||||
}
|
||||
inline void DEBUG_UTURN(const NodeID /* node */,
|
||||
const std::vector<QueryNode> & /* m_node_info_list */,
|
||||
const std::vector<extractor::QueryNode> & /* m_node_info_list */,
|
||||
const int /* uturn_penalty */)
|
||||
{
|
||||
}
|
||||
inline void DEBUG_SIGNAL(const NodeID /* node */,
|
||||
const std::vector<QueryNode> & /* m_node_info_list */,
|
||||
const std::vector<extractor::QueryNode> & /* m_node_info_list */,
|
||||
const int /* signal_penalty */)
|
||||
{
|
||||
}
|
||||
|
||||
inline void DEBUG_TURNS_STOP() {}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#else // DEBUG_GEOMETRY
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
@@ -47,6 +55,12 @@ inline void DEBUG_TURNS_STOP() {}
|
||||
#include "util/coordinate.hpp"
|
||||
#include "util/coordinate_calculation.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
|
||||
boost::filesystem::ofstream debug_geometry_file;
|
||||
bool dg_output_debug_geometry = false;
|
||||
bool dg_first_debug_geometry = true;
|
||||
@@ -56,7 +70,7 @@ boost::filesystem::ofstream dg_debug_turns_file;
|
||||
bool dg_output_turn_debug = false;
|
||||
bool dg_first_turn_debug = true;
|
||||
|
||||
inline void DEBUG_GEOMETRY_START(const ContractorConfig &config)
|
||||
inline void DEBUG_GEOMETRY_START(const contractor::ContractorConfig &config)
|
||||
{
|
||||
time_t raw_time;
|
||||
struct tm *timeinfo;
|
||||
@@ -118,12 +132,12 @@ inline void DEBUG_TURNS_START(const std::string &debug_turns_path)
|
||||
}
|
||||
|
||||
inline void DEBUG_SIGNAL(const NodeID node,
|
||||
const std::vector<QueryNode> &m_node_info_list,
|
||||
const std::vector<extractor::QueryNode> &m_node_info_list,
|
||||
const int traffic_signal_penalty)
|
||||
{
|
||||
if (dg_output_turn_debug)
|
||||
{
|
||||
const QueryNode &nodeinfo = m_node_info_list[node];
|
||||
const extractor::QueryNode &nodeinfo = m_node_info_list[node];
|
||||
if (!dg_first_turn_debug)
|
||||
dg_debug_turns_file << "," << std::endl;
|
||||
dg_debug_turns_file
|
||||
@@ -137,12 +151,12 @@ inline void DEBUG_SIGNAL(const NodeID node,
|
||||
}
|
||||
|
||||
inline void DEBUG_UTURN(const NodeID node,
|
||||
const std::vector<QueryNode> &m_node_info_list,
|
||||
const std::vector<extractor::QueryNode> &m_node_info_list,
|
||||
const int traffic_signal_penalty)
|
||||
{
|
||||
if (dg_output_turn_debug)
|
||||
{
|
||||
const QueryNode &nodeinfo = m_node_info_list[node];
|
||||
const extractor::QueryNode &nodeinfo = m_node_info_list[node];
|
||||
if (!dg_first_turn_debug)
|
||||
dg_debug_turns_file << "," << std::endl;
|
||||
dg_debug_turns_file
|
||||
@@ -156,14 +170,14 @@ inline void DEBUG_UTURN(const NodeID node,
|
||||
}
|
||||
|
||||
inline void DEBUG_TURN(const NodeID node,
|
||||
const std::vector<QueryNode> &m_node_info_list,
|
||||
const std::vector<extractor::QueryNode> &m_node_info_list,
|
||||
const FixedPointCoordinate &first_coordinate,
|
||||
const int turn_angle,
|
||||
const int turn_penalty)
|
||||
{
|
||||
if (turn_penalty > 0 && dg_output_turn_debug)
|
||||
{
|
||||
const QueryNode &v = m_node_info_list[node];
|
||||
const extractor::QueryNode &v = m_node_info_list[node];
|
||||
|
||||
const float bearing_uv = coordinate_calculation::bearing(first_coordinate, v);
|
||||
float uvw_normal = bearing_uv + turn_angle / 2;
|
||||
@@ -194,6 +208,9 @@ inline void DEBUG_TURNS_STOP()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // DEBUG_GEOMETRY
|
||||
|
||||
#endif // DEBUG_GEOMETRY_H
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
#include <boost/assert.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
// This Wrapper provides an easier access to a distance table that is given as an linear vector
|
||||
|
||||
template <typename T> class DistTableWrapper
|
||||
@@ -58,4 +63,7 @@ template <typename T> class DistTableWrapper
|
||||
const std::size_t number_of_nodes_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // DIST_TABLE_WRAPPER_H
|
||||
|
||||
@@ -15,13 +15,18 @@
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
template <typename EdgeDataT> class DynamicGraph
|
||||
{
|
||||
public:
|
||||
using EdgeData = EdgeDataT;
|
||||
using NodeIterator = unsigned;
|
||||
using EdgeIterator = unsigned;
|
||||
using EdgeRange = osrm::range<EdgeIterator>;
|
||||
using EdgeRange = range<EdgeIterator>;
|
||||
|
||||
class InputEdge
|
||||
{
|
||||
@@ -72,7 +77,7 @@ template <typename EdgeDataT> class DynamicGraph
|
||||
node_array.resize(number_of_nodes + 1);
|
||||
EdgeIterator edge = 0;
|
||||
EdgeIterator position = 0;
|
||||
for (const auto node : osrm::irange(0u, number_of_nodes))
|
||||
for (const auto node : irange(0u, number_of_nodes))
|
||||
{
|
||||
EdgeIterator last_edge = edge;
|
||||
while (edge < number_of_edges && graph[edge].source == node)
|
||||
@@ -87,9 +92,9 @@ template <typename EdgeDataT> class DynamicGraph
|
||||
edge_list.reserve(static_cast<std::size_t>(edge_list.size() * 1.1));
|
||||
edge_list.resize(position);
|
||||
edge = 0;
|
||||
for (const auto node : osrm::irange(0u, number_of_nodes))
|
||||
for (const auto node : irange(0u, number_of_nodes))
|
||||
{
|
||||
for (const auto i : osrm::irange(node_array[node].first_edge,
|
||||
for (const auto i : irange(node_array[node].first_edge,
|
||||
node_array[node].first_edge + node_array[node].edges))
|
||||
{
|
||||
edge_list[i].target = graph[edge].target;
|
||||
@@ -111,7 +116,7 @@ template <typename EdgeDataT> class DynamicGraph
|
||||
unsigned GetDirectedOutDegree(const NodeIterator n) const
|
||||
{
|
||||
unsigned degree = 0;
|
||||
for (const auto edge : osrm::irange(BeginEdges(n), EndEdges(n)))
|
||||
for (const auto edge : irange(BeginEdges(n), EndEdges(n)))
|
||||
{
|
||||
if (!GetEdgeData(edge).reversed)
|
||||
{
|
||||
@@ -141,7 +146,7 @@ template <typename EdgeDataT> class DynamicGraph
|
||||
|
||||
EdgeRange GetAdjacentEdgeRange(const NodeIterator node) const
|
||||
{
|
||||
return osrm::irange(BeginEdges(node), EndEdges(node));
|
||||
return irange(BeginEdges(node), EndEdges(node));
|
||||
}
|
||||
|
||||
NodeIterator InsertNode()
|
||||
@@ -175,12 +180,12 @@ template <typename EdgeDataT> class DynamicGraph
|
||||
edge_list.reserve(requiredCapacity * 1.1);
|
||||
}
|
||||
edge_list.resize(edge_list.size() + newSize);
|
||||
for (const auto i : osrm::irange(0u, node.edges))
|
||||
for (const auto i : irange(0u, node.edges))
|
||||
{
|
||||
edge_list[newFirstEdge + i] = edge_list[node.first_edge + i];
|
||||
makeDummy(node.first_edge + i);
|
||||
}
|
||||
for (const auto i : osrm::irange(node.edges + 1, newSize))
|
||||
for (const auto i : irange(node.edges + 1, newSize))
|
||||
{
|
||||
makeDummy(newFirstEdge + i);
|
||||
}
|
||||
@@ -235,7 +240,7 @@ template <typename EdgeDataT> class DynamicGraph
|
||||
// searches for a specific edge
|
||||
EdgeIterator FindEdge(const NodeIterator from, const NodeIterator to) const
|
||||
{
|
||||
for (const auto i : osrm::irange(BeginEdges(from), EndEdges(from)))
|
||||
for (const auto i : irange(BeginEdges(from), EndEdges(from)))
|
||||
{
|
||||
if (to == edge_list[i].target)
|
||||
{
|
||||
@@ -316,4 +321,7 @@ template <typename EdgeDataT> class DynamicGraph
|
||||
DeallocatingVector<Edge> edge_list;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // DYNAMICGRAPH_HPP
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
#include <boost/uuid/uuid.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
// implements a singleton, i.e. there is one and only one conviguration object
|
||||
class FingerPrint
|
||||
{
|
||||
@@ -29,4 +34,7 @@ class FingerPrint
|
||||
|
||||
static_assert(std::is_trivial<FingerPrint>::value, "FingerPrint needs to be trivial.");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* FingerPrint_H */
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
#cmakedefine MD5GRAPH "${MD5GRAPH}"
|
||||
#cmakedefine MD5OBJECTS "${MD5OBJECTS}"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
FingerPrint FingerPrint::GetValid()
|
||||
{
|
||||
FingerPrint fingerprint;
|
||||
@@ -52,7 +57,7 @@ bool FingerPrint::TestGraphUtil(const FingerPrint &other) const
|
||||
{
|
||||
if (!IsMagicNumberOK(other))
|
||||
{
|
||||
throw osrm::exception("hsgr input file misses magic number. Check or reprocess the file");
|
||||
throw exception("hsgr input file misses magic number. Check or reprocess the file");
|
||||
}
|
||||
return std::equal(md5_graph, md5_graph + 32, other.md5_graph);
|
||||
}
|
||||
@@ -61,7 +66,7 @@ bool FingerPrint::TestPrepare(const FingerPrint &other) const
|
||||
{
|
||||
if (!IsMagicNumberOK(other))
|
||||
{
|
||||
throw osrm::exception("osrm input file misses magic number. Check or reprocess the file");
|
||||
throw exception("osrm input file misses magic number. Check or reprocess the file");
|
||||
}
|
||||
return std::equal(md5_prepare, md5_prepare + 32, other.md5_prepare);
|
||||
}
|
||||
@@ -70,7 +75,7 @@ bool FingerPrint::TestRTree(const FingerPrint &other) const
|
||||
{
|
||||
if (!IsMagicNumberOK(other))
|
||||
{
|
||||
throw osrm::exception("r-tree input file misses magic number. Check or reprocess the file");
|
||||
throw exception("r-tree input file misses magic number. Check or reprocess the file");
|
||||
}
|
||||
return std::equal(md5_tree, md5_tree + 32, other.md5_tree);
|
||||
}
|
||||
@@ -79,7 +84,10 @@ bool FingerPrint::TestQueryObjects(const FingerPrint &other) const
|
||||
{
|
||||
if (!IsMagicNumberOK(other))
|
||||
{
|
||||
throw osrm::exception("missing magic number. Check or reprocess the file");
|
||||
throw exception("missing magic number. Check or reprocess the file");
|
||||
}
|
||||
return std::equal(md5_objects, md5_objects + 32, other.md5_objects);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
// implements an binary based fixed point number type
|
||||
template <unsigned FractionalBitSize,
|
||||
@@ -185,5 +187,8 @@ class FixedPointNumber
|
||||
};
|
||||
|
||||
static_assert(4 == sizeof(FixedPointNumber<1>), "FP19 has wrong size != 4");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // FIXED_POINT_NUMBER_HPP
|
||||
|
||||
@@ -8,11 +8,16 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
template <typename FloatT> bool epsilon_compare(const FloatT number1, const FloatT number2)
|
||||
{
|
||||
static_assert(std::is_floating_point<FloatT>::value, "type must be floating point");
|
||||
return (std::abs(number1 - number2) < std::numeric_limits<FloatT>::epsilon());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // FLOATING_POINT_HPP
|
||||
|
||||
@@ -22,13 +22,18 @@
|
||||
#include <ios>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
/**
|
||||
* Reads the .restrictions file and loads it to a vector.
|
||||
* The since the restrictions reference nodes using their external node id,
|
||||
* we need to renumber it to the new internal id.
|
||||
*/
|
||||
unsigned loadRestrictionsFromFile(std::istream &input_stream,
|
||||
std::vector<TurnRestriction> &restriction_list)
|
||||
std::vector<extractor::TurnRestriction> &restriction_list)
|
||||
{
|
||||
const FingerPrint fingerprint_valid = FingerPrint::GetValid();
|
||||
FingerPrint fingerprint_loaded;
|
||||
@@ -45,7 +50,7 @@ unsigned loadRestrictionsFromFile(std::istream &input_stream,
|
||||
if (number_of_usable_restrictions > 0)
|
||||
{
|
||||
input_stream.read((char *)restriction_list.data(),
|
||||
number_of_usable_restrictions * sizeof(TurnRestriction));
|
||||
number_of_usable_restrictions * sizeof(extractor::TurnRestriction));
|
||||
}
|
||||
|
||||
return number_of_usable_restrictions;
|
||||
@@ -60,7 +65,7 @@ unsigned loadRestrictionsFromFile(std::istream &input_stream,
|
||||
NodeID loadNodesFromFile(std::istream &input_stream,
|
||||
std::vector<NodeID> &barrier_node_list,
|
||||
std::vector<NodeID> &traffic_light_node_list,
|
||||
std::vector<QueryNode> &node_array)
|
||||
std::vector<extractor::QueryNode> &node_array)
|
||||
{
|
||||
const FingerPrint fingerprint_valid = FingerPrint::GetValid();
|
||||
FingerPrint fingerprint_loaded;
|
||||
@@ -76,10 +81,10 @@ NodeID loadNodesFromFile(std::istream &input_stream,
|
||||
input_stream.read(reinterpret_cast<char *>(&n), sizeof(NodeID));
|
||||
SimpleLogger().Write() << "Importing n = " << n << " nodes ";
|
||||
|
||||
ExternalMemoryNode current_node;
|
||||
extractor::ExternalMemoryNode current_node;
|
||||
for (NodeID i = 0; i < n; ++i)
|
||||
{
|
||||
input_stream.read(reinterpret_cast<char *>(¤t_node), sizeof(ExternalMemoryNode));
|
||||
input_stream.read(reinterpret_cast<char *>(¤t_node), sizeof(extractor::ExternalMemoryNode));
|
||||
node_array.emplace_back(current_node.lat, current_node.lon, current_node.node_id);
|
||||
if (current_node.barrier)
|
||||
{
|
||||
@@ -101,21 +106,21 @@ NodeID loadNodesFromFile(std::istream &input_stream,
|
||||
/**
|
||||
* Reads a .osrm file and produces the edges.
|
||||
*/
|
||||
NodeID loadEdgesFromFile(std::istream &input_stream, std::vector<NodeBasedEdge> &edge_list)
|
||||
NodeID loadEdgesFromFile(std::istream &input_stream, std::vector<extractor::NodeBasedEdge> &edge_list)
|
||||
{
|
||||
EdgeID m;
|
||||
input_stream.read(reinterpret_cast<char *>(&m), sizeof(unsigned));
|
||||
edge_list.resize(m);
|
||||
SimpleLogger().Write() << " and " << m << " edges ";
|
||||
|
||||
input_stream.read((char *)edge_list.data(), m * sizeof(NodeBasedEdge));
|
||||
input_stream.read((char *)edge_list.data(), m * sizeof(extractor::NodeBasedEdge));
|
||||
|
||||
BOOST_ASSERT(edge_list.size() > 0);
|
||||
|
||||
#ifndef NDEBUG
|
||||
SimpleLogger().Write() << "Validating loaded edges...";
|
||||
tbb::parallel_sort(edge_list.begin(), edge_list.end(),
|
||||
[](const NodeBasedEdge &lhs, const NodeBasedEdge &rhs)
|
||||
[](const extractor::NodeBasedEdge &lhs, const extractor::NodeBasedEdge &rhs)
|
||||
{
|
||||
return (lhs.source < rhs.source) ||
|
||||
(lhs.source == rhs.source && lhs.target < rhs.target);
|
||||
@@ -148,11 +153,11 @@ unsigned readHSGRFromStream(const boost::filesystem::path &hsgr_file,
|
||||
{
|
||||
if (!boost::filesystem::exists(hsgr_file))
|
||||
{
|
||||
throw osrm::exception("hsgr file does not exist");
|
||||
throw exception("hsgr file does not exist");
|
||||
}
|
||||
if (0 == boost::filesystem::file_size(hsgr_file))
|
||||
{
|
||||
throw osrm::exception("hsgr file is empty");
|
||||
throw exception("hsgr file is empty");
|
||||
}
|
||||
|
||||
boost::filesystem::ifstream hsgr_input_stream(hsgr_file, std::ios::binary);
|
||||
@@ -192,4 +197,7 @@ unsigned readHSGRFromStream(const boost::filesystem::path &hsgr_file,
|
||||
return number_of_nodes;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // GRAPH_LOADER_HPP
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
#include <boost/assert.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
/// This function checks if the graph (consisting of directed edges) is undirected
|
||||
template <typename GraphT> bool isUndirectedGraph(const GraphT &graph)
|
||||
{
|
||||
@@ -91,4 +96,7 @@ std::vector<OutputEdgeT> directedEdgesFromCompressed(const std::vector<InputEdge
|
||||
|
||||
return output_edge_list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
// computes a 64 bit value that corresponds to the hilbert space filling curve
|
||||
|
||||
struct FixedPointCoordinate;
|
||||
@@ -19,4 +24,7 @@ class HilbertCode
|
||||
inline void TransposeCoordinate(uint32_t *X) const;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* HILBERT_VALUE_HPP */
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
#include <algorithm>
|
||||
#include <string>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
@@ -21,4 +26,7 @@ std::string read_file_lower_content(const boost::filesystem::path &path)
|
||||
return ini_file_content;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // INI_FILE_HPP
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
template <typename Integer> class range
|
||||
{
|
||||
@@ -45,6 +47,8 @@ irange(const Integer first,
|
||||
{
|
||||
return range<Integer>(first, last);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // INTEGER_RANGE_HPP
|
||||
|
||||
@@ -5,6 +5,11 @@
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/spirit/include/qi_action.hpp>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
namespace qi = boost::spirit::qi;
|
||||
|
||||
template <typename Iterator> struct iso_8601_grammar : qi::grammar<Iterator>
|
||||
@@ -72,4 +77,7 @@ template <typename Iterator> struct iso_8601_grammar : qi::grammar<Iterator>
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ISO_8601_DURATION_PARSER_HPP
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
namespace json
|
||||
{
|
||||
|
||||
@@ -17,7 +19,7 @@ namespace json
|
||||
// thread safe manner.
|
||||
class Logger
|
||||
{
|
||||
using MapT = std::unordered_map<std::string, osrm::json::Value>;
|
||||
using MapT = std::unordered_map<std::string, Value>;
|
||||
|
||||
public:
|
||||
static Logger *get()
|
||||
@@ -53,6 +55,8 @@ class Logger
|
||||
|
||||
boost::thread_specific_ptr<MapT> map;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
namespace json
|
||||
{
|
||||
|
||||
@@ -156,5 +158,7 @@ inline void render(std::vector<char> &out, const Object &object)
|
||||
}
|
||||
|
||||
} // namespace json
|
||||
} // namespace util
|
||||
} // namespace osrm
|
||||
|
||||
#endif // JSON_RENDERER_HPP
|
||||
|
||||
+15
-11
@@ -8,6 +8,8 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
namespace json
|
||||
{
|
||||
|
||||
@@ -26,16 +28,16 @@ template <typename T> T clamp_float(T d)
|
||||
return d;
|
||||
}
|
||||
|
||||
template <typename... Args> osrm::json::Array make_array(Args... args)
|
||||
template <typename... Args> Array make_array(Args... args)
|
||||
{
|
||||
osrm::json::Array a;
|
||||
Array a;
|
||||
append_to_container(a.values, args...);
|
||||
return a;
|
||||
}
|
||||
|
||||
template <typename T> osrm::json::Array make_array(const std::vector<T> &vector)
|
||||
template <typename T> Array make_array(const std::vector<T> &vector)
|
||||
{
|
||||
osrm::json::Array a;
|
||||
Array a;
|
||||
for (const auto &v : vector)
|
||||
{
|
||||
a.values.emplace_back(v);
|
||||
@@ -44,9 +46,9 @@ template <typename T> osrm::json::Array make_array(const std::vector<T> &vector)
|
||||
}
|
||||
|
||||
// template specialization needed as clang does not play nice
|
||||
template <> osrm::json::Array make_array(const std::vector<bool> &vector)
|
||||
template <> Array make_array(const std::vector<bool> &vector)
|
||||
{
|
||||
osrm::json::Array a;
|
||||
Array a;
|
||||
for (const bool v : vector)
|
||||
{
|
||||
a.values.emplace_back(v);
|
||||
@@ -55,22 +57,24 @@ template <> osrm::json::Array make_array(const std::vector<bool> &vector)
|
||||
}
|
||||
|
||||
// Easy acces to object hierachies
|
||||
osrm::json::Value &get(osrm::json::Value &value) { return value; }
|
||||
Value &get(Value &value) { return value; }
|
||||
|
||||
template <typename... Keys>
|
||||
osrm::json::Value &get(osrm::json::Value &value, const char *key, Keys... keys)
|
||||
Value &get(Value &value, const char *key, Keys... keys)
|
||||
{
|
||||
using recursive_object_t = mapbox::util::recursive_wrapper<osrm::json::Object>;
|
||||
using recursive_object_t = mapbox::util::recursive_wrapper<Object>;
|
||||
return get(value.get<recursive_object_t>().get().values[key], keys...);
|
||||
}
|
||||
|
||||
template <typename... Keys>
|
||||
osrm::json::Value &get(osrm::json::Value &value, unsigned key, Keys... keys)
|
||||
Value &get(Value &value, unsigned key, Keys... keys)
|
||||
{
|
||||
using recursive_array_t = mapbox::util::recursive_wrapper<osrm::json::Array>;
|
||||
using recursive_array_t = mapbox::util::recursive_wrapper<Array>;
|
||||
return get(value.get<recursive_array_t>().get().values[key], keys...);
|
||||
}
|
||||
|
||||
} // namespace json
|
||||
} // namespace util
|
||||
} // namespace osrm
|
||||
|
||||
#endif // JSON_UTIL_HPP
|
||||
|
||||
@@ -13,6 +13,11 @@ extern "C" {
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
template <typename T> void LUA_print(T output) { std::cout << "[LUA] " << output << std::endl; }
|
||||
|
||||
// Check if the lua function <name> is defined
|
||||
@@ -35,4 +40,7 @@ inline void luaAddScriptFolderToLoadPath(lua_State *lua_state, const char *file_
|
||||
luaL_dostring(lua_state, lua_code.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // LUA_UTIL_HPP
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
// Implement make_unique according to N3656. Taken from libcxx's implementation
|
||||
|
||||
/// \brief Constructs a `new T()` with the given args and returns a
|
||||
@@ -42,5 +45,8 @@ make_unique(size_t n)
|
||||
/// This function isn't used and is only here to provide better compile errors.
|
||||
template <class T, class... Args>
|
||||
typename std::enable_if<std::extent<T>::value != 0>::type make_unique(Args &&...) = delete;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MAKE_UNIQUE_H_
|
||||
|
||||
@@ -7,10 +7,15 @@
|
||||
|
||||
#include "osrm/coordinate.hpp"
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
// Provides the debug interface for introspection tools
|
||||
struct MatchingDebugInfo
|
||||
{
|
||||
MatchingDebugInfo(const osrm::json::Logger *logger) : logger(logger)
|
||||
MatchingDebugInfo(const json::Logger *logger) : logger(logger)
|
||||
{
|
||||
if (logger)
|
||||
{
|
||||
@@ -26,25 +31,25 @@ struct MatchingDebugInfo
|
||||
return;
|
||||
}
|
||||
|
||||
osrm::json::Array states;
|
||||
json::Array states;
|
||||
for (auto &elem : candidates_list)
|
||||
{
|
||||
osrm::json::Array timestamps;
|
||||
json::Array timestamps;
|
||||
for (auto &elem_s : elem)
|
||||
{
|
||||
osrm::json::Object state;
|
||||
state.values["transitions"] = osrm::json::Array();
|
||||
json::Object state;
|
||||
state.values["transitions"] = json::Array();
|
||||
state.values["coordinate"] =
|
||||
osrm::json::make_array(elem_s.phantom_node.location.lat / COORDINATE_PRECISION,
|
||||
json::make_array(elem_s.phantom_node.location.lat / COORDINATE_PRECISION,
|
||||
elem_s.phantom_node.location.lon / COORDINATE_PRECISION);
|
||||
state.values["viterbi"] =
|
||||
osrm::json::clamp_float(osrm::matching::IMPOSSIBLE_LOG_PROB);
|
||||
json::clamp_float(engine::map_matching::IMPOSSIBLE_LOG_PROB);
|
||||
state.values["pruned"] = 0u;
|
||||
timestamps.values.push_back(state);
|
||||
}
|
||||
states.values.push_back(timestamps);
|
||||
}
|
||||
osrm::json::get(*object, "states") = states;
|
||||
json::get(*object, "states") = states;
|
||||
}
|
||||
|
||||
void add_transition_info(const unsigned prev_t,
|
||||
@@ -63,14 +68,14 @@ struct MatchingDebugInfo
|
||||
return;
|
||||
}
|
||||
|
||||
osrm::json::Object transistion;
|
||||
transistion.values["to"] = osrm::json::make_array(current_t, current_state);
|
||||
transistion.values["properties"] = osrm::json::make_array(
|
||||
osrm::json::clamp_float(prev_viterbi), osrm::json::clamp_float(emission_pr),
|
||||
osrm::json::clamp_float(transition_pr), network_distance, haversine_distance);
|
||||
json::Object transistion;
|
||||
transistion.values["to"] = json::make_array(current_t, current_state);
|
||||
transistion.values["properties"] = json::make_array(
|
||||
json::clamp_float(prev_viterbi), json::clamp_float(emission_pr),
|
||||
json::clamp_float(transition_pr), network_distance, haversine_distance);
|
||||
|
||||
osrm::json::get(*object, "states", prev_t, prev_state, "transitions")
|
||||
.get<mapbox::util::recursive_wrapper<osrm::json::Array>>()
|
||||
json::get(*object, "states", prev_t, prev_state, "transitions")
|
||||
.get<mapbox::util::recursive_wrapper<json::Array>>()
|
||||
.get()
|
||||
.values.push_back(transistion);
|
||||
}
|
||||
@@ -89,11 +94,11 @@ struct MatchingDebugInfo
|
||||
{
|
||||
for (auto s_prime = 0u; s_prime < viterbi[t].size(); ++s_prime)
|
||||
{
|
||||
osrm::json::get(*object, "states", t, s_prime, "viterbi") =
|
||||
osrm::json::clamp_float(viterbi[t][s_prime]);
|
||||
osrm::json::get(*object, "states", t, s_prime, "pruned") =
|
||||
json::get(*object, "states", t, s_prime, "viterbi") =
|
||||
json::clamp_float(viterbi[t][s_prime]);
|
||||
json::get(*object, "states", t, s_prime, "pruned") =
|
||||
static_cast<unsigned>(pruned[t][s_prime]);
|
||||
osrm::json::get(*object, "states", t, s_prime, "suspicious") =
|
||||
json::get(*object, "states", t, s_prime, "suspicious") =
|
||||
static_cast<unsigned>(suspicious[t][s_prime]);
|
||||
}
|
||||
}
|
||||
@@ -107,7 +112,7 @@ struct MatchingDebugInfo
|
||||
return;
|
||||
}
|
||||
|
||||
osrm::json::get(*object, "states", t, s, "chosen") = true;
|
||||
json::get(*object, "states", t, s, "chosen") = true;
|
||||
}
|
||||
|
||||
void add_breakage(const std::vector<bool> &breakage)
|
||||
@@ -118,11 +123,14 @@ struct MatchingDebugInfo
|
||||
return;
|
||||
}
|
||||
|
||||
osrm::json::get(*object, "breakage") = osrm::json::make_array(breakage);
|
||||
json::get(*object, "breakage") = json::make_array(breakage);
|
||||
}
|
||||
|
||||
const osrm::json::Logger *logger;
|
||||
osrm::json::Value *object;
|
||||
const json::Logger *logger;
|
||||
json::Value *object;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MATCHING_DEBUG_INFO_HPP
|
||||
|
||||
@@ -7,7 +7,12 @@
|
||||
|
||||
#include "util/typedefs.hpp"
|
||||
|
||||
// This Wrapper provides all methods that are needed for TarjanSCC, when the graph is given in a
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
// This Wrapper provides all methods that are needed for extractor::TarjanSCC, when the graph is given in a
|
||||
// matrix representation (e.g. as output from a distance table call)
|
||||
|
||||
template <typename T> class MatrixGraphWrapper
|
||||
@@ -40,4 +45,7 @@ template <typename T> class MatrixGraphWrapper
|
||||
const std::size_t number_of_nodes_;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MATRIX_GRAPH_WRAPPER_H
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
#ifndef MERCATOR_HPP
|
||||
#define MERCATOR_HPP
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
struct mercator
|
||||
{
|
||||
static double y2lat(const double value) noexcept;
|
||||
@@ -8,4 +13,7 @@ struct mercator
|
||||
static double lat2y(const double latitude) noexcept;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MERCATOR_HPP
|
||||
|
||||
@@ -9,6 +9,11 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
struct NodeBasedEdgeData
|
||||
{
|
||||
NodeBasedEdgeData()
|
||||
@@ -25,7 +30,7 @@ struct NodeBasedEdgeData
|
||||
bool reversed,
|
||||
bool roundabout,
|
||||
bool startpoint,
|
||||
TravelMode travel_mode)
|
||||
extractor::TravelMode travel_mode)
|
||||
: distance(distance), edge_id(edge_id), name_id(name_id),
|
||||
access_restricted(access_restricted), reversed(reversed), roundabout(roundabout),
|
||||
startpoint(startpoint), travel_mode(travel_mode)
|
||||
@@ -39,7 +44,7 @@ struct NodeBasedEdgeData
|
||||
bool reversed : 1;
|
||||
bool roundabout : 1;
|
||||
bool startpoint : 1;
|
||||
TravelMode travel_mode : 4;
|
||||
extractor::TravelMode travel_mode : 4;
|
||||
|
||||
bool IsCompatibleTo(const NodeBasedEdgeData &other) const
|
||||
{
|
||||
@@ -55,11 +60,11 @@ using NodeBasedDynamicGraph = DynamicGraph<NodeBasedEdgeData>;
|
||||
/// two edges for undirected edges.
|
||||
inline std::shared_ptr<NodeBasedDynamicGraph>
|
||||
NodeBasedDynamicGraphFromEdges(std::size_t number_of_nodes,
|
||||
const std::vector<NodeBasedEdge> &input_edge_list)
|
||||
const std::vector<extractor::NodeBasedEdge> &input_edge_list)
|
||||
{
|
||||
auto edges_list = directedEdgesFromCompressed<NodeBasedDynamicGraph::InputEdge>(
|
||||
input_edge_list,
|
||||
[](NodeBasedDynamicGraph::InputEdge &output_edge, const NodeBasedEdge &input_edge)
|
||||
[](NodeBasedDynamicGraph::InputEdge &output_edge, const extractor::NodeBasedEdge &input_edge)
|
||||
{
|
||||
output_edge.data.distance = static_cast<int>(input_edge.weight);
|
||||
BOOST_ASSERT(output_edge.data.distance > 0);
|
||||
@@ -79,4 +84,7 @@ NodeBasedDynamicGraphFromEdges(std::size_t number_of_nodes,
|
||||
return graph;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // NODE_BASED_GRAPH_HPP
|
||||
|
||||
@@ -7,6 +7,9 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
class exception final : public std::exception
|
||||
{
|
||||
public:
|
||||
@@ -21,5 +24,8 @@ class exception final : public std::exception
|
||||
const char *what() const noexcept override { return message.c_str(); }
|
||||
const std::string message;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* OSRM_EXCEPTION_HPP */
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
#include <iostream>
|
||||
#include <atomic>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
class Percent
|
||||
{
|
||||
public:
|
||||
@@ -71,4 +76,7 @@ class Percent
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // PERCENT_HPP
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
template <class Container>
|
||||
auto max_element(const Container &c) -> decltype(std::max_element(c.begin(), c.end()))
|
||||
@@ -17,6 +19,8 @@ auto max_element(const Container &c) -> decltype(std::max_element(c.cbegin(), c.
|
||||
{
|
||||
return std::max_element(c.cbegin(), c.cend());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // RANGE_ALGORITHMS_HPP
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
|
||||
#include <fstream>
|
||||
#include <array>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
/*
|
||||
* These pre-declarations are needed because parsing C++ is hard
|
||||
* and otherwise the compiler gets confused.
|
||||
@@ -35,7 +40,7 @@ template <unsigned BLOCK_SIZE, bool USE_SHARED_MEMORY> class RangeTable
|
||||
using BlockT = std::array<unsigned char, BLOCK_SIZE>;
|
||||
using BlockContainerT = typename ShM<BlockT, USE_SHARED_MEMORY>::vector;
|
||||
using OffsetContainerT = typename ShM<unsigned, USE_SHARED_MEMORY>::vector;
|
||||
using RangeT = osrm::range<unsigned>;
|
||||
using RangeT = range<unsigned>;
|
||||
|
||||
friend std::ostream &operator<<<>(std::ostream &out, const RangeTable &table);
|
||||
friend std::istream &operator>><>(std::istream &in, RangeTable &table);
|
||||
@@ -166,7 +171,7 @@ template <unsigned BLOCK_SIZE, bool USE_SHARED_MEMORY> class RangeTable
|
||||
BOOST_ASSERT(begin_idx < sum_lengths && end_idx <= sum_lengths);
|
||||
BOOST_ASSERT(begin_idx <= end_idx);
|
||||
|
||||
return osrm::irange(begin_idx, end_idx);
|
||||
return irange(begin_idx, end_idx);
|
||||
}
|
||||
|
||||
private:
|
||||
@@ -229,4 +234,7 @@ std::istream &operator>>(std::istream &in, RangeTable<BLOCK_SIZE, USE_SHARED_MEM
|
||||
return in;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // RANGE_TABLE_HPP
|
||||
|
||||
@@ -11,6 +11,11 @@
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
// TODO: Make template type, add tests
|
||||
struct RectangleInt2D
|
||||
{
|
||||
@@ -173,4 +178,7 @@ struct RectangleInt2D
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -12,6 +12,11 @@
|
||||
#include <unordered_map>
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
const static unsigned INIT_OK_START_ENGINE = 0;
|
||||
const static unsigned INIT_OK_DO_NOT_START_ENGINE = 1;
|
||||
const static unsigned INIT_FAILED = -1;
|
||||
@@ -53,49 +58,49 @@ populate_base_path(std::unordered_map<std::string, boost::filesystem::path> &ser
|
||||
if (path_iterator == server_paths.end() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw osrm::exception(".hsgr not found");
|
||||
throw exception(".hsgr not found");
|
||||
}
|
||||
|
||||
path_iterator = server_paths.find("nodesdata");
|
||||
if (path_iterator == server_paths.end() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw osrm::exception(".nodes not found");
|
||||
throw exception(".nodes not found");
|
||||
}
|
||||
|
||||
path_iterator = server_paths.find("edgesdata");
|
||||
if (path_iterator == server_paths.end() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw osrm::exception(".edges not found");
|
||||
throw exception(".edges not found");
|
||||
}
|
||||
|
||||
path_iterator = server_paths.find("geometries");
|
||||
if (path_iterator == server_paths.end() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw osrm::exception(".geometry not found");
|
||||
throw exception(".geometry not found");
|
||||
}
|
||||
|
||||
path_iterator = server_paths.find("ramindex");
|
||||
if (path_iterator == server_paths.end() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw osrm::exception(".ramIndex not found");
|
||||
throw exception(".ramIndex not found");
|
||||
}
|
||||
|
||||
path_iterator = server_paths.find("fileindex");
|
||||
if (path_iterator == server_paths.end() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw osrm::exception(".fileIndex not found");
|
||||
throw exception(".fileIndex not found");
|
||||
}
|
||||
|
||||
path_iterator = server_paths.find("namesdata");
|
||||
if (path_iterator == server_paths.end() ||
|
||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
||||
{
|
||||
throw osrm::exception(".namesIndex not found");
|
||||
throw exception(".namesIndex not found");
|
||||
}
|
||||
|
||||
SimpleLogger().Write() << "HSGR file:\t" << server_paths["hsgrdata"];
|
||||
@@ -226,15 +231,15 @@ GenerateServerProgramOptions(const int argc,
|
||||
|
||||
if (1 > requested_num_threads)
|
||||
{
|
||||
throw osrm::exception("Number of threads must be a positive number");
|
||||
throw exception("Number of threads must be a positive number");
|
||||
}
|
||||
if (2 > max_locations_distance_table)
|
||||
{
|
||||
throw osrm::exception("Max location for distance table must be at least two");
|
||||
throw exception("Max location for distance table must be at least two");
|
||||
}
|
||||
if (2 > max_locations_map_matching)
|
||||
{
|
||||
throw osrm::exception("Max location for map matching must be at least two");
|
||||
throw exception("Max location for map matching must be at least two");
|
||||
}
|
||||
|
||||
if (!use_shared_memory && option_variables.count("base"))
|
||||
@@ -254,4 +259,7 @@ GenerateServerProgramOptions(const int argc,
|
||||
return INIT_OK_DO_NOT_START_ENGINE;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // ROUTED_OPTIONS_HPP
|
||||
|
||||
@@ -8,6 +8,11 @@
|
||||
#include <type_traits>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
template <typename DataT> class ShMemIterator : public std::iterator<std::input_iterator_tag, DataT>
|
||||
{
|
||||
DataT *p;
|
||||
@@ -124,4 +129,7 @@ template <typename DataT, bool UseSharedMemory> struct ShM
|
||||
std::vector<DataT>>::type;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SHARED_MEMORY_VECTOR_WRAPPER_HPP
|
||||
|
||||
@@ -12,6 +12,11 @@ enum LogLevel
|
||||
logDEBUG
|
||||
};
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
class LogPolicy
|
||||
{
|
||||
public:
|
||||
@@ -44,4 +49,7 @@ class SimpleLogger
|
||||
LogLevel level;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* SIMPLE_LOGGER_HPP */
|
||||
|
||||
@@ -13,13 +13,18 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
template <typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph
|
||||
{
|
||||
public:
|
||||
using NodeIterator = NodeID;
|
||||
using EdgeIterator = NodeID;
|
||||
using EdgeData = EdgeDataT;
|
||||
using EdgeRange = osrm::range<EdgeIterator>;
|
||||
using EdgeRange = range<EdgeIterator>;
|
||||
|
||||
class InputEdge
|
||||
{
|
||||
@@ -57,7 +62,7 @@ template <typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph
|
||||
|
||||
EdgeRange GetAdjacentEdgeRange(const NodeID node) const
|
||||
{
|
||||
return osrm::irange(BeginEdges(node), EndEdges(node));
|
||||
return irange(BeginEdges(node), EndEdges(node));
|
||||
}
|
||||
|
||||
template <typename ContainerT> StaticGraph(const int nodes, const ContainerT &graph)
|
||||
@@ -70,7 +75,7 @@ template <typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph
|
||||
node_array.resize(number_of_nodes + 1);
|
||||
EdgeIterator edge = 0;
|
||||
EdgeIterator position = 0;
|
||||
for (const auto node : osrm::irange(0u, number_of_nodes + 1))
|
||||
for (const auto node : irange(0u, number_of_nodes + 1))
|
||||
{
|
||||
EdgeIterator last_edge = edge;
|
||||
while (edge < number_of_edges && graph[edge].source == node)
|
||||
@@ -82,10 +87,10 @@ template <typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph
|
||||
}
|
||||
edge_array.resize(position); //(edge)
|
||||
edge = 0;
|
||||
for (const auto node : osrm::irange(0u, number_of_nodes))
|
||||
for (const auto node : irange(0u, number_of_nodes))
|
||||
{
|
||||
EdgeIterator e = node_array[node + 1].first_edge;
|
||||
for (const auto i : osrm::irange(node_array[node].first_edge, e))
|
||||
for (const auto i : irange(node_array[node].first_edge, e))
|
||||
{
|
||||
edge_array[i].target = graph[edge].target;
|
||||
edge_array[i].data = graph[edge].data;
|
||||
@@ -132,7 +137,7 @@ template <typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph
|
||||
// searches for a specific edge
|
||||
EdgeIterator FindEdge(const NodeIterator from, const NodeIterator to) const
|
||||
{
|
||||
for (const auto i : osrm::irange(BeginEdges(from), EndEdges(from)))
|
||||
for (const auto i : irange(BeginEdges(from), EndEdges(from)))
|
||||
{
|
||||
if (to == edge_array[i].target)
|
||||
{
|
||||
@@ -189,4 +194,7 @@ template <typename EdgeDataT, bool UseSharedMemory = false> class StaticGraph
|
||||
typename ShM<EdgeArrayEntry, UseSharedMemory>::vector edge_array;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // STATIC_GRAPH_HPP
|
||||
|
||||
@@ -32,6 +32,11 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
// Static RTree for serving nearest neighbour queries
|
||||
template <class EdgeDataT,
|
||||
class CoordinateListT = std::vector<FixedPointCoordinate>,
|
||||
@@ -265,11 +270,11 @@ class StaticRTree
|
||||
|
||||
if (!boost::filesystem::exists(node_file))
|
||||
{
|
||||
throw osrm::exception("ram index file does not exist");
|
||||
throw exception("ram index file does not exist");
|
||||
}
|
||||
if (0 == boost::filesystem::file_size(node_file))
|
||||
{
|
||||
throw osrm::exception("ram index file is empty");
|
||||
throw exception("ram index file is empty");
|
||||
}
|
||||
boost::filesystem::ifstream tree_node_file(node_file, std::ios::binary);
|
||||
|
||||
@@ -285,11 +290,11 @@ class StaticRTree
|
||||
// open leaf node file and store thread specific pointer
|
||||
if (!boost::filesystem::exists(leaf_file))
|
||||
{
|
||||
throw osrm::exception("mem index file does not exist");
|
||||
throw exception("mem index file does not exist");
|
||||
}
|
||||
if (0 == boost::filesystem::file_size(leaf_file))
|
||||
{
|
||||
throw osrm::exception("mem index file is empty");
|
||||
throw exception("mem index file is empty");
|
||||
}
|
||||
|
||||
leaves_stream.open(leaf_file, std::ios::binary);
|
||||
@@ -306,11 +311,11 @@ class StaticRTree
|
||||
// open leaf node file and store thread specific pointer
|
||||
if (!boost::filesystem::exists(leaf_file))
|
||||
{
|
||||
throw osrm::exception("mem index file does not exist");
|
||||
throw exception("mem index file does not exist");
|
||||
}
|
||||
if (0 == boost::filesystem::file_size(leaf_file))
|
||||
{
|
||||
throw osrm::exception("mem index file is empty");
|
||||
throw exception("mem index file is empty");
|
||||
}
|
||||
|
||||
leaves_stream.open(leaf_file, std::ios::binary);
|
||||
@@ -411,7 +416,7 @@ class StaticRTree
|
||||
LoadLeafFromDisk(leaf_id, current_leaf_node);
|
||||
|
||||
// current object represents a block on disk
|
||||
for (const auto i : osrm::irange(0u, current_leaf_node.object_count))
|
||||
for (const auto i : irange(0u, current_leaf_node.object_count))
|
||||
{
|
||||
auto ¤t_edge = current_leaf_node.objects[i];
|
||||
const float current_perpendicular_distance =
|
||||
@@ -449,7 +454,7 @@ class StaticRTree
|
||||
}
|
||||
if (!leaves_stream.good())
|
||||
{
|
||||
throw osrm::exception("Could not read from leaf file.");
|
||||
throw exception("Could not read from leaf file.");
|
||||
}
|
||||
const uint64_t seek_pos = sizeof(uint64_t) + leaf_id * sizeof(LeafNode);
|
||||
leaves_stream.seekg(seek_pos);
|
||||
@@ -491,4 +496,7 @@ class StaticRTree
|
||||
//[2] "Nearest Neighbor Queries", N. Roussopulos et al; 1995; DOI: 10.1145/223784.223794
|
||||
//[3] "Distance Browsing in Spatial Databases"; G. Hjaltason, H. Samet; 1999; ACM Trans. DB Sys
|
||||
// Vol.24 No.2, pp.265-318
|
||||
}
|
||||
}
|
||||
|
||||
#endif // STATIC_RTREE_HPP
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
// precision: position after decimal point
|
||||
// length: maximum number of digits including comma and decimals
|
||||
// work with negative values to prevent overflowing when taking -value
|
||||
@@ -122,4 +127,7 @@ inline std::size_t URIDecode(const std::string &input, std::string &output)
|
||||
|
||||
inline std::size_t URIDecodeInPlace(std::string &URI) { return URIDecode(URI, URI); }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // STRING_UTIL_HPP
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
struct GlobalTimer
|
||||
{
|
||||
GlobalTimer() : time(0) {}
|
||||
@@ -60,4 +65,7 @@ class GlobalTimerFactory
|
||||
#define TIMER_MIN(_X) \
|
||||
std::chrono::duration_cast<std::chrono::minutes>(_X##_stop - _X##_start).count()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // TIMING_UTIL_HPP
|
||||
|
||||
@@ -3,11 +3,16 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
enum class tribool : char
|
||||
{
|
||||
yes,
|
||||
no,
|
||||
indeterminate
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
#endif // TRIBOOL_HPP
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
|
||||
#include <limits>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
constexpr unsigned short atan_table[4096] = {
|
||||
0x0000, 0x0014, 0x0028, 0x003d, 0x0051, 0x0065, 0x007a, 0x008e, 0x00a3, 0x00b7, 0x00cb, 0x00e0,
|
||||
0x00f4, 0x0108, 0x011d, 0x0131, 0x0146, 0x015a, 0x016e, 0x0183, 0x0197, 0x01ab, 0x01c0, 0x01d4,
|
||||
@@ -418,4 +423,7 @@ inline double atan2_lookup(double y, double x)
|
||||
return angle;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // TRIGONOMETRY_TABLE_HPP
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
#ifndef TYPEDEFS_H
|
||||
#define TYPEDEFS_H
|
||||
|
||||
#include <limits>
|
||||
#include "osrm/strong_typedef.hpp"
|
||||
|
||||
#include <limits>
|
||||
#include <cstddef>
|
||||
|
||||
// Necessary workaround for Windows as VS doesn't implement C99
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
namespace json
|
||||
{
|
||||
|
||||
@@ -105,6 +107,9 @@ template <class JSONObject> inline void gpx_render(std::vector<char> &out, const
|
||||
const std::string footer{"</rte></gpx>"};
|
||||
out.insert(out.end(), footer.begin(), footer.end());
|
||||
}
|
||||
|
||||
} // namespace json
|
||||
} // namespace util
|
||||
} // namespace osrm
|
||||
|
||||
#endif // XML_RENDERER_HPP
|
||||
|
||||
@@ -4,6 +4,11 @@
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
/*
|
||||
This is an implementation of Tabulation hashing, which has suprising properties like
|
||||
universality.
|
||||
@@ -85,4 +90,7 @@ class XORMiniHash
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // XOR_FAST_HASH_HPP
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
|
||||
namespace osrm
|
||||
{
|
||||
namespace util
|
||||
{
|
||||
|
||||
template <typename NodeID, typename Key> class XORFastHashStorage
|
||||
{
|
||||
public:
|
||||
@@ -71,4 +76,7 @@ template <typename NodeID, typename Key> class XORFastHashStorage
|
||||
unsigned current_timestamp;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // XOR_FAST_HASH_STORAGE_HPP
|
||||
|
||||
Reference in New Issue
Block a user