Add namespace around all files
This commit is contained in:
parent
efc9007cbf
commit
6b18e4f7e9
@ -26,6 +26,11 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace contractor
|
||||||
|
{
|
||||||
|
|
||||||
class Contractor
|
class Contractor
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -65,12 +70,12 @@ class Contractor
|
|||||||
ContractorHeapData(short h, bool t) : hop(h), target(t) {}
|
ContractorHeapData(short h, bool t) : hop(h), target(t) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
using ContractorGraph = DynamicGraph<ContractorEdgeData>;
|
using ContractorGraph = util::DynamicGraph<ContractorEdgeData>;
|
||||||
// using ContractorHeap = BinaryHeap<NodeID, NodeID, int, ContractorHeapData,
|
// using ContractorHeap = util::BinaryHeap<NodeID, NodeID, int, ContractorHeapData,
|
||||||
// ArrayStorage<NodeID, NodeID>
|
// ArrayStorage<NodeID, NodeID>
|
||||||
// >;
|
// >;
|
||||||
using ContractorHeap =
|
using ContractorHeap =
|
||||||
BinaryHeap<NodeID, NodeID, int, ContractorHeapData, XORFastHashStorage<NodeID, NodeID>>;
|
util::BinaryHeap<NodeID, NodeID, int, ContractorHeapData, util::XORFastHashStorage<NodeID, NodeID>>;
|
||||||
using ContractorEdge = ContractorGraph::InputEdge;
|
using ContractorEdge = ContractorGraph::InputEdge;
|
||||||
|
|
||||||
struct ContractorThreadData
|
struct ContractorThreadData
|
||||||
@ -151,7 +156,7 @@ class Contractor
|
|||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if (static_cast<unsigned int>(std::max(diter->weight, 1)) > 24 * 60 * 60 * 10)
|
if (static_cast<unsigned int>(std::max(diter->weight, 1)) > 24 * 60 * 60 * 10)
|
||||||
{
|
{
|
||||||
SimpleLogger().Write(logWARNING)
|
util::SimpleLogger().Write(logWARNING)
|
||||||
<< "Edge weight large -> "
|
<< "Edge weight large -> "
|
||||||
<< static_cast<unsigned int>(std::max(diter->weight, 1)) << " : "
|
<< static_cast<unsigned int>(std::max(diter->weight, 1)) << " : "
|
||||||
<< static_cast<unsigned int>(diter->source) << " -> "
|
<< static_cast<unsigned int>(diter->source) << " -> "
|
||||||
@ -253,11 +258,11 @@ class Contractor
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// SimpleLogger().Write() << "edges at node with id " << highestNode << " has degree
|
// util::SimpleLogger().Write() << "edges at node with id " << highestNode << " has degree
|
||||||
// " << maxdegree;
|
// " << maxdegree;
|
||||||
// for(unsigned i = contractor_graph->BeginEdges(highestNode); i <
|
// for(unsigned i = contractor_graph->BeginEdges(highestNode); i <
|
||||||
// contractor_graph->EndEdges(highestNode); ++i) {
|
// contractor_graph->EndEdges(highestNode); ++i) {
|
||||||
// SimpleLogger().Write() << " ->(" << highestNode << "," <<
|
// util::SimpleLogger().Write() << " ->(" << highestNode << "," <<
|
||||||
// contractor_graph->GetTarget(i)
|
// contractor_graph->GetTarget(i)
|
||||||
// << "); via: " << contractor_graph->GetEdgeData(i).via;
|
// << "); via: " << contractor_graph->GetEdgeData(i).via;
|
||||||
// }
|
// }
|
||||||
@ -281,7 +286,7 @@ class Contractor
|
|||||||
constexpr size_t DeleteGrainSize = 1;
|
constexpr size_t DeleteGrainSize = 1;
|
||||||
|
|
||||||
const NodeID number_of_nodes = contractor_graph->GetNumberOfNodes();
|
const NodeID number_of_nodes = contractor_graph->GetNumberOfNodes();
|
||||||
Percent p(number_of_nodes);
|
util::Percent p(number_of_nodes);
|
||||||
|
|
||||||
ThreadDataContainer thread_data_list(number_of_nodes);
|
ThreadDataContainer thread_data_list(number_of_nodes);
|
||||||
|
|
||||||
@ -340,7 +345,7 @@ class Contractor
|
|||||||
if (!flushed_contractor && (number_of_contracted_nodes >
|
if (!flushed_contractor && (number_of_contracted_nodes >
|
||||||
static_cast<NodeID>(number_of_nodes * 0.65 * core_factor)))
|
static_cast<NodeID>(number_of_nodes * 0.65 * core_factor)))
|
||||||
{
|
{
|
||||||
DeallocatingVector<ContractorEdge> new_edge_set; // this one is not explicitely
|
util::DeallocatingVector<ContractorEdge> new_edge_set; // this one is not explicitely
|
||||||
// cleared since it goes out of
|
// cleared since it goes out of
|
||||||
// scope anywa
|
// scope anywa
|
||||||
std::cout << " [flush " << number_of_contracted_nodes << " nodes] " << std::flush;
|
std::cout << " [flush " << number_of_contracted_nodes << " nodes] " << std::flush;
|
||||||
@ -357,7 +362,7 @@ class Contractor
|
|||||||
// remaining graph
|
// remaining graph
|
||||||
std::vector<NodeID> new_node_id_from_orig_id_map(number_of_nodes, UINT_MAX);
|
std::vector<NodeID> new_node_id_from_orig_id_map(number_of_nodes, UINT_MAX);
|
||||||
|
|
||||||
for (const auto new_node_id : osrm::irange<std::size_t>(0, remaining_nodes.size()))
|
for (const auto new_node_id : util::irange<std::size_t>(0, remaining_nodes.size()))
|
||||||
{
|
{
|
||||||
auto &node = remaining_nodes[new_node_id];
|
auto &node = remaining_nodes[new_node_id];
|
||||||
BOOST_ASSERT(node_priorities.size() > node.id);
|
BOOST_ASSERT(node_priorities.size() > node.id);
|
||||||
@ -365,7 +370,7 @@ class Contractor
|
|||||||
}
|
}
|
||||||
|
|
||||||
// build forward and backward renumbering map and remap ids in remaining_nodes
|
// build forward and backward renumbering map and remap ids in remaining_nodes
|
||||||
for (const auto new_node_id : osrm::irange<std::size_t>(0, remaining_nodes.size()))
|
for (const auto new_node_id : util::irange<std::size_t>(0, remaining_nodes.size()))
|
||||||
{
|
{
|
||||||
auto &node = remaining_nodes[new_node_id];
|
auto &node = remaining_nodes[new_node_id];
|
||||||
// create renumbering maps in both directions
|
// create renumbering maps in both directions
|
||||||
@ -375,7 +380,7 @@ class Contractor
|
|||||||
}
|
}
|
||||||
// walk over all nodes
|
// walk over all nodes
|
||||||
for (const auto source :
|
for (const auto source :
|
||||||
osrm::irange<NodeID>(0, contractor_graph->GetNumberOfNodes()))
|
util::irange<NodeID>(0, contractor_graph->GetNumberOfNodes()))
|
||||||
{
|
{
|
||||||
for (auto current_edge : contractor_graph->GetAdjacentEdgeRange(source))
|
for (auto current_edge : contractor_graph->GetAdjacentEdgeRange(source))
|
||||||
{
|
{
|
||||||
@ -389,7 +394,7 @@ class Contractor
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// node is not yet contracted.
|
// node is not yet contracted.
|
||||||
// add (renumbered) outgoing edges to new DynamicGraph.
|
// add (renumbered) outgoing edges to new util::DynamicGraph.
|
||||||
ContractorEdge new_edge = {new_node_id_from_orig_id_map[source],
|
ContractorEdge new_edge = {new_node_id_from_orig_id_map[source],
|
||||||
new_node_id_from_orig_id_map[target], data};
|
new_node_id_from_orig_id_map[target], data};
|
||||||
|
|
||||||
@ -590,7 +595,7 @@ class Contractor
|
|||||||
// avgdegree /= std::max((unsigned)1,(unsigned)remaining_nodes.size() );
|
// avgdegree /= std::max((unsigned)1,(unsigned)remaining_nodes.size() );
|
||||||
// quaddegree /= std::max((unsigned)1,(unsigned)remaining_nodes.size() );
|
// quaddegree /= std::max((unsigned)1,(unsigned)remaining_nodes.size() );
|
||||||
//
|
//
|
||||||
// SimpleLogger().Write() << "rest: " << remaining_nodes.size() << ", max: "
|
// util::SimpleLogger().Write() << "rest: " << remaining_nodes.size() << ", max: "
|
||||||
// << maxdegree << ", min: " << mindegree << ", avg: " << avgdegree << ",
|
// << maxdegree << ", min: " << mindegree << ", avg: " << avgdegree << ",
|
||||||
// quad: " << quaddegree;
|
// quad: " << quaddegree;
|
||||||
|
|
||||||
@ -633,7 +638,7 @@ class Contractor
|
|||||||
is_core_node.clear();
|
is_core_node.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleLogger().Write() << "[core] " << remaining_nodes.size() << " nodes "
|
util::SimpleLogger().Write() << "[core] " << remaining_nodes.size() << " nodes "
|
||||||
<< contractor_graph->GetNumberOfEdges() << " edges." << std::endl;
|
<< contractor_graph->GetNumberOfEdges() << " edges." << std::endl;
|
||||||
|
|
||||||
thread_data_list.data.clear();
|
thread_data_list.data.clear();
|
||||||
@ -649,15 +654,15 @@ class Contractor
|
|||||||
out_node_levels.swap(node_levels);
|
out_node_levels.swap(node_levels);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Edge> inline void GetEdges(DeallocatingVector<Edge> &edges)
|
template <class Edge> inline void GetEdges(util::DeallocatingVector<Edge> &edges)
|
||||||
{
|
{
|
||||||
Percent p(contractor_graph->GetNumberOfNodes());
|
util::Percent p(contractor_graph->GetNumberOfNodes());
|
||||||
SimpleLogger().Write() << "Getting edges of minimized graph";
|
util::SimpleLogger().Write() << "Getting edges of minimized graph";
|
||||||
const NodeID number_of_nodes = contractor_graph->GetNumberOfNodes();
|
const NodeID number_of_nodes = contractor_graph->GetNumberOfNodes();
|
||||||
if (contractor_graph->GetNumberOfNodes())
|
if (contractor_graph->GetNumberOfNodes())
|
||||||
{
|
{
|
||||||
Edge new_edge;
|
Edge new_edge;
|
||||||
for (const auto node : osrm::irange(0u, number_of_nodes))
|
for (const auto node : util::irange(0u, number_of_nodes))
|
||||||
{
|
{
|
||||||
p.printStatus(node);
|
p.printStatus(node);
|
||||||
for (auto edge : contractor_graph->GetAdjacentEdgeRange(node))
|
for (auto edge : contractor_graph->GetAdjacentEdgeRange(node))
|
||||||
@ -940,7 +945,7 @@ class Contractor
|
|||||||
std::sort(neighbours.begin(), neighbours.end());
|
std::sort(neighbours.begin(), neighbours.end());
|
||||||
neighbours.resize(std::unique(neighbours.begin(), neighbours.end()) - neighbours.begin());
|
neighbours.resize(std::unique(neighbours.begin(), neighbours.end()) - neighbours.begin());
|
||||||
|
|
||||||
for (const auto i : osrm::irange<std::size_t>(0, neighbours.size()))
|
for (const auto i : util::irange<std::size_t>(0, neighbours.size()))
|
||||||
{
|
{
|
||||||
contractor_graph->DeleteEdgesTo(neighbours[i], node);
|
contractor_graph->DeleteEdgesTo(neighbours[i], node);
|
||||||
}
|
}
|
||||||
@ -1060,7 +1065,10 @@ class Contractor
|
|||||||
std::vector<NodeID> orig_node_id_from_new_node_id_map;
|
std::vector<NodeID> orig_node_id_from_new_node_id_map;
|
||||||
std::vector<float> node_levels;
|
std::vector<float> node_levels;
|
||||||
std::vector<bool> is_core_node;
|
std::vector<bool> is_core_node;
|
||||||
XORFastHash fast_hash;
|
util::XORFastHash fast_hash;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // CONTRACTOR_HPP
|
#endif // CONTRACTOR_HPP
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace contractor
|
||||||
|
{
|
||||||
|
|
||||||
enum class return_code : unsigned
|
enum class return_code : unsigned
|
||||||
{
|
{
|
||||||
ok,
|
ok,
|
||||||
@ -51,4 +56,7 @@ struct ContractorOptions
|
|||||||
static void GenerateOutputFilesNames(ContractorConfig &extractor_config);
|
static void GenerateOutputFilesNames(ContractorConfig &extractor_config);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // EXTRACTOR_OPTIONS_HPP
|
#endif // EXTRACTOR_OPTIONS_HPP
|
||||||
|
@ -9,6 +9,11 @@
|
|||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace contractor
|
||||||
|
{
|
||||||
|
|
||||||
class IteratorbasedCRC32
|
class IteratorbasedCRC32
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -115,4 +120,7 @@ struct RangebasedCRC32
|
|||||||
IteratorbasedCRC32 crc32;
|
IteratorbasedCRC32 crc32;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* ITERATOR_BASED_CRC32_H */
|
#endif /* ITERATOR_BASED_CRC32_H */
|
||||||
|
@ -8,14 +8,22 @@
|
|||||||
#include "util/deallocating_vector.hpp"
|
#include "util/deallocating_vector.hpp"
|
||||||
#include "util/node_based_graph.hpp"
|
#include "util/node_based_graph.hpp"
|
||||||
|
|
||||||
struct SpeedProfileProperties;
|
|
||||||
struct EdgeBasedNode;
|
|
||||||
struct lua_State;
|
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
struct lua_State;
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
struct SpeedProfileProperties;
|
||||||
|
struct EdgeBasedNode;
|
||||||
|
}
|
||||||
|
namespace contractor
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief class of 'prepare' utility.
|
\brief class of 'prepare' utility.
|
||||||
*/
|
*/
|
||||||
@ -32,26 +40,29 @@ class Prepare
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
void ContractGraph(const unsigned max_edge_id,
|
void ContractGraph(const unsigned max_edge_id,
|
||||||
DeallocatingVector<EdgeBasedEdge> &edge_based_edge_list,
|
util::DeallocatingVector<extractor::EdgeBasedEdge> &edge_based_edge_list,
|
||||||
DeallocatingVector<QueryEdge> &contracted_edge_list,
|
util::DeallocatingVector<QueryEdge> &contracted_edge_list,
|
||||||
std::vector<bool> &is_core_node,
|
std::vector<bool> &is_core_node,
|
||||||
std::vector<float> &node_levels) const;
|
std::vector<float> &node_levels) const;
|
||||||
void WriteCoreNodeMarker(std::vector<bool> &&is_core_node) const;
|
void WriteCoreNodeMarker(std::vector<bool> &&is_core_node) const;
|
||||||
void WriteNodeLevels(std::vector<float> &&node_levels) const;
|
void WriteNodeLevels(std::vector<float> &&node_levels) const;
|
||||||
void ReadNodeLevels(std::vector<float> &contraction_order) const;
|
void ReadNodeLevels(std::vector<float> &contraction_order) const;
|
||||||
std::size_t WriteContractedGraph(unsigned number_of_edge_based_nodes,
|
std::size_t WriteContractedGraph(unsigned number_of_edge_based_nodes,
|
||||||
const DeallocatingVector<QueryEdge> &contracted_edge_list);
|
const util::DeallocatingVector<QueryEdge> &contracted_edge_list);
|
||||||
void FindComponents(unsigned max_edge_id,
|
void FindComponents(unsigned max_edge_id,
|
||||||
const DeallocatingVector<EdgeBasedEdge> &edges,
|
const util::DeallocatingVector<extractor::EdgeBasedEdge> &edges,
|
||||||
std::vector<EdgeBasedNode> &nodes) const;
|
std::vector<extractor::EdgeBasedNode> &nodes) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ContractorConfig config;
|
ContractorConfig config;
|
||||||
std::size_t LoadEdgeExpandedGraph(const std::string &edge_based_graph_path,
|
std::size_t LoadEdgeExpandedGraph(const std::string &edge_based_graph_path,
|
||||||
DeallocatingVector<EdgeBasedEdge> &edge_based_edge_list,
|
util::DeallocatingVector<extractor::EdgeBasedEdge> &edge_based_edge_list,
|
||||||
const std::string &edge_segment_lookup_path,
|
const std::string &edge_segment_lookup_path,
|
||||||
const std::string &edge_penalty_path,
|
const std::string &edge_penalty_path,
|
||||||
const std::string &segment_speed_path);
|
const std::string &segment_speed_path);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // PROCESSING_CHAIN_HPP
|
#endif // PROCESSING_CHAIN_HPP
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace contractor
|
||||||
|
{
|
||||||
|
|
||||||
struct QueryEdge
|
struct QueryEdge
|
||||||
{
|
{
|
||||||
NodeID source;
|
NodeID source;
|
||||||
@ -49,4 +54,7 @@ struct QueryEdge
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // QUERYEDGE_HPP
|
#endif // QUERYEDGE_HPP
|
||||||
|
@ -24,6 +24,11 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace datastore
|
||||||
|
{
|
||||||
|
|
||||||
struct OSRMLockFile
|
struct OSRMLockFile
|
||||||
{
|
{
|
||||||
boost::filesystem::path operator()()
|
boost::filesystem::path operator()()
|
||||||
@ -58,10 +63,10 @@ class SharedMemory
|
|||||||
{
|
{
|
||||||
if (m_initialized)
|
if (m_initialized)
|
||||||
{
|
{
|
||||||
SimpleLogger().Write(logDEBUG) << "automatic memory deallocation";
|
util::SimpleLogger().Write(logDEBUG) << "automatic memory deallocation";
|
||||||
if (!boost::interprocess::xsi_shared_memory::remove(m_shmid))
|
if (!boost::interprocess::xsi_shared_memory::remove(m_shmid))
|
||||||
{
|
{
|
||||||
SimpleLogger().Write(logDEBUG) << "could not deallocate id " << m_shmid;
|
util::SimpleLogger().Write(logDEBUG) << "could not deallocate id " << m_shmid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -103,14 +108,14 @@ class SharedMemory
|
|||||||
{
|
{
|
||||||
if (ENOMEM == errno)
|
if (ENOMEM == errno)
|
||||||
{
|
{
|
||||||
SimpleLogger().Write(logWARNING) << "could not lock shared memory to RAM";
|
util::SimpleLogger().Write(logWARNING) << "could not lock shared memory to RAM";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
region = boost::interprocess::mapped_region(shm, boost::interprocess::read_write);
|
region = boost::interprocess::mapped_region(shm, boost::interprocess::read_write);
|
||||||
|
|
||||||
remover.SetID(shm.get_shmid());
|
remover.SetID(shm.get_shmid());
|
||||||
SimpleLogger().Write(logDEBUG) << "writeable memory allocated " << size << " bytes";
|
util::SimpleLogger().Write(logDEBUG) << "writeable memory allocated " << size << " bytes";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,7 +162,7 @@ class SharedMemory
|
|||||||
bool ret = false;
|
bool ret = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SimpleLogger().Write(logDEBUG) << "deallocating prev memory";
|
util::SimpleLogger().Write(logDEBUG) << "deallocating prev memory";
|
||||||
boost::interprocess::xsi_shared_memory xsi(boost::interprocess::open_only, key);
|
boost::interprocess::xsi_shared_memory xsi(boost::interprocess::open_only, key);
|
||||||
ret = boost::interprocess::xsi_shared_memory::remove(xsi.get_shmid());
|
ret = boost::interprocess::xsi_shared_memory::remove(xsi.get_shmid());
|
||||||
}
|
}
|
||||||
@ -202,10 +207,10 @@ class SharedMemory
|
|||||||
{
|
{
|
||||||
if (m_initialized)
|
if (m_initialized)
|
||||||
{
|
{
|
||||||
SimpleLogger().Write(logDEBUG) << "automatic memory deallocation";
|
util::SimpleLogger().Write(logDEBUG) << "automatic memory deallocation";
|
||||||
if (!boost::interprocess::shared_memory_object::remove(m_shmid))
|
if (!boost::interprocess::shared_memory_object::remove(m_shmid))
|
||||||
{
|
{
|
||||||
SimpleLogger().Write(logDEBUG) << "could not deallocate id " << m_shmid;
|
util::SimpleLogger().Write(logDEBUG) << "could not deallocate id " << m_shmid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -242,7 +247,7 @@ class SharedMemory
|
|||||||
region = boost::interprocess::mapped_region(shm, boost::interprocess::read_write);
|
region = boost::interprocess::mapped_region(shm, boost::interprocess::read_write);
|
||||||
|
|
||||||
remover.SetID(key);
|
remover.SetID(key);
|
||||||
SimpleLogger().Write(logDEBUG) << "writeable memory allocated " << size << " bytes";
|
util::SimpleLogger().Write(logDEBUG) << "writeable memory allocated " << size << " bytes";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +297,7 @@ class SharedMemory
|
|||||||
bool ret = false;
|
bool ret = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
SimpleLogger().Write(logDEBUG) << "deallocating prev memory";
|
util::SimpleLogger().Write(logDEBUG) << "deallocating prev memory";
|
||||||
ret = boost::interprocess::shared_memory_object::remove(key);
|
ret = boost::interprocess::shared_memory_object::remove(key);
|
||||||
}
|
}
|
||||||
catch (const boost::interprocess::interprocess_exception &e)
|
catch (const boost::interprocess::interprocess_exception &e)
|
||||||
@ -328,7 +333,7 @@ template <class LockFileT = OSRMLockFile> class SharedMemoryFactory_tmpl
|
|||||||
{
|
{
|
||||||
if (0 == size)
|
if (0 == size)
|
||||||
{
|
{
|
||||||
throw osrm::exception("lock file does not exist, exiting");
|
throw util::exception("lock file does not exist, exiting");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -340,9 +345,9 @@ template <class LockFileT = OSRMLockFile> class SharedMemoryFactory_tmpl
|
|||||||
}
|
}
|
||||||
catch (const boost::interprocess::interprocess_exception &e)
|
catch (const boost::interprocess::interprocess_exception &e)
|
||||||
{
|
{
|
||||||
SimpleLogger().Write(logWARNING) << "caught exception: " << e.what() << ", code "
|
util::SimpleLogger().Write(logWARNING) << "caught exception: " << e.what() << ", code "
|
||||||
<< e.get_error_code();
|
<< e.get_error_code();
|
||||||
throw osrm::exception(e.what());
|
throw util::exception(e.what());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -352,4 +357,7 @@ template <class LockFileT = OSRMLockFile> class SharedMemoryFactory_tmpl
|
|||||||
|
|
||||||
using SharedMemoryFactory = SharedMemoryFactory_tmpl<>;
|
using SharedMemoryFactory = SharedMemoryFactory_tmpl<>;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // SHARED_MEMORY_FACTORY_HPP
|
#endif // SHARED_MEMORY_FACTORY_HPP
|
||||||
|
@ -57,7 +57,7 @@ template <typename DataFacadeT> class ApiResponseGenerator
|
|||||||
// The output is tailored to the viaroute plugin.
|
// The output is tailored to the viaroute plugin.
|
||||||
void DescribeRoute(const RouteParameters &config,
|
void DescribeRoute(const RouteParameters &config,
|
||||||
const InternalRouteResult &raw_route,
|
const InternalRouteResult &raw_route,
|
||||||
osrm::json::Object &json_result);
|
util::json::Object &json_result);
|
||||||
|
|
||||||
// The following functions allow access to the different parts of the Describe Route
|
// The following functions allow access to the different parts of the Describe Route
|
||||||
// functionality.
|
// functionality.
|
||||||
@ -65,20 +65,20 @@ template <typename DataFacadeT> class ApiResponseGenerator
|
|||||||
// In the normal situation, Describe Route is the desired usecase.
|
// In the normal situation, Describe Route is the desired usecase.
|
||||||
|
|
||||||
// generate an overview of a raw route
|
// generate an overview of a raw route
|
||||||
osrm::json::Object SummarizeRoute(const InternalRouteResult &raw_route,
|
util::json::Object SummarizeRoute(const InternalRouteResult &raw_route,
|
||||||
const Segments &segment_list) const;
|
const Segments &segment_list) const;
|
||||||
|
|
||||||
// create an array containing all via-points/-indices used in the query
|
// create an array containing all via-points/-indices used in the query
|
||||||
osrm::json::Array ListViaPoints(const InternalRouteResult &raw_route) const;
|
util::json::Array ListViaPoints(const InternalRouteResult &raw_route) const;
|
||||||
osrm::json::Array ListViaIndices(const Segments &segment_list) const;
|
util::json::Array ListViaIndices(const Segments &segment_list) const;
|
||||||
|
|
||||||
osrm::json::Value GetGeometry(const bool return_encoded, const Segments &segments) const;
|
util::json::Value GetGeometry(const bool return_encoded, const Segments &segments) const;
|
||||||
|
|
||||||
// TODO this dedicated creation seems unnecessary? Only used for route names
|
// TODO this dedicated creation seems unnecessary? Only used for route names
|
||||||
std::vector<Segment> BuildRouteSegments(const Segments &segment_list) const;
|
std::vector<Segment> BuildRouteSegments(const Segments &segment_list) const;
|
||||||
|
|
||||||
// adds checksum and locations
|
// adds checksum and locations
|
||||||
osrm::json::Object BuildHintData(const InternalRouteResult &raw_route) const;
|
util::json::Object BuildHintData(const InternalRouteResult &raw_route) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// data access to translate ids back into names
|
// data access to translate ids back into names
|
||||||
@ -94,7 +94,7 @@ ApiResponseGenerator<DataFacadeT>::ApiResponseGenerator(DataFacadeT *facade_)
|
|||||||
template <typename DataFacadeT>
|
template <typename DataFacadeT>
|
||||||
void ApiResponseGenerator<DataFacadeT>::DescribeRoute(const RouteParameters &config,
|
void ApiResponseGenerator<DataFacadeT>::DescribeRoute(const RouteParameters &config,
|
||||||
const InternalRouteResult &raw_route,
|
const InternalRouteResult &raw_route,
|
||||||
osrm::json::Object &json_result)
|
util::json::Object &json_result)
|
||||||
{
|
{
|
||||||
if( not raw_route.is_valid() ){
|
if( not raw_route.is_valid() ){
|
||||||
return;
|
return;
|
||||||
@ -129,7 +129,7 @@ void ApiResponseGenerator<DataFacadeT>::DescribeRoute(const RouteParameters &con
|
|||||||
|
|
||||||
// Alternative Route Summaries are stored in an array to (down the line) allow multiple
|
// Alternative Route Summaries are stored in an array to (down the line) allow multiple
|
||||||
// alternatives
|
// alternatives
|
||||||
osrm::json::Array json_alternate_route_summary_array;
|
util::json::Array json_alternate_route_summary_array;
|
||||||
json_alternate_route_summary_array.values.emplace_back(
|
json_alternate_route_summary_array.values.emplace_back(
|
||||||
SummarizeRoute(raw_route, alternate_segment_list));
|
SummarizeRoute(raw_route, alternate_segment_list));
|
||||||
json_result.values["alternative_summaries"] = json_alternate_route_summary_array;
|
json_result.values["alternative_summaries"] = json_alternate_route_summary_array;
|
||||||
@ -139,14 +139,14 @@ void ApiResponseGenerator<DataFacadeT>::DescribeRoute(const RouteParameters &con
|
|||||||
{
|
{
|
||||||
auto alternate_geometry_string =
|
auto alternate_geometry_string =
|
||||||
GetGeometry(config.compression, alternate_segment_list);
|
GetGeometry(config.compression, alternate_segment_list);
|
||||||
osrm::json::Array json_alternate_geometries_array;
|
util::json::Array json_alternate_geometries_array;
|
||||||
json_alternate_geometries_array.values.emplace_back(std::move(alternate_geometry_string));
|
json_alternate_geometries_array.values.emplace_back(std::move(alternate_geometry_string));
|
||||||
json_result.values["alternative_geometries"] = json_alternate_geometries_array;
|
json_result.values["alternative_geometries"] = json_alternate_geometries_array;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.print_instructions)
|
if (config.print_instructions)
|
||||||
{
|
{
|
||||||
osrm::json::Array json_alternate_annotations_array;
|
util::json::Array json_alternate_annotations_array;
|
||||||
json_alternate_annotations_array.values.emplace_back(
|
json_alternate_annotations_array.values.emplace_back(
|
||||||
guidance::AnnotateRoute(alternate_segment_list.Get(), facade));
|
guidance::AnnotateRoute(alternate_segment_list.Get(), facade));
|
||||||
json_result.values["alternative_instructions"] = json_alternate_annotations_array;
|
json_result.values["alternative_instructions"] = json_alternate_annotations_array;
|
||||||
@ -157,24 +157,24 @@ void ApiResponseGenerator<DataFacadeT>::DescribeRoute(const RouteParameters &con
|
|||||||
auto alternate_segments = BuildRouteSegments(alternate_segment_list);
|
auto alternate_segments = BuildRouteSegments(alternate_segment_list);
|
||||||
route_names = generate_route_names(path_segments, alternate_segments, facade);
|
route_names = generate_route_names(path_segments, alternate_segments, facade);
|
||||||
|
|
||||||
osrm::json::Array json_alternate_names_array;
|
util::json::Array json_alternate_names_array;
|
||||||
osrm::json::Array json_alternate_names;
|
util::json::Array json_alternate_names;
|
||||||
json_alternate_names.values.push_back(route_names.alternative_path_name_1);
|
json_alternate_names.values.push_back(route_names.alternative_path_name_1);
|
||||||
json_alternate_names.values.push_back(route_names.alternative_path_name_2);
|
json_alternate_names.values.push_back(route_names.alternative_path_name_2);
|
||||||
json_alternate_names_array.values.emplace_back(std::move(json_alternate_names));
|
json_alternate_names_array.values.emplace_back(std::move(json_alternate_names));
|
||||||
json_result.values["alternative_names"] = json_alternate_names_array;
|
json_result.values["alternative_names"] = json_alternate_names_array;
|
||||||
json_result.values["found_alternative"] = osrm::json::True();
|
json_result.values["found_alternative"] = util::json::True();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
json_result.values["found_alternative"] = osrm::json::False();
|
json_result.values["found_alternative"] = util::json::False();
|
||||||
// generate names for the main route on its own
|
// generate names for the main route on its own
|
||||||
auto path_segments = BuildRouteSegments(segment_list);
|
auto path_segments = BuildRouteSegments(segment_list);
|
||||||
std::vector<detail::Segment> alternate_segments;
|
std::vector<detail::Segment> alternate_segments;
|
||||||
route_names = generate_route_names(path_segments, alternate_segments, facade);
|
route_names = generate_route_names(path_segments, alternate_segments, facade);
|
||||||
}
|
}
|
||||||
|
|
||||||
osrm::json::Array json_route_names;
|
util::json::Array json_route_names;
|
||||||
json_route_names.values.push_back(route_names.shortest_path_name_1);
|
json_route_names.values.push_back(route_names.shortest_path_name_1);
|
||||||
json_route_names.values.push_back(route_names.shortest_path_name_2);
|
json_route_names.values.push_back(route_names.shortest_path_name_2);
|
||||||
json_result.values["route_name"] = json_route_names;
|
json_result.values["route_name"] = json_route_names;
|
||||||
@ -183,11 +183,11 @@ void ApiResponseGenerator<DataFacadeT>::DescribeRoute(const RouteParameters &con
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename DataFacadeT>
|
template <typename DataFacadeT>
|
||||||
osrm::json::Object
|
util::json::Object
|
||||||
ApiResponseGenerator<DataFacadeT>::SummarizeRoute(const InternalRouteResult &raw_route,
|
ApiResponseGenerator<DataFacadeT>::SummarizeRoute(const InternalRouteResult &raw_route,
|
||||||
const Segments &segment_list) const
|
const Segments &segment_list) const
|
||||||
{
|
{
|
||||||
osrm::json::Object json_route_summary;
|
util::json::Object json_route_summary;
|
||||||
if (not raw_route.segment_end_coordinates.empty())
|
if (not raw_route.segment_end_coordinates.empty())
|
||||||
{
|
{
|
||||||
const auto start_name_id = raw_route.segment_end_coordinates.front().source_phantom.name_id;
|
const auto start_name_id = raw_route.segment_end_coordinates.front().source_phantom.name_id;
|
||||||
@ -201,11 +201,11 @@ ApiResponseGenerator<DataFacadeT>::SummarizeRoute(const InternalRouteResult &raw
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename DataFacadeT>
|
template <typename DataFacadeT>
|
||||||
osrm::json::Array
|
util::json::Array
|
||||||
ApiResponseGenerator<DataFacadeT>::ListViaPoints(const InternalRouteResult &raw_route) const
|
ApiResponseGenerator<DataFacadeT>::ListViaPoints(const InternalRouteResult &raw_route) const
|
||||||
{
|
{
|
||||||
osrm::json::Array json_via_points_array;
|
util::json::Array json_via_points_array;
|
||||||
osrm::json::Array json_first_coordinate;
|
util::json::Array json_first_coordinate;
|
||||||
json_first_coordinate.values.emplace_back(
|
json_first_coordinate.values.emplace_back(
|
||||||
raw_route.segment_end_coordinates.front().source_phantom.location.lat /
|
raw_route.segment_end_coordinates.front().source_phantom.location.lat /
|
||||||
COORDINATE_PRECISION);
|
COORDINATE_PRECISION);
|
||||||
@ -216,7 +216,7 @@ ApiResponseGenerator<DataFacadeT>::ListViaPoints(const InternalRouteResult &raw_
|
|||||||
for (const PhantomNodes &nodes : raw_route.segment_end_coordinates)
|
for (const PhantomNodes &nodes : raw_route.segment_end_coordinates)
|
||||||
{
|
{
|
||||||
std::string tmp;
|
std::string tmp;
|
||||||
osrm::json::Array json_coordinate;
|
util::json::Array json_coordinate;
|
||||||
json_coordinate.values.emplace_back(nodes.target_phantom.location.lat / COORDINATE_PRECISION);
|
json_coordinate.values.emplace_back(nodes.target_phantom.location.lat / COORDINATE_PRECISION);
|
||||||
json_coordinate.values.emplace_back(nodes.target_phantom.location.lon / COORDINATE_PRECISION);
|
json_coordinate.values.emplace_back(nodes.target_phantom.location.lon / COORDINATE_PRECISION);
|
||||||
json_via_points_array.values.emplace_back(std::move(json_coordinate));
|
json_via_points_array.values.emplace_back(std::move(json_coordinate));
|
||||||
@ -225,17 +225,17 @@ ApiResponseGenerator<DataFacadeT>::ListViaPoints(const InternalRouteResult &raw_
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename DataFacadeT>
|
template <typename DataFacadeT>
|
||||||
osrm::json::Array
|
util::json::Array
|
||||||
ApiResponseGenerator<DataFacadeT>::ListViaIndices(const Segments &segment_list) const
|
ApiResponseGenerator<DataFacadeT>::ListViaIndices(const Segments &segment_list) const
|
||||||
{
|
{
|
||||||
osrm::json::Array via_indices;
|
util::json::Array via_indices;
|
||||||
via_indices.values.insert(via_indices.values.end(), segment_list.GetViaIndices().begin(),
|
via_indices.values.insert(via_indices.values.end(), segment_list.GetViaIndices().begin(),
|
||||||
segment_list.GetViaIndices().end());
|
segment_list.GetViaIndices().end());
|
||||||
return via_indices;
|
return via_indices;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename DataFacadeT>
|
template <typename DataFacadeT>
|
||||||
osrm::json::Value ApiResponseGenerator<DataFacadeT>::GetGeometry(const bool return_encoded, const Segments &segments) const
|
util::json::Value ApiResponseGenerator<DataFacadeT>::GetGeometry(const bool return_encoded, const Segments &segments) const
|
||||||
{
|
{
|
||||||
if (return_encoded)
|
if (return_encoded)
|
||||||
return PolylineFormatter().printEncodedString(segments.Get());
|
return PolylineFormatter().printEncodedString(segments.Get());
|
||||||
@ -251,8 +251,8 @@ ApiResponseGenerator<DataFacadeT>::BuildRouteSegments(const Segments &segment_li
|
|||||||
for (const auto &segment : segment_list.Get())
|
for (const auto &segment : segment_list.Get())
|
||||||
{
|
{
|
||||||
const auto current_turn = segment.turn_instruction;
|
const auto current_turn = segment.turn_instruction;
|
||||||
if (TurnInstructionsClass::TurnIsNecessary(current_turn) and
|
if (extractor::TurnInstructionsClass::TurnIsNecessary(current_turn) and
|
||||||
(TurnInstruction::EnterRoundAbout != current_turn))
|
(extractor::TurnInstruction::EnterRoundAbout != current_turn))
|
||||||
{
|
{
|
||||||
|
|
||||||
detail::Segment seg = {segment.name_id, static_cast<int32_t>(segment.length),
|
detail::Segment seg = {segment.name_id, static_cast<int32_t>(segment.length),
|
||||||
@ -264,14 +264,14 @@ ApiResponseGenerator<DataFacadeT>::BuildRouteSegments(const Segments &segment_li
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename DataFacadeT>
|
template <typename DataFacadeT>
|
||||||
osrm::json::Object
|
util::json::Object
|
||||||
ApiResponseGenerator<DataFacadeT>::BuildHintData(const InternalRouteResult &raw_route) const
|
ApiResponseGenerator<DataFacadeT>::BuildHintData(const InternalRouteResult &raw_route) const
|
||||||
{
|
{
|
||||||
osrm::json::Object json_hint_object;
|
util::json::Object json_hint_object;
|
||||||
json_hint_object.values["checksum"] = facade->GetCheckSum();
|
json_hint_object.values["checksum"] = facade->GetCheckSum();
|
||||||
osrm::json::Array json_location_hint_array;
|
util::json::Array json_location_hint_array;
|
||||||
std::string hint;
|
std::string hint;
|
||||||
for (const auto i : osrm::irange<std::size_t>(0, raw_route.segment_end_coordinates.size()))
|
for (const auto i : util::irange<std::size_t>(0, raw_route.segment_end_coordinates.size()))
|
||||||
{
|
{
|
||||||
ObjectEncoder::EncodeToBase64(raw_route.segment_end_coordinates[i].source_phantom, hint);
|
ObjectEncoder::EncodeToBase64(raw_route.segment_end_coordinates[i].source_phantom, hint);
|
||||||
json_location_hint_array.values.push_back(hint);
|
json_location_hint_array.values.push_back(hint);
|
||||||
|
@ -17,12 +17,19 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <boost/optional.hpp>
|
#include <boost/optional.hpp>
|
||||||
|
|
||||||
using EdgeRange = osrm::range<EdgeID>;
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace datafacade
|
||||||
|
{
|
||||||
|
|
||||||
|
using EdgeRange = util::range<EdgeID>;
|
||||||
|
|
||||||
template <class EdgeDataT> class BaseDataFacade
|
template <class EdgeDataT> class BaseDataFacade
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using RTreeLeaf = EdgeBasedNode;
|
using RTreeLeaf = extractor::EdgeBasedNode;
|
||||||
using EdgeData = EdgeDataT;
|
using EdgeData = EdgeDataT;
|
||||||
BaseDataFacade() {}
|
BaseDataFacade() {}
|
||||||
virtual ~BaseDataFacade() {}
|
virtual ~BaseDataFacade() {}
|
||||||
@ -53,7 +60,7 @@ template <class EdgeDataT> class BaseDataFacade
|
|||||||
FindEdgeIndicateIfReverse(const NodeID from, const NodeID to, bool &result) const = 0;
|
FindEdgeIndicateIfReverse(const NodeID from, const NodeID to, bool &result) const = 0;
|
||||||
|
|
||||||
// node and edge information access
|
// node and edge information access
|
||||||
virtual FixedPointCoordinate GetCoordinateOfNode(const unsigned id) const = 0;
|
virtual util::FixedPointCoordinate GetCoordinateOfNode(const unsigned id) const = 0;
|
||||||
|
|
||||||
virtual bool EdgeIsCompressed(const unsigned id) const = 0;
|
virtual bool EdgeIsCompressed(const unsigned id) const = 0;
|
||||||
|
|
||||||
@ -62,24 +69,24 @@ template <class EdgeDataT> class BaseDataFacade
|
|||||||
virtual void GetUncompressedGeometry(const unsigned id,
|
virtual void GetUncompressedGeometry(const unsigned id,
|
||||||
std::vector<unsigned> &result_nodes) const = 0;
|
std::vector<unsigned> &result_nodes) const = 0;
|
||||||
|
|
||||||
virtual TurnInstruction GetTurnInstructionForEdgeID(const unsigned id) const = 0;
|
virtual extractor::TurnInstruction GetTurnInstructionForEdgeID(const unsigned id) const = 0;
|
||||||
|
|
||||||
virtual TravelMode GetTravelModeForEdgeID(const unsigned id) const = 0;
|
virtual extractor::TravelMode GetTravelModeForEdgeID(const unsigned id) const = 0;
|
||||||
|
|
||||||
virtual std::vector<PhantomNodeWithDistance>
|
virtual std::vector<PhantomNodeWithDistance>
|
||||||
NearestPhantomNodesInRange(const FixedPointCoordinate &input_coordinate,
|
NearestPhantomNodesInRange(const util::FixedPointCoordinate &input_coordinate,
|
||||||
const float max_distance,
|
const float max_distance,
|
||||||
const int bearing = 0,
|
const int bearing = 0,
|
||||||
const int bearing_range = 180) = 0;
|
const int bearing_range = 180) = 0;
|
||||||
|
|
||||||
virtual std::vector<PhantomNodeWithDistance>
|
virtual std::vector<PhantomNodeWithDistance>
|
||||||
NearestPhantomNodes(const FixedPointCoordinate &input_coordinate,
|
NearestPhantomNodes(const util::FixedPointCoordinate &input_coordinate,
|
||||||
const unsigned max_results,
|
const unsigned max_results,
|
||||||
const int bearing = 0,
|
const int bearing = 0,
|
||||||
const int bearing_range = 180) = 0;
|
const int bearing_range = 180) = 0;
|
||||||
|
|
||||||
virtual std::pair<PhantomNode, PhantomNode>
|
virtual std::pair<PhantomNode, PhantomNode>
|
||||||
NearestPhantomNodeWithAlternativeFromBigComponent(const FixedPointCoordinate &input_coordinate,
|
NearestPhantomNodeWithAlternativeFromBigComponent(const util::FixedPointCoordinate &input_coordinate,
|
||||||
const int bearing = 0,
|
const int bearing = 0,
|
||||||
const int bearing_range = 180) = 0;
|
const int bearing_range = 180) = 0;
|
||||||
|
|
||||||
@ -96,4 +103,8 @@ template <class EdgeDataT> class BaseDataFacade
|
|||||||
virtual std::string GetTimestamp() const = 0;
|
virtual std::string GetTimestamp() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DATAFACADE_BASE_HPP
|
#endif // DATAFACADE_BASE_HPP
|
||||||
|
@ -22,15 +22,22 @@
|
|||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace datafacade
|
||||||
|
{
|
||||||
|
|
||||||
template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacade<EdgeDataT>
|
template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacade<EdgeDataT>
|
||||||
{
|
{
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using super = BaseDataFacade<EdgeDataT>;
|
using super = BaseDataFacade<EdgeDataT>;
|
||||||
using QueryGraph = StaticGraph<typename super::EdgeData>;
|
using QueryGraph = util::StaticGraph<typename super::EdgeData>;
|
||||||
using InputEdge = typename QueryGraph::InputEdge;
|
using InputEdge = typename QueryGraph::InputEdge;
|
||||||
using RTreeLeaf = typename super::RTreeLeaf;
|
using RTreeLeaf = typename super::RTreeLeaf;
|
||||||
using InternalRTree = StaticRTree<RTreeLeaf, ShM<FixedPointCoordinate, false>::vector, false>;
|
using InternalRTree = util::StaticRTree<RTreeLeaf, util::ShM<util::FixedPointCoordinate, false>::vector, false>;
|
||||||
using InternalGeospatialQuery = GeospatialQuery<InternalRTree>;
|
using InternalGeospatialQuery = GeospatialQuery<InternalRTree>;
|
||||||
|
|
||||||
InternalDataFacade() {}
|
InternalDataFacade() {}
|
||||||
@ -40,32 +47,32 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
|||||||
std::unique_ptr<QueryGraph> m_query_graph;
|
std::unique_ptr<QueryGraph> m_query_graph;
|
||||||
std::string m_timestamp;
|
std::string m_timestamp;
|
||||||
|
|
||||||
std::shared_ptr<ShM<FixedPointCoordinate, false>::vector> m_coordinate_list;
|
std::shared_ptr<util::ShM<util::FixedPointCoordinate, false>::vector> m_coordinate_list;
|
||||||
ShM<NodeID, false>::vector m_via_node_list;
|
util::ShM<NodeID, false>::vector m_via_node_list;
|
||||||
ShM<unsigned, false>::vector m_name_ID_list;
|
util::ShM<unsigned, false>::vector m_name_ID_list;
|
||||||
ShM<TurnInstruction, false>::vector m_turn_instruction_list;
|
util::ShM<extractor::TurnInstruction, false>::vector m_turn_instruction_list;
|
||||||
ShM<TravelMode, false>::vector m_travel_mode_list;
|
util::ShM<extractor::TravelMode, false>::vector m_travel_mode_list;
|
||||||
ShM<char, false>::vector m_names_char_list;
|
util::ShM<char, false>::vector m_names_char_list;
|
||||||
ShM<bool, false>::vector m_edge_is_compressed;
|
util::ShM<bool, false>::vector m_edge_is_compressed;
|
||||||
ShM<unsigned, false>::vector m_geometry_indices;
|
util::ShM<unsigned, false>::vector m_geometry_indices;
|
||||||
ShM<unsigned, false>::vector m_geometry_list;
|
util::ShM<unsigned, false>::vector m_geometry_list;
|
||||||
ShM<bool, false>::vector m_is_core_node;
|
util::ShM<bool, false>::vector m_is_core_node;
|
||||||
|
|
||||||
boost::thread_specific_ptr<InternalRTree> m_static_rtree;
|
boost::thread_specific_ptr<InternalRTree> m_static_rtree;
|
||||||
boost::thread_specific_ptr<InternalGeospatialQuery> m_geospatial_query;
|
boost::thread_specific_ptr<InternalGeospatialQuery> m_geospatial_query;
|
||||||
boost::filesystem::path ram_index_path;
|
boost::filesystem::path ram_index_path;
|
||||||
boost::filesystem::path file_index_path;
|
boost::filesystem::path file_index_path;
|
||||||
RangeTable<16, false> m_name_table;
|
util::RangeTable<16, false> m_name_table;
|
||||||
|
|
||||||
void LoadTimestamp(const boost::filesystem::path ×tamp_path)
|
void LoadTimestamp(const boost::filesystem::path ×tamp_path)
|
||||||
{
|
{
|
||||||
if (boost::filesystem::exists(timestamp_path))
|
if (boost::filesystem::exists(timestamp_path))
|
||||||
{
|
{
|
||||||
SimpleLogger().Write() << "Loading Timestamp";
|
util::SimpleLogger().Write() << "Loading Timestamp";
|
||||||
boost::filesystem::ifstream timestamp_stream(timestamp_path);
|
boost::filesystem::ifstream timestamp_stream(timestamp_path);
|
||||||
if (!timestamp_stream)
|
if (!timestamp_stream)
|
||||||
{
|
{
|
||||||
SimpleLogger().Write(logWARNING) << timestamp_path << " not found";
|
util::SimpleLogger().Write(logWARNING) << timestamp_path << " not found";
|
||||||
}
|
}
|
||||||
getline(timestamp_stream, m_timestamp);
|
getline(timestamp_stream, m_timestamp);
|
||||||
timestamp_stream.close();
|
timestamp_stream.close();
|
||||||
@ -82,22 +89,22 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
|||||||
|
|
||||||
void LoadGraph(const boost::filesystem::path &hsgr_path)
|
void LoadGraph(const boost::filesystem::path &hsgr_path)
|
||||||
{
|
{
|
||||||
typename ShM<typename QueryGraph::NodeArrayEntry, false>::vector node_list;
|
typename util::ShM<typename QueryGraph::NodeArrayEntry, false>::vector node_list;
|
||||||
typename ShM<typename QueryGraph::EdgeArrayEntry, false>::vector edge_list;
|
typename util::ShM<typename QueryGraph::EdgeArrayEntry, false>::vector edge_list;
|
||||||
|
|
||||||
SimpleLogger().Write() << "loading graph from " << hsgr_path.string();
|
util::SimpleLogger().Write() << "loading graph from " << hsgr_path.string();
|
||||||
|
|
||||||
m_number_of_nodes = readHSGRFromStream(hsgr_path, node_list, edge_list, &m_check_sum);
|
m_number_of_nodes = readHSGRFromStream(hsgr_path, node_list, edge_list, &m_check_sum);
|
||||||
|
|
||||||
BOOST_ASSERT_MSG(0 != node_list.size(), "node list empty");
|
BOOST_ASSERT_MSG(0 != node_list.size(), "node list empty");
|
||||||
// BOOST_ASSERT_MSG(0 != edge_list.size(), "edge list empty");
|
// BOOST_ASSERT_MSG(0 != edge_list.size(), "edge list empty");
|
||||||
SimpleLogger().Write() << "loaded " << node_list.size() << " nodes and " << edge_list.size()
|
util::SimpleLogger().Write() << "loaded " << node_list.size() << " nodes and " << edge_list.size()
|
||||||
<< " edges";
|
<< " edges";
|
||||||
m_query_graph = std::unique_ptr<QueryGraph>(new QueryGraph(node_list, edge_list));
|
m_query_graph = std::unique_ptr<QueryGraph>(new QueryGraph(node_list, edge_list));
|
||||||
|
|
||||||
BOOST_ASSERT_MSG(0 == node_list.size(), "node list not flushed");
|
BOOST_ASSERT_MSG(0 == node_list.size(), "node list not flushed");
|
||||||
BOOST_ASSERT_MSG(0 == edge_list.size(), "edge list not flushed");
|
BOOST_ASSERT_MSG(0 == edge_list.size(), "edge list not flushed");
|
||||||
SimpleLogger().Write() << "Data checksum is " << m_check_sum;
|
util::SimpleLogger().Write() << "Data checksum is " << m_check_sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadNodeAndEdgeInformation(const boost::filesystem::path &nodes_file,
|
void LoadNodeAndEdgeInformation(const boost::filesystem::path &nodes_file,
|
||||||
@ -105,15 +112,15 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
|||||||
{
|
{
|
||||||
boost::filesystem::ifstream nodes_input_stream(nodes_file, std::ios::binary);
|
boost::filesystem::ifstream nodes_input_stream(nodes_file, std::ios::binary);
|
||||||
|
|
||||||
QueryNode current_node;
|
extractor::QueryNode current_node;
|
||||||
unsigned number_of_coordinates = 0;
|
unsigned number_of_coordinates = 0;
|
||||||
nodes_input_stream.read((char *)&number_of_coordinates, sizeof(unsigned));
|
nodes_input_stream.read((char *)&number_of_coordinates, sizeof(unsigned));
|
||||||
m_coordinate_list =
|
m_coordinate_list =
|
||||||
std::make_shared<std::vector<FixedPointCoordinate>>(number_of_coordinates);
|
std::make_shared<std::vector<util::FixedPointCoordinate>>(number_of_coordinates);
|
||||||
for (unsigned i = 0; i < number_of_coordinates; ++i)
|
for (unsigned i = 0; i < number_of_coordinates; ++i)
|
||||||
{
|
{
|
||||||
nodes_input_stream.read((char *)¤t_node, sizeof(QueryNode));
|
nodes_input_stream.read((char *)¤t_node, sizeof(extractor::QueryNode));
|
||||||
m_coordinate_list->at(i) = FixedPointCoordinate(current_node.lat, current_node.lon);
|
m_coordinate_list->at(i) = util::FixedPointCoordinate(current_node.lat, current_node.lon);
|
||||||
BOOST_ASSERT((std::abs(m_coordinate_list->at(i).lat) >> 30) == 0);
|
BOOST_ASSERT((std::abs(m_coordinate_list->at(i).lat) >> 30) == 0);
|
||||||
BOOST_ASSERT((std::abs(m_coordinate_list->at(i).lon) >> 30) == 0);
|
BOOST_ASSERT((std::abs(m_coordinate_list->at(i).lon) >> 30) == 0);
|
||||||
}
|
}
|
||||||
@ -130,10 +137,10 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
|||||||
|
|
||||||
unsigned compressed = 0;
|
unsigned compressed = 0;
|
||||||
|
|
||||||
OriginalEdgeData current_edge_data;
|
extractor::OriginalEdgeData current_edge_data;
|
||||||
for (unsigned i = 0; i < number_of_edges; ++i)
|
for (unsigned i = 0; i < number_of_edges; ++i)
|
||||||
{
|
{
|
||||||
edges_input_stream.read((char *)&(current_edge_data), sizeof(OriginalEdgeData));
|
edges_input_stream.read((char *)&(current_edge_data), sizeof(extractor::OriginalEdgeData));
|
||||||
m_via_node_list[i] = current_edge_data.via_node;
|
m_via_node_list[i] = current_edge_data.via_node;
|
||||||
m_name_ID_list[i] = current_edge_data.name_id;
|
m_name_ID_list[i] = current_edge_data.name_id;
|
||||||
m_turn_instruction_list[i] = current_edge_data.turn_instruction;
|
m_turn_instruction_list[i] = current_edge_data.turn_instruction;
|
||||||
@ -220,7 +227,7 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
|||||||
name_stream.read((char *)&m_names_char_list[0], number_of_chars * sizeof(char));
|
name_stream.read((char *)&m_names_char_list[0], number_of_chars * sizeof(char));
|
||||||
if (0 == m_names_char_list.size())
|
if (0 == m_names_char_list.size())
|
||||||
{
|
{
|
||||||
SimpleLogger().Write(logWARNING) << "list of street names is empty";
|
util::SimpleLogger().Write(logWARNING) << "list of street names is empty";
|
||||||
}
|
}
|
||||||
name_stream.close();
|
name_stream.close();
|
||||||
}
|
}
|
||||||
@ -242,29 +249,29 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
|||||||
{
|
{
|
||||||
const auto it = server_paths.find(path);
|
const auto it = server_paths.find(path);
|
||||||
if (it == end_it || !boost::filesystem::is_regular_file(it->second))
|
if (it == end_it || !boost::filesystem::is_regular_file(it->second))
|
||||||
throw osrm::exception("no valid " + path + " file given in ini file");
|
throw util::exception("no valid " + path + " file given in ini file");
|
||||||
return it->second;
|
return it->second;
|
||||||
};
|
};
|
||||||
|
|
||||||
ram_index_path = file_for("ramindex");
|
ram_index_path = file_for("ramindex");
|
||||||
file_index_path = file_for("fileindex");
|
file_index_path = file_for("fileindex");
|
||||||
|
|
||||||
SimpleLogger().Write() << "loading graph data";
|
util::SimpleLogger().Write() << "loading graph data";
|
||||||
LoadGraph(file_for("hsgrdata"));
|
LoadGraph(file_for("hsgrdata"));
|
||||||
|
|
||||||
SimpleLogger().Write() << "loading edge information";
|
util::SimpleLogger().Write() << "loading edge information";
|
||||||
LoadNodeAndEdgeInformation(file_for("nodesdata"), file_for("edgesdata"));
|
LoadNodeAndEdgeInformation(file_for("nodesdata"), file_for("edgesdata"));
|
||||||
|
|
||||||
SimpleLogger().Write() << "loading core information";
|
util::SimpleLogger().Write() << "loading core information";
|
||||||
LoadCoreInformation(file_for("coredata"));
|
LoadCoreInformation(file_for("coredata"));
|
||||||
|
|
||||||
SimpleLogger().Write() << "loading geometries";
|
util::SimpleLogger().Write() << "loading geometries";
|
||||||
LoadGeometries(file_for("geometries"));
|
LoadGeometries(file_for("geometries"));
|
||||||
|
|
||||||
SimpleLogger().Write() << "loading timestamp";
|
util::SimpleLogger().Write() << "loading timestamp";
|
||||||
LoadTimestamp(file_for("timestamp"));
|
LoadTimestamp(file_for("timestamp"));
|
||||||
|
|
||||||
SimpleLogger().Write() << "loading street names";
|
util::SimpleLogger().Write() << "loading street names";
|
||||||
LoadStreetNames(file_for("namesdata"));
|
LoadStreetNames(file_for("namesdata"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,7 +319,7 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
|||||||
}
|
}
|
||||||
|
|
||||||
// node and edge information access
|
// node and edge information access
|
||||||
FixedPointCoordinate GetCoordinateOfNode(const unsigned id) const override final
|
util::FixedPointCoordinate GetCoordinateOfNode(const unsigned id) const override final
|
||||||
{
|
{
|
||||||
return m_coordinate_list->at(id);
|
return m_coordinate_list->at(id);
|
||||||
};
|
};
|
||||||
@ -322,18 +329,18 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
|||||||
return m_edge_is_compressed.at(id);
|
return m_edge_is_compressed.at(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
TurnInstruction GetTurnInstructionForEdgeID(const unsigned id) const override final
|
extractor::TurnInstruction GetTurnInstructionForEdgeID(const unsigned id) const override final
|
||||||
{
|
{
|
||||||
return m_turn_instruction_list.at(id);
|
return m_turn_instruction_list.at(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
TravelMode GetTravelModeForEdgeID(const unsigned id) const override final
|
extractor::TravelMode GetTravelModeForEdgeID(const unsigned id) const override final
|
||||||
{
|
{
|
||||||
return m_travel_mode_list.at(id);
|
return m_travel_mode_list.at(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<PhantomNodeWithDistance>
|
std::vector<PhantomNodeWithDistance>
|
||||||
NearestPhantomNodesInRange(const FixedPointCoordinate &input_coordinate,
|
NearestPhantomNodesInRange(const util::FixedPointCoordinate &input_coordinate,
|
||||||
const float max_distance,
|
const float max_distance,
|
||||||
const int bearing = 0,
|
const int bearing = 0,
|
||||||
const int bearing_range = 180) override final
|
const int bearing_range = 180) override final
|
||||||
@ -349,7 +356,7 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<PhantomNodeWithDistance>
|
std::vector<PhantomNodeWithDistance>
|
||||||
NearestPhantomNodes(const FixedPointCoordinate &input_coordinate,
|
NearestPhantomNodes(const util::FixedPointCoordinate &input_coordinate,
|
||||||
const unsigned max_results,
|
const unsigned max_results,
|
||||||
const int bearing = 0,
|
const int bearing = 0,
|
||||||
const int bearing_range = 180) override final
|
const int bearing_range = 180) override final
|
||||||
@ -365,7 +372,7 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::pair<PhantomNode, PhantomNode>
|
std::pair<PhantomNode, PhantomNode>
|
||||||
NearestPhantomNodeWithAlternativeFromBigComponent(const FixedPointCoordinate &input_coordinate,
|
NearestPhantomNodeWithAlternativeFromBigComponent(const util::FixedPointCoordinate &input_coordinate,
|
||||||
const int bearing = 0,
|
const int bearing = 0,
|
||||||
const int bearing_range = 180) override final
|
const int bearing_range = 180) override final
|
||||||
{
|
{
|
||||||
@ -438,4 +445,8 @@ template <class EdgeDataT> class InternalDataFacade final : public BaseDataFacad
|
|||||||
std::string GetTimestamp() const override final { return m_timestamp; }
|
std::string GetTimestamp() const override final { return m_timestamp; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // INTERNAL_DATAFACADE_HPP
|
#endif // INTERNAL_DATAFACADE_HPP
|
||||||
|
@ -4,6 +4,13 @@
|
|||||||
#include <boost/interprocess/sync/named_mutex.hpp>
|
#include <boost/interprocess/sync/named_mutex.hpp>
|
||||||
#include <boost/interprocess/sync/named_condition.hpp>
|
#include <boost/interprocess/sync/named_condition.hpp>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace datafacade
|
||||||
|
{
|
||||||
|
|
||||||
struct SharedBarriers
|
struct SharedBarriers
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -30,4 +37,8 @@ struct SharedBarriers
|
|||||||
int number_of_queries;
|
int number_of_queries;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // SHARED_BARRIERS_HPP
|
#endif // SHARED_BARRIERS_HPP
|
||||||
|
@ -19,19 +19,26 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace datafacade
|
||||||
|
{
|
||||||
|
|
||||||
template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<EdgeDataT>
|
template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<EdgeDataT>
|
||||||
{
|
{
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using EdgeData = EdgeDataT;
|
using EdgeData = EdgeDataT;
|
||||||
using super = BaseDataFacade<EdgeData>;
|
using super = BaseDataFacade<EdgeData>;
|
||||||
using QueryGraph = StaticGraph<EdgeData, true>;
|
using QueryGraph = util::StaticGraph<EdgeData, true>;
|
||||||
using GraphNode = typename StaticGraph<EdgeData, true>::NodeArrayEntry;
|
using GraphNode = typename QueryGraph::NodeArrayEntry;
|
||||||
using GraphEdge = typename StaticGraph<EdgeData, true>::EdgeArrayEntry;
|
using GraphEdge = typename QueryGraph::EdgeArrayEntry;
|
||||||
using NameIndexBlock = typename RangeTable<16, true>::BlockT;
|
using NameIndexBlock = typename util::RangeTable<16, true>::BlockT;
|
||||||
using InputEdge = typename QueryGraph::InputEdge;
|
using InputEdge = typename QueryGraph::InputEdge;
|
||||||
using RTreeLeaf = typename super::RTreeLeaf;
|
using RTreeLeaf = typename super::RTreeLeaf;
|
||||||
using SharedRTree = StaticRTree<RTreeLeaf, ShM<FixedPointCoordinate, true>::vector, true>;
|
using SharedRTree = util::StaticRTree<RTreeLeaf, util::ShM<util::FixedPointCoordinate, true>::vector, true>;
|
||||||
using SharedGeospatialQuery = GeospatialQuery<SharedRTree>;
|
using SharedGeospatialQuery = GeospatialQuery<SharedRTree>;
|
||||||
using TimeStampedRTreePair = std::pair<unsigned, std::shared_ptr<SharedRTree>>;
|
using TimeStampedRTreePair = std::pair<unsigned, std::shared_ptr<SharedRTree>>;
|
||||||
using RTreeNode = typename SharedRTree::TreeNode;
|
using RTreeNode = typename SharedRTree::TreeNode;
|
||||||
@ -46,33 +53,33 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
|
|
||||||
unsigned m_check_sum;
|
unsigned m_check_sum;
|
||||||
std::unique_ptr<QueryGraph> m_query_graph;
|
std::unique_ptr<QueryGraph> m_query_graph;
|
||||||
std::unique_ptr<SharedMemory> m_layout_memory;
|
std::unique_ptr<datastore::SharedMemory> m_layout_memory;
|
||||||
std::unique_ptr<SharedMemory> m_large_memory;
|
std::unique_ptr<datastore::SharedMemory> m_large_memory;
|
||||||
std::string m_timestamp;
|
std::string m_timestamp;
|
||||||
|
|
||||||
std::shared_ptr<ShM<FixedPointCoordinate, true>::vector> m_coordinate_list;
|
std::shared_ptr<util::ShM<util::FixedPointCoordinate, true>::vector> m_coordinate_list;
|
||||||
ShM<NodeID, true>::vector m_via_node_list;
|
util::ShM<NodeID, true>::vector m_via_node_list;
|
||||||
ShM<unsigned, true>::vector m_name_ID_list;
|
util::ShM<unsigned, true>::vector m_name_ID_list;
|
||||||
ShM<TurnInstruction, true>::vector m_turn_instruction_list;
|
util::ShM<extractor::TurnInstruction, true>::vector m_turn_instruction_list;
|
||||||
ShM<TravelMode, true>::vector m_travel_mode_list;
|
util::ShM<extractor::TravelMode, true>::vector m_travel_mode_list;
|
||||||
ShM<char, true>::vector m_names_char_list;
|
util::ShM<char, true>::vector m_names_char_list;
|
||||||
ShM<unsigned, true>::vector m_name_begin_indices;
|
util::ShM<unsigned, true>::vector m_name_begin_indices;
|
||||||
ShM<bool, true>::vector m_edge_is_compressed;
|
util::ShM<bool, true>::vector m_edge_is_compressed;
|
||||||
ShM<unsigned, true>::vector m_geometry_indices;
|
util::ShM<unsigned, true>::vector m_geometry_indices;
|
||||||
ShM<unsigned, true>::vector m_geometry_list;
|
util::ShM<unsigned, true>::vector m_geometry_list;
|
||||||
ShM<bool, true>::vector m_is_core_node;
|
util::ShM<bool, true>::vector m_is_core_node;
|
||||||
|
|
||||||
boost::thread_specific_ptr<std::pair<unsigned, std::shared_ptr<SharedRTree>>> m_static_rtree;
|
boost::thread_specific_ptr<std::pair<unsigned, std::shared_ptr<SharedRTree>>> m_static_rtree;
|
||||||
boost::thread_specific_ptr<SharedGeospatialQuery> m_geospatial_query;
|
boost::thread_specific_ptr<SharedGeospatialQuery> m_geospatial_query;
|
||||||
boost::filesystem::path file_index_path;
|
boost::filesystem::path file_index_path;
|
||||||
|
|
||||||
std::shared_ptr<RangeTable<16, true>> m_name_table;
|
std::shared_ptr<util::RangeTable<16, true>> m_name_table;
|
||||||
|
|
||||||
void LoadChecksum()
|
void LoadChecksum()
|
||||||
{
|
{
|
||||||
m_check_sum =
|
m_check_sum =
|
||||||
*data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::HSGR_CHECKSUM);
|
*data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::HSGR_CHECKSUM);
|
||||||
SimpleLogger().Write() << "set checksum: " << m_check_sum;
|
util::SimpleLogger().Write() << "set checksum: " << m_check_sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoadTimestamp()
|
void LoadTimestamp()
|
||||||
@ -93,7 +100,7 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
data_layout->GetBlockPtr<RTreeNode>(shared_memory, SharedDataLayout::R_SEARCH_TREE);
|
data_layout->GetBlockPtr<RTreeNode>(shared_memory, SharedDataLayout::R_SEARCH_TREE);
|
||||||
m_static_rtree.reset(new TimeStampedRTreePair(
|
m_static_rtree.reset(new TimeStampedRTreePair(
|
||||||
CURRENT_TIMESTAMP,
|
CURRENT_TIMESTAMP,
|
||||||
osrm::make_unique<SharedRTree>(
|
util::make_unique<SharedRTree>(
|
||||||
tree_ptr, data_layout->num_entries[SharedDataLayout::R_SEARCH_TREE],
|
tree_ptr, data_layout->num_entries[SharedDataLayout::R_SEARCH_TREE],
|
||||||
file_index_path, m_coordinate_list)));
|
file_index_path, m_coordinate_list)));
|
||||||
m_geospatial_query.reset(
|
m_geospatial_query.reset(
|
||||||
@ -108,9 +115,9 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
GraphEdge *graph_edges_ptr =
|
GraphEdge *graph_edges_ptr =
|
||||||
data_layout->GetBlockPtr<GraphEdge>(shared_memory, SharedDataLayout::GRAPH_EDGE_LIST);
|
data_layout->GetBlockPtr<GraphEdge>(shared_memory, SharedDataLayout::GRAPH_EDGE_LIST);
|
||||||
|
|
||||||
typename ShM<GraphNode, true>::vector node_list(
|
typename util::ShM<GraphNode, true>::vector node_list(
|
||||||
graph_nodes_ptr, data_layout->num_entries[SharedDataLayout::GRAPH_NODE_LIST]);
|
graph_nodes_ptr, data_layout->num_entries[SharedDataLayout::GRAPH_NODE_LIST]);
|
||||||
typename ShM<GraphEdge, true>::vector edge_list(
|
typename util::ShM<GraphEdge, true>::vector edge_list(
|
||||||
graph_edges_ptr, data_layout->num_entries[SharedDataLayout::GRAPH_EDGE_LIST]);
|
graph_edges_ptr, data_layout->num_entries[SharedDataLayout::GRAPH_EDGE_LIST]);
|
||||||
m_query_graph.reset(new QueryGraph(node_list, edge_list));
|
m_query_graph.reset(new QueryGraph(node_list, edge_list));
|
||||||
}
|
}
|
||||||
@ -118,27 +125,27 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
void LoadNodeAndEdgeInformation()
|
void LoadNodeAndEdgeInformation()
|
||||||
{
|
{
|
||||||
|
|
||||||
FixedPointCoordinate *coordinate_list_ptr = data_layout->GetBlockPtr<FixedPointCoordinate>(
|
util::FixedPointCoordinate *coordinate_list_ptr = data_layout->GetBlockPtr<util::FixedPointCoordinate>(
|
||||||
shared_memory, SharedDataLayout::COORDINATE_LIST);
|
shared_memory, SharedDataLayout::COORDINATE_LIST);
|
||||||
m_coordinate_list = osrm::make_unique<ShM<FixedPointCoordinate, true>::vector>(
|
m_coordinate_list = util::make_unique<util::ShM<util::FixedPointCoordinate, true>::vector>(
|
||||||
coordinate_list_ptr, data_layout->num_entries[SharedDataLayout::COORDINATE_LIST]);
|
coordinate_list_ptr, data_layout->num_entries[SharedDataLayout::COORDINATE_LIST]);
|
||||||
|
|
||||||
TravelMode *travel_mode_list_ptr =
|
extractor::TravelMode *travel_mode_list_ptr =
|
||||||
data_layout->GetBlockPtr<TravelMode>(shared_memory, SharedDataLayout::TRAVEL_MODE);
|
data_layout->GetBlockPtr<extractor::TravelMode>(shared_memory, SharedDataLayout::TRAVEL_MODE);
|
||||||
typename ShM<TravelMode, true>::vector travel_mode_list(
|
typename util::ShM<extractor::TravelMode, true>::vector travel_mode_list(
|
||||||
travel_mode_list_ptr, data_layout->num_entries[SharedDataLayout::TRAVEL_MODE]);
|
travel_mode_list_ptr, data_layout->num_entries[SharedDataLayout::TRAVEL_MODE]);
|
||||||
m_travel_mode_list.swap(travel_mode_list);
|
m_travel_mode_list.swap(travel_mode_list);
|
||||||
|
|
||||||
TurnInstruction *turn_instruction_list_ptr = data_layout->GetBlockPtr<TurnInstruction>(
|
extractor::TurnInstruction *turn_instruction_list_ptr = data_layout->GetBlockPtr<extractor::TurnInstruction>(
|
||||||
shared_memory, SharedDataLayout::TURN_INSTRUCTION);
|
shared_memory, SharedDataLayout::TURN_INSTRUCTION);
|
||||||
typename ShM<TurnInstruction, true>::vector turn_instruction_list(
|
typename util::ShM<extractor::TurnInstruction, true>::vector turn_instruction_list(
|
||||||
turn_instruction_list_ptr,
|
turn_instruction_list_ptr,
|
||||||
data_layout->num_entries[SharedDataLayout::TURN_INSTRUCTION]);
|
data_layout->num_entries[SharedDataLayout::TURN_INSTRUCTION]);
|
||||||
m_turn_instruction_list.swap(turn_instruction_list);
|
m_turn_instruction_list.swap(turn_instruction_list);
|
||||||
|
|
||||||
unsigned *name_id_list_ptr =
|
unsigned *name_id_list_ptr =
|
||||||
data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::NAME_ID_LIST);
|
data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::NAME_ID_LIST);
|
||||||
typename ShM<unsigned, true>::vector name_id_list(
|
typename util::ShM<unsigned, true>::vector name_id_list(
|
||||||
name_id_list_ptr, data_layout->num_entries[SharedDataLayout::NAME_ID_LIST]);
|
name_id_list_ptr, data_layout->num_entries[SharedDataLayout::NAME_ID_LIST]);
|
||||||
m_name_ID_list.swap(name_id_list);
|
m_name_ID_list.swap(name_id_list);
|
||||||
}
|
}
|
||||||
@ -147,7 +154,7 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
{
|
{
|
||||||
NodeID *via_node_list_ptr =
|
NodeID *via_node_list_ptr =
|
||||||
data_layout->GetBlockPtr<NodeID>(shared_memory, SharedDataLayout::VIA_NODE_LIST);
|
data_layout->GetBlockPtr<NodeID>(shared_memory, SharedDataLayout::VIA_NODE_LIST);
|
||||||
typename ShM<NodeID, true>::vector via_node_list(
|
typename util::ShM<NodeID, true>::vector via_node_list(
|
||||||
via_node_list_ptr, data_layout->num_entries[SharedDataLayout::VIA_NODE_LIST]);
|
via_node_list_ptr, data_layout->num_entries[SharedDataLayout::VIA_NODE_LIST]);
|
||||||
m_via_node_list.swap(via_node_list);
|
m_via_node_list.swap(via_node_list);
|
||||||
}
|
}
|
||||||
@ -158,16 +165,16 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::NAME_OFFSETS);
|
data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::NAME_OFFSETS);
|
||||||
NameIndexBlock *blocks_ptr =
|
NameIndexBlock *blocks_ptr =
|
||||||
data_layout->GetBlockPtr<NameIndexBlock>(shared_memory, SharedDataLayout::NAME_BLOCKS);
|
data_layout->GetBlockPtr<NameIndexBlock>(shared_memory, SharedDataLayout::NAME_BLOCKS);
|
||||||
typename ShM<unsigned, true>::vector name_offsets(
|
typename util::ShM<unsigned, true>::vector name_offsets(
|
||||||
offsets_ptr, data_layout->num_entries[SharedDataLayout::NAME_OFFSETS]);
|
offsets_ptr, data_layout->num_entries[SharedDataLayout::NAME_OFFSETS]);
|
||||||
typename ShM<NameIndexBlock, true>::vector name_blocks(
|
typename util::ShM<NameIndexBlock, true>::vector name_blocks(
|
||||||
blocks_ptr, data_layout->num_entries[SharedDataLayout::NAME_BLOCKS]);
|
blocks_ptr, data_layout->num_entries[SharedDataLayout::NAME_BLOCKS]);
|
||||||
|
|
||||||
char *names_list_ptr =
|
char *names_list_ptr =
|
||||||
data_layout->GetBlockPtr<char>(shared_memory, SharedDataLayout::NAME_CHAR_LIST);
|
data_layout->GetBlockPtr<char>(shared_memory, SharedDataLayout::NAME_CHAR_LIST);
|
||||||
typename ShM<char, true>::vector names_char_list(
|
typename util::ShM<char, true>::vector names_char_list(
|
||||||
names_list_ptr, data_layout->num_entries[SharedDataLayout::NAME_CHAR_LIST]);
|
names_list_ptr, data_layout->num_entries[SharedDataLayout::NAME_CHAR_LIST]);
|
||||||
m_name_table = osrm::make_unique<RangeTable<16, true>>(
|
m_name_table = util::make_unique<util::RangeTable<16, true>>(
|
||||||
name_offsets, name_blocks, static_cast<unsigned>(names_char_list.size()));
|
name_offsets, name_blocks, static_cast<unsigned>(names_char_list.size()));
|
||||||
|
|
||||||
m_names_char_list.swap(names_char_list);
|
m_names_char_list.swap(names_char_list);
|
||||||
@ -182,7 +189,7 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
|
|
||||||
unsigned *core_marker_ptr =
|
unsigned *core_marker_ptr =
|
||||||
data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::CORE_MARKER);
|
data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::CORE_MARKER);
|
||||||
typename ShM<bool, true>::vector is_core_node(
|
typename util::ShM<bool, true>::vector is_core_node(
|
||||||
core_marker_ptr, data_layout->num_entries[SharedDataLayout::CORE_MARKER]);
|
core_marker_ptr, data_layout->num_entries[SharedDataLayout::CORE_MARKER]);
|
||||||
m_is_core_node.swap(is_core_node);
|
m_is_core_node.swap(is_core_node);
|
||||||
}
|
}
|
||||||
@ -191,20 +198,20 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
{
|
{
|
||||||
unsigned *geometries_compressed_ptr = data_layout->GetBlockPtr<unsigned>(
|
unsigned *geometries_compressed_ptr = data_layout->GetBlockPtr<unsigned>(
|
||||||
shared_memory, SharedDataLayout::GEOMETRIES_INDICATORS);
|
shared_memory, SharedDataLayout::GEOMETRIES_INDICATORS);
|
||||||
typename ShM<bool, true>::vector edge_is_compressed(
|
typename util::ShM<bool, true>::vector edge_is_compressed(
|
||||||
geometries_compressed_ptr,
|
geometries_compressed_ptr,
|
||||||
data_layout->num_entries[SharedDataLayout::GEOMETRIES_INDICATORS]);
|
data_layout->num_entries[SharedDataLayout::GEOMETRIES_INDICATORS]);
|
||||||
m_edge_is_compressed.swap(edge_is_compressed);
|
m_edge_is_compressed.swap(edge_is_compressed);
|
||||||
|
|
||||||
unsigned *geometries_index_ptr =
|
unsigned *geometries_index_ptr =
|
||||||
data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::GEOMETRIES_INDEX);
|
data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::GEOMETRIES_INDEX);
|
||||||
typename ShM<unsigned, true>::vector geometry_begin_indices(
|
typename util::ShM<unsigned, true>::vector geometry_begin_indices(
|
||||||
geometries_index_ptr, data_layout->num_entries[SharedDataLayout::GEOMETRIES_INDEX]);
|
geometries_index_ptr, data_layout->num_entries[SharedDataLayout::GEOMETRIES_INDEX]);
|
||||||
m_geometry_indices.swap(geometry_begin_indices);
|
m_geometry_indices.swap(geometry_begin_indices);
|
||||||
|
|
||||||
unsigned *geometries_list_ptr =
|
unsigned *geometries_list_ptr =
|
||||||
data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::GEOMETRIES_LIST);
|
data_layout->GetBlockPtr<unsigned>(shared_memory, SharedDataLayout::GEOMETRIES_LIST);
|
||||||
typename ShM<unsigned, true>::vector geometry_list(
|
typename util::ShM<unsigned, true>::vector geometry_list(
|
||||||
geometries_list_ptr, data_layout->num_entries[SharedDataLayout::GEOMETRIES_LIST]);
|
geometries_list_ptr, data_layout->num_entries[SharedDataLayout::GEOMETRIES_LIST]);
|
||||||
m_geometry_list.swap(geometry_list);
|
m_geometry_list.swap(geometry_list);
|
||||||
}
|
}
|
||||||
@ -214,7 +221,7 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
|
|
||||||
SharedDataFacade()
|
SharedDataFacade()
|
||||||
{
|
{
|
||||||
data_timestamp_ptr = (SharedDataTimestamp *)SharedMemoryFactory::Get(
|
data_timestamp_ptr = (SharedDataTimestamp *)datastore::SharedMemoryFactory::Get(
|
||||||
CURRENT_REGIONS, sizeof(SharedDataTimestamp), false, false)
|
CURRENT_REGIONS, sizeof(SharedDataTimestamp), false, false)
|
||||||
->Ptr();
|
->Ptr();
|
||||||
CURRENT_LAYOUT = LAYOUT_NONE;
|
CURRENT_LAYOUT = LAYOUT_NONE;
|
||||||
@ -232,18 +239,18 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
CURRENT_TIMESTAMP != data_timestamp_ptr->timestamp)
|
CURRENT_TIMESTAMP != data_timestamp_ptr->timestamp)
|
||||||
{
|
{
|
||||||
// release the previous shared memory segments
|
// release the previous shared memory segments
|
||||||
SharedMemory::Remove(CURRENT_LAYOUT);
|
datastore::SharedMemory::Remove(CURRENT_LAYOUT);
|
||||||
SharedMemory::Remove(CURRENT_DATA);
|
datastore::SharedMemory::Remove(CURRENT_DATA);
|
||||||
|
|
||||||
CURRENT_LAYOUT = data_timestamp_ptr->layout;
|
CURRENT_LAYOUT = data_timestamp_ptr->layout;
|
||||||
CURRENT_DATA = data_timestamp_ptr->data;
|
CURRENT_DATA = data_timestamp_ptr->data;
|
||||||
CURRENT_TIMESTAMP = data_timestamp_ptr->timestamp;
|
CURRENT_TIMESTAMP = data_timestamp_ptr->timestamp;
|
||||||
|
|
||||||
m_layout_memory.reset(SharedMemoryFactory::Get(CURRENT_LAYOUT));
|
m_layout_memory.reset(datastore::SharedMemoryFactory::Get(CURRENT_LAYOUT));
|
||||||
|
|
||||||
data_layout = (SharedDataLayout *)(m_layout_memory->Ptr());
|
data_layout = (SharedDataLayout *)(m_layout_memory->Ptr());
|
||||||
|
|
||||||
m_large_memory.reset(SharedMemoryFactory::Get(CURRENT_DATA));
|
m_large_memory.reset(datastore::SharedMemoryFactory::Get(CURRENT_DATA));
|
||||||
shared_memory = (char *)(m_large_memory->Ptr());
|
shared_memory = (char *)(m_large_memory->Ptr());
|
||||||
|
|
||||||
const char *file_index_ptr =
|
const char *file_index_ptr =
|
||||||
@ -251,8 +258,8 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
file_index_path = boost::filesystem::path(file_index_ptr);
|
file_index_path = boost::filesystem::path(file_index_ptr);
|
||||||
if (!boost::filesystem::exists(file_index_path))
|
if (!boost::filesystem::exists(file_index_path))
|
||||||
{
|
{
|
||||||
SimpleLogger().Write(logDEBUG) << "Leaf file name " << file_index_path.string();
|
util::SimpleLogger().Write(logDEBUG) << "Leaf file name " << file_index_path.string();
|
||||||
throw osrm::exception("Could not load leaf index file. "
|
throw util::exception("Could not load leaf index file. "
|
||||||
"Is any data loaded into shared memory?");
|
"Is any data loaded into shared memory?");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,12 +274,12 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
|
|
||||||
data_layout->PrintInformation();
|
data_layout->PrintInformation();
|
||||||
|
|
||||||
SimpleLogger().Write() << "number of geometries: " << m_coordinate_list->size();
|
util::SimpleLogger().Write() << "number of geometries: " << m_coordinate_list->size();
|
||||||
for (unsigned i = 0; i < m_coordinate_list->size(); ++i)
|
for (unsigned i = 0; i < m_coordinate_list->size(); ++i)
|
||||||
{
|
{
|
||||||
if (!GetCoordinateOfNode(i).IsValid())
|
if (!GetCoordinateOfNode(i).IsValid())
|
||||||
{
|
{
|
||||||
SimpleLogger().Write() << "coordinate " << i << " not valid";
|
util::SimpleLogger().Write() << "coordinate " << i << " not valid";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +329,7 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
}
|
}
|
||||||
|
|
||||||
// node and edge information access
|
// node and edge information access
|
||||||
FixedPointCoordinate GetCoordinateOfNode(const NodeID id) const override final
|
util::FixedPointCoordinate GetCoordinateOfNode(const NodeID id) const override final
|
||||||
{
|
{
|
||||||
return m_coordinate_list->at(id);
|
return m_coordinate_list->at(id);
|
||||||
};
|
};
|
||||||
@ -348,18 +355,18 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
return m_via_node_list.at(id);
|
return m_via_node_list.at(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
TurnInstruction GetTurnInstructionForEdgeID(const unsigned id) const override final
|
extractor::TurnInstruction GetTurnInstructionForEdgeID(const unsigned id) const override final
|
||||||
{
|
{
|
||||||
return m_turn_instruction_list.at(id);
|
return m_turn_instruction_list.at(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
TravelMode GetTravelModeForEdgeID(const unsigned id) const override final
|
extractor::TravelMode GetTravelModeForEdgeID(const unsigned id) const override final
|
||||||
{
|
{
|
||||||
return m_travel_mode_list.at(id);
|
return m_travel_mode_list.at(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<PhantomNodeWithDistance>
|
std::vector<PhantomNodeWithDistance>
|
||||||
NearestPhantomNodesInRange(const FixedPointCoordinate &input_coordinate,
|
NearestPhantomNodesInRange(const util::FixedPointCoordinate &input_coordinate,
|
||||||
const float max_distance,
|
const float max_distance,
|
||||||
const int bearing = 0,
|
const int bearing = 0,
|
||||||
const int bearing_range = 180) override final
|
const int bearing_range = 180) override final
|
||||||
@ -375,7 +382,7 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<PhantomNodeWithDistance>
|
std::vector<PhantomNodeWithDistance>
|
||||||
NearestPhantomNodes(const FixedPointCoordinate &input_coordinate,
|
NearestPhantomNodes(const util::FixedPointCoordinate &input_coordinate,
|
||||||
const unsigned max_results,
|
const unsigned max_results,
|
||||||
const int bearing = 0,
|
const int bearing = 0,
|
||||||
const int bearing_range = 180) override final
|
const int bearing_range = 180) override final
|
||||||
@ -391,7 +398,7 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::pair<PhantomNode, PhantomNode>
|
std::pair<PhantomNode, PhantomNode>
|
||||||
NearestPhantomNodeWithAlternativeFromBigComponent(const FixedPointCoordinate &input_coordinate,
|
NearestPhantomNodeWithAlternativeFromBigComponent(const util::FixedPointCoordinate &input_coordinate,
|
||||||
const int bearing = 0,
|
const int bearing = 0,
|
||||||
const int bearing_range = 180) override final
|
const int bearing_range = 180) override final
|
||||||
{
|
{
|
||||||
@ -446,4 +453,8 @@ template <class EdgeDataT> class SharedDataFacade final : public BaseDataFacade<
|
|||||||
std::string GetTimestamp() const override final { return m_timestamp; }
|
std::string GetTimestamp() const override final { return m_timestamp; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // SHARED_DATAFACADE_HPP
|
#endif // SHARED_DATAFACADE_HPP
|
||||||
|
@ -8,6 +8,13 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace datafacade
|
||||||
|
{
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
// Added at the start and end of each block as sanity check
|
// Added at the start and end of each block as sanity check
|
||||||
@ -46,41 +53,41 @@ struct SharedDataLayout
|
|||||||
|
|
||||||
void PrintInformation() const
|
void PrintInformation() const
|
||||||
{
|
{
|
||||||
SimpleLogger().Write(logDEBUG) << "NAME_OFFSETS "
|
util::SimpleLogger().Write(logDEBUG) << "NAME_OFFSETS "
|
||||||
<< ": " << GetBlockSize(NAME_OFFSETS);
|
<< ": " << GetBlockSize(NAME_OFFSETS);
|
||||||
SimpleLogger().Write(logDEBUG) << "NAME_BLOCKS "
|
util::SimpleLogger().Write(logDEBUG) << "NAME_BLOCKS "
|
||||||
<< ": " << GetBlockSize(NAME_BLOCKS);
|
<< ": " << GetBlockSize(NAME_BLOCKS);
|
||||||
SimpleLogger().Write(logDEBUG) << "NAME_CHAR_LIST "
|
util::SimpleLogger().Write(logDEBUG) << "NAME_CHAR_LIST "
|
||||||
<< ": " << GetBlockSize(NAME_CHAR_LIST);
|
<< ": " << GetBlockSize(NAME_CHAR_LIST);
|
||||||
SimpleLogger().Write(logDEBUG) << "NAME_ID_LIST "
|
util::SimpleLogger().Write(logDEBUG) << "NAME_ID_LIST "
|
||||||
<< ": " << GetBlockSize(NAME_ID_LIST);
|
<< ": " << GetBlockSize(NAME_ID_LIST);
|
||||||
SimpleLogger().Write(logDEBUG) << "VIA_NODE_LIST "
|
util::SimpleLogger().Write(logDEBUG) << "VIA_NODE_LIST "
|
||||||
<< ": " << GetBlockSize(VIA_NODE_LIST);
|
<< ": " << GetBlockSize(VIA_NODE_LIST);
|
||||||
SimpleLogger().Write(logDEBUG) << "GRAPH_NODE_LIST "
|
util::SimpleLogger().Write(logDEBUG) << "GRAPH_NODE_LIST "
|
||||||
<< ": " << GetBlockSize(GRAPH_NODE_LIST);
|
<< ": " << GetBlockSize(GRAPH_NODE_LIST);
|
||||||
SimpleLogger().Write(logDEBUG) << "GRAPH_EDGE_LIST "
|
util::SimpleLogger().Write(logDEBUG) << "GRAPH_EDGE_LIST "
|
||||||
<< ": " << GetBlockSize(GRAPH_EDGE_LIST);
|
<< ": " << GetBlockSize(GRAPH_EDGE_LIST);
|
||||||
SimpleLogger().Write(logDEBUG) << "COORDINATE_LIST "
|
util::SimpleLogger().Write(logDEBUG) << "COORDINATE_LIST "
|
||||||
<< ": " << GetBlockSize(COORDINATE_LIST);
|
<< ": " << GetBlockSize(COORDINATE_LIST);
|
||||||
SimpleLogger().Write(logDEBUG) << "TURN_INSTRUCTION "
|
util::SimpleLogger().Write(logDEBUG) << "TURN_INSTRUCTION "
|
||||||
<< ": " << GetBlockSize(TURN_INSTRUCTION);
|
<< ": " << GetBlockSize(TURN_INSTRUCTION);
|
||||||
SimpleLogger().Write(logDEBUG) << "TRAVEL_MODE "
|
util::SimpleLogger().Write(logDEBUG) << "TRAVEL_MODE "
|
||||||
<< ": " << GetBlockSize(TRAVEL_MODE);
|
<< ": " << GetBlockSize(TRAVEL_MODE);
|
||||||
SimpleLogger().Write(logDEBUG) << "R_SEARCH_TREE "
|
util::SimpleLogger().Write(logDEBUG) << "R_SEARCH_TREE "
|
||||||
<< ": " << GetBlockSize(R_SEARCH_TREE);
|
<< ": " << GetBlockSize(R_SEARCH_TREE);
|
||||||
SimpleLogger().Write(logDEBUG) << "GEOMETRIES_INDEX "
|
util::SimpleLogger().Write(logDEBUG) << "GEOMETRIES_INDEX "
|
||||||
<< ": " << GetBlockSize(GEOMETRIES_INDEX);
|
<< ": " << GetBlockSize(GEOMETRIES_INDEX);
|
||||||
SimpleLogger().Write(logDEBUG) << "GEOMETRIES_LIST "
|
util::SimpleLogger().Write(logDEBUG) << "GEOMETRIES_LIST "
|
||||||
<< ": " << GetBlockSize(GEOMETRIES_LIST);
|
<< ": " << GetBlockSize(GEOMETRIES_LIST);
|
||||||
SimpleLogger().Write(logDEBUG) << "GEOMETRIES_INDICATORS"
|
util::SimpleLogger().Write(logDEBUG) << "GEOMETRIES_INDICATORS"
|
||||||
<< ": " << GetBlockSize(GEOMETRIES_INDICATORS);
|
<< ": " << GetBlockSize(GEOMETRIES_INDICATORS);
|
||||||
SimpleLogger().Write(logDEBUG) << "HSGR_CHECKSUM "
|
util::SimpleLogger().Write(logDEBUG) << "HSGR_CHECKSUM "
|
||||||
<< ": " << GetBlockSize(HSGR_CHECKSUM);
|
<< ": " << GetBlockSize(HSGR_CHECKSUM);
|
||||||
SimpleLogger().Write(logDEBUG) << "TIMESTAMP "
|
util::SimpleLogger().Write(logDEBUG) << "TIMESTAMP "
|
||||||
<< ": " << GetBlockSize(TIMESTAMP);
|
<< ": " << GetBlockSize(TIMESTAMP);
|
||||||
SimpleLogger().Write(logDEBUG) << "FILE_INDEX_PATH "
|
util::SimpleLogger().Write(logDEBUG) << "FILE_INDEX_PATH "
|
||||||
<< ": " << GetBlockSize(FILE_INDEX_PATH);
|
<< ": " << GetBlockSize(FILE_INDEX_PATH);
|
||||||
SimpleLogger().Write(logDEBUG) << "CORE_MARKER "
|
util::SimpleLogger().Write(logDEBUG) << "CORE_MARKER "
|
||||||
<< ": " << GetBlockSize(CORE_MARKER);
|
<< ": " << GetBlockSize(CORE_MARKER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,11 +142,11 @@ struct SharedDataLayout
|
|||||||
bool end_canary_alive = std::equal(CANARY, CANARY + sizeof(CANARY), end_canary_ptr);
|
bool end_canary_alive = std::equal(CANARY, CANARY + sizeof(CANARY), end_canary_ptr);
|
||||||
if (!start_canary_alive)
|
if (!start_canary_alive)
|
||||||
{
|
{
|
||||||
throw osrm::exception("Start canary of block corrupted.");
|
throw util::exception("Start canary of block corrupted.");
|
||||||
}
|
}
|
||||||
if (!end_canary_alive)
|
if (!end_canary_alive)
|
||||||
{
|
{
|
||||||
throw osrm::exception("End canary of block corrupted.");
|
throw util::exception("End canary of block corrupted.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,4 +172,8 @@ struct SharedDataTimestamp
|
|||||||
unsigned timestamp;
|
unsigned timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* SHARED_DATA_TYPE_HPP */
|
#endif /* SHARED_DATA_TYPE_HPP */
|
||||||
|
@ -8,6 +8,11 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
|
||||||
/* This class object computes the bitvector of indicating generalized input
|
/* This class object computes the bitvector of indicating generalized input
|
||||||
* points according to the (Ramer-)Douglas-Peucker algorithm.
|
* points according to the (Ramer-)Douglas-Peucker algorithm.
|
||||||
*
|
*
|
||||||
@ -51,4 +56,7 @@ class DouglasPeucker
|
|||||||
void Run(std::vector<SegmentInformation> &input_geometry, const unsigned zoom_level);
|
void Run(std::vector<SegmentInformation> &input_geometry, const unsigned zoom_level);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* DOUGLAS_PEUCKER_HPP_ */
|
#endif /* DOUGLAS_PEUCKER_HPP_ */
|
||||||
|
@ -13,6 +13,11 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
|
||||||
// Implements complex queries on top of an RTree and builds PhantomNodes from it.
|
// Implements complex queries on top of an RTree and builds PhantomNodes from it.
|
||||||
//
|
//
|
||||||
// Only holds a weak reference on the RTree!
|
// Only holds a weak reference on the RTree!
|
||||||
@ -30,7 +35,7 @@ template <typename RTreeT> class GeospatialQuery
|
|||||||
// Returns nearest PhantomNodes in the given bearing range within max_distance.
|
// Returns nearest PhantomNodes in the given bearing range within max_distance.
|
||||||
// Does not filter by small/big component!
|
// Does not filter by small/big component!
|
||||||
std::vector<PhantomNodeWithDistance>
|
std::vector<PhantomNodeWithDistance>
|
||||||
NearestPhantomNodesInRange(const FixedPointCoordinate &input_coordinate,
|
NearestPhantomNodesInRange(const util::FixedPointCoordinate &input_coordinate,
|
||||||
const double max_distance,
|
const double max_distance,
|
||||||
const int bearing = 0,
|
const int bearing = 0,
|
||||||
const int bearing_range = 180)
|
const int bearing_range = 180)
|
||||||
@ -52,7 +57,7 @@ template <typename RTreeT> class GeospatialQuery
|
|||||||
// Returns max_results nearest PhantomNodes in the given bearing range.
|
// Returns max_results nearest PhantomNodes in the given bearing range.
|
||||||
// Does not filter by small/big component!
|
// Does not filter by small/big component!
|
||||||
std::vector<PhantomNodeWithDistance>
|
std::vector<PhantomNodeWithDistance>
|
||||||
NearestPhantomNodes(const FixedPointCoordinate &input_coordinate,
|
NearestPhantomNodes(const util::FixedPointCoordinate &input_coordinate,
|
||||||
const unsigned max_results,
|
const unsigned max_results,
|
||||||
const int bearing = 0,
|
const int bearing = 0,
|
||||||
const int bearing_range = 180)
|
const int bearing_range = 180)
|
||||||
@ -73,7 +78,7 @@ template <typename RTreeT> class GeospatialQuery
|
|||||||
// Returns the nearest phantom node. If this phantom node is not from a big component
|
// Returns the nearest phantom node. If this phantom node is not from a big component
|
||||||
// a second phantom node is return that is the nearest coordinate in a big component.
|
// a second phantom node is return that is the nearest coordinate in a big component.
|
||||||
std::pair<PhantomNode, PhantomNode>
|
std::pair<PhantomNode, PhantomNode>
|
||||||
NearestPhantomNodeWithAlternativeFromBigComponent(const FixedPointCoordinate &input_coordinate,
|
NearestPhantomNodeWithAlternativeFromBigComponent(const util::FixedPointCoordinate &input_coordinate,
|
||||||
const int bearing = 0,
|
const int bearing = 0,
|
||||||
const int bearing_range = 180)
|
const int bearing_range = 180)
|
||||||
{
|
{
|
||||||
@ -117,7 +122,7 @@ template <typename RTreeT> class GeospatialQuery
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<PhantomNodeWithDistance>
|
std::vector<PhantomNodeWithDistance>
|
||||||
MakePhantomNodes(const FixedPointCoordinate &input_coordinate,
|
MakePhantomNodes(const util::FixedPointCoordinate &input_coordinate,
|
||||||
const std::vector<EdgeData> &results) const
|
const std::vector<EdgeData> &results) const
|
||||||
{
|
{
|
||||||
std::vector<PhantomNodeWithDistance> distance_and_phantoms(results.size());
|
std::vector<PhantomNodeWithDistance> distance_and_phantoms(results.size());
|
||||||
@ -129,12 +134,12 @@ template <typename RTreeT> class GeospatialQuery
|
|||||||
return distance_and_phantoms;
|
return distance_and_phantoms;
|
||||||
}
|
}
|
||||||
|
|
||||||
PhantomNodeWithDistance MakePhantomNode(const FixedPointCoordinate &input_coordinate,
|
PhantomNodeWithDistance MakePhantomNode(const util::FixedPointCoordinate &input_coordinate,
|
||||||
const EdgeData &data) const
|
const EdgeData &data) const
|
||||||
{
|
{
|
||||||
FixedPointCoordinate point_on_segment;
|
util::FixedPointCoordinate point_on_segment;
|
||||||
double ratio;
|
double ratio;
|
||||||
const auto current_perpendicular_distance = coordinate_calculation::perpendicularDistance(
|
const auto current_perpendicular_distance = util::coordinate_calculation::perpendicularDistance(
|
||||||
coordinates->at(data.u), coordinates->at(data.v), input_coordinate, point_on_segment,
|
coordinates->at(data.u), coordinates->at(data.v), input_coordinate, point_on_segment,
|
||||||
ratio);
|
ratio);
|
||||||
|
|
||||||
@ -159,18 +164,18 @@ template <typename RTreeT> class GeospatialQuery
|
|||||||
const int filter_bearing_range)
|
const int filter_bearing_range)
|
||||||
{
|
{
|
||||||
const double forward_edge_bearing =
|
const double forward_edge_bearing =
|
||||||
coordinate_calculation::bearing(coordinates->at(segment.u), coordinates->at(segment.v));
|
util::coordinate_calculation::bearing(coordinates->at(segment.u), coordinates->at(segment.v));
|
||||||
|
|
||||||
const double backward_edge_bearing = (forward_edge_bearing + 180) > 360
|
const double backward_edge_bearing = (forward_edge_bearing + 180) > 360
|
||||||
? (forward_edge_bearing - 180)
|
? (forward_edge_bearing - 180)
|
||||||
: (forward_edge_bearing + 180);
|
: (forward_edge_bearing + 180);
|
||||||
|
|
||||||
const bool forward_bearing_valid =
|
const bool forward_bearing_valid =
|
||||||
bearing::CheckInBounds(std::round(forward_edge_bearing), filter_bearing,
|
util::bearing::CheckInBounds(std::round(forward_edge_bearing), filter_bearing,
|
||||||
filter_bearing_range) &&
|
filter_bearing_range) &&
|
||||||
segment.forward_edge_based_node_id != SPECIAL_NODEID;
|
segment.forward_edge_based_node_id != SPECIAL_NODEID;
|
||||||
const bool backward_bearing_valid =
|
const bool backward_bearing_valid =
|
||||||
bearing::CheckInBounds(std::round(backward_edge_bearing), filter_bearing,
|
util::bearing::CheckInBounds(std::round(backward_edge_bearing), filter_bearing,
|
||||||
filter_bearing_range) &&
|
filter_bearing_range) &&
|
||||||
segment.reverse_edge_based_node_id != SPECIAL_NODEID;
|
segment.reverse_edge_based_node_id != SPECIAL_NODEID;
|
||||||
return std::make_pair(forward_bearing_valid, backward_bearing_valid);
|
return std::make_pair(forward_bearing_valid, backward_bearing_valid);
|
||||||
@ -180,4 +185,7 @@ template <typename RTreeT> class GeospatialQuery
|
|||||||
const std::shared_ptr<CoordinateList> coordinates;
|
const std::shared_ptr<CoordinateList> coordinates;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "engine/segment_information.hpp"
|
#include "engine/segment_information.hpp"
|
||||||
#include "util/integer_range.hpp"
|
#include "util/integer_range.hpp"
|
||||||
#include "util/coordinate_calculation.hpp"
|
#include "util/coordinate_calculation.hpp"
|
||||||
|
#include "util/container.hpp"
|
||||||
#include "extractor/turn_instructions.hpp"
|
#include "extractor/turn_instructions.hpp"
|
||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
@ -124,7 +125,7 @@ void SegmentList<DataFacadeT>::InitRoute(const PhantomNode &node, const bool tra
|
|||||||
const auto travel_mode =
|
const auto travel_mode =
|
||||||
(traversed_in_reverse ? node.backward_travel_mode : node.forward_travel_mode);
|
(traversed_in_reverse ? node.backward_travel_mode : node.forward_travel_mode);
|
||||||
|
|
||||||
AppendSegment(node.location, PathData(0, node.name_id, TurnInstruction::HeadOn,
|
AppendSegment(node.location, PathData(0, node.name_id, extractor::TurnInstruction::HeadOn,
|
||||||
segment_duration, travel_mode));
|
segment_duration, travel_mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,10 +143,10 @@ void SegmentList<DataFacadeT>::AddLeg(const std::vector<PathData> &leg_data,
|
|||||||
|
|
||||||
const EdgeWeight segment_duration =
|
const EdgeWeight segment_duration =
|
||||||
(traversed_in_reverse ? target_node.reverse_weight : target_node.forward_weight);
|
(traversed_in_reverse ? target_node.reverse_weight : target_node.forward_weight);
|
||||||
const TravelMode travel_mode =
|
const extractor::TravelMode travel_mode =
|
||||||
(traversed_in_reverse ? target_node.backward_travel_mode : target_node.forward_travel_mode);
|
(traversed_in_reverse ? target_node.backward_travel_mode : target_node.forward_travel_mode);
|
||||||
segments.emplace_back(target_node.location, target_node.name_id, segment_duration, 0.f,
|
segments.emplace_back(target_node.location, target_node.name_id, segment_duration, 0.f,
|
||||||
is_via_leg ? TurnInstruction::ReachViaLocation : TurnInstruction::NoTurn,
|
is_via_leg ? extractor::TurnInstruction::ReachViaLocation : extractor::TurnInstruction::NoTurn,
|
||||||
true, true, travel_mode);
|
true, true, travel_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -187,12 +188,12 @@ void SegmentList<DataFacadeT>::AppendSegment(const FixedPointCoordinate &coordin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make sure mode changes are announced, even when there otherwise is no turn
|
// make sure mode changes are announced, even when there otherwise is no turn
|
||||||
const auto getTurn = [](const PathData &path_point, const TravelMode previous_mode)
|
const auto getTurn = [](const PathData &path_point, const extractor::TravelMode previous_mode)
|
||||||
{
|
{
|
||||||
if (TurnInstruction::NoTurn == path_point.turn_instruction and
|
if (extractor::TurnInstruction::NoTurn == path_point.turn_instruction and
|
||||||
previous_mode != path_point.travel_mode and path_point.segment_duration > 0)
|
previous_mode != path_point.travel_mode and path_point.segment_duration > 0)
|
||||||
{
|
{
|
||||||
return TurnInstruction::GoStraight;
|
return extractor::TurnInstruction::GoStraight;
|
||||||
}
|
}
|
||||||
return path_point.turn_instruction;
|
return path_point.turn_instruction;
|
||||||
};
|
};
|
||||||
@ -215,11 +216,11 @@ void SegmentList<DataFacadeT>::Finalize(const bool extract_alternative,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
segments[0].length = 0.f;
|
segments[0].length = 0.f;
|
||||||
for (const auto i : osrm::irange<std::size_t>(1, segments.size()))
|
for (const auto i : util::irange<std::size_t>(1, segments.size()))
|
||||||
{
|
{
|
||||||
// move down names by one, q&d hack
|
// move down names by one, q&d hack
|
||||||
segments[i - 1].name_id = segments[i].name_id;
|
segments[i - 1].name_id = segments[i].name_id;
|
||||||
segments[i].length = coordinate_calculation::greatCircleDistance(segments[i - 1].location,
|
segments[i].length = util::coordinate_calculation::greatCircleDistance(segments[i - 1].location,
|
||||||
segments[i].location);
|
segments[i].location);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,7 +230,7 @@ void SegmentList<DataFacadeT>::Finalize(const bool extract_alternative,
|
|||||||
|
|
||||||
double path_length = 0;
|
double path_length = 0;
|
||||||
|
|
||||||
for (const auto i : osrm::irange<std::size_t>(1, segments.size()))
|
for (const auto i : util::irange<std::size_t>(1, segments.size()))
|
||||||
{
|
{
|
||||||
path_length += segments[i].length;
|
path_length += segments[i].length;
|
||||||
segment_length += segments[i].length;
|
segment_length += segments[i].length;
|
||||||
@ -237,7 +238,7 @@ void SegmentList<DataFacadeT>::Finalize(const bool extract_alternative,
|
|||||||
segments[segment_start_index].length = segment_length;
|
segments[segment_start_index].length = segment_length;
|
||||||
segments[segment_start_index].duration = segment_duration;
|
segments[segment_start_index].duration = segment_duration;
|
||||||
|
|
||||||
if (TurnInstruction::NoTurn != segments[i].turn_instruction)
|
if (extractor::TurnInstruction::NoTurn != segments[i].turn_instruction)
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(segments[i].necessary);
|
BOOST_ASSERT(segments[i].necessary);
|
||||||
segment_length = 0;
|
segment_length = 0;
|
||||||
@ -257,14 +258,14 @@ void SegmentList<DataFacadeT>::Finalize(const bool extract_alternative,
|
|||||||
{
|
{
|
||||||
segments.pop_back();
|
segments.pop_back();
|
||||||
segments.back().necessary = true;
|
segments.back().necessary = true;
|
||||||
segments.back().turn_instruction = TurnInstruction::NoTurn;
|
segments.back().turn_instruction = extractor::TurnInstruction::NoTurn;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (segments.size() > 2 && std::numeric_limits<float>::epsilon() > segments.front().length &&
|
if (segments.size() > 2 && std::numeric_limits<float>::epsilon() > segments.front().length &&
|
||||||
!(segments.begin() + 1)->is_via_location)
|
!(segments.begin() + 1)->is_via_location)
|
||||||
{
|
{
|
||||||
segments.erase(segments.begin());
|
segments.erase(segments.begin());
|
||||||
segments.front().turn_instruction = TurnInstruction::HeadOn;
|
segments.front().turn_instruction = extractor::TurnInstruction::HeadOn;
|
||||||
segments.front().necessary = true;
|
segments.front().necessary = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,9 +288,9 @@ void SegmentList<DataFacadeT>::Finalize(const bool extract_alternative,
|
|||||||
via_indices.push_back(necessary_segments);
|
via_indices.push_back(necessary_segments);
|
||||||
|
|
||||||
const double post_turn_bearing =
|
const double post_turn_bearing =
|
||||||
coordinate_calculation::bearing(first.location, second.location);
|
util::coordinate_calculation::bearing(first.location, second.location);
|
||||||
const double pre_turn_bearing =
|
const double pre_turn_bearing =
|
||||||
coordinate_calculation::bearing(second.location, first.location);
|
util::coordinate_calculation::bearing(second.location, first.location);
|
||||||
first.post_turn_bearing = static_cast<short>(post_turn_bearing * 10);
|
first.post_turn_bearing = static_cast<short>(post_turn_bearing * 10);
|
||||||
first.pre_turn_bearing = static_cast<short>(pre_turn_bearing * 10);
|
first.pre_turn_bearing = static_cast<short>(pre_turn_bearing * 10);
|
||||||
|
|
||||||
@ -297,7 +298,7 @@ void SegmentList<DataFacadeT>::Finalize(const bool extract_alternative,
|
|||||||
};
|
};
|
||||||
|
|
||||||
// calculate which segments are necessary and update segments for bearings
|
// calculate which segments are necessary and update segments for bearings
|
||||||
osrm::for_each_pair(segments, markNecessarySegments);
|
util::for_each_pair(segments, markNecessarySegments);
|
||||||
via_indices.push_back(necessary_segments);
|
via_indices.push_back(necessary_segments);
|
||||||
|
|
||||||
BOOST_ASSERT(via_indices.size() >= 2);
|
BOOST_ASSERT(via_indices.size() >= 2);
|
||||||
|
@ -22,10 +22,10 @@ namespace engine
|
|||||||
namespace guidance
|
namespace guidance
|
||||||
{
|
{
|
||||||
template< typename DataFacadeT >
|
template< typename DataFacadeT >
|
||||||
inline osrm::json::Array
|
inline util::json::Array
|
||||||
AnnotateRoute(const std::vector<SegmentInformation> &route_segments, DataFacadeT* facade)
|
AnnotateRoute(const std::vector<SegmentInformation> &route_segments, DataFacadeT* facade)
|
||||||
{
|
{
|
||||||
osrm::json::Array json_instruction_array;
|
util::json::Array json_instruction_array;
|
||||||
if( route_segments.empty() )
|
if( route_segments.empty() )
|
||||||
return json_instruction_array;
|
return json_instruction_array;
|
||||||
// Segment information has following format:
|
// Segment information has following format:
|
||||||
@ -45,11 +45,11 @@ AnnotateRoute(const std::vector<SegmentInformation> &route_segments, DataFacadeT
|
|||||||
//Generate annotations for every segment
|
//Generate annotations for every segment
|
||||||
for (const SegmentInformation &segment : route_segments)
|
for (const SegmentInformation &segment : route_segments)
|
||||||
{
|
{
|
||||||
osrm::json::Array json_instruction_row;
|
util::json::Array json_instruction_row;
|
||||||
TurnInstruction current_instruction = segment.turn_instruction;
|
extractor::TurnInstruction current_instruction = segment.turn_instruction;
|
||||||
if (TurnInstructionsClass::TurnIsNecessary(current_instruction))
|
if (extractor::TurnInstructionsClass::TurnIsNecessary(current_instruction))
|
||||||
{
|
{
|
||||||
if (TurnInstruction::EnterRoundAbout == current_instruction)
|
if (extractor::TurnInstruction::EnterRoundAbout == current_instruction)
|
||||||
{
|
{
|
||||||
round_about.name_id = segment.name_id;
|
round_about.name_id = segment.name_id;
|
||||||
round_about.start_index = necessary_segments_running_index;
|
round_about.start_index = necessary_segments_running_index;
|
||||||
@ -57,10 +57,10 @@ AnnotateRoute(const std::vector<SegmentInformation> &route_segments, DataFacadeT
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::string current_turn_instruction;
|
std::string current_turn_instruction;
|
||||||
if (TurnInstruction::LeaveRoundAbout == current_instruction)
|
if (extractor::TurnInstruction::LeaveRoundAbout == current_instruction)
|
||||||
{
|
{
|
||||||
temp_instruction =
|
temp_instruction =
|
||||||
std::to_string(cast::enum_to_underlying(TurnInstruction::EnterRoundAbout));
|
std::to_string(util::cast::enum_to_underlying(extractor::TurnInstruction::EnterRoundAbout));
|
||||||
current_turn_instruction += temp_instruction;
|
current_turn_instruction += temp_instruction;
|
||||||
current_turn_instruction += "-";
|
current_turn_instruction += "-";
|
||||||
temp_instruction = std::to_string(round_about.leave_at_exit + 1);
|
temp_instruction = std::to_string(round_about.leave_at_exit + 1);
|
||||||
@ -70,7 +70,7 @@ AnnotateRoute(const std::vector<SegmentInformation> &route_segments, DataFacadeT
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
temp_instruction =
|
temp_instruction =
|
||||||
std::to_string(cast::enum_to_underlying(current_instruction));
|
std::to_string(util::cast::enum_to_underlying(current_instruction));
|
||||||
current_turn_instruction += temp_instruction;
|
current_turn_instruction += temp_instruction;
|
||||||
}
|
}
|
||||||
json_instruction_row.values.emplace_back(std::move(current_turn_instruction));
|
json_instruction_row.values.emplace_back(std::move(current_turn_instruction));
|
||||||
@ -84,7 +84,7 @@ AnnotateRoute(const std::vector<SegmentInformation> &route_segments, DataFacadeT
|
|||||||
|
|
||||||
// post turn bearing
|
// post turn bearing
|
||||||
const double post_turn_bearing_value = (segment.post_turn_bearing / 10.);
|
const double post_turn_bearing_value = (segment.post_turn_bearing / 10.);
|
||||||
json_instruction_row.values.push_back(bearing::get(post_turn_bearing_value));
|
json_instruction_row.values.push_back(util::bearing::get(post_turn_bearing_value));
|
||||||
json_instruction_row.values.push_back(
|
json_instruction_row.values.push_back(
|
||||||
static_cast<std::uint32_t>(std::round(post_turn_bearing_value)));
|
static_cast<std::uint32_t>(std::round(post_turn_bearing_value)));
|
||||||
|
|
||||||
@ -92,14 +92,14 @@ AnnotateRoute(const std::vector<SegmentInformation> &route_segments, DataFacadeT
|
|||||||
|
|
||||||
// pre turn bearing
|
// pre turn bearing
|
||||||
const double pre_turn_bearing_value = (segment.pre_turn_bearing / 10.);
|
const double pre_turn_bearing_value = (segment.pre_turn_bearing / 10.);
|
||||||
json_instruction_row.values.push_back(bearing::get(pre_turn_bearing_value));
|
json_instruction_row.values.push_back(util::bearing::get(pre_turn_bearing_value));
|
||||||
json_instruction_row.values.push_back(
|
json_instruction_row.values.push_back(
|
||||||
static_cast<std::uint32_t>(std::round(pre_turn_bearing_value)));
|
static_cast<std::uint32_t>(std::round(pre_turn_bearing_value)));
|
||||||
|
|
||||||
json_instruction_array.values.push_back(json_instruction_row);
|
json_instruction_array.values.push_back(json_instruction_row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (TurnInstruction::StayOnRoundAbout == current_instruction)
|
else if (extractor::TurnInstruction::StayOnRoundAbout == current_instruction)
|
||||||
{
|
{
|
||||||
++round_about.leave_at_exit;
|
++round_about.leave_at_exit;
|
||||||
}
|
}
|
||||||
@ -109,18 +109,18 @@ AnnotateRoute(const std::vector<SegmentInformation> &route_segments, DataFacadeT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
osrm::json::Array json_last_instruction_row;
|
util::json::Array json_last_instruction_row;
|
||||||
temp_instruction =
|
temp_instruction =
|
||||||
std::to_string(cast::enum_to_underlying(TurnInstruction::ReachedYourDestination));
|
std::to_string(util::cast::enum_to_underlying(extractor::TurnInstruction::ReachedYourDestination));
|
||||||
json_last_instruction_row.values.emplace_back( std::move(temp_instruction));
|
json_last_instruction_row.values.emplace_back( std::move(temp_instruction));
|
||||||
json_last_instruction_row.values.push_back("");
|
json_last_instruction_row.values.push_back("");
|
||||||
json_last_instruction_row.values.push_back(0);
|
json_last_instruction_row.values.push_back(0);
|
||||||
json_last_instruction_row.values.push_back(necessary_segments_running_index - 1);
|
json_last_instruction_row.values.push_back(necessary_segments_running_index - 1);
|
||||||
json_last_instruction_row.values.push_back(0);
|
json_last_instruction_row.values.push_back(0);
|
||||||
json_last_instruction_row.values.push_back("0m");
|
json_last_instruction_row.values.push_back("0m");
|
||||||
json_last_instruction_row.values.push_back(bearing::get(0.0));
|
json_last_instruction_row.values.push_back(util::bearing::get(0.0));
|
||||||
json_last_instruction_row.values.push_back(0.);
|
json_last_instruction_row.values.push_back(0.);
|
||||||
json_last_instruction_row.values.push_back(bearing::get(0.0));
|
json_last_instruction_row.values.push_back(util::bearing::get(0.0));
|
||||||
json_last_instruction_row.values.push_back(0.);
|
json_last_instruction_row.values.push_back(0.);
|
||||||
json_instruction_array.values.emplace_back(std::move(json_last_instruction_row));
|
json_instruction_array.values.emplace_back(std::move(json_last_instruction_row));
|
||||||
|
|
||||||
|
@ -10,19 +10,24 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
|
||||||
struct PathData
|
struct PathData
|
||||||
{
|
{
|
||||||
PathData()
|
PathData()
|
||||||
: node(SPECIAL_NODEID), name_id(INVALID_EDGE_WEIGHT), segment_duration(INVALID_EDGE_WEIGHT),
|
: node(SPECIAL_NODEID), name_id(INVALID_EDGE_WEIGHT), segment_duration(INVALID_EDGE_WEIGHT),
|
||||||
turn_instruction(TurnInstruction::NoTurn), travel_mode(TRAVEL_MODE_INACCESSIBLE)
|
turn_instruction(extractor::TurnInstruction::NoTurn), travel_mode(TRAVEL_MODE_INACCESSIBLE)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PathData(NodeID node,
|
PathData(NodeID node,
|
||||||
unsigned name_id,
|
unsigned name_id,
|
||||||
TurnInstruction turn_instruction,
|
extractor::TurnInstruction turn_instruction,
|
||||||
EdgeWeight segment_duration,
|
EdgeWeight segment_duration,
|
||||||
TravelMode travel_mode)
|
extractor::TravelMode travel_mode)
|
||||||
: node(node), name_id(name_id), segment_duration(segment_duration),
|
: node(node), name_id(name_id), segment_duration(segment_duration),
|
||||||
turn_instruction(turn_instruction), travel_mode(travel_mode)
|
turn_instruction(turn_instruction), travel_mode(travel_mode)
|
||||||
{
|
{
|
||||||
@ -30,8 +35,8 @@ struct PathData
|
|||||||
NodeID node;
|
NodeID node;
|
||||||
unsigned name_id;
|
unsigned name_id;
|
||||||
EdgeWeight segment_duration;
|
EdgeWeight segment_duration;
|
||||||
TurnInstruction turn_instruction;
|
extractor::TurnInstruction turn_instruction;
|
||||||
TravelMode travel_mode : 4;
|
extractor::TravelMode travel_mode : 4;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct InternalRouteResult
|
struct InternalRouteResult
|
||||||
@ -61,4 +66,7 @@ struct InternalRouteResult
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // RAW_ROUTE_DATA_H
|
#endif // RAW_ROUTE_DATA_H
|
||||||
|
@ -6,6 +6,13 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace map_matching
|
||||||
|
{
|
||||||
|
|
||||||
struct NormalDistribution
|
struct NormalDistribution
|
||||||
{
|
{
|
||||||
NormalDistribution(const double mean, const double standard_deviation)
|
NormalDistribution(const double mean, const double standard_deviation)
|
||||||
@ -88,4 +95,8 @@ class BayesClassifier
|
|||||||
double negative_apriori_probability;
|
double negative_apriori_probability;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // BAYES_CLASSIFIER_HPP
|
#endif // BAYES_CLASSIFIER_HPP
|
||||||
|
@ -12,14 +12,15 @@
|
|||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
namespace matching
|
namespace engine
|
||||||
{
|
{
|
||||||
|
namespace map_matching
|
||||||
|
{
|
||||||
|
|
||||||
static const double log_2_pi = std::log(2. * M_PI);
|
static const double log_2_pi = std::log(2. * M_PI);
|
||||||
static const double IMPOSSIBLE_LOG_PROB = -std::numeric_limits<double>::infinity();
|
static const double IMPOSSIBLE_LOG_PROB = -std::numeric_limits<double>::infinity();
|
||||||
static const double MINIMAL_LOG_PROB = std::numeric_limits<double>::lowest();
|
static const double MINIMAL_LOG_PROB = std::numeric_limits<double>::lowest();
|
||||||
static const std::size_t INVALID_STATE = std::numeric_limits<std::size_t>::max();
|
static const std::size_t INVALID_STATE = std::numeric_limits<std::size_t>::max();
|
||||||
} // namespace matching
|
|
||||||
} // namespace osrm
|
|
||||||
|
|
||||||
// closures to precompute log -> only simple floating point operations
|
// closures to precompute log -> only simple floating point operations
|
||||||
struct EmissionLogProbability
|
struct EmissionLogProbability
|
||||||
@ -33,7 +34,7 @@ struct EmissionLogProbability
|
|||||||
|
|
||||||
double operator()(const double distance) const
|
double operator()(const double distance) const
|
||||||
{
|
{
|
||||||
return -0.5 * (osrm::matching::log_2_pi + (distance / sigma_z) * (distance / sigma_z)) -
|
return -0.5 * (log_2_pi + (distance / sigma_z) * (distance / sigma_z)) -
|
||||||
log_sigma_z;
|
log_sigma_z;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -70,7 +71,7 @@ template <class CandidateLists> struct HiddenMarkovModel
|
|||||||
suspicious.resize(candidates_list.size());
|
suspicious.resize(candidates_list.size());
|
||||||
pruned.resize(candidates_list.size());
|
pruned.resize(candidates_list.size());
|
||||||
breakage.resize(candidates_list.size());
|
breakage.resize(candidates_list.size());
|
||||||
for (const auto i : osrm::irange<std::size_t>(0u, candidates_list.size()))
|
for (const auto i : util::irange<std::size_t>(0u, candidates_list.size()))
|
||||||
{
|
{
|
||||||
const auto &num_candidates = candidates_list[i].size();
|
const auto &num_candidates = candidates_list[i].size();
|
||||||
// add empty vectors
|
// add empty vectors
|
||||||
@ -92,9 +93,9 @@ template <class CandidateLists> struct HiddenMarkovModel
|
|||||||
BOOST_ASSERT(viterbi.size() == parents.size() && parents.size() == path_lengths.size() &&
|
BOOST_ASSERT(viterbi.size() == parents.size() && parents.size() == path_lengths.size() &&
|
||||||
path_lengths.size() == pruned.size() && pruned.size() == breakage.size());
|
path_lengths.size() == pruned.size() && pruned.size() == breakage.size());
|
||||||
|
|
||||||
for (const auto t : osrm::irange(initial_timestamp, viterbi.size()))
|
for (const auto t : util::irange(initial_timestamp, viterbi.size()))
|
||||||
{
|
{
|
||||||
std::fill(viterbi[t].begin(), viterbi[t].end(), osrm::matching::IMPOSSIBLE_LOG_PROB);
|
std::fill(viterbi[t].begin(), viterbi[t].end(), IMPOSSIBLE_LOG_PROB);
|
||||||
std::fill(parents[t].begin(), parents[t].end(), std::make_pair(0u, 0u));
|
std::fill(parents[t].begin(), parents[t].end(), std::make_pair(0u, 0u));
|
||||||
std::fill(path_lengths[t].begin(), path_lengths[t].end(), 0);
|
std::fill(path_lengths[t].begin(), path_lengths[t].end(), 0);
|
||||||
std::fill(suspicious[t].begin(), suspicious[t].end(), true);
|
std::fill(suspicious[t].begin(), suspicious[t].end(), true);
|
||||||
@ -110,13 +111,13 @@ template <class CandidateLists> struct HiddenMarkovModel
|
|||||||
{
|
{
|
||||||
BOOST_ASSERT(initial_timestamp < num_points);
|
BOOST_ASSERT(initial_timestamp < num_points);
|
||||||
|
|
||||||
for (const auto s : osrm::irange<std::size_t>(0u, viterbi[initial_timestamp].size()))
|
for (const auto s : util::irange<std::size_t>(0u, viterbi[initial_timestamp].size()))
|
||||||
{
|
{
|
||||||
viterbi[initial_timestamp][s] =
|
viterbi[initial_timestamp][s] =
|
||||||
emission_log_probability(candidates_list[initial_timestamp][s].distance);
|
emission_log_probability(candidates_list[initial_timestamp][s].distance);
|
||||||
parents[initial_timestamp][s] = std::make_pair(initial_timestamp, s);
|
parents[initial_timestamp][s] = std::make_pair(initial_timestamp, s);
|
||||||
pruned[initial_timestamp][s] =
|
pruned[initial_timestamp][s] =
|
||||||
viterbi[initial_timestamp][s] < osrm::matching::MINIMAL_LOG_PROB;
|
viterbi[initial_timestamp][s] < MINIMAL_LOG_PROB;
|
||||||
suspicious[initial_timestamp][s] = false;
|
suspicious[initial_timestamp][s] = false;
|
||||||
|
|
||||||
breakage[initial_timestamp] =
|
breakage[initial_timestamp] =
|
||||||
@ -128,7 +129,7 @@ template <class CandidateLists> struct HiddenMarkovModel
|
|||||||
|
|
||||||
if (initial_timestamp >= num_points)
|
if (initial_timestamp >= num_points)
|
||||||
{
|
{
|
||||||
return osrm::matching::INVALID_STATE;
|
return INVALID_STATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_ASSERT(initial_timestamp > 0);
|
BOOST_ASSERT(initial_timestamp > 0);
|
||||||
@ -140,4 +141,8 @@ template <class CandidateLists> struct HiddenMarkovModel
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // HIDDEN_MARKOV_MODEL
|
#endif // HIDDEN_MARKOV_MODEL
|
||||||
|
@ -11,6 +11,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
|
||||||
struct ObjectEncoder
|
struct ObjectEncoder
|
||||||
{
|
{
|
||||||
using base64_t = boost::archive::iterators::base64_from_binary<
|
using base64_t = boost::archive::iterators::base64_from_binary<
|
||||||
@ -59,4 +64,7 @@ struct ObjectEncoder
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* OBJECT_ENCODER_HPP */
|
#endif /* OBJECT_ENCODER_HPP */
|
||||||
|
@ -1,9 +1,6 @@
|
|||||||
#ifndef OSRM_IMPL_HPP
|
#ifndef OSRM_IMPL_HPP
|
||||||
#define OSRM_IMPL_HPP
|
#define OSRM_IMPL_HPP
|
||||||
|
|
||||||
class BasePlugin;
|
|
||||||
struct RouteParameters;
|
|
||||||
|
|
||||||
#include "contractor/query_edge.hpp"
|
#include "contractor/query_edge.hpp"
|
||||||
|
|
||||||
#include "osrm/json_container.hpp"
|
#include "osrm/json_container.hpp"
|
||||||
@ -14,31 +11,55 @@ struct RouteParameters;
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
namespace json
|
||||||
|
{
|
||||||
|
struct Object;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
struct RouteParameters;
|
||||||
|
namespace plugins
|
||||||
|
{
|
||||||
|
class BasePlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace datafacade
|
||||||
|
{
|
||||||
struct SharedBarriers;
|
struct SharedBarriers;
|
||||||
template <class EdgeDataT> class BaseDataFacade;
|
template <class EdgeDataT> class BaseDataFacade;
|
||||||
|
}
|
||||||
|
|
||||||
class OSRM::OSRM_impl final
|
class OSRM::OSRM_impl final
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
using PluginMap = std::unordered_map<std::string, std::unique_ptr<BasePlugin>>;
|
using PluginMap = std::unordered_map<std::string, std::unique_ptr<plugins::BasePlugin>>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OSRM_impl(LibOSRMConfig &lib_config);
|
OSRM_impl(LibOSRMConfig &lib_config);
|
||||||
OSRM_impl(const OSRM_impl &) = delete;
|
OSRM_impl(const OSRM_impl &) = delete;
|
||||||
int RunQuery(const RouteParameters &route_parameters, osrm::json::Object &json_result);
|
int RunQuery(const RouteParameters &route_parameters, util::json::Object &json_result);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void RegisterPlugin(BasePlugin *plugin);
|
void RegisterPlugin(plugins::BasePlugin *plugin);
|
||||||
PluginMap plugin_map;
|
PluginMap plugin_map;
|
||||||
// will only be initialized if shared memory is used
|
// will only be initialized if shared memory is used
|
||||||
std::unique_ptr<SharedBarriers> barrier;
|
std::unique_ptr<datafacade::SharedBarriers> barrier;
|
||||||
// base class pointer to the objects
|
// base class pointer to the objects
|
||||||
BaseDataFacade<QueryEdge::EdgeData> *query_data_facade;
|
datafacade::BaseDataFacade<contractor::QueryEdge::EdgeData> *query_data_facade;
|
||||||
|
|
||||||
// decrease number of concurrent queries
|
// decrease number of concurrent queries
|
||||||
void decrease_concurrent_query_count();
|
void decrease_concurrent_query_count();
|
||||||
// increase number of concurrent queries
|
// increase number of concurrent queries
|
||||||
void increase_concurrent_query_count();
|
void increase_concurrent_query_count();
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // OSRM_IMPL_HPP
|
#endif // OSRM_IMPL_HPP
|
||||||
|
@ -10,6 +10,11 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
|
||||||
struct PhantomNode
|
struct PhantomNode
|
||||||
{
|
{
|
||||||
PhantomNode(NodeID forward_node_id,
|
PhantomNode(NodeID forward_node_id,
|
||||||
@ -22,14 +27,14 @@ struct PhantomNode
|
|||||||
unsigned packed_geometry_id,
|
unsigned packed_geometry_id,
|
||||||
bool is_tiny_component,
|
bool is_tiny_component,
|
||||||
unsigned component_id,
|
unsigned component_id,
|
||||||
FixedPointCoordinate &location,
|
util::FixedPointCoordinate &location,
|
||||||
unsigned short fwd_segment_position,
|
unsigned short fwd_segment_position,
|
||||||
TravelMode forward_travel_mode,
|
extractor::TravelMode forward_travel_mode,
|
||||||
TravelMode backward_travel_mode);
|
extractor::TravelMode backward_travel_mode);
|
||||||
|
|
||||||
PhantomNode();
|
PhantomNode();
|
||||||
|
|
||||||
template <class OtherT> PhantomNode(const OtherT &other, const FixedPointCoordinate &foot_point)
|
template <class OtherT> PhantomNode(const OtherT &other, const util::FixedPointCoordinate &foot_point)
|
||||||
{
|
{
|
||||||
forward_node_id = other.forward_edge_based_node_id;
|
forward_node_id = other.forward_edge_based_node_id;
|
||||||
reverse_node_id = other.reverse_edge_based_node_id;
|
reverse_node_id = other.reverse_edge_based_node_id;
|
||||||
@ -70,12 +75,12 @@ struct PhantomNode
|
|||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
static_assert(sizeof(ComponentType) == 4, "ComponentType needs to 4 bytes big");
|
static_assert(sizeof(ComponentType) == 4, "ComponentType needs to 4 bytes big");
|
||||||
#endif
|
#endif
|
||||||
FixedPointCoordinate location;
|
util::FixedPointCoordinate location;
|
||||||
unsigned short fwd_segment_position;
|
unsigned short fwd_segment_position;
|
||||||
// note 4 bits would suffice for each,
|
// note 4 bits would suffice for each,
|
||||||
// but the saved byte would be padding anyway
|
// but the saved byte would be padding anyway
|
||||||
TravelMode forward_travel_mode;
|
extractor::TravelMode forward_travel_mode;
|
||||||
TravelMode backward_travel_mode;
|
extractor::TravelMode backward_travel_mode;
|
||||||
|
|
||||||
int GetForwardWeightPlusOffset() const;
|
int GetForwardWeightPlusOffset() const;
|
||||||
|
|
||||||
@ -133,4 +138,7 @@ inline std::ostream &operator<<(std::ostream &out, const PhantomNode &pn)
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // PHANTOM_NODES_H
|
#endif // PHANTOM_NODES_H
|
||||||
|
@ -16,6 +16,13 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace plugins
|
||||||
|
{
|
||||||
|
|
||||||
template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -27,7 +34,7 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
|||||||
: max_locations_distance_table(max_locations_distance_table), descriptor_string("table"),
|
: max_locations_distance_table(max_locations_distance_table), descriptor_string("table"),
|
||||||
facade(facade)
|
facade(facade)
|
||||||
{
|
{
|
||||||
search_engine_ptr = osrm::make_unique<SearchEngine<DataFacadeT>>(facade);
|
search_engine_ptr = util::make_unique<SearchEngine<DataFacadeT>>(facade);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~DistanceTablePlugin() {}
|
virtual ~DistanceTablePlugin() {}
|
||||||
@ -35,7 +42,7 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
|||||||
const std::string GetDescriptor() const override final { return descriptor_string; }
|
const std::string GetDescriptor() const override final { return descriptor_string; }
|
||||||
|
|
||||||
Status HandleRequest(const RouteParameters &route_parameters,
|
Status HandleRequest(const RouteParameters &route_parameters,
|
||||||
osrm::json::Object &json_result) override final
|
util::json::Object &json_result) override final
|
||||||
{
|
{
|
||||||
if (!check_all_coordinates(route_parameters.coordinates))
|
if (!check_all_coordinates(route_parameters.coordinates))
|
||||||
{
|
{
|
||||||
@ -82,7 +89,7 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
|||||||
std::vector<PhantomNodePair> phantom_node_target_vector(number_of_destination);
|
std::vector<PhantomNodePair> phantom_node_target_vector(number_of_destination);
|
||||||
auto phantom_node_source_out_iter = phantom_node_source_vector.begin();
|
auto phantom_node_source_out_iter = phantom_node_source_vector.begin();
|
||||||
auto phantom_node_target_out_iter = phantom_node_target_vector.begin();
|
auto phantom_node_target_out_iter = phantom_node_target_vector.begin();
|
||||||
for (const auto i : osrm::irange<std::size_t>(0u, route_parameters.coordinates.size()))
|
for (const auto i : util::irange<std::size_t>(0u, route_parameters.coordinates.size()))
|
||||||
{
|
{
|
||||||
if (checksum_OK && i < route_parameters.hints.size() &&
|
if (checksum_OK && i < route_parameters.hints.size() &&
|
||||||
!route_parameters.hints[i].empty())
|
!route_parameters.hints[i].empty())
|
||||||
@ -176,10 +183,10 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
|||||||
return Status::EmptyResult;
|
return Status::EmptyResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
osrm::json::Array matrix_json_array;
|
util::json::Array matrix_json_array;
|
||||||
for (const auto row : osrm::irange<std::size_t>(0, number_of_sources))
|
for (const auto row : util::irange<std::size_t>(0, number_of_sources))
|
||||||
{
|
{
|
||||||
osrm::json::Array json_row;
|
util::json::Array json_row;
|
||||||
auto row_begin_iterator = result_table->begin() + (row * number_of_destination);
|
auto row_begin_iterator = result_table->begin() + (row * number_of_destination);
|
||||||
auto row_end_iterator = result_table->begin() + ((row + 1) * number_of_destination);
|
auto row_end_iterator = result_table->begin() + ((row + 1) * number_of_destination);
|
||||||
json_row.values.insert(json_row.values.end(), row_begin_iterator, row_end_iterator);
|
json_row.values.insert(json_row.values.end(), row_begin_iterator, row_end_iterator);
|
||||||
@ -187,19 +194,19 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
|||||||
}
|
}
|
||||||
json_result.values["distance_table"] = matrix_json_array;
|
json_result.values["distance_table"] = matrix_json_array;
|
||||||
|
|
||||||
osrm::json::Array target_coord_json_array;
|
util::json::Array target_coord_json_array;
|
||||||
for (const auto &phantom : snapped_target_phantoms)
|
for (const auto &phantom : snapped_target_phantoms)
|
||||||
{
|
{
|
||||||
osrm::json::Array json_coord;
|
util::json::Array json_coord;
|
||||||
json_coord.values.push_back(phantom.location.lat / COORDINATE_PRECISION);
|
json_coord.values.push_back(phantom.location.lat / COORDINATE_PRECISION);
|
||||||
json_coord.values.push_back(phantom.location.lon / COORDINATE_PRECISION);
|
json_coord.values.push_back(phantom.location.lon / COORDINATE_PRECISION);
|
||||||
target_coord_json_array.values.push_back(json_coord);
|
target_coord_json_array.values.push_back(json_coord);
|
||||||
}
|
}
|
||||||
json_result.values["destination_coordinates"] = target_coord_json_array;
|
json_result.values["destination_coordinates"] = target_coord_json_array;
|
||||||
osrm::json::Array source_coord_json_array;
|
util::json::Array source_coord_json_array;
|
||||||
for (const auto &phantom : snapped_source_phantoms)
|
for (const auto &phantom : snapped_source_phantoms)
|
||||||
{
|
{
|
||||||
osrm::json::Array json_coord;
|
util::json::Array json_coord;
|
||||||
json_coord.values.push_back(phantom.location.lat / COORDINATE_PRECISION);
|
json_coord.values.push_back(phantom.location.lat / COORDINATE_PRECISION);
|
||||||
json_coord.values.push_back(phantom.location.lon / COORDINATE_PRECISION);
|
json_coord.values.push_back(phantom.location.lon / COORDINATE_PRECISION);
|
||||||
source_coord_json_array.values.push_back(json_coord);
|
source_coord_json_array.values.push_back(json_coord);
|
||||||
@ -213,4 +220,8 @@ template <class DataFacadeT> class DistanceTablePlugin final : public BasePlugin
|
|||||||
DataFacadeT *facade;
|
DataFacadeT *facade;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DISTANCE_TABLE_HPP
|
#endif // DISTANCE_TABLE_HPP
|
||||||
|
@ -7,6 +7,13 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace plugins
|
||||||
|
{
|
||||||
|
|
||||||
class HelloWorldPlugin final : public BasePlugin
|
class HelloWorldPlugin final : public BasePlugin
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -18,7 +25,7 @@ class HelloWorldPlugin final : public BasePlugin
|
|||||||
const std::string GetDescriptor() const override final { return descriptor_string; }
|
const std::string GetDescriptor() const override final { return descriptor_string; }
|
||||||
|
|
||||||
Status HandleRequest(const RouteParameters &routeParameters,
|
Status HandleRequest(const RouteParameters &routeParameters,
|
||||||
osrm::json::Object &json_result) override final
|
util::json::Object &json_result) override final
|
||||||
{
|
{
|
||||||
std::string temp_string;
|
std::string temp_string;
|
||||||
json_result.values["title"] = "Hello World";
|
json_result.values["title"] = "Hello World";
|
||||||
@ -41,12 +48,12 @@ class HelloWorldPlugin final : public BasePlugin
|
|||||||
temp_string = std::to_string(routeParameters.coordinates.size());
|
temp_string = std::to_string(routeParameters.coordinates.size());
|
||||||
json_result.values["location_count"] = temp_string;
|
json_result.values["location_count"] = temp_string;
|
||||||
|
|
||||||
osrm::json::Array json_locations;
|
util::json::Array json_locations;
|
||||||
unsigned counter = 0;
|
unsigned counter = 0;
|
||||||
for (const FixedPointCoordinate &coordinate : routeParameters.coordinates)
|
for (const util::FixedPointCoordinate &coordinate : routeParameters.coordinates)
|
||||||
{
|
{
|
||||||
osrm::json::Object json_location;
|
util::json::Object json_location;
|
||||||
osrm::json::Array json_coordinates;
|
util::json::Array json_coordinates;
|
||||||
|
|
||||||
json_coordinates.values.push_back(
|
json_coordinates.values.push_back(
|
||||||
static_cast<double>(coordinate.lat / COORDINATE_PRECISION));
|
static_cast<double>(coordinate.lat / COORDINATE_PRECISION));
|
||||||
@ -59,7 +66,7 @@ class HelloWorldPlugin final : public BasePlugin
|
|||||||
json_result.values["locations"] = json_locations;
|
json_result.values["locations"] = json_locations;
|
||||||
json_result.values["hint_count"] = routeParameters.hints.size();
|
json_result.values["hint_count"] = routeParameters.hints.size();
|
||||||
|
|
||||||
osrm::json::Array json_hints;
|
util::json::Array json_hints;
|
||||||
counter = 0;
|
counter = 0;
|
||||||
for (const std::string ¤t_hint : routeParameters.hints)
|
for (const std::string ¤t_hint : routeParameters.hints)
|
||||||
{
|
{
|
||||||
@ -74,4 +81,8 @@ class HelloWorldPlugin final : public BasePlugin
|
|||||||
std::string descriptor_string;
|
std::string descriptor_string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // HELLO_WORLD_HPP
|
#endif // HELLO_WORLD_HPP
|
||||||
|
@ -23,11 +23,21 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace plugins
|
||||||
|
{
|
||||||
|
|
||||||
template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
||||||
{
|
{
|
||||||
std::shared_ptr<SearchEngine<DataFacadeT>> search_engine_ptr;
|
std::shared_ptr<SearchEngine<DataFacadeT>> search_engine_ptr;
|
||||||
|
|
||||||
using ClassifierT = BayesClassifier<LaplaceDistribution, LaplaceDistribution, double>;
|
using SubMatching = routing_algorithms::SubMatching;
|
||||||
|
using SubMatchingList = routing_algorithms::SubMatchingList;
|
||||||
|
using CandidateLists = routing_algorithms::CandidateLists;
|
||||||
|
using ClassifierT = map_matching::BayesClassifier<map_matching::LaplaceDistribution, map_matching::LaplaceDistribution, double>;
|
||||||
using TraceClassification = ClassifierT::ClassificationT;
|
using TraceClassification = ClassifierT::ClassificationT;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -36,8 +46,8 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
|||||||
max_locations_map_matching(max_locations_map_matching),
|
max_locations_map_matching(max_locations_map_matching),
|
||||||
// the values where derived from fitting a laplace distribution
|
// the values where derived from fitting a laplace distribution
|
||||||
// to the values of manually classified traces
|
// to the values of manually classified traces
|
||||||
classifier(LaplaceDistribution(0.005986, 0.016646),
|
classifier(map_matching::LaplaceDistribution(0.005986, 0.016646),
|
||||||
LaplaceDistribution(0.054385, 0.458432),
|
map_matching::LaplaceDistribution(0.054385, 0.458432),
|
||||||
0.696774) // valid apriori probability
|
0.696774) // valid apriori probability
|
||||||
{
|
{
|
||||||
search_engine_ptr = std::make_shared<SearchEngine<DataFacadeT>>(facade);
|
search_engine_ptr = std::make_shared<SearchEngine<DataFacadeT>>(facade);
|
||||||
@ -65,28 +75,28 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
|||||||
return label_with_confidence;
|
return label_with_confidence;
|
||||||
}
|
}
|
||||||
|
|
||||||
osrm::matching::CandidateLists getCandidates(
|
CandidateLists getCandidates(
|
||||||
const std::vector<FixedPointCoordinate> &input_coords,
|
const std::vector<util::FixedPointCoordinate> &input_coords,
|
||||||
const std::vector<std::pair<const int, const boost::optional<int>>> &input_bearings,
|
const std::vector<std::pair<const int, const boost::optional<int>>> &input_bearings,
|
||||||
const double gps_precision,
|
const double gps_precision,
|
||||||
std::vector<double> &sub_trace_lengths)
|
std::vector<double> &sub_trace_lengths)
|
||||||
{
|
{
|
||||||
osrm::matching::CandidateLists candidates_lists;
|
CandidateLists candidates_lists;
|
||||||
|
|
||||||
// assuming the gps_precision is the standart-diviation of normal distribution that models
|
// assuming the gps_precision is the standart-diviation of normal distribution that models
|
||||||
// GPS noise (in this model) this should give us the correct candidate with >0.95
|
// GPS noise (in this model) this should give us the correct candidate with >0.95
|
||||||
double query_radius = 3 * gps_precision;
|
double query_radius = 3 * gps_precision;
|
||||||
double last_distance =
|
double last_distance =
|
||||||
coordinate_calculation::haversineDistance(input_coords[0], input_coords[1]);
|
util::coordinate_calculation::haversineDistance(input_coords[0], input_coords[1]);
|
||||||
|
|
||||||
sub_trace_lengths.resize(input_coords.size());
|
sub_trace_lengths.resize(input_coords.size());
|
||||||
sub_trace_lengths[0] = 0;
|
sub_trace_lengths[0] = 0;
|
||||||
for (const auto current_coordinate : osrm::irange<std::size_t>(0, input_coords.size()))
|
for (const auto current_coordinate : util::irange<std::size_t>(0, input_coords.size()))
|
||||||
{
|
{
|
||||||
bool allow_uturn = false;
|
bool allow_uturn = false;
|
||||||
if (0 < current_coordinate)
|
if (0 < current_coordinate)
|
||||||
{
|
{
|
||||||
last_distance = coordinate_calculation::haversineDistance(
|
last_distance = util::coordinate_calculation::haversineDistance(
|
||||||
input_coords[current_coordinate - 1], input_coords[current_coordinate]);
|
input_coords[current_coordinate - 1], input_coords[current_coordinate]);
|
||||||
|
|
||||||
sub_trace_lengths[current_coordinate] +=
|
sub_trace_lengths[current_coordinate] +=
|
||||||
@ -95,7 +105,7 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
|||||||
|
|
||||||
if (input_coords.size() - 1 > current_coordinate && 0 < current_coordinate)
|
if (input_coords.size() - 1 > current_coordinate && 0 < current_coordinate)
|
||||||
{
|
{
|
||||||
double turn_angle = ComputeAngle::OfThreeFixedPointCoordinates(
|
double turn_angle = util::ComputeAngle::OfThreeFixedPointCoordinates(
|
||||||
input_coords[current_coordinate - 1], input_coords[current_coordinate],
|
input_coords[current_coordinate - 1], input_coords[current_coordinate],
|
||||||
input_coords[current_coordinate + 1]);
|
input_coords[current_coordinate + 1]);
|
||||||
|
|
||||||
@ -146,7 +156,7 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
|||||||
if (!allow_uturn)
|
if (!allow_uturn)
|
||||||
{
|
{
|
||||||
const auto compact_size = candidates.size();
|
const auto compact_size = candidates.size();
|
||||||
for (const auto i : osrm::irange<std::size_t>(0, compact_size))
|
for (const auto i : util::irange<std::size_t>(0, compact_size))
|
||||||
{
|
{
|
||||||
// Split edge if it is bidirectional and append reverse direction to end of list
|
// Split edge if it is bidirectional and append reverse direction to end of list
|
||||||
if (candidates[i].phantom_node.forward_node_id != SPECIAL_NODEID &&
|
if (candidates[i].phantom_node.forward_node_id != SPECIAL_NODEID &&
|
||||||
@ -175,24 +185,24 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
|||||||
return candidates_lists;
|
return candidates_lists;
|
||||||
}
|
}
|
||||||
|
|
||||||
osrm::json::Object submatchingToJSON(const osrm::matching::SubMatching &sub,
|
util::json::Object submatchingToJSON(const SubMatching &sub,
|
||||||
const RouteParameters &route_parameters,
|
const RouteParameters &route_parameters,
|
||||||
const InternalRouteResult &raw_route)
|
const InternalRouteResult &raw_route)
|
||||||
{
|
{
|
||||||
osrm::json::Object subtrace;
|
util::json::Object subtrace;
|
||||||
|
|
||||||
if (route_parameters.classify)
|
if (route_parameters.classify)
|
||||||
{
|
{
|
||||||
subtrace.values["confidence"] = sub.confidence;
|
subtrace.values["confidence"] = sub.confidence;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto response_generator = osrm::engine::MakeApiResponseGenerator(facade);
|
auto response_generator = MakeApiResponseGenerator(facade);
|
||||||
|
|
||||||
subtrace.values["hint_data"] = response_generator.BuildHintData(raw_route);
|
subtrace.values["hint_data"] = response_generator.BuildHintData(raw_route);
|
||||||
|
|
||||||
if (route_parameters.geometry || route_parameters.print_instructions)
|
if (route_parameters.geometry || route_parameters.print_instructions)
|
||||||
{
|
{
|
||||||
using SegmentList = osrm::engine::guidance::SegmentList<DataFacadeT>;
|
using SegmentList = guidance::SegmentList<DataFacadeT>;
|
||||||
//Passing false to extract_alternative extracts the route.
|
//Passing false to extract_alternative extracts the route.
|
||||||
const constexpr bool EXTRACT_ROUTE = false;
|
const constexpr bool EXTRACT_ROUTE = false;
|
||||||
// by passing false to segment_list, we skip the douglas peucker simplification
|
// by passing false to segment_list, we skip the douglas peucker simplification
|
||||||
@ -210,28 +220,28 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
|||||||
if (route_parameters.print_instructions)
|
if (route_parameters.print_instructions)
|
||||||
{
|
{
|
||||||
subtrace.values["instructions"] =
|
subtrace.values["instructions"] =
|
||||||
osrm::engine::guidance::AnnotateRoute<DataFacadeT>(
|
guidance::AnnotateRoute<DataFacadeT>(
|
||||||
segment_list.Get(), facade);
|
segment_list.Get(), facade);
|
||||||
}
|
}
|
||||||
|
|
||||||
osrm::json::Object json_route_summary;
|
util::json::Object json_route_summary;
|
||||||
json_route_summary.values["total_distance"] = segment_list.GetDistance();
|
json_route_summary.values["total_distance"] = segment_list.GetDistance();
|
||||||
json_route_summary.values["total_time"] = segment_list.GetDuration();
|
json_route_summary.values["total_time"] = segment_list.GetDuration();
|
||||||
subtrace.values["route_summary"] = json_route_summary;
|
subtrace.values["route_summary"] = json_route_summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
subtrace.values["indices"] = osrm::json::make_array(sub.indices);
|
subtrace.values["indices"] = util::json::make_array(sub.indices);
|
||||||
|
|
||||||
osrm::json::Array points;
|
util::json::Array points;
|
||||||
for (const auto &node : sub.nodes)
|
for (const auto &node : sub.nodes)
|
||||||
{
|
{
|
||||||
points.values.emplace_back(
|
points.values.emplace_back(
|
||||||
osrm::json::make_array(node.location.lat / COORDINATE_PRECISION,
|
util::json::make_array(node.location.lat / COORDINATE_PRECISION,
|
||||||
node.location.lon / COORDINATE_PRECISION));
|
node.location.lon / COORDINATE_PRECISION));
|
||||||
}
|
}
|
||||||
subtrace.values["matched_points"] = points;
|
subtrace.values["matched_points"] = points;
|
||||||
|
|
||||||
osrm::json::Array names;
|
util::json::Array names;
|
||||||
for (const auto &node : sub.nodes)
|
for (const auto &node : sub.nodes)
|
||||||
{
|
{
|
||||||
names.values.emplace_back(facade->get_name_for_id(node.name_id));
|
names.values.emplace_back(facade->get_name_for_id(node.name_id));
|
||||||
@ -242,7 +252,7 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
Status HandleRequest(const RouteParameters &route_parameters,
|
Status HandleRequest(const RouteParameters &route_parameters,
|
||||||
osrm::json::Object &json_result) final override
|
util::json::Object &json_result) final override
|
||||||
{
|
{
|
||||||
// enforce maximum number of locations for performance reasons
|
// enforce maximum number of locations for performance reasons
|
||||||
if (max_locations_map_matching > 0 &&
|
if (max_locations_map_matching > 0 &&
|
||||||
@ -296,16 +306,16 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// setup logging if enabled
|
// setup logging if enabled
|
||||||
if (osrm::json::Logger::get())
|
if (util::json::Logger::get())
|
||||||
osrm::json::Logger::get()->initialize("matching");
|
util::json::Logger::get()->initialize("matching");
|
||||||
|
|
||||||
// call the actual map matching
|
// call the actual map matching
|
||||||
osrm::matching::SubMatchingList sub_matchings;
|
SubMatchingList sub_matchings;
|
||||||
search_engine_ptr->map_matching(candidates_lists, input_coords, input_timestamps,
|
search_engine_ptr->map_matching(candidates_lists, input_coords, input_timestamps,
|
||||||
route_parameters.matching_beta,
|
route_parameters.matching_beta,
|
||||||
route_parameters.gps_precision, sub_matchings);
|
route_parameters.gps_precision, sub_matchings);
|
||||||
|
|
||||||
osrm::json::Array matchings;
|
util::json::Array matchings;
|
||||||
for (auto &sub : sub_matchings)
|
for (auto &sub : sub_matchings)
|
||||||
{
|
{
|
||||||
// classify result
|
// classify result
|
||||||
@ -349,8 +359,8 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
|||||||
matchings.values.emplace_back(submatchingToJSON(sub, route_parameters, raw_route));
|
matchings.values.emplace_back(submatchingToJSON(sub, route_parameters, raw_route));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (osrm::json::Logger::get())
|
if (util::json::Logger::get())
|
||||||
osrm::json::Logger::get()->render("matching", json_result);
|
util::json::Logger::get()->render("matching", json_result);
|
||||||
json_result.values["matchings"] = matchings;
|
json_result.values["matchings"] = matchings;
|
||||||
|
|
||||||
if (sub_matchings.empty())
|
if (sub_matchings.empty())
|
||||||
@ -370,4 +380,8 @@ template <class DataFacadeT> class MapMatchingPlugin : public BasePlugin
|
|||||||
ClassifierT classifier;
|
ClassifierT classifier;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // MATCH_HPP
|
#endif // MATCH_HPP
|
||||||
|
@ -8,6 +8,13 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace plugins
|
||||||
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This Plugin locates the nearest point on a street in the road network for a given coordinate.
|
* This Plugin locates the nearest point on a street in the road network for a given coordinate.
|
||||||
*/
|
*/
|
||||||
@ -20,7 +27,7 @@ template <class DataFacadeT> class NearestPlugin final : public BasePlugin
|
|||||||
const std::string GetDescriptor() const override final { return descriptor_string; }
|
const std::string GetDescriptor() const override final { return descriptor_string; }
|
||||||
|
|
||||||
Status HandleRequest(const RouteParameters &route_parameters,
|
Status HandleRequest(const RouteParameters &route_parameters,
|
||||||
osrm::json::Object &json_result) override final
|
util::json::Object &json_result) override final
|
||||||
{
|
{
|
||||||
// check number of parameters
|
// check number of parameters
|
||||||
if (route_parameters.coordinates.empty() ||
|
if (route_parameters.coordinates.empty() ||
|
||||||
@ -58,15 +65,15 @@ template <class DataFacadeT> class NearestPlugin final : public BasePlugin
|
|||||||
json_result.values["status_message"] = "Found nearest edge";
|
json_result.values["status_message"] = "Found nearest edge";
|
||||||
if (number_of_results > 1)
|
if (number_of_results > 1)
|
||||||
{
|
{
|
||||||
osrm::json::Array results;
|
util::json::Array results;
|
||||||
|
|
||||||
auto vector_length = phantom_node_vector.size();
|
auto vector_length = phantom_node_vector.size();
|
||||||
for (const auto i :
|
for (const auto i :
|
||||||
osrm::irange<std::size_t>(0, std::min(number_of_results, vector_length)))
|
util::irange<std::size_t>(0, std::min(number_of_results, vector_length)))
|
||||||
{
|
{
|
||||||
const auto &node = phantom_node_vector[i].phantom_node;
|
const auto &node = phantom_node_vector[i].phantom_node;
|
||||||
osrm::json::Array json_coordinate;
|
util::json::Array json_coordinate;
|
||||||
osrm::json::Object result;
|
util::json::Object result;
|
||||||
json_coordinate.values.push_back(node.location.lat / COORDINATE_PRECISION);
|
json_coordinate.values.push_back(node.location.lat / COORDINATE_PRECISION);
|
||||||
json_coordinate.values.push_back(node.location.lon / COORDINATE_PRECISION);
|
json_coordinate.values.push_back(node.location.lon / COORDINATE_PRECISION);
|
||||||
result.values["mapped coordinate"] = json_coordinate;
|
result.values["mapped coordinate"] = json_coordinate;
|
||||||
@ -77,7 +84,7 @@ template <class DataFacadeT> class NearestPlugin final : public BasePlugin
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
osrm::json::Array json_coordinate;
|
util::json::Array json_coordinate;
|
||||||
json_coordinate.values.push_back(
|
json_coordinate.values.push_back(
|
||||||
phantom_node_vector.front().phantom_node.location.lat / COORDINATE_PRECISION);
|
phantom_node_vector.front().phantom_node.location.lat / COORDINATE_PRECISION);
|
||||||
json_coordinate.values.push_back(
|
json_coordinate.values.push_back(
|
||||||
@ -95,4 +102,8 @@ template <class DataFacadeT> class NearestPlugin final : public BasePlugin
|
|||||||
std::string descriptor_string;
|
std::string descriptor_string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* NEAREST_HPP */
|
#endif /* NEAREST_HPP */
|
||||||
|
@ -11,6 +11,13 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace plugins
|
||||||
|
{
|
||||||
|
|
||||||
class BasePlugin
|
class BasePlugin
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -26,12 +33,12 @@ class BasePlugin
|
|||||||
// Maybe someone can explain the pure virtual destructor thing to me (dennis)
|
// Maybe someone can explain the pure virtual destructor thing to me (dennis)
|
||||||
virtual ~BasePlugin() {}
|
virtual ~BasePlugin() {}
|
||||||
virtual const std::string GetDescriptor() const = 0;
|
virtual const std::string GetDescriptor() const = 0;
|
||||||
virtual Status HandleRequest(const RouteParameters &, osrm::json::Object &) = 0;
|
virtual Status HandleRequest(const RouteParameters &, util::json::Object &) = 0;
|
||||||
virtual bool check_all_coordinates(const std::vector<FixedPointCoordinate> &coordinates,
|
virtual bool check_all_coordinates(const std::vector<util::FixedPointCoordinate> &coordinates,
|
||||||
const unsigned min = 2) const final
|
const unsigned min = 2) const final
|
||||||
{
|
{
|
||||||
if (min > coordinates.size() || std::any_of(std::begin(coordinates), std::end(coordinates),
|
if (min > coordinates.size() || std::any_of(std::begin(coordinates), std::end(coordinates),
|
||||||
[](const FixedPointCoordinate &coordinate)
|
[](const util::FixedPointCoordinate &coordinate)
|
||||||
{
|
{
|
||||||
return !coordinate.IsValid();
|
return !coordinate.IsValid();
|
||||||
}))
|
}))
|
||||||
@ -106,4 +113,8 @@ class BasePlugin
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* BASE_PLUGIN_HPP */
|
#endif /* BASE_PLUGIN_HPP */
|
||||||
|
@ -7,6 +7,13 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace plugins
|
||||||
|
{
|
||||||
|
|
||||||
template <class DataFacadeT> class TimestampPlugin final : public BasePlugin
|
template <class DataFacadeT> class TimestampPlugin final : public BasePlugin
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -16,7 +23,7 @@ template <class DataFacadeT> class TimestampPlugin final : public BasePlugin
|
|||||||
}
|
}
|
||||||
const std::string GetDescriptor() const override final { return descriptor_string; }
|
const std::string GetDescriptor() const override final { return descriptor_string; }
|
||||||
Status HandleRequest(const RouteParameters &route_parameters,
|
Status HandleRequest(const RouteParameters &route_parameters,
|
||||||
osrm::json::Object &json_result) override final
|
util::json::Object &json_result) override final
|
||||||
{
|
{
|
||||||
(void)route_parameters; // unused
|
(void)route_parameters; // unused
|
||||||
|
|
||||||
@ -30,4 +37,8 @@ template <class DataFacadeT> class TimestampPlugin final : public BasePlugin
|
|||||||
std::string descriptor_string;
|
std::string descriptor_string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* TIMESTAMP_PLUGIN_H */
|
#endif /* TIMESTAMP_PLUGIN_H */
|
||||||
|
@ -25,6 +25,13 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace plugins
|
||||||
|
{
|
||||||
|
|
||||||
template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -37,7 +44,7 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
|||||||
explicit RoundTripPlugin(DataFacadeT *facade, int max_locations_trip)
|
explicit RoundTripPlugin(DataFacadeT *facade, int max_locations_trip)
|
||||||
: descriptor_string("trip"), facade(facade), max_locations_trip(max_locations_trip)
|
: descriptor_string("trip"), facade(facade), max_locations_trip(max_locations_trip)
|
||||||
{
|
{
|
||||||
search_engine_ptr = osrm::make_unique<SearchEngine<DataFacadeT>>(facade);
|
search_engine_ptr = util::make_unique<SearchEngine<DataFacadeT>>(facade);
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string GetDescriptor() const override final { return descriptor_string; }
|
const std::string GetDescriptor() const override final { return descriptor_string; }
|
||||||
@ -51,7 +58,7 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
|||||||
phantom_node_list.reserve(route_parameters.coordinates.size());
|
phantom_node_list.reserve(route_parameters.coordinates.size());
|
||||||
|
|
||||||
// find phantom nodes for all input coords
|
// find phantom nodes for all input coords
|
||||||
for (const auto i : osrm::irange<std::size_t>(0, route_parameters.coordinates.size()))
|
for (const auto i : util::irange<std::size_t>(0, route_parameters.coordinates.size()))
|
||||||
{
|
{
|
||||||
// if client hints are helpful, encode hints
|
// if client hints are helpful, encode hints
|
||||||
if (checksum_OK && i < route_parameters.hints.size() &&
|
if (checksum_OK && i < route_parameters.hints.size() &&
|
||||||
@ -129,7 +136,7 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
|||||||
// identifies and splits the graph in its strongly connected components (scc)
|
// identifies and splits the graph in its strongly connected components (scc)
|
||||||
// and returns an SCC_Component
|
// and returns an SCC_Component
|
||||||
SCC_Component SplitUnaccessibleLocations(const std::size_t number_of_locations,
|
SCC_Component SplitUnaccessibleLocations(const std::size_t number_of_locations,
|
||||||
const DistTableWrapper<EdgeWeight> &result_table)
|
const util::DistTableWrapper<EdgeWeight> &result_table)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (std::find(std::begin(result_table), std::end(result_table), INVALID_EDGE_WEIGHT) ==
|
if (std::find(std::begin(result_table), std::end(result_table), INVALID_EDGE_WEIGHT) ==
|
||||||
@ -142,9 +149,9 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run TarjanSCC
|
// Run TarjanSCC
|
||||||
auto wrapper = std::make_shared<MatrixGraphWrapper<EdgeWeight>>(result_table.GetTable(),
|
auto wrapper = std::make_shared<util::MatrixGraphWrapper<EdgeWeight>>(result_table.GetTable(),
|
||||||
number_of_locations);
|
number_of_locations);
|
||||||
auto scc = TarjanSCC<MatrixGraphWrapper<EdgeWeight>>(wrapper);
|
auto scc = extractor::TarjanSCC<util::MatrixGraphWrapper<EdgeWeight>>(wrapper);
|
||||||
scc.run();
|
scc.run();
|
||||||
|
|
||||||
const auto number_of_components = scc.get_number_of_components();
|
const auto number_of_components = scc.get_number_of_components();
|
||||||
@ -174,9 +181,9 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SetLocPermutationOutput(const std::vector<NodeID> &permutation,
|
void SetLocPermutationOutput(const std::vector<NodeID> &permutation,
|
||||||
osrm::json::Object &json_result)
|
util::json::Object &json_result)
|
||||||
{
|
{
|
||||||
osrm::json::Array json_permutation;
|
util::json::Array json_permutation;
|
||||||
json_permutation.values.insert(std::end(json_permutation.values), std::begin(permutation),
|
json_permutation.values.insert(std::end(json_permutation.values), std::begin(permutation),
|
||||||
std::end(permutation));
|
std::end(permutation));
|
||||||
json_result.values["permutation"] = json_permutation;
|
json_result.values["permutation"] = json_permutation;
|
||||||
@ -218,7 +225,7 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
Status HandleRequest(const RouteParameters &route_parameters,
|
Status HandleRequest(const RouteParameters &route_parameters,
|
||||||
osrm::json::Object &json_result) override final
|
util::json::Object &json_result) override final
|
||||||
{
|
{
|
||||||
if (max_locations_trip > 0 &&
|
if (max_locations_trip > 0 &&
|
||||||
(static_cast<int>(route_parameters.coordinates.size()) > max_locations_trip))
|
(static_cast<int>(route_parameters.coordinates.size()) > max_locations_trip))
|
||||||
@ -259,7 +266,7 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
|||||||
const auto number_of_locations = phantom_node_list.size();
|
const auto number_of_locations = phantom_node_list.size();
|
||||||
|
|
||||||
// compute the distance table of all phantom nodes
|
// compute the distance table of all phantom nodes
|
||||||
const auto result_table = DistTableWrapper<EdgeWeight>(
|
const auto result_table = util::DistTableWrapper<EdgeWeight>(
|
||||||
*search_engine_ptr->distance_table(phantom_node_list, phantom_node_list),
|
*search_engine_ptr->distance_table(phantom_node_list, phantom_node_list),
|
||||||
number_of_locations);
|
number_of_locations);
|
||||||
|
|
||||||
@ -295,16 +302,16 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
|||||||
if (component_size < BF_MAX_FEASABLE)
|
if (component_size < BF_MAX_FEASABLE)
|
||||||
{
|
{
|
||||||
scc_route =
|
scc_route =
|
||||||
osrm::trip::BruteForceTrip(start, end, number_of_locations, result_table);
|
trip::BruteForceTrip(start, end, number_of_locations, result_table);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
scc_route = osrm::trip::FarthestInsertionTrip(start, end, number_of_locations,
|
scc_route = trip::FarthestInsertionTrip(start, end, number_of_locations,
|
||||||
result_table);
|
result_table);
|
||||||
}
|
}
|
||||||
|
|
||||||
// use this output if debugging of route is needed:
|
// use this output if debugging of route is needed:
|
||||||
// SimpleLogger().Write() << "Route #" << k << ": " << [&scc_route]()
|
// util::SimpleLogger().Write() << "Route #" << k << ": " << [&scc_route]()
|
||||||
// {
|
// {
|
||||||
// std::string s = "";
|
// std::string s = "";
|
||||||
// for (auto x : scc_route)
|
// for (auto x : scc_route)
|
||||||
@ -333,13 +340,13 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
|||||||
|
|
||||||
// prepare JSON output
|
// prepare JSON output
|
||||||
// create a json object for every trip
|
// create a json object for every trip
|
||||||
osrm::json::Array trip;
|
util::json::Array trip;
|
||||||
for (std::size_t i = 0; i < route_result.size(); ++i)
|
for (std::size_t i = 0; i < route_result.size(); ++i)
|
||||||
{
|
{
|
||||||
osrm::json::Object scc_trip;
|
util::json::Object scc_trip;
|
||||||
|
|
||||||
// annotate comp_route[i] as a json trip
|
// annotate comp_route[i] as a json trip
|
||||||
auto generator = osrm::engine::MakeApiResponseGenerator(facade);
|
auto generator = MakeApiResponseGenerator(facade);
|
||||||
generator.DescribeRoute(route_parameters, comp_route[i], scc_trip);
|
generator.DescribeRoute(route_parameters, comp_route[i], scc_trip);
|
||||||
|
|
||||||
// set permutation output
|
// set permutation output
|
||||||
@ -360,4 +367,8 @@ template <class DataFacadeT> class RoundTripPlugin final : public BasePlugin
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // TRIP_HPP
|
#endif // TRIP_HPP
|
||||||
|
@ -20,6 +20,13 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace plugins
|
||||||
|
{
|
||||||
|
|
||||||
template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -33,7 +40,7 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
|||||||
: descriptor_string("viaroute"), facade(facade),
|
: descriptor_string("viaroute"), facade(facade),
|
||||||
max_locations_viaroute(max_locations_viaroute)
|
max_locations_viaroute(max_locations_viaroute)
|
||||||
{
|
{
|
||||||
search_engine_ptr = osrm::make_unique<SearchEngine<DataFacadeT>>(facade);
|
search_engine_ptr = util::make_unique<SearchEngine<DataFacadeT>>(facade);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~ViaRoutePlugin() {}
|
virtual ~ViaRoutePlugin() {}
|
||||||
@ -41,7 +48,7 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
|||||||
const std::string GetDescriptor() const override final { return descriptor_string; }
|
const std::string GetDescriptor() const override final { return descriptor_string; }
|
||||||
|
|
||||||
Status HandleRequest(const RouteParameters &route_parameters,
|
Status HandleRequest(const RouteParameters &route_parameters,
|
||||||
osrm::json::Object &json_result) override final
|
util::json::Object &json_result) override final
|
||||||
{
|
{
|
||||||
if (max_locations_viaroute > 0 &&
|
if (max_locations_viaroute > 0 &&
|
||||||
(static_cast<int>(route_parameters.coordinates.size()) > max_locations_viaroute))
|
(static_cast<int>(route_parameters.coordinates.size()) > max_locations_viaroute))
|
||||||
@ -70,7 +77,7 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
|||||||
std::vector<PhantomNodePair> phantom_node_pair_list(route_parameters.coordinates.size());
|
std::vector<PhantomNodePair> phantom_node_pair_list(route_parameters.coordinates.size());
|
||||||
const bool checksum_OK = (route_parameters.check_sum == facade->GetCheckSum());
|
const bool checksum_OK = (route_parameters.check_sum == facade->GetCheckSum());
|
||||||
|
|
||||||
for (const auto i : osrm::irange<std::size_t>(0, route_parameters.coordinates.size()))
|
for (const auto i : util::irange<std::size_t>(0, route_parameters.coordinates.size()))
|
||||||
{
|
{
|
||||||
if (checksum_OK && i < route_parameters.hints.size() &&
|
if (checksum_OK && i < route_parameters.hints.size() &&
|
||||||
!route_parameters.hints[i].empty())
|
!route_parameters.hints[i].empty())
|
||||||
@ -108,7 +115,7 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
|||||||
{
|
{
|
||||||
raw_route.segment_end_coordinates.push_back(PhantomNodes{first_node, second_node});
|
raw_route.segment_end_coordinates.push_back(PhantomNodes{first_node, second_node});
|
||||||
};
|
};
|
||||||
osrm::for_each_pair(snapped_phantoms, build_phantom_pairs);
|
util::for_each_pair(snapped_phantoms, build_phantom_pairs);
|
||||||
|
|
||||||
if (1 == raw_route.segment_end_coordinates.size())
|
if (1 == raw_route.segment_end_coordinates.size())
|
||||||
{
|
{
|
||||||
@ -131,7 +138,7 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
|||||||
|
|
||||||
bool no_route = INVALID_EDGE_WEIGHT == raw_route.shortest_path_length;
|
bool no_route = INVALID_EDGE_WEIGHT == raw_route.shortest_path_length;
|
||||||
|
|
||||||
auto generator = osrm::engine::MakeApiResponseGenerator(facade);
|
auto generator = MakeApiResponseGenerator(facade);
|
||||||
generator.DescribeRoute(route_parameters, raw_route, json_result);
|
generator.DescribeRoute(route_parameters, raw_route, json_result);
|
||||||
|
|
||||||
// we can only know this after the fact, different SCC ids still
|
// we can only know this after the fact, different SCC ids still
|
||||||
@ -160,4 +167,8 @@ template <class DataFacadeT> class ViaRoutePlugin final : public BasePlugin
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // VIA_ROUTE_HPP
|
#endif // VIA_ROUTE_HPP
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
#ifndef POLYLINECOMPRESSOR_H_
|
#ifndef POLYLINECOMPRESSOR_H_
|
||||||
#define POLYLINECOMPRESSOR_H_
|
#define POLYLINECOMPRESSOR_H_
|
||||||
|
|
||||||
struct SegmentInformation;
|
|
||||||
|
|
||||||
#include "osrm/coordinate.hpp"
|
#include "osrm/coordinate.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
|
||||||
|
struct SegmentInformation;
|
||||||
|
|
||||||
class PolylineCompressor
|
class PolylineCompressor
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -18,7 +23,10 @@ class PolylineCompressor
|
|||||||
public:
|
public:
|
||||||
std::string get_encoded_string(const std::vector<SegmentInformation> &polyline) const;
|
std::string get_encoded_string(const std::vector<SegmentInformation> &polyline) const;
|
||||||
|
|
||||||
std::vector<FixedPointCoordinate> decode_string(const std::string &geometry_string) const;
|
std::vector<util::FixedPointCoordinate> decode_string(const std::string &geometry_string) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* POLYLINECOMPRESSOR_H_ */
|
#endif /* POLYLINECOMPRESSOR_H_ */
|
||||||
|
@ -1,18 +1,26 @@
|
|||||||
#ifndef POLYLINE_FORMATTER_HPP
|
#ifndef POLYLINE_FORMATTER_HPP
|
||||||
#define POLYLINE_FORMATTER_HPP
|
#define POLYLINE_FORMATTER_HPP
|
||||||
|
|
||||||
struct SegmentInformation;
|
|
||||||
|
|
||||||
#include "osrm/json_container.hpp"
|
#include "osrm/json_container.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
|
||||||
|
struct SegmentInformation;
|
||||||
|
|
||||||
struct PolylineFormatter
|
struct PolylineFormatter
|
||||||
{
|
{
|
||||||
osrm::json::String printEncodedString(const std::vector<SegmentInformation> &polyline) const;
|
util::json::String printEncodedString(const std::vector<SegmentInformation> &polyline) const;
|
||||||
|
|
||||||
osrm::json::Array printUnencodedString(const std::vector<SegmentInformation> &polyline) const;
|
util::json::Array printUnencodedString(const std::vector<SegmentInformation> &polyline) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* POLYLINE_FORMATTER_HPP */
|
#endif /* POLYLINE_FORMATTER_HPP */
|
||||||
|
@ -7,6 +7,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
|
||||||
struct RouteNames
|
struct RouteNames
|
||||||
{
|
{
|
||||||
std::string shortest_path_name_1;
|
std::string shortest_path_name_1;
|
||||||
@ -135,4 +140,7 @@ template <class DataFacadeT, class SegmentT> struct ExtractRouteNames
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // EXTRACT_ROUTE_NAMES_H
|
#endif // EXTRACT_ROUTE_NAMES_H
|
||||||
|
@ -13,6 +13,13 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace routing_algorithms
|
||||||
|
{
|
||||||
|
|
||||||
const double VIAPATH_ALPHA = 0.10;
|
const double VIAPATH_ALPHA = 0.10;
|
||||||
const double VIAPATH_EPSILON = 0.15; // alternative at most 15% longer
|
const double VIAPATH_EPSILON = 0.15; // alternative at most 15% longer
|
||||||
const double VIAPATH_GAMMA = 0.75; // alternative shares at most 75% with the shortest.
|
const double VIAPATH_GAMMA = 0.75; // alternative shares at most 75% with the shortest.
|
||||||
@ -81,7 +88,7 @@ class AlternativeRouting final
|
|||||||
|
|
||||||
if (phantom_node_pair.source_phantom.forward_node_id != SPECIAL_NODEID)
|
if (phantom_node_pair.source_phantom.forward_node_id != SPECIAL_NODEID)
|
||||||
{
|
{
|
||||||
// SimpleLogger().Write(logDEBUG) << "fwd-a insert: " <<
|
// util::SimpleLogger().Write(logDEBUG) << "fwd-a insert: " <<
|
||||||
// phantom_node_pair.source_phantom.forward_node_id << ", w: " <<
|
// phantom_node_pair.source_phantom.forward_node_id << ", w: " <<
|
||||||
// -phantom_node_pair.source_phantom.GetForwardWeightPlusOffset();
|
// -phantom_node_pair.source_phantom.GetForwardWeightPlusOffset();
|
||||||
forward_heap1.Insert(phantom_node_pair.source_phantom.forward_node_id,
|
forward_heap1.Insert(phantom_node_pair.source_phantom.forward_node_id,
|
||||||
@ -90,7 +97,7 @@ class AlternativeRouting final
|
|||||||
}
|
}
|
||||||
if (phantom_node_pair.source_phantom.reverse_node_id != SPECIAL_NODEID)
|
if (phantom_node_pair.source_phantom.reverse_node_id != SPECIAL_NODEID)
|
||||||
{
|
{
|
||||||
// SimpleLogger().Write(logDEBUG) << "fwd-b insert: " <<
|
// util::SimpleLogger().Write(logDEBUG) << "fwd-b insert: " <<
|
||||||
// phantom_node_pair.source_phantom.reverse_node_id << ", w: " <<
|
// phantom_node_pair.source_phantom.reverse_node_id << ", w: " <<
|
||||||
// -phantom_node_pair.source_phantom.GetReverseWeightPlusOffset();
|
// -phantom_node_pair.source_phantom.GetReverseWeightPlusOffset();
|
||||||
forward_heap1.Insert(phantom_node_pair.source_phantom.reverse_node_id,
|
forward_heap1.Insert(phantom_node_pair.source_phantom.reverse_node_id,
|
||||||
@ -100,7 +107,7 @@ class AlternativeRouting final
|
|||||||
|
|
||||||
if (phantom_node_pair.target_phantom.forward_node_id != SPECIAL_NODEID)
|
if (phantom_node_pair.target_phantom.forward_node_id != SPECIAL_NODEID)
|
||||||
{
|
{
|
||||||
// SimpleLogger().Write(logDEBUG) << "rev-a insert: " <<
|
// util::SimpleLogger().Write(logDEBUG) << "rev-a insert: " <<
|
||||||
// phantom_node_pair.target_phantom.forward_node_id << ", w: " <<
|
// phantom_node_pair.target_phantom.forward_node_id << ", w: " <<
|
||||||
// phantom_node_pair.target_phantom.GetForwardWeightPlusOffset();
|
// phantom_node_pair.target_phantom.GetForwardWeightPlusOffset();
|
||||||
reverse_heap1.Insert(phantom_node_pair.target_phantom.forward_node_id,
|
reverse_heap1.Insert(phantom_node_pair.target_phantom.forward_node_id,
|
||||||
@ -109,7 +116,7 @@ class AlternativeRouting final
|
|||||||
}
|
}
|
||||||
if (phantom_node_pair.target_phantom.reverse_node_id != SPECIAL_NODEID)
|
if (phantom_node_pair.target_phantom.reverse_node_id != SPECIAL_NODEID)
|
||||||
{
|
{
|
||||||
// SimpleLogger().Write(logDEBUG) << "rev-b insert: " <<
|
// util::SimpleLogger().Write(logDEBUG) << "rev-b insert: " <<
|
||||||
// phantom_node_pair.target_phantom.reverse_node_id << ", w: " <<
|
// phantom_node_pair.target_phantom.reverse_node_id << ", w: " <<
|
||||||
// phantom_node_pair.target_phantom.GetReverseWeightPlusOffset();
|
// phantom_node_pair.target_phantom.GetReverseWeightPlusOffset();
|
||||||
reverse_heap1.Insert(phantom_node_pair.target_phantom.reverse_node_id,
|
reverse_heap1.Insert(phantom_node_pair.target_phantom.reverse_node_id,
|
||||||
@ -141,7 +148,7 @@ class AlternativeRouting final
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
osrm::sort_unique_resize(via_node_candidate_list);
|
util::sort_unique_resize(via_node_candidate_list);
|
||||||
|
|
||||||
std::vector<NodeID> packed_forward_path;
|
std::vector<NodeID> packed_forward_path;
|
||||||
std::vector<NodeID> packed_reverse_path;
|
std::vector<NodeID> packed_reverse_path;
|
||||||
@ -204,10 +211,10 @@ class AlternativeRouting final
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// SimpleLogger().Write(logDEBUG) << "fwd_search_space size: " <<
|
// util::SimpleLogger().Write(logDEBUG) << "fwd_search_space size: " <<
|
||||||
// forward_search_space.size() << ", marked " << approximated_forward_sharing.size() << "
|
// forward_search_space.size() << ", marked " << approximated_forward_sharing.size() << "
|
||||||
// nodes";
|
// nodes";
|
||||||
// SimpleLogger().Write(logDEBUG) << "rev_search_space size: " <<
|
// util::SimpleLogger().Write(logDEBUG) << "rev_search_space size: " <<
|
||||||
// reverse_search_space.size() << ", marked " << approximated_reverse_sharing.size() << "
|
// reverse_search_space.size() << ", marked " << approximated_reverse_sharing.size() << "
|
||||||
// nodes";
|
// nodes";
|
||||||
|
|
||||||
@ -403,7 +410,7 @@ class AlternativeRouting final
|
|||||||
// First partially unpack s-->v until paths deviate, note length of common path.
|
// First partially unpack s-->v until paths deviate, note length of common path.
|
||||||
const int64_t s_v_min_path_size =
|
const int64_t s_v_min_path_size =
|
||||||
static_cast<int64_t>(std::min(packed_s_v_path.size(), packed_shortest_path.size())) - 1;
|
static_cast<int64_t>(std::min(packed_s_v_path.size(), packed_shortest_path.size())) - 1;
|
||||||
for (const int64_t current_node : osrm::irange<int64_t>(0, s_v_min_path_size))
|
for (const int64_t current_node : util::irange<int64_t>(0, s_v_min_path_size))
|
||||||
{
|
{
|
||||||
if (packed_s_v_path[current_node] == packed_shortest_path[current_node] &&
|
if (packed_s_v_path[current_node] == packed_shortest_path[current_node] &&
|
||||||
packed_s_v_path[current_node + 1] == packed_shortest_path[current_node + 1])
|
packed_s_v_path[current_node + 1] == packed_shortest_path[current_node + 1])
|
||||||
@ -519,7 +526,7 @@ class AlternativeRouting final
|
|||||||
// //compute forward sharing
|
// //compute forward sharing
|
||||||
// while( (packed_alternate_path[aindex] == packed_shortest_path[aindex]) &&
|
// while( (packed_alternate_path[aindex] == packed_shortest_path[aindex]) &&
|
||||||
// (packed_alternate_path[aindex+1] == packed_shortest_path[aindex+1]) ) {
|
// (packed_alternate_path[aindex+1] == packed_shortest_path[aindex+1]) ) {
|
||||||
// // SimpleLogger().Write() << "retrieving edge (" <<
|
// // util::SimpleLogger().Write() << "retrieving edge (" <<
|
||||||
// packed_alternate_path[aindex] << "," << packed_alternate_path[aindex+1] << ")";
|
// packed_alternate_path[aindex] << "," << packed_alternate_path[aindex+1] << ")";
|
||||||
// EdgeID edgeID = facade->FindEdgeInEitherDirection(packed_alternate_path[aindex],
|
// EdgeID edgeID = facade->FindEdgeInEitherDirection(packed_alternate_path[aindex],
|
||||||
// packed_alternate_path[aindex+1]);
|
// packed_alternate_path[aindex+1]);
|
||||||
@ -557,7 +564,7 @@ class AlternativeRouting final
|
|||||||
const NodeID node = forward_heap.DeleteMin();
|
const NodeID node = forward_heap.DeleteMin();
|
||||||
const int distance = forward_heap.GetKey(node);
|
const int distance = forward_heap.GetKey(node);
|
||||||
// const NodeID parentnode = forward_heap.GetData(node).parent;
|
// const NodeID parentnode = forward_heap.GetData(node).parent;
|
||||||
// SimpleLogger().Write() << (is_forward_directed ? "[fwd] " : "[rev] ") << "settled edge ("
|
// util::SimpleLogger().Write() << (is_forward_directed ? "[fwd] " : "[rev] ") << "settled edge ("
|
||||||
// << parentnode << "," << node << "), dist: " << distance;
|
// << parentnode << "," << node << "), dist: " << distance;
|
||||||
|
|
||||||
const int scaled_distance =
|
const int scaled_distance =
|
||||||
@ -581,10 +588,10 @@ class AlternativeRouting final
|
|||||||
{
|
{
|
||||||
*middle_node = node;
|
*middle_node = node;
|
||||||
*upper_bound_to_shortest_path_distance = new_distance;
|
*upper_bound_to_shortest_path_distance = new_distance;
|
||||||
// SimpleLogger().Write() << "accepted middle_node " << *middle_node << " at
|
// util::SimpleLogger().Write() << "accepted middle_node " << *middle_node << " at
|
||||||
// distance " << new_distance;
|
// distance " << new_distance;
|
||||||
// } else {
|
// } else {
|
||||||
// SimpleLogger().Write() << "discarded middle_node " << *middle_node << "
|
// util::SimpleLogger().Write() << "discarded middle_node " << *middle_node << "
|
||||||
// at distance " << new_distance;
|
// at distance " << new_distance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -840,4 +847,8 @@ class AlternativeRouting final
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* ALTERNATIVE_PATH_ROUTING_HPP */
|
#endif /* ALTERNATIVE_PATH_ROUTING_HPP */
|
||||||
|
@ -10,6 +10,13 @@
|
|||||||
#include "util/timing_util.hpp"
|
#include "util/timing_util.hpp"
|
||||||
#include "util/typedefs.hpp"
|
#include "util/typedefs.hpp"
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace routing_algorithms
|
||||||
|
{
|
||||||
|
|
||||||
/// This is a striped down version of the general shortest path algorithm.
|
/// This is a striped down version of the general shortest path algorithm.
|
||||||
/// The general algorithm always computes two queries for each leg. This is only
|
/// The general algorithm always computes two queries for each leg. This is only
|
||||||
/// necessary in case of vias, where the directions of the start node is constrainted
|
/// necessary in case of vias, where the directions of the start node is constrainted
|
||||||
@ -125,4 +132,8 @@ class DirectShortestPathRouting final
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* DIRECT_SHORTEST_PATH_HPP */
|
#endif /* DIRECT_SHORTEST_PATH_HPP */
|
||||||
|
@ -12,6 +12,13 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace routing_algorithms
|
||||||
|
{
|
||||||
|
|
||||||
template <class DataFacadeT>
|
template <class DataFacadeT>
|
||||||
class ManyToManyRouting final
|
class ManyToManyRouting final
|
||||||
: public BasicRoutingInterface<DataFacadeT, ManyToManyRouting<DataFacadeT>>
|
: public BasicRoutingInterface<DataFacadeT, ManyToManyRouting<DataFacadeT>>
|
||||||
@ -226,4 +233,8 @@ class ManyToManyRouting final
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,7 +19,9 @@
|
|||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
namespace matching
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace routing_algorithms
|
||||||
{
|
{
|
||||||
|
|
||||||
struct SubMatching
|
struct SubMatching
|
||||||
@ -32,15 +34,12 @@ struct SubMatching
|
|||||||
|
|
||||||
using CandidateList = std::vector<PhantomNodeWithDistance>;
|
using CandidateList = std::vector<PhantomNodeWithDistance>;
|
||||||
using CandidateLists = std::vector<CandidateList>;
|
using CandidateLists = std::vector<CandidateList>;
|
||||||
using HMM = HiddenMarkovModel<CandidateLists>;
|
using HMM = map_matching::HiddenMarkovModel<CandidateLists>;
|
||||||
using SubMatchingList = std::vector<SubMatching>;
|
using SubMatchingList = std::vector<SubMatching>;
|
||||||
|
|
||||||
constexpr static const unsigned MAX_BROKEN_STATES = 10;
|
constexpr static const unsigned MAX_BROKEN_STATES = 10;
|
||||||
|
|
||||||
constexpr static const double MAX_SPEED = 180 / 3.6; // 180km -> m/s
|
constexpr static const double MAX_SPEED = 180 / 3.6; // 180km -> m/s
|
||||||
constexpr static const unsigned SUSPICIOUS_DISTANCE_DELTA = 100;
|
constexpr static const unsigned SUSPICIOUS_DISTANCE_DELTA = 100;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// implements a hidden markov model map matching algorithm
|
// implements a hidden markov model map matching algorithm
|
||||||
template <class DataFacadeT>
|
template <class DataFacadeT>
|
||||||
@ -71,12 +70,12 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(const osrm::matching::CandidateLists &candidates_list,
|
void operator()(const CandidateLists &candidates_list,
|
||||||
const std::vector<FixedPointCoordinate> &trace_coordinates,
|
const std::vector<util::FixedPointCoordinate> &trace_coordinates,
|
||||||
const std::vector<unsigned> &trace_timestamps,
|
const std::vector<unsigned> &trace_timestamps,
|
||||||
const double matching_beta,
|
const double matching_beta,
|
||||||
const double gps_precision,
|
const double gps_precision,
|
||||||
osrm::matching::SubMatchingList &sub_matchings) const
|
SubMatchingList &sub_matchings) const
|
||||||
{
|
{
|
||||||
BOOST_ASSERT(candidates_list.size() == trace_coordinates.size());
|
BOOST_ASSERT(candidates_list.size() == trace_coordinates.size());
|
||||||
BOOST_ASSERT(candidates_list.size() > 1);
|
BOOST_ASSERT(candidates_list.size() > 1);
|
||||||
@ -94,12 +93,12 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
|||||||
return 1u;
|
return 1u;
|
||||||
}
|
}
|
||||||
}();
|
}();
|
||||||
const auto max_broken_time = median_sample_time * osrm::matching::MAX_BROKEN_STATES;
|
const auto max_broken_time = median_sample_time * MAX_BROKEN_STATES;
|
||||||
const auto max_distance_delta = [&]()
|
const auto max_distance_delta = [&]()
|
||||||
{
|
{
|
||||||
if (use_timestamps)
|
if (use_timestamps)
|
||||||
{
|
{
|
||||||
return median_sample_time * osrm::matching::MAX_SPEED;
|
return median_sample_time * MAX_SPEED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -108,18 +107,18 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
|||||||
}();
|
}();
|
||||||
|
|
||||||
// TODO replace default values with table lookup based on sampling frequency
|
// TODO replace default values with table lookup based on sampling frequency
|
||||||
EmissionLogProbability emission_log_probability(gps_precision);
|
map_matching::EmissionLogProbability emission_log_probability(gps_precision);
|
||||||
TransitionLogProbability transition_log_probability(matching_beta);
|
map_matching::TransitionLogProbability transition_log_probability(matching_beta);
|
||||||
|
|
||||||
osrm::matching::HMM model(candidates_list, emission_log_probability);
|
HMM model(candidates_list, emission_log_probability);
|
||||||
|
|
||||||
std::size_t initial_timestamp = model.initialize(0);
|
std::size_t initial_timestamp = model.initialize(0);
|
||||||
if (initial_timestamp == osrm::matching::INVALID_STATE)
|
if (initial_timestamp == map_matching::INVALID_STATE)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MatchingDebugInfo matching_debug(osrm::json::Logger::get());
|
util::MatchingDebugInfo matching_debug(util::json::Logger::get());
|
||||||
matching_debug.initialize(candidates_list);
|
matching_debug.initialize(candidates_list);
|
||||||
|
|
||||||
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
|
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
|
||||||
@ -128,7 +127,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
|||||||
QueryHeap &forward_heap = *(engine_working_data.forward_heap_1);
|
QueryHeap &forward_heap = *(engine_working_data.forward_heap_1);
|
||||||
QueryHeap &reverse_heap = *(engine_working_data.reverse_heap_1);
|
QueryHeap &reverse_heap = *(engine_working_data.reverse_heap_1);
|
||||||
|
|
||||||
std::size_t breakage_begin = osrm::matching::INVALID_STATE;
|
std::size_t breakage_begin = map_matching::INVALID_STATE;
|
||||||
std::vector<std::size_t> split_points;
|
std::vector<std::size_t> split_points;
|
||||||
std::vector<std::size_t> prev_unbroken_timestamps;
|
std::vector<std::size_t> prev_unbroken_timestamps;
|
||||||
prev_unbroken_timestamps.reserve(candidates_list.size());
|
prev_unbroken_timestamps.reserve(candidates_list.size());
|
||||||
@ -149,16 +148,16 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
trace_split = trace_split || (t - prev_unbroken_timestamps.back() >
|
trace_split = trace_split || (t - prev_unbroken_timestamps.back() >
|
||||||
osrm::matching::MAX_BROKEN_STATES);
|
MAX_BROKEN_STATES);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (trace_split)
|
if (trace_split)
|
||||||
{
|
{
|
||||||
std::size_t split_index = t;
|
std::size_t split_index = t;
|
||||||
if (breakage_begin != osrm::matching::INVALID_STATE)
|
if (breakage_begin != map_matching::INVALID_STATE)
|
||||||
{
|
{
|
||||||
split_index = breakage_begin;
|
split_index = breakage_begin;
|
||||||
breakage_begin = osrm::matching::INVALID_STATE;
|
breakage_begin = map_matching::INVALID_STATE;
|
||||||
}
|
}
|
||||||
split_points.push_back(split_index);
|
split_points.push_back(split_index);
|
||||||
|
|
||||||
@ -166,7 +165,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
|||||||
model.clear(split_index);
|
model.clear(split_index);
|
||||||
std::size_t new_start = model.initialize(split_index);
|
std::size_t new_start = model.initialize(split_index);
|
||||||
// no new start was found -> stop viterbi calculation
|
// no new start was found -> stop viterbi calculation
|
||||||
if (new_start == osrm::matching::INVALID_STATE)
|
if (new_start == map_matching::INVALID_STATE)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -196,17 +195,17 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
|||||||
const auto ¤t_coordinate = trace_coordinates[t];
|
const auto ¤t_coordinate = trace_coordinates[t];
|
||||||
|
|
||||||
const auto haversine_distance =
|
const auto haversine_distance =
|
||||||
coordinate_calculation::haversineDistance(prev_coordinate, current_coordinate);
|
util::coordinate_calculation::haversineDistance(prev_coordinate, current_coordinate);
|
||||||
|
|
||||||
// compute d_t for this timestamp and the next one
|
// compute d_t for this timestamp and the next one
|
||||||
for (const auto s : osrm::irange<std::size_t>(0u, prev_viterbi.size()))
|
for (const auto s : util::irange<std::size_t>(0u, prev_viterbi.size()))
|
||||||
{
|
{
|
||||||
if (prev_pruned[s])
|
if (prev_pruned[s])
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto s_prime : osrm::irange<std::size_t>(0u, current_viterbi.size()))
|
for (const auto s_prime : util::irange<std::size_t>(0u, current_viterbi.size()))
|
||||||
{
|
{
|
||||||
// how likely is candidate s_prime at time t to be emitted?
|
// how likely is candidate s_prime at time t to be emitted?
|
||||||
// FIXME this can be pre-computed
|
// FIXME this can be pre-computed
|
||||||
@ -248,7 +247,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
|||||||
current_lengths[s_prime] = network_distance;
|
current_lengths[s_prime] = network_distance;
|
||||||
current_pruned[s_prime] = false;
|
current_pruned[s_prime] = false;
|
||||||
current_suspicious[s_prime] =
|
current_suspicious[s_prime] =
|
||||||
d_t > osrm::matching::SUSPICIOUS_DISTANCE_DELTA;
|
d_t > SUSPICIOUS_DISTANCE_DELTA;
|
||||||
model.breakage[t] = false;
|
model.breakage[t] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,7 +281,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
|||||||
std::size_t sub_matching_begin = initial_timestamp;
|
std::size_t sub_matching_begin = initial_timestamp;
|
||||||
for (const auto sub_matching_end : split_points)
|
for (const auto sub_matching_end : split_points)
|
||||||
{
|
{
|
||||||
osrm::matching::SubMatching matching;
|
SubMatching matching;
|
||||||
|
|
||||||
std::size_t parent_timestamp_index = sub_matching_end - 1;
|
std::size_t parent_timestamp_index = sub_matching_end - 1;
|
||||||
while (parent_timestamp_index >= sub_matching_begin &&
|
while (parent_timestamp_index >= sub_matching_begin &&
|
||||||
@ -338,7 +337,7 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
|||||||
matching.length = 0.0;
|
matching.length = 0.0;
|
||||||
matching.nodes.resize(reconstructed_indices.size());
|
matching.nodes.resize(reconstructed_indices.size());
|
||||||
matching.indices.resize(reconstructed_indices.size());
|
matching.indices.resize(reconstructed_indices.size());
|
||||||
for (const auto i : osrm::irange<std::size_t>(0u, reconstructed_indices.size()))
|
for (const auto i : util::irange<std::size_t>(0u, reconstructed_indices.size()))
|
||||||
{
|
{
|
||||||
const auto timestamp_index = reconstructed_indices[i].first;
|
const auto timestamp_index = reconstructed_indices[i].first;
|
||||||
const auto location_index = reconstructed_indices[i].second;
|
const auto location_index = reconstructed_indices[i].second;
|
||||||
@ -357,6 +356,10 @@ class MapMatching final : public BasicRoutingInterface<DataFacadeT, MapMatching<
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//[1] "Hidden Markov Map Matching Through Noise and Sparseness"; P. Newson and J. Krumm; 2009; ACM
|
//[1] "Hidden Markov Map Matching Through Noise and Sparseness"; P. Newson and J. Krumm; 2009; ACM
|
||||||
// GIS
|
// GIS
|
||||||
|
|
||||||
|
@ -10,6 +10,11 @@
|
|||||||
|
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
|
||||||
SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_1;
|
SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_1;
|
||||||
SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_1;
|
SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_1;
|
||||||
SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_2;
|
SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_2;
|
||||||
@ -17,6 +22,10 @@ SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_2;
|
|||||||
SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_3;
|
SearchEngineData::SearchEngineHeapPtr SearchEngineData::forward_heap_3;
|
||||||
SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_3;
|
SearchEngineData::SearchEngineHeapPtr SearchEngineData::reverse_heap_3;
|
||||||
|
|
||||||
|
namespace routing_algorithms
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -222,8 +231,8 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
|||||||
{
|
{
|
||||||
BOOST_ASSERT_MSG(!ed.shortcut, "original edge flagged as shortcut");
|
BOOST_ASSERT_MSG(!ed.shortcut, "original edge flagged as shortcut");
|
||||||
unsigned name_index = facade->GetNameIndexFromEdgeID(ed.id);
|
unsigned name_index = facade->GetNameIndexFromEdgeID(ed.id);
|
||||||
const TurnInstruction turn_instruction = facade->GetTurnInstructionForEdgeID(ed.id);
|
const extractor::TurnInstruction turn_instruction = facade->GetTurnInstructionForEdgeID(ed.id);
|
||||||
const TravelMode travel_mode = facade->GetTravelModeForEdgeID(ed.id);
|
const extractor::TravelMode travel_mode = facade->GetTravelModeForEdgeID(ed.id);
|
||||||
|
|
||||||
if (!facade->EdgeIsCompressed(ed.id))
|
if (!facade->EdgeIsCompressed(ed.id))
|
||||||
{
|
{
|
||||||
@ -251,7 +260,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
|||||||
for (std::size_t i = start_index; i < end_index; ++i)
|
for (std::size_t i = start_index; i < end_index; ++i)
|
||||||
{
|
{
|
||||||
unpacked_path.emplace_back(id_vector[i], name_index,
|
unpacked_path.emplace_back(id_vector[i], name_index,
|
||||||
TurnInstruction::NoTurn, 0, travel_mode);
|
extractor::TurnInstruction::NoTurn, 0, travel_mode);
|
||||||
}
|
}
|
||||||
unpacked_path.back().turn_instruction = turn_instruction;
|
unpacked_path.back().turn_instruction = turn_instruction;
|
||||||
unpacked_path.back().segment_duration = ed.distance;
|
unpacked_path.back().segment_duration = ed.distance;
|
||||||
@ -296,7 +305,7 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
|||||||
BOOST_ASSERT(i < id_vector.size());
|
BOOST_ASSERT(i < id_vector.size());
|
||||||
BOOST_ASSERT(phantom_node_pair.target_phantom.forward_travel_mode > 0);
|
BOOST_ASSERT(phantom_node_pair.target_phantom.forward_travel_mode > 0);
|
||||||
unpacked_path.emplace_back(PathData{
|
unpacked_path.emplace_back(PathData{
|
||||||
id_vector[i], phantom_node_pair.target_phantom.name_id, TurnInstruction::NoTurn,
|
id_vector[i], phantom_node_pair.target_phantom.name_id, extractor::TurnInstruction::NoTurn,
|
||||||
0, phantom_node_pair.target_phantom.forward_travel_mode});
|
0, phantom_node_pair.target_phantom.forward_travel_mode});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -642,21 +651,25 @@ template <class DataFacadeT, class Derived> class BasicRoutingInterface
|
|||||||
nodes.target_phantom = target_phantom;
|
nodes.target_phantom = target_phantom;
|
||||||
UnpackPath(packed_leg.begin(), packed_leg.end(), nodes, unpacked_path);
|
UnpackPath(packed_leg.begin(), packed_leg.end(), nodes, unpacked_path);
|
||||||
|
|
||||||
FixedPointCoordinate previous_coordinate = source_phantom.location;
|
util::FixedPointCoordinate previous_coordinate = source_phantom.location;
|
||||||
FixedPointCoordinate current_coordinate;
|
util::FixedPointCoordinate current_coordinate;
|
||||||
distance = 0;
|
distance = 0;
|
||||||
for (const auto &p : unpacked_path)
|
for (const auto &p : unpacked_path)
|
||||||
{
|
{
|
||||||
current_coordinate = facade->GetCoordinateOfNode(p.node);
|
current_coordinate = facade->GetCoordinateOfNode(p.node);
|
||||||
distance += coordinate_calculation::haversineDistance(previous_coordinate,
|
distance += util::coordinate_calculation::haversineDistance(previous_coordinate,
|
||||||
current_coordinate);
|
current_coordinate);
|
||||||
previous_coordinate = current_coordinate;
|
previous_coordinate = current_coordinate;
|
||||||
}
|
}
|
||||||
distance += coordinate_calculation::haversineDistance(previous_coordinate,
|
distance += util::coordinate_calculation::haversineDistance(previous_coordinate,
|
||||||
target_phantom.location);
|
target_phantom.location);
|
||||||
}
|
}
|
||||||
return distance;
|
return distance;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // ROUTING_BASE_HPP
|
#endif // ROUTING_BASE_HPP
|
||||||
|
@ -10,6 +10,13 @@
|
|||||||
|
|
||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
namespace routing_algorithms
|
||||||
|
{
|
||||||
|
|
||||||
template <class DataFacadeT>
|
template <class DataFacadeT>
|
||||||
class ShortestPathRouting final
|
class ShortestPathRouting final
|
||||||
: public BasicRoutingInterface<DataFacadeT, ShortestPathRouting<DataFacadeT>>
|
: public BasicRoutingInterface<DataFacadeT, ShortestPathRouting<DataFacadeT>>
|
||||||
@ -262,7 +269,7 @@ class ShortestPathRouting final
|
|||||||
|
|
||||||
raw_route_data.shortest_path_length = shortest_path_length;
|
raw_route_data.shortest_path_length = shortest_path_length;
|
||||||
|
|
||||||
for (const auto current_leg : osrm::irange<std::size_t>(0, packed_leg_begin.size() - 1))
|
for (const auto current_leg : util::irange<std::size_t>(0, packed_leg_begin.size() - 1))
|
||||||
{
|
{
|
||||||
auto leg_begin = total_packed_path.begin() + packed_leg_begin[current_leg];
|
auto leg_begin = total_packed_path.begin() + packed_leg_begin[current_leg];
|
||||||
auto leg_end = total_packed_path.begin() + packed_leg_begin[current_leg + 1];
|
auto leg_end = total_packed_path.begin() + packed_leg_begin[current_leg + 1];
|
||||||
@ -515,4 +522,8 @@ class ShortestPathRouting final
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* SHORTEST_PATH_HPP */
|
#endif /* SHORTEST_PATH_HPP */
|
||||||
|
@ -10,6 +10,11 @@
|
|||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
|
||||||
template <class DataFacadeT> class SearchEngine
|
template <class DataFacadeT> class SearchEngine
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -17,11 +22,11 @@ template <class DataFacadeT> class SearchEngine
|
|||||||
SearchEngineData engine_working_data;
|
SearchEngineData engine_working_data;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ShortestPathRouting<DataFacadeT> shortest_path;
|
routing_algorithms::ShortestPathRouting<DataFacadeT> shortest_path;
|
||||||
DirectShortestPathRouting<DataFacadeT> direct_shortest_path;
|
routing_algorithms::DirectShortestPathRouting<DataFacadeT> direct_shortest_path;
|
||||||
AlternativeRouting<DataFacadeT> alternative_path;
|
routing_algorithms::AlternativeRouting<DataFacadeT> alternative_path;
|
||||||
ManyToManyRouting<DataFacadeT> distance_table;
|
routing_algorithms::ManyToManyRouting<DataFacadeT> distance_table;
|
||||||
MapMatching<DataFacadeT> map_matching;
|
routing_algorithms::MapMatching<DataFacadeT> map_matching;
|
||||||
|
|
||||||
explicit SearchEngine(DataFacadeT *facade)
|
explicit SearchEngine(DataFacadeT *facade)
|
||||||
: facade(facade), shortest_path(facade, engine_working_data),
|
: facade(facade), shortest_path(facade, engine_working_data),
|
||||||
@ -37,4 +42,7 @@ template <class DataFacadeT> class SearchEngine
|
|||||||
~SearchEngine() {}
|
~SearchEngine() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // SEARCH_ENGINE_HPP
|
#endif // SEARCH_ENGINE_HPP
|
||||||
|
@ -6,6 +6,11 @@
|
|||||||
#include "util/typedefs.hpp"
|
#include "util/typedefs.hpp"
|
||||||
#include "util/binary_heap.hpp"
|
#include "util/binary_heap.hpp"
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
|
||||||
struct HeapData
|
struct HeapData
|
||||||
{
|
{
|
||||||
NodeID parent;
|
NodeID parent;
|
||||||
@ -14,7 +19,7 @@ struct HeapData
|
|||||||
|
|
||||||
struct SearchEngineData
|
struct SearchEngineData
|
||||||
{
|
{
|
||||||
using QueryHeap = BinaryHeap<NodeID, NodeID, int, HeapData, UnorderedMapStorage<NodeID, int>>;
|
using QueryHeap = util::BinaryHeap<NodeID, NodeID, int, HeapData, util::UnorderedMapStorage<NodeID, int>>;
|
||||||
using SearchEngineHeapPtr = boost::thread_specific_ptr<QueryHeap>;
|
using SearchEngineHeapPtr = boost::thread_specific_ptr<QueryHeap>;
|
||||||
|
|
||||||
static SearchEngineHeapPtr forward_heap_1;
|
static SearchEngineHeapPtr forward_heap_1;
|
||||||
@ -31,4 +36,7 @@ struct SearchEngineData
|
|||||||
void InitializeOrClearThirdThreadLocalStorage(const unsigned number_of_nodes);
|
void InitializeOrClearThirdThreadLocalStorage(const unsigned number_of_nodes);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // SEARCH_ENGINE_DATA_HPP
|
#endif // SEARCH_ENGINE_DATA_HPP
|
||||||
|
@ -2,53 +2,60 @@
|
|||||||
#define SEGMENT_INFORMATION_HPP
|
#define SEGMENT_INFORMATION_HPP
|
||||||
|
|
||||||
#include "extractor/turn_instructions.hpp"
|
#include "extractor/turn_instructions.hpp"
|
||||||
|
|
||||||
#include "extractor/travel_mode.hpp"
|
#include "extractor/travel_mode.hpp"
|
||||||
#include "util/typedefs.hpp"
|
#include "util/typedefs.hpp"
|
||||||
|
|
||||||
#include "osrm/coordinate.hpp"
|
#include "osrm/coordinate.hpp"
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
|
||||||
// Struct fits everything in one cache line
|
// Struct fits everything in one cache line
|
||||||
struct SegmentInformation
|
struct SegmentInformation
|
||||||
{
|
{
|
||||||
FixedPointCoordinate location;
|
util::FixedPointCoordinate location;
|
||||||
NodeID name_id;
|
NodeID name_id;
|
||||||
EdgeWeight duration;
|
EdgeWeight duration;
|
||||||
float length;
|
float length;
|
||||||
short pre_turn_bearing; // more than enough [0..3600] fits into 12 bits
|
short pre_turn_bearing; // more than enough [0..3600] fits into 12 bits
|
||||||
short post_turn_bearing;
|
short post_turn_bearing;
|
||||||
TurnInstruction turn_instruction;
|
extractor::TurnInstruction turn_instruction;
|
||||||
TravelMode travel_mode;
|
extractor::TravelMode travel_mode;
|
||||||
bool necessary;
|
bool necessary;
|
||||||
bool is_via_location;
|
bool is_via_location;
|
||||||
|
|
||||||
explicit SegmentInformation(FixedPointCoordinate location,
|
explicit SegmentInformation(util::FixedPointCoordinate location,
|
||||||
const NodeID name_id,
|
const NodeID name_id,
|
||||||
const EdgeWeight duration,
|
const EdgeWeight duration,
|
||||||
const float length,
|
const float length,
|
||||||
const TurnInstruction turn_instruction,
|
const extractor::TurnInstruction turn_instruction,
|
||||||
const bool necessary,
|
const bool necessary,
|
||||||
const bool is_via_location,
|
const bool is_via_location,
|
||||||
const TravelMode travel_mode)
|
const extractor::TravelMode travel_mode)
|
||||||
: location(std::move(location)), name_id(name_id), duration(duration), length(length),
|
: location(std::move(location)), name_id(name_id), duration(duration), length(length),
|
||||||
pre_turn_bearing(0), post_turn_bearing(0), turn_instruction(turn_instruction),
|
pre_turn_bearing(0), post_turn_bearing(0), turn_instruction(turn_instruction),
|
||||||
travel_mode(travel_mode), necessary(necessary), is_via_location(is_via_location)
|
travel_mode(travel_mode), necessary(necessary), is_via_location(is_via_location)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
explicit SegmentInformation(FixedPointCoordinate location,
|
explicit SegmentInformation(util::FixedPointCoordinate location,
|
||||||
const NodeID name_id,
|
const NodeID name_id,
|
||||||
const EdgeWeight duration,
|
const EdgeWeight duration,
|
||||||
const float length,
|
const float length,
|
||||||
const TurnInstruction turn_instruction,
|
const extractor::TurnInstruction turn_instruction,
|
||||||
const TravelMode travel_mode)
|
const extractor::TravelMode travel_mode)
|
||||||
: location(std::move(location)), name_id(name_id), duration(duration), length(length),
|
: location(std::move(location)), name_id(name_id), duration(duration), length(length),
|
||||||
pre_turn_bearing(0), post_turn_bearing(0), turn_instruction(turn_instruction),
|
pre_turn_bearing(0), post_turn_bearing(0), turn_instruction(turn_instruction),
|
||||||
travel_mode(travel_mode), necessary(turn_instruction != TurnInstruction::NoTurn),
|
travel_mode(travel_mode), necessary(turn_instruction != extractor::TurnInstruction::NoTurn),
|
||||||
is_via_location(false)
|
is_via_location(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* SEGMENT_INFORMATION_HPP */
|
#endif /* SEGMENT_INFORMATION_HPP */
|
||||||
|
@ -16,11 +16,13 @@
|
|||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
namespace trip
|
namespace trip
|
||||||
{
|
{
|
||||||
|
|
||||||
// computes the distance of a given permutation
|
// computes the distance of a given permutation
|
||||||
EdgeWeight ReturnDistance(const DistTableWrapper<EdgeWeight> &dist_table,
|
EdgeWeight ReturnDistance(const util::DistTableWrapper<EdgeWeight> &dist_table,
|
||||||
const std::vector<NodeID> &location_order,
|
const std::vector<NodeID> &location_order,
|
||||||
const EdgeWeight min_route_dist,
|
const EdgeWeight min_route_dist,
|
||||||
const std::size_t component_size)
|
const std::size_t component_size)
|
||||||
@ -44,7 +46,7 @@ template <typename NodeIDIterator>
|
|||||||
std::vector<NodeID> BruteForceTrip(const NodeIDIterator start,
|
std::vector<NodeID> BruteForceTrip(const NodeIDIterator start,
|
||||||
const NodeIDIterator end,
|
const NodeIDIterator end,
|
||||||
const std::size_t number_of_locations,
|
const std::size_t number_of_locations,
|
||||||
const DistTableWrapper<EdgeWeight> &dist_table)
|
const util::DistTableWrapper<EdgeWeight> &dist_table)
|
||||||
{
|
{
|
||||||
(void)number_of_locations; // unused
|
(void)number_of_locations; // unused
|
||||||
|
|
||||||
@ -76,6 +78,8 @@ std::vector<NodeID> BruteForceTrip(const NodeIDIterator start,
|
|||||||
return route;
|
return route;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace trip
|
}
|
||||||
} // end namespace osrm
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // TRIP_BRUTE_FORCE_HPP
|
#endif // TRIP_BRUTE_FORCE_HPP
|
||||||
|
@ -15,6 +15,8 @@
|
|||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
namespace trip
|
namespace trip
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -23,7 +25,7 @@ namespace trip
|
|||||||
using NodeIDIter = std::vector<NodeID>::iterator;
|
using NodeIDIter = std::vector<NodeID>::iterator;
|
||||||
std::pair<EdgeWeight, NodeIDIter>
|
std::pair<EdgeWeight, NodeIDIter>
|
||||||
GetShortestRoundTrip(const NodeID new_loc,
|
GetShortestRoundTrip(const NodeID new_loc,
|
||||||
const DistTableWrapper<EdgeWeight> &dist_table,
|
const util::DistTableWrapper<EdgeWeight> &dist_table,
|
||||||
const std::size_t number_of_locations,
|
const std::size_t number_of_locations,
|
||||||
std::vector<NodeID> &route)
|
std::vector<NodeID> &route)
|
||||||
{
|
{
|
||||||
@ -76,7 +78,7 @@ std::vector<NodeID> FindRoute(const std::size_t &number_of_locations,
|
|||||||
const std::size_t &component_size,
|
const std::size_t &component_size,
|
||||||
const NodeIDIterator &start,
|
const NodeIDIterator &start,
|
||||||
const NodeIDIterator &end,
|
const NodeIDIterator &end,
|
||||||
const DistTableWrapper<EdgeWeight> &dist_table,
|
const util::DistTableWrapper<EdgeWeight> &dist_table,
|
||||||
const NodeID &start1,
|
const NodeID &start1,
|
||||||
const NodeID &start2)
|
const NodeID &start2)
|
||||||
{
|
{
|
||||||
@ -138,7 +140,7 @@ template <typename NodeIDIterator>
|
|||||||
std::vector<NodeID> FarthestInsertionTrip(const NodeIDIterator &start,
|
std::vector<NodeID> FarthestInsertionTrip(const NodeIDIterator &start,
|
||||||
const NodeIDIterator &end,
|
const NodeIDIterator &end,
|
||||||
const std::size_t number_of_locations,
|
const std::size_t number_of_locations,
|
||||||
const DistTableWrapper<EdgeWeight> &dist_table)
|
const util::DistTableWrapper<EdgeWeight> &dist_table)
|
||||||
{
|
{
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// START FARTHEST INSERTION HERE
|
// START FARTHEST INSERTION HERE
|
||||||
@ -189,7 +191,8 @@ std::vector<NodeID> FarthestInsertionTrip(const NodeIDIterator &start,
|
|||||||
return FindRoute(number_of_locations, component_size, start, end, dist_table, max_from, max_to);
|
return FindRoute(number_of_locations, component_size, start, end, dist_table, max_from, max_to);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace trip
|
}
|
||||||
} // end namespace osrm
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // TRIP_FARTHEST_INSERTION_HPP
|
#endif // TRIP_FARTHEST_INSERTION_HPP
|
||||||
|
@ -15,13 +15,16 @@
|
|||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
namespace trip
|
namespace trip
|
||||||
{
|
{
|
||||||
|
|
||||||
template <typename NodeIDIterator>
|
template <typename NodeIDIterator>
|
||||||
std::vector<NodeID> NearestNeighbourTrip(const NodeIDIterator &start,
|
std::vector<NodeID> NearestNeighbourTrip(const NodeIDIterator &start,
|
||||||
const NodeIDIterator &end,
|
const NodeIDIterator &end,
|
||||||
const std::size_t number_of_locations,
|
const std::size_t number_of_locations,
|
||||||
const DistTableWrapper<EdgeWeight> &dist_table)
|
const util::DistTableWrapper<EdgeWeight> &dist_table)
|
||||||
{
|
{
|
||||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// START GREEDY NEAREST NEIGHBOUR HERE
|
// START GREEDY NEAREST NEIGHBOUR HERE
|
||||||
@ -90,6 +93,8 @@ std::vector<NodeID> NearestNeighbourTrip(const NodeIDIterator &start,
|
|||||||
return route;
|
return route;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // end namespace trip
|
}
|
||||||
} // end namespace osrm
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // TRIP_NEAREST_NEIGHBOUR_HPP
|
#endif // TRIP_NEAREST_NEIGHBOUR_HPP
|
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
namespace trip
|
namespace trip
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -32,6 +34,9 @@ void TabuSearchTrip(const PhantomNodeArray &phantom_node_vector,
|
|||||||
std::vector<int> &min_loc_permutation)
|
std::vector<int> &min_loc_permutation)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // TRIP_BRUTE_FORCE_HPP
|
#endif // TRIP_BRUTE_FORCE_HPP
|
@ -8,6 +8,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
class CompressedEdgeContainer
|
class CompressedEdgeContainer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -39,4 +44,7 @@ class CompressedEdgeContainer
|
|||||||
std::unordered_map<EdgeID, unsigned> m_edge_id_to_list_index_map;
|
std::unordered_map<EdgeID, unsigned> m_edge_id_to_list_index_map;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // GEOMETRY_COMPRESSOR_HPP_
|
#endif // GEOMETRY_COMPRESSOR_HPP_
|
||||||
|
@ -27,13 +27,18 @@
|
|||||||
|
|
||||||
struct lua_State;
|
struct lua_State;
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
class EdgeBasedGraphFactory
|
class EdgeBasedGraphFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EdgeBasedGraphFactory() = delete;
|
EdgeBasedGraphFactory() = delete;
|
||||||
EdgeBasedGraphFactory(const 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 CompressedEdgeContainer &compressed_edge_container,
|
||||||
const std::unordered_set<NodeID> &barrier_nodes,
|
const std::unordered_set<NodeID> &barrier_nodes,
|
||||||
const std::unordered_set<NodeID> &traffic_lights,
|
const std::unordered_set<NodeID> &traffic_lights,
|
||||||
@ -56,7 +61,7 @@ class EdgeBasedGraphFactory
|
|||||||
const bool generate_edge_lookup);
|
const bool generate_edge_lookup);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void GetEdgeBasedEdges(DeallocatingVector<EdgeBasedEdge> &edges);
|
void GetEdgeBasedEdges(util::DeallocatingVector<EdgeBasedEdge> &edges);
|
||||||
|
|
||||||
void GetEdgeBasedNodes(std::vector<EdgeBasedNode> &nodes);
|
void GetEdgeBasedNodes(std::vector<EdgeBasedNode> &nodes);
|
||||||
void GetStartPointMarkers(std::vector<bool> &node_is_startpoint);
|
void GetStartPointMarkers(std::vector<bool> &node_is_startpoint);
|
||||||
@ -69,18 +74,18 @@ class EdgeBasedGraphFactory
|
|||||||
int GetTurnPenalty(double angle, lua_State *lua_state) const;
|
int GetTurnPenalty(double angle, lua_State *lua_state) const;
|
||||||
|
|
||||||
private:
|
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
|
//! maps index from m_edge_based_node_list to ture/false if the node is an entry point to the
|
||||||
//! graph
|
//! graph
|
||||||
std::vector<bool> m_edge_based_node_is_startpoint;
|
std::vector<bool> m_edge_based_node_is_startpoint;
|
||||||
//! list of edge based nodes (compressed segments)
|
//! list of edge based nodes (compressed segments)
|
||||||
std::vector<EdgeBasedNode> m_edge_based_node_list;
|
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;
|
unsigned m_max_edge_id;
|
||||||
|
|
||||||
const std::vector<QueryNode> &m_node_info_list;
|
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;
|
std::shared_ptr<RestrictionMap const> m_restriction_map;
|
||||||
|
|
||||||
const std::unordered_set<NodeID> &m_barrier_nodes;
|
const std::unordered_set<NodeID> &m_barrier_nodes;
|
||||||
@ -113,4 +118,7 @@ class EdgeBasedGraphFactory
|
|||||||
std::vector<OriginalEdgeData> &original_edge_data_vector) const;
|
std::vector<OriginalEdgeData> &original_edge_data_vector) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* EDGE_BASED_GRAPH_FACTORY_HPP_ */
|
#endif /* EDGE_BASED_GRAPH_FACTORY_HPP_ */
|
||||||
|
@ -10,7 +10,12 @@
|
|||||||
|
|
||||||
#include <limits>
|
#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.
|
/// It is generated in EdgeBasedGraphFactory.
|
||||||
struct EdgeBasedNode
|
struct EdgeBasedNode
|
||||||
{
|
{
|
||||||
@ -53,10 +58,10 @@ struct EdgeBasedNode
|
|||||||
(reverse_edge_based_node_id != SPECIAL_NODEID));
|
(reverse_edge_based_node_id != SPECIAL_NODEID));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline FixedPointCoordinate Centroid(const FixedPointCoordinate &a,
|
static inline util::FixedPointCoordinate Centroid(const util::FixedPointCoordinate &a,
|
||||||
const FixedPointCoordinate &b)
|
const util::FixedPointCoordinate &b)
|
||||||
{
|
{
|
||||||
FixedPointCoordinate centroid;
|
util::FixedPointCoordinate centroid;
|
||||||
// The coordinates of the midpoint are given by:
|
// The coordinates of the midpoint are given by:
|
||||||
centroid.lat = (a.lat + b.lat) / 2;
|
centroid.lat = (a.lat + b.lat) / 2;
|
||||||
centroid.lon = (a.lon + b.lon) / 2;
|
centroid.lon = (a.lon + b.lon) / 2;
|
||||||
@ -85,4 +90,7 @@ struct EdgeBasedNode
|
|||||||
TravelMode backward_travel_mode : 4;
|
TravelMode backward_travel_mode : 4;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // EDGE_BASED_NODE_HPP
|
#endif // EDGE_BASED_NODE_HPP
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
|
|
||||||
#include "util/typedefs.hpp"
|
#include "util/typedefs.hpp"
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
struct ExternalMemoryNode : QueryNode
|
struct ExternalMemoryNode : QueryNode
|
||||||
{
|
{
|
||||||
ExternalMemoryNode(int lat, int lon, OSMNodeID id, bool barrier, bool traffic_light);
|
ExternalMemoryNode(int lat, int lon, OSMNodeID id, bool barrier, bool traffic_light);
|
||||||
@ -27,4 +32,7 @@ struct ExternalMemoryNodeSTXXLCompare
|
|||||||
value_type min_value();
|
value_type min_value();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* EXTERNAL_MEMORY_NODE_HPP_ */
|
#endif /* EXTERNAL_MEMORY_NODE_HPP_ */
|
||||||
|
@ -10,6 +10,11 @@
|
|||||||
#include <stxxl/vector>
|
#include <stxxl/vector>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Uses external memory containers from stxxl to store all the data that
|
* Uses external memory containers from stxxl to store all the data that
|
||||||
* is collected by the extractor callbacks.
|
* is collected by the extractor callbacks.
|
||||||
@ -61,4 +66,7 @@ class ExtractionContainers
|
|||||||
lua_State *segment_state);
|
lua_State *segment_state);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* EXTRACTION_CONTAINERS_HPP */
|
#endif /* EXTRACTION_CONTAINERS_HPP */
|
||||||
|
@ -12,6 +12,11 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
bool simple_duration_is_valid(const std::string &s)
|
bool simple_duration_is_valid(const std::string &s)
|
||||||
{
|
{
|
||||||
boost::regex simple_format(
|
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)
|
bool iso_8601_duration_is_valid(const std::string &s)
|
||||||
{
|
{
|
||||||
iso_8601_grammar<std::string::const_iterator> iso_parser;
|
util::iso_8601_grammar<std::string::const_iterator> iso_parser;
|
||||||
const bool result = qi::parse(s.begin(), s.end(), iso_parser);
|
const bool result = boost::spirit::qi::parse(s.begin(), s.end(), iso_parser);
|
||||||
|
|
||||||
// check if the was an error with the request
|
// check if the was an error with the request
|
||||||
if (result && (0 != iso_parser.get_duration()))
|
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))
|
else if (iso_8601_duration_is_valid(s))
|
||||||
{
|
{
|
||||||
iso_8601_grammar<std::string::const_iterator> iso_parser;
|
util::iso_8601_grammar<std::string::const_iterator> iso_parser;
|
||||||
qi::parse(s.begin(), s.end(), iso_parser);
|
boost::spirit::qi::parse(s.begin(), s.end(), iso_parser);
|
||||||
|
|
||||||
return iso_parser.get_duration();
|
return iso_parser.get_duration();
|
||||||
}
|
}
|
||||||
@ -90,4 +95,7 @@ unsigned parseDuration(const std::string &s)
|
|||||||
return std::numeric_limits<unsigned>::max();
|
return std::numeric_limits<unsigned>::max();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // EXTRACTION_HELPER_FUNCTIONS_HPP
|
#endif // EXTRACTION_HELPER_FUNCTIONS_HPP
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
#ifndef EXTRACTION_NODE_HPP
|
#ifndef EXTRACTION_NODE_HPP
|
||||||
#define EXTRACTION_NODE_HPP
|
#define EXTRACTION_NODE_HPP
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
struct ExtractionNode
|
struct ExtractionNode
|
||||||
{
|
{
|
||||||
ExtractionNode() : traffic_lights(false), barrier(false) {}
|
ExtractionNode() : traffic_lights(false), barrier(false) {}
|
||||||
@ -8,4 +13,8 @@ struct ExtractionNode
|
|||||||
bool traffic_lights;
|
bool traffic_lights;
|
||||||
bool barrier;
|
bool barrier;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // EXTRACTION_NODE_HPP
|
#endif // EXTRACTION_NODE_HPP
|
||||||
|
@ -7,6 +7,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This struct is the direct result of the call to ```way_function```
|
* This struct is the direct result of the call to ```way_function```
|
||||||
* in the lua based profile.
|
* in the lua based profile.
|
||||||
@ -99,4 +104,7 @@ struct ExtractionWay
|
|||||||
TravelMode backward_travel_mode : 4;
|
TravelMode backward_travel_mode : 4;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // EXTRACTION_WAY_HPP
|
#endif // EXTRACTION_WAY_HPP
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
#include "extractor/edge_based_graph_factory.hpp"
|
#include "extractor/edge_based_graph_factory.hpp"
|
||||||
#include "extractor/graph_compressor.hpp"
|
#include "extractor/graph_compressor.hpp"
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
class extractor
|
class extractor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -18,22 +23,25 @@ class extractor
|
|||||||
BuildEdgeExpandedGraph(std::vector<QueryNode> &internal_to_external_node_map,
|
BuildEdgeExpandedGraph(std::vector<QueryNode> &internal_to_external_node_map,
|
||||||
std::vector<EdgeBasedNode> &node_based_edge_list,
|
std::vector<EdgeBasedNode> &node_based_edge_list,
|
||||||
std::vector<bool> &node_is_startpoint,
|
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 WriteNodeMapping(const std::vector<QueryNode> &internal_to_external_node_map);
|
||||||
void FindComponents(unsigned max_edge_id,
|
void FindComponents(unsigned max_edge_id,
|
||||||
const DeallocatingVector<EdgeBasedEdge> &edges,
|
const util::DeallocatingVector<EdgeBasedEdge> &edges,
|
||||||
std::vector<EdgeBasedNode> &nodes) const;
|
std::vector<EdgeBasedNode> &nodes) const;
|
||||||
void BuildRTree(std::vector<EdgeBasedNode> node_based_edge_list,
|
void BuildRTree(std::vector<EdgeBasedNode> node_based_edge_list,
|
||||||
std::vector<bool> node_is_startpoint,
|
std::vector<bool> node_is_startpoint,
|
||||||
const std::vector<QueryNode> &internal_to_external_node_map);
|
const std::vector<QueryNode> &internal_to_external_node_map);
|
||||||
std::shared_ptr<RestrictionMap> LoadRestrictionMap();
|
std::shared_ptr<RestrictionMap> LoadRestrictionMap();
|
||||||
std::shared_ptr<NodeBasedDynamicGraph>
|
std::shared_ptr<util::NodeBasedDynamicGraph>
|
||||||
LoadNodeBasedGraph(std::unordered_set<NodeID> &barrier_nodes,
|
LoadNodeBasedGraph(std::unordered_set<NodeID> &barrier_nodes,
|
||||||
std::unordered_set<NodeID> &traffic_lights,
|
std::unordered_set<NodeID> &traffic_lights,
|
||||||
std::vector<QueryNode> &internal_to_external_node_map);
|
std::vector<QueryNode> &internal_to_external_node_map);
|
||||||
|
|
||||||
void WriteEdgeBasedGraph(std::string const &output_file_filename,
|
void WriteEdgeBasedGraph(std::string const &output_file_filename,
|
||||||
size_t const max_edge_id,
|
size_t const max_edge_id,
|
||||||
DeallocatingVector<EdgeBasedEdge> const &edge_based_edge_list);
|
util::DeallocatingVector<EdgeBasedEdge> const &edge_based_edge_list);
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* EXTRACTOR_HPP */
|
#endif /* EXTRACTOR_HPP */
|
||||||
|
@ -7,17 +7,22 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
struct ExternalMemoryNode;
|
|
||||||
class ExtractionContainers;
|
|
||||||
struct InputRestrictionContainer;
|
|
||||||
struct ExtractionNode;
|
|
||||||
struct ExtractionWay;
|
|
||||||
namespace osmium
|
namespace osmium
|
||||||
{
|
{
|
||||||
class Node;
|
class Node;
|
||||||
class Way;
|
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
|
* This class is uses by the extractor with the results of the
|
||||||
* osmium based parsing and the customization through the lua profile.
|
* osmium based parsing and the customization through the lua profile.
|
||||||
@ -47,4 +52,7 @@ class ExtractorCallbacks
|
|||||||
void ProcessWay(const osmium::Way ¤t_way, const ExtractionWay &result_way);
|
void ProcessWay(const osmium::Way ¤t_way, const ExtractionWay &result_way);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* EXTRACTOR_CALLBACKS_HPP */
|
#endif /* EXTRACTOR_CALLBACKS_HPP */
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
enum class return_code : unsigned
|
enum class return_code : unsigned
|
||||||
{
|
{
|
||||||
ok,
|
ok,
|
||||||
@ -48,4 +53,7 @@ struct ExtractorOptions
|
|||||||
static void GenerateOutputFilesNames(ExtractorConfig &extractor_config);
|
static void GenerateOutputFilesNames(ExtractorConfig &extractor_config);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // EXTRACTOR_OPTIONS_HPP
|
#endif // EXTRACTOR_OPTIONS_HPP
|
||||||
|
@ -7,6 +7,11 @@
|
|||||||
#include <limits>
|
#include <limits>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
struct FirstAndLastSegmentOfWay
|
struct FirstAndLastSegmentOfWay
|
||||||
{
|
{
|
||||||
OSMWayID way_id;
|
OSMWayID way_id;
|
||||||
@ -49,4 +54,7 @@ struct FirstAndLastSegmentOfWayStxxlCompare
|
|||||||
value_type min_value() { return FirstAndLastSegmentOfWay::min_value(); }
|
value_type min_value() { return FirstAndLastSegmentOfWay::min_value(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* FIRST_AND_LAST_SEGMENT_OF_WAY_HPP */
|
#endif /* FIRST_AND_LAST_SEGMENT_OF_WAY_HPP */
|
||||||
|
@ -9,12 +9,17 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
class CompressedEdgeContainer;
|
class CompressedEdgeContainer;
|
||||||
class RestrictionMap;
|
class RestrictionMap;
|
||||||
|
|
||||||
class GraphCompressor
|
class GraphCompressor
|
||||||
{
|
{
|
||||||
using EdgeData = NodeBasedDynamicGraph::EdgeData;
|
using EdgeData = util::NodeBasedDynamicGraph::EdgeData;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GraphCompressor(SpeedProfileProperties speed_profile);
|
GraphCompressor(SpeedProfileProperties speed_profile);
|
||||||
@ -22,15 +27,18 @@ class GraphCompressor
|
|||||||
void Compress(const std::unordered_set<NodeID> &barrier_nodes,
|
void Compress(const std::unordered_set<NodeID> &barrier_nodes,
|
||||||
const std::unordered_set<NodeID> &traffic_lights,
|
const std::unordered_set<NodeID> &traffic_lights,
|
||||||
RestrictionMap &restriction_map,
|
RestrictionMap &restriction_map,
|
||||||
NodeBasedDynamicGraph &graph,
|
util::NodeBasedDynamicGraph &graph,
|
||||||
CompressedEdgeContainer &geometry_compressor);
|
CompressedEdgeContainer &geometry_compressor);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void PrintStatistics(unsigned original_number_of_nodes,
|
void PrintStatistics(unsigned original_number_of_nodes,
|
||||||
unsigned original_number_of_edges,
|
unsigned original_number_of_edges,
|
||||||
const NodeBasedDynamicGraph &graph) const;
|
const util::NodeBasedDynamicGraph &graph) const;
|
||||||
|
|
||||||
SpeedProfileProperties speed_profile;
|
SpeedProfileProperties speed_profile;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -4,6 +4,11 @@
|
|||||||
#include "extractor/travel_mode.hpp"
|
#include "extractor/travel_mode.hpp"
|
||||||
#include "util/typedefs.hpp"
|
#include "util/typedefs.hpp"
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
struct NodeBasedEdge
|
struct NodeBasedEdge
|
||||||
{
|
{
|
||||||
bool operator<(const NodeBasedEdge &e) const;
|
bool operator<(const NodeBasedEdge &e) const;
|
||||||
@ -90,4 +95,7 @@ struct EdgeBasedEdge
|
|||||||
bool backward : 1;
|
bool backward : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* IMPORT_EDGE_HPP */
|
#endif /* IMPORT_EDGE_HPP */
|
||||||
|
@ -10,6 +10,11 @@
|
|||||||
#include "osrm/coordinate.hpp"
|
#include "osrm/coordinate.hpp"
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
struct InternalExtractorEdge
|
struct InternalExtractorEdge
|
||||||
{
|
{
|
||||||
// specify the type of the weight data
|
// specify the type of the weight data
|
||||||
@ -80,7 +85,7 @@ struct InternalExtractorEdge
|
|||||||
// intermediate edge weight
|
// intermediate edge weight
|
||||||
WeightData weight_data;
|
WeightData weight_data;
|
||||||
// coordinate of the source node
|
// coordinate of the source node
|
||||||
FixedPointCoordinate source_coordinate;
|
util::FixedPointCoordinate source_coordinate;
|
||||||
|
|
||||||
// necessary static util functions for stxxl's sorting
|
// necessary static util functions for stxxl's sorting
|
||||||
static InternalExtractorEdge min_osm_value()
|
static InternalExtractorEdge min_osm_value()
|
||||||
@ -148,4 +153,7 @@ struct CmpEdgeByOSMTargetID
|
|||||||
value_type min_value() { return InternalExtractorEdge::min_osm_value(); }
|
value_type min_value() { return InternalExtractorEdge::min_osm_value(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // INTERNAL_EXTRACTOR_EDGE_HPP
|
#endif // INTERNAL_EXTRACTOR_EDGE_HPP
|
||||||
|
@ -3,6 +3,11 @@
|
|||||||
|
|
||||||
#include "util/typedefs.hpp"
|
#include "util/typedefs.hpp"
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
struct Cmp
|
struct Cmp
|
||||||
{
|
{
|
||||||
using value_type = OSMNodeID;
|
using value_type = OSMNodeID;
|
||||||
@ -11,4 +16,7 @@ struct Cmp
|
|||||||
value_type min_value() { return MIN_OSM_NODEID; }
|
value_type min_value() { return MIN_OSM_NODEID; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // NODE_ID_HPP
|
#endif // NODE_ID_HPP
|
||||||
|
@ -7,6 +7,11 @@
|
|||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
struct OriginalEdgeData
|
struct OriginalEdgeData
|
||||||
{
|
{
|
||||||
explicit OriginalEdgeData(NodeID via_node,
|
explicit OriginalEdgeData(NodeID via_node,
|
||||||
@ -33,4 +38,7 @@ struct OriginalEdgeData
|
|||||||
TravelMode travel_mode;
|
TravelMode travel_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // ORIGINAL_EDGE_DATA_HPP
|
#endif // ORIGINAL_EDGE_DATA_HPP
|
||||||
|
@ -9,6 +9,11 @@
|
|||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
struct QueryNode
|
struct QueryNode
|
||||||
{
|
{
|
||||||
using key_type = OSMNodeID; // type of NodeID
|
using key_type = OSMNodeID; // type of NodeID
|
||||||
@ -55,4 +60,7 @@ struct QueryNode
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // QUERY_NODE_HPP
|
#endif // QUERY_NODE_HPP
|
||||||
|
@ -13,6 +13,11 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\brief Small wrapper around raster source queries to optionally provide results
|
\brief Small wrapper around raster source queries to optionally provide results
|
||||||
gracefully, depending on source bounds
|
gracefully, depending on source bounds
|
||||||
@ -40,7 +45,7 @@ class RasterGrid
|
|||||||
boost::filesystem::ifstream stream(filepath);
|
boost::filesystem::ifstream stream(filepath);
|
||||||
if (!stream)
|
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);
|
stream.seekg(0, std::ios_base::end);
|
||||||
@ -65,13 +70,13 @@ class RasterGrid
|
|||||||
}
|
}
|
||||||
catch (std::exception const &ex)
|
catch (std::exception const &ex)
|
||||||
{
|
{
|
||||||
throw osrm::exception(
|
throw util::exception(
|
||||||
std::string("Failed to read from raster source with exception: ") + ex.what());
|
std::string("Failed to read from raster source with exception: ") + ex.what());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!r || itr != end)
|
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;
|
std::unordered_map<std::string, int> LoadedSourcePaths;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* RASTER_SOURCE_HPP */
|
#endif /* RASTER_SOURCE_HPP */
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
struct TurnRestriction
|
struct TurnRestriction
|
||||||
{
|
{
|
||||||
union WayOrNode
|
union WayOrNode
|
||||||
@ -104,4 +109,7 @@ struct CmpRestrictionContainerByTo
|
|||||||
value_type min_value() const { return InputRestrictionContainer::min_value(); }
|
value_type min_value() const { return InputRestrictionContainer::min_value(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // RESTRICTION_HPP
|
#endif // RESTRICTION_HPP
|
||||||
|
@ -12,6 +12,11 @@
|
|||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
struct RestrictionSource
|
struct RestrictionSource
|
||||||
{
|
{
|
||||||
NodeID start_node;
|
NodeID start_node;
|
||||||
@ -37,26 +42,33 @@ struct RestrictionTarget
|
|||||||
return (lhs.target_node == rhs.target_node && lhs.is_only == rhs.is_only);
|
return (lhs.target_node == rhs.target_node && lhs.is_only == rhs.is_only);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace std
|
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);
|
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);
|
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
|
\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
|
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;
|
std::unordered_set<NodeID> m_no_turn_via_node_set;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // RESTRICTION_MAP_HPP
|
#endif // RESTRICTION_MAP_HPP
|
||||||
|
@ -14,6 +14,12 @@ namespace osmium
|
|||||||
class Relation;
|
class Relation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the relations that represents turn restrictions.
|
* Parses the relations that represents turn restrictions.
|
||||||
*
|
*
|
||||||
@ -47,4 +53,7 @@ class RestrictionParser
|
|||||||
bool use_turn_restrictions;
|
bool use_turn_restrictions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* RESTRICTION_PARSER_HPP */
|
#endif /* RESTRICTION_PARSER_HPP */
|
||||||
|
@ -8,6 +8,11 @@
|
|||||||
|
|
||||||
struct lua_State;
|
struct lua_State;
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a lua context and binds osmium way, node and relation objects and
|
* Creates a lua context and binds osmium way, node and relation objects and
|
||||||
* ExtractionWay and ExtractionNode to lua objects.
|
* ExtractionWay and ExtractionNode to lua objects.
|
||||||
@ -30,4 +35,7 @@ class ScriptingEnvironment
|
|||||||
tbb::enumerable_thread_specific<std::shared_ptr<lua_State>> script_contexts;
|
tbb::enumerable_thread_specific<std::shared_ptr<lua_State>> script_contexts;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* SCRIPTING_ENVIRONMENT_HPP */
|
#endif /* SCRIPTING_ENVIRONMENT_HPP */
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
#ifndef SPEED_PROFILE_PROPERTIES_HPP
|
#ifndef SPEED_PROFILE_PROPERTIES_HPP
|
||||||
#define SPEED_PROFILE_PROPERTIES_HPP
|
#define SPEED_PROFILE_PROPERTIES_HPP
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
struct SpeedProfileProperties
|
struct SpeedProfileProperties
|
||||||
{
|
{
|
||||||
SpeedProfileProperties()
|
SpeedProfileProperties()
|
||||||
@ -13,4 +18,7 @@ struct SpeedProfileProperties
|
|||||||
bool has_turn_penalty_function;
|
bool has_turn_penalty_function;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -22,6 +22,11 @@
|
|||||||
#include <stack>
|
#include <stack>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
template <typename GraphT> class TarjanSCC
|
template <typename GraphT> class TarjanSCC
|
||||||
{
|
{
|
||||||
struct TarjanStackFrame
|
struct TarjanStackFrame
|
||||||
@ -66,7 +71,7 @@ template <typename GraphT> class TarjanSCC
|
|||||||
unsigned component_index = 0, size_of_current_component = 0;
|
unsigned component_index = 0, size_of_current_component = 0;
|
||||||
unsigned index = 0;
|
unsigned index = 0;
|
||||||
std::vector<bool> processing_node_before_recursion(max_node_id, true);
|
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])
|
if (SPECIAL_NODEID == components_index[node])
|
||||||
{
|
{
|
||||||
@ -141,7 +146,7 @@ template <typename GraphT> class TarjanSCC
|
|||||||
|
|
||||||
if (size_of_current_component > 1000)
|
if (size_of_current_component > 1000)
|
||||||
{
|
{
|
||||||
SimpleLogger().Write() << "large component [" << component_index
|
util::SimpleLogger().Write() << "large component [" << component_index
|
||||||
<< "]=" << size_of_current_component;
|
<< "]=" << size_of_current_component;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,7 +158,7 @@ template <typename GraphT> class TarjanSCC
|
|||||||
}
|
}
|
||||||
|
|
||||||
TIMER_STOP(SCC_RUN);
|
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(),
|
size_one_counter = std::count_if(component_size_vector.begin(), component_size_vector.end(),
|
||||||
[](unsigned value)
|
[](unsigned value)
|
||||||
@ -174,4 +179,7 @@ template <typename GraphT> class TarjanSCC
|
|||||||
unsigned get_component_id(const NodeID node) const { return components_index[node]; }
|
unsigned get_component_id(const NodeID node) const { return components_index[node]; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* TARJAN_SCC_HPP */
|
#endif /* TARJAN_SCC_HPP */
|
||||||
|
@ -1,10 +1,18 @@
|
|||||||
#ifndef TRAVEL_MODE_HPP
|
#ifndef TRAVEL_MODE_HPP
|
||||||
#define TRAVEL_MODE_HPP
|
#define TRAVEL_MODE_HPP
|
||||||
|
|
||||||
namespace
|
namespace osrm
|
||||||
{
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
using TravelMode = unsigned char;
|
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 */
|
#endif /* TRAVEL_MODE_HPP */
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
#ifndef TURN_INSTRUCTIONS_HPP
|
#ifndef TURN_INSTRUCTIONS_HPP
|
||||||
#define TURN_INSTRUCTIONS_HPP
|
#define TURN_INSTRUCTIONS_HPP
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace extractor
|
||||||
|
{
|
||||||
|
|
||||||
enum class TurnInstruction : unsigned char
|
enum class TurnInstruction : unsigned char
|
||||||
{
|
{
|
||||||
NoTurn = 0,
|
NoTurn = 0,
|
||||||
@ -75,4 +80,7 @@ struct TurnInstructionsClass
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* TURN_INSTRUCTIONS_HPP */
|
#endif /* TURN_INSTRUCTIONS_HPP */
|
||||||
|
@ -32,10 +32,13 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
namespace
|
namespace osrm
|
||||||
{
|
{
|
||||||
|
|
||||||
constexpr static const double COORDINATE_PRECISION = 1000000.0;
|
constexpr static const double COORDINATE_PRECISION = 1000000.0;
|
||||||
}
|
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
struct FixedPointCoordinate
|
struct FixedPointCoordinate
|
||||||
{
|
{
|
||||||
@ -61,5 +64,10 @@ struct FixedPointCoordinate
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::ostream &operator<<(std::ostream &out, const FixedPointCoordinate &coordinate);
|
std::ostream &operator<<(std::ostream &out, const FixedPointCoordinate &coordinate);
|
||||||
|
}
|
||||||
|
|
||||||
|
using util::FixedPointCoordinate;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* COORDINATE_HPP_ */
|
#endif /* COORDINATE_HPP_ */
|
||||||
|
@ -40,6 +40,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
namespace json
|
namespace json
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -92,5 +96,12 @@ struct Array
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace JSON
|
} // namespace JSON
|
||||||
|
} // namespace util
|
||||||
|
|
||||||
|
namespace json {
|
||||||
|
using namespace osrm::util::json;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace osrm
|
} // namespace osrm
|
||||||
|
|
||||||
#endif // JSON_CONTAINER_HPP
|
#endif // JSON_CONTAINER_HPP
|
||||||
|
@ -33,6 +33,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
|
||||||
struct LibOSRMConfig
|
struct LibOSRMConfig
|
||||||
{
|
{
|
||||||
std::unordered_map<std::string, boost::filesystem::path> server_paths;
|
std::unordered_map<std::string, boost::filesystem::path> server_paths;
|
||||||
@ -43,4 +46,6 @@ struct LibOSRMConfig
|
|||||||
bool use_shared_memory = true;
|
bool use_shared_memory = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // SERVER_CONFIG_HPP
|
#endif // SERVER_CONFIG_HPP
|
||||||
|
@ -30,17 +30,21 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
struct LibOSRMConfig;
|
|
||||||
struct RouteParameters;
|
|
||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
|
|
||||||
|
struct LibOSRMConfig;
|
||||||
|
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
namespace json
|
namespace json
|
||||||
{
|
{
|
||||||
struct Object;
|
struct Object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace engine {
|
||||||
|
struct RouteParameters;
|
||||||
class OSRM
|
class OSRM
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
@ -50,7 +54,12 @@ class OSRM
|
|||||||
public:
|
public:
|
||||||
OSRM(LibOSRMConfig &lib_config);
|
OSRM(LibOSRMConfig &lib_config);
|
||||||
~OSRM(); // needed because we need to define it with the implementation of OSRM_impl
|
~OSRM(); // needed because we need to define it with the implementation of OSRM_impl
|
||||||
int RunQuery(const RouteParameters &route_parameters, osrm::json::Object &json_result);
|
int RunQuery(const RouteParameters &route_parameters, util::json::Object &json_result);
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
using engine::OSRM;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // OSRM_HPP
|
#endif // OSRM_HPP
|
||||||
|
@ -36,6 +36,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
|
|
||||||
struct RouteParameters
|
struct RouteParameters
|
||||||
{
|
{
|
||||||
RouteParameters();
|
RouteParameters();
|
||||||
@ -115,4 +120,10 @@ struct RouteParameters
|
|||||||
std::vector<bool> is_source;
|
std::vector<bool> is_source;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
using engine::RouteParameters;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // ROUTE_PARAMETERS_HPP
|
#endif // ROUTE_PARAMETERS_HPP
|
||||||
|
@ -31,6 +31,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
|
||||||
/* Creates strongly typed wrappers around scalar types.
|
/* Creates strongly typed wrappers around scalar types.
|
||||||
* Useful for stopping accidental assignment of lats to lons,
|
* Useful for stopping accidental assignment of lats to lons,
|
||||||
* etc. Also clarifies what this random "int" value is
|
* etc. Also clarifies what this random "int" value is
|
||||||
@ -66,4 +69,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
}; \
|
}; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // OSRM_STRONG_TYPEDEF_HPP
|
#endif // OSRM_STRONG_TYPEDEF_HPP
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
#include <boost/spirit/include/qi.hpp>
|
#include <boost/spirit/include/qi.hpp>
|
||||||
#include <boost/spirit/include/qi_action.hpp>
|
#include <boost/spirit/include/qi_action.hpp>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace server
|
||||||
|
{
|
||||||
|
|
||||||
namespace qi = boost::spirit::qi;
|
namespace qi = boost::spirit::qi;
|
||||||
|
|
||||||
template <typename Iterator, class HandlerT> struct APIGrammar : qi::grammar<Iterator>
|
template <typename Iterator, class HandlerT> struct APIGrammar : qi::grammar<Iterator>
|
||||||
@ -98,4 +103,7 @@ template <typename Iterator, class HandlerT> struct APIGrammar : qi::grammar<Ite
|
|||||||
HandlerT *handler;
|
HandlerT *handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* API_GRAMMAR_HPP */
|
#endif /* API_GRAMMAR_HPP */
|
||||||
|
@ -26,10 +26,12 @@ template <class T> T *get_pointer(std::shared_ptr<T> &p) { return p.get(); }
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class RequestHandler;
|
namespace osrm
|
||||||
|
|
||||||
namespace http
|
|
||||||
{
|
{
|
||||||
|
namespace server
|
||||||
|
{
|
||||||
|
|
||||||
|
class RequestHandler;
|
||||||
|
|
||||||
/// Represents a single connection from a client.
|
/// Represents a single connection from a client.
|
||||||
class Connection : public std::enable_shared_from_this<Connection>
|
class Connection : public std::enable_shared_from_this<Connection>
|
||||||
@ -51,18 +53,19 @@ class Connection : public std::enable_shared_from_this<Connection>
|
|||||||
void handle_write(const boost::system::error_code &e);
|
void handle_write(const boost::system::error_code &e);
|
||||||
|
|
||||||
std::vector<char> compress_buffers(const std::vector<char> &uncompressed_data,
|
std::vector<char> compress_buffers(const std::vector<char> &uncompressed_data,
|
||||||
const compression_type compression_type);
|
const http::compression_type compression_type);
|
||||||
|
|
||||||
boost::asio::io_service::strand strand;
|
boost::asio::io_service::strand strand;
|
||||||
boost::asio::ip::tcp::socket TCP_socket;
|
boost::asio::ip::tcp::socket TCP_socket;
|
||||||
RequestHandler &request_handler;
|
RequestHandler &request_handler;
|
||||||
RequestParser request_parser;
|
RequestParser request_parser;
|
||||||
boost::array<char, 8192> incoming_data_buffer;
|
boost::array<char, 8192> incoming_data_buffer;
|
||||||
request current_request;
|
http::request current_request;
|
||||||
reply current_reply;
|
http::reply current_reply;
|
||||||
std::vector<char> compressed_output;
|
std::vector<char> compressed_output;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace http
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // CONNECTION_HPP
|
#endif // CONNECTION_HPP
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
#ifndef COMPRESSION_TYPE_HPP
|
#ifndef COMPRESSION_TYPE_HPP
|
||||||
#define COMPRESSION_TYPE_HPP
|
#define COMPRESSION_TYPE_HPP
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace server
|
||||||
|
{
|
||||||
namespace http
|
namespace http
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -10,6 +14,9 @@ enum compression_type
|
|||||||
gzip_rfc1952,
|
gzip_rfc1952,
|
||||||
deflate_rfc1951
|
deflate_rfc1951
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // COMPRESSION_TYPE_HPP
|
#endif // COMPRESSION_TYPE_HPP
|
||||||
|
@ -4,8 +4,13 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace server
|
||||||
|
{
|
||||||
namespace http
|
namespace http
|
||||||
{
|
{
|
||||||
|
|
||||||
struct header
|
struct header
|
||||||
{
|
{
|
||||||
// explicitly use default copy c'tor as adding move c'tor
|
// explicitly use default copy c'tor as adding move c'tor
|
||||||
@ -22,6 +27,9 @@ struct header
|
|||||||
std::string name;
|
std::string name;
|
||||||
std::string value;
|
std::string value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HEADER_HPP
|
#endif // HEADER_HPP
|
||||||
|
@ -7,8 +7,13 @@
|
|||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace server
|
||||||
|
{
|
||||||
namespace http
|
namespace http
|
||||||
{
|
{
|
||||||
|
|
||||||
class reply
|
class reply
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -33,6 +38,9 @@ class reply
|
|||||||
std::string status_to_string(reply::status_type status);
|
std::string status_to_string(reply::status_type status);
|
||||||
boost::asio::const_buffer status_to_buffer(reply::status_type status);
|
boost::asio::const_buffer status_to_buffer(reply::status_type status);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // REPLY_HPP
|
#endif // REPLY_HPP
|
||||||
|
@ -5,6 +5,10 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace server
|
||||||
|
{
|
||||||
namespace http
|
namespace http
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -16,6 +20,8 @@ struct request
|
|||||||
boost::asio::ip::address endpoint;
|
boost::asio::ip::address endpoint;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace http
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // REQUEST_HPP
|
#endif // REQUEST_HPP
|
||||||
|
@ -3,9 +3,16 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
template <typename Iterator, class HandlerT> struct APIGrammar;
|
namespace osrm
|
||||||
struct RouteParameters;
|
{
|
||||||
|
namespace engine
|
||||||
|
{
|
||||||
class OSRM;
|
class OSRM;
|
||||||
|
struct RouteParameters;
|
||||||
|
}
|
||||||
|
namespace server
|
||||||
|
{
|
||||||
|
template <typename Iterator, class HandlerT> struct APIGrammar;
|
||||||
|
|
||||||
namespace http
|
namespace http
|
||||||
{
|
{
|
||||||
@ -17,16 +24,19 @@ class RequestHandler
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using APIGrammarParser = APIGrammar<std::string::iterator, RouteParameters>;
|
using APIGrammarParser = APIGrammar<std::string::iterator, engine::RouteParameters>;
|
||||||
|
|
||||||
RequestHandler();
|
RequestHandler();
|
||||||
RequestHandler(const RequestHandler &) = delete;
|
RequestHandler(const RequestHandler &) = delete;
|
||||||
|
|
||||||
void handle_request(const http::request ¤t_request, http::reply ¤t_reply);
|
void handle_request(const http::request ¤t_request, http::reply ¤t_reply);
|
||||||
void RegisterRoutingMachine(OSRM *osrm);
|
void RegisterRoutingMachine(engine::OSRM *osrm);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OSRM *routing_machine;
|
engine::OSRM *routing_machine;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // REQUEST_HANDLER_HPP
|
#endif // REQUEST_HANDLER_HPP
|
||||||
|
@ -7,21 +7,27 @@
|
|||||||
|
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
|
|
||||||
namespace http
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace server
|
||||||
{
|
{
|
||||||
|
|
||||||
|
namespace http
|
||||||
|
{
|
||||||
struct request;
|
struct request;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class RequestParser
|
class RequestParser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RequestParser();
|
RequestParser();
|
||||||
|
|
||||||
std::tuple<osrm::tribool, compression_type>
|
std::tuple<util::tribool, http::compression_type>
|
||||||
parse(request ¤t_request, char *begin, char *end);
|
parse(http::request ¤t_request, char *begin, char *end);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
osrm::tribool consume(request ¤t_request, const char input);
|
util::tribool consume(http::request ¤t_request, const char input);
|
||||||
|
|
||||||
bool is_char(const int character) const;
|
bool is_char(const int character) const;
|
||||||
|
|
||||||
@ -60,12 +66,13 @@ class RequestParser
|
|||||||
post_request
|
post_request
|
||||||
} state;
|
} state;
|
||||||
|
|
||||||
header current_header;
|
http::header current_header;
|
||||||
compression_type selected_compression;
|
http::compression_type selected_compression;
|
||||||
bool is_post_header;
|
bool is_post_header;
|
||||||
int content_length;
|
int content_length;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace http
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // REQUEST_PARSER_HPP
|
#endif // REQUEST_PARSER_HPP
|
||||||
|
@ -18,6 +18,11 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace server
|
||||||
|
{
|
||||||
|
|
||||||
class Server
|
class Server
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -25,7 +30,7 @@ class Server
|
|||||||
static std::shared_ptr<Server>
|
static std::shared_ptr<Server>
|
||||||
CreateServer(std::string &ip_address, int ip_port, unsigned requested_num_threads)
|
CreateServer(std::string &ip_address, int ip_port, unsigned requested_num_threads)
|
||||||
{
|
{
|
||||||
SimpleLogger().Write() << "http 1.1 compression handled by zlib version " << zlibVersion();
|
util::SimpleLogger().Write() << "http 1.1 compression handled by zlib version " << zlibVersion();
|
||||||
const unsigned hardware_threads = std::max(1u, std::thread::hardware_concurrency());
|
const unsigned hardware_threads = std::max(1u, std::thread::hardware_concurrency());
|
||||||
const unsigned real_num_threads = std::min(hardware_threads, requested_num_threads);
|
const unsigned real_num_threads = std::min(hardware_threads, requested_num_threads);
|
||||||
return std::make_shared<Server>(ip_address, ip_port, real_num_threads);
|
return std::make_shared<Server>(ip_address, ip_port, real_num_threads);
|
||||||
@ -33,7 +38,7 @@ class Server
|
|||||||
|
|
||||||
explicit Server(const std::string &address, const int port, const unsigned thread_pool_size)
|
explicit Server(const std::string &address, const int port, const unsigned thread_pool_size)
|
||||||
: thread_pool_size(thread_pool_size), acceptor(io_service),
|
: thread_pool_size(thread_pool_size), acceptor(io_service),
|
||||||
new_connection(std::make_shared<http::Connection>(io_service, request_handler))
|
new_connection(std::make_shared<Connection>(io_service, request_handler))
|
||||||
{
|
{
|
||||||
const auto port_string = std::to_string(port);
|
const auto port_string = std::to_string(port);
|
||||||
|
|
||||||
@ -75,7 +80,7 @@ class Server
|
|||||||
if (!e)
|
if (!e)
|
||||||
{
|
{
|
||||||
new_connection->start();
|
new_connection->start();
|
||||||
new_connection = std::make_shared<http::Connection>(io_service, request_handler);
|
new_connection = std::make_shared<Connection>(io_service, request_handler);
|
||||||
acceptor.async_accept(
|
acceptor.async_accept(
|
||||||
new_connection->socket(),
|
new_connection->socket(),
|
||||||
boost::bind(&Server::HandleAccept, this, boost::asio::placeholders::error));
|
boost::bind(&Server::HandleAccept, this, boost::asio::placeholders::error));
|
||||||
@ -85,8 +90,11 @@ class Server
|
|||||||
unsigned thread_pool_size;
|
unsigned thread_pool_size;
|
||||||
boost::asio::io_service io_service;
|
boost::asio::io_service io_service;
|
||||||
boost::asio::ip::tcp::acceptor acceptor;
|
boost::asio::ip::tcp::acceptor acceptor;
|
||||||
std::shared_ptr<http::Connection> new_connection;
|
std::shared_ptr<Connection> new_connection;
|
||||||
RequestHandler request_handler;
|
RequestHandler request_handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // SERVER_HPP
|
#endif // SERVER_HPP
|
||||||
|
@ -4,6 +4,11 @@
|
|||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
namespace bearing
|
namespace bearing
|
||||||
{
|
{
|
||||||
inline std::string get(const double heading)
|
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
|
#endif // BEARING_HPP
|
||||||
|
@ -10,6 +10,11 @@
|
|||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
template <typename NodeID, typename Key> class ArrayStorage
|
template <typename NodeID, typename Key> class ArrayStorage
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -286,4 +291,7 @@ class BinaryHeap
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // BINARY_HEAP_H
|
#endif // BINARY_HEAP_H
|
||||||
|
@ -9,6 +9,11 @@
|
|||||||
#include <boost/algorithm/string/classification.hpp>
|
#include <boost/algorithm/string/classification.hpp>
|
||||||
#include <boost/algorithm/string/trim.hpp>
|
#include <boost/algorithm/string/trim.hpp>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
namespace cast
|
namespace cast
|
||||||
{
|
{
|
||||||
template <typename Enumeration>
|
template <typename Enumeration>
|
||||||
@ -39,4 +44,7 @@ template <typename T, int Precision = 6> inline std::string to_string_with_preci
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // CAST_HPP
|
#endif // CAST_HPP
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
#ifndef COMPUTE_ANGLE_HPP
|
#ifndef COMPUTE_ANGLE_HPP
|
||||||
#define COMPUTE_ANGLE_HPP
|
#define COMPUTE_ANGLE_HPP
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
struct FixedPointCoordinate;
|
struct FixedPointCoordinate;
|
||||||
|
|
||||||
struct ComputeAngle
|
struct ComputeAngle
|
||||||
@ -12,4 +17,7 @@ struct ComputeAngle
|
|||||||
const FixedPointCoordinate &third) noexcept;
|
const FixedPointCoordinate &third) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // COMPUTE_ANGLE_HPP
|
#endif // COMPUTE_ANGLE_HPP
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
|
|
||||||
namespace osrm
|
namespace osrm
|
||||||
{
|
{
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
// Culled by SFINAE if reserve does not exist or is not accessible
|
// 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
|
} // namespace osrm
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* CONTAINER_HPP */
|
#endif /* CONTAINER_HPP */
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
#ifndef COORDINATE_CALCULATION
|
#ifndef COORDINATE_CALCULATION
|
||||||
#define COORDINATE_CALCULATION
|
#define COORDINATE_CALCULATION
|
||||||
|
|
||||||
struct FixedPointCoordinate;
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
|
struct FixedPointCoordinate;
|
||||||
|
|
||||||
namespace coordinate_calculation
|
namespace coordinate_calculation
|
||||||
{
|
{
|
||||||
double haversineDistance(const int lat1, const int lon1, const int lat2, const int lon2);
|
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);
|
const FixedPointCoordinate &second_coordinate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // COORDINATE_CALCULATION
|
#endif // COORDINATE_CALCULATION
|
||||||
|
@ -13,6 +13,11 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
// generate boost::program_options object for the routing part
|
// generate boost::program_options object for the routing part
|
||||||
bool GenerateDataStoreOptions(const int argc,
|
bool GenerateDataStoreOptions(const int argc,
|
||||||
const char *argv[],
|
const char *argv[],
|
||||||
@ -199,59 +204,62 @@ bool GenerateDataStoreOptions(const int argc,
|
|||||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
!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");
|
path_iterator = paths.find("nodesdata");
|
||||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
!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");
|
path_iterator = paths.find("edgesdata");
|
||||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
!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");
|
path_iterator = paths.find("geometry");
|
||||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
!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");
|
path_iterator = paths.find("ramindex");
|
||||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
!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");
|
path_iterator = paths.find("fileindex");
|
||||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
!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");
|
path_iterator = paths.find("namesdata");
|
||||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
!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");
|
path_iterator = paths.find("timestamp");
|
||||||
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
if (path_iterator == paths.end() || path_iterator->second.string().empty() ||
|
||||||
!boost::filesystem::is_regular_file(path_iterator->second))
|
!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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* DATASTORE_OPTIONS_HPP */
|
#endif /* DATASTORE_OPTIONS_HPP */
|
||||||
|
@ -9,6 +9,11 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
template <typename ElementT> struct ConstDeallocatingVectorIteratorState
|
template <typename ElementT> struct ConstDeallocatingVectorIteratorState
|
||||||
{
|
{
|
||||||
ConstDeallocatingVectorIteratorState()
|
ConstDeallocatingVectorIteratorState()
|
||||||
@ -302,7 +307,7 @@ class DeallocatingVector
|
|||||||
{ // down-size
|
{ // down-size
|
||||||
const std::size_t number_of_necessary_buckets = 1 + (new_size / ELEMENTS_PER_BLOCK);
|
const std::size_t number_of_necessary_buckets = 1 + (new_size / ELEMENTS_PER_BLOCK);
|
||||||
for (const auto bucket_index :
|
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])
|
if (nullptr != bucket_list[bucket_index])
|
||||||
{
|
{
|
||||||
@ -374,4 +379,7 @@ void swap(DeallocatingVector<T, S> &lhs, DeallocatingVector<T, S> &rhs)
|
|||||||
lhs.swap(rhs);
|
lhs.swap(rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* DEALLOCATING_VECTOR_HPP */
|
#endif /* DEALLOCATING_VECTOR_HPP */
|
||||||
|
@ -6,7 +6,12 @@
|
|||||||
|
|
||||||
#ifndef DEBUG_GEOMETRY
|
#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 */,
|
inline void DEBUG_GEOMETRY_EDGE(int /* new_segment_weight */,
|
||||||
double /* segment_length */,
|
double /* segment_length */,
|
||||||
OSMNodeID /* previous_osm_node_id */,
|
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_TURNS_START(const std::string & /* debug_turns_filename */) {}
|
||||||
inline void DEBUG_TURN(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 FixedPointCoordinate & /* first_coordinate */,
|
||||||
const int /* turn_angle */,
|
const int /* turn_angle */,
|
||||||
const int /* turn_penalty */)
|
const int /* turn_penalty */)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
inline void DEBUG_UTURN(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 /* uturn_penalty */)
|
const int /* uturn_penalty */)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
inline void DEBUG_SIGNAL(const NodeID /* node */,
|
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 */)
|
const int /* signal_penalty */)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void DEBUG_TURNS_STOP() {}
|
inline void DEBUG_TURNS_STOP() {}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#else // DEBUG_GEOMETRY
|
#else // DEBUG_GEOMETRY
|
||||||
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
@ -47,6 +55,12 @@ inline void DEBUG_TURNS_STOP() {}
|
|||||||
#include "util/coordinate.hpp"
|
#include "util/coordinate.hpp"
|
||||||
#include "util/coordinate_calculation.hpp"
|
#include "util/coordinate_calculation.hpp"
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
boost::filesystem::ofstream debug_geometry_file;
|
boost::filesystem::ofstream debug_geometry_file;
|
||||||
bool dg_output_debug_geometry = false;
|
bool dg_output_debug_geometry = false;
|
||||||
bool dg_first_debug_geometry = true;
|
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_output_turn_debug = false;
|
||||||
bool dg_first_turn_debug = true;
|
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;
|
time_t raw_time;
|
||||||
struct tm *timeinfo;
|
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,
|
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)
|
const int traffic_signal_penalty)
|
||||||
{
|
{
|
||||||
if (dg_output_turn_debug)
|
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)
|
if (!dg_first_turn_debug)
|
||||||
dg_debug_turns_file << "," << std::endl;
|
dg_debug_turns_file << "," << std::endl;
|
||||||
dg_debug_turns_file
|
dg_debug_turns_file
|
||||||
@ -137,12 +151,12 @@ inline void DEBUG_SIGNAL(const NodeID node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void DEBUG_UTURN(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)
|
const int traffic_signal_penalty)
|
||||||
{
|
{
|
||||||
if (dg_output_turn_debug)
|
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)
|
if (!dg_first_turn_debug)
|
||||||
dg_debug_turns_file << "," << std::endl;
|
dg_debug_turns_file << "," << std::endl;
|
||||||
dg_debug_turns_file
|
dg_debug_turns_file
|
||||||
@ -156,14 +170,14 @@ inline void DEBUG_UTURN(const NodeID node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void DEBUG_TURN(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 FixedPointCoordinate &first_coordinate,
|
||||||
const int turn_angle,
|
const int turn_angle,
|
||||||
const int turn_penalty)
|
const int turn_penalty)
|
||||||
{
|
{
|
||||||
if (turn_penalty > 0 && dg_output_turn_debug)
|
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);
|
const float bearing_uv = coordinate_calculation::bearing(first_coordinate, v);
|
||||||
float uvw_normal = bearing_uv + turn_angle / 2;
|
float uvw_normal = bearing_uv + turn_angle / 2;
|
||||||
@ -194,6 +208,9 @@ inline void DEBUG_TURNS_STOP()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DEBUG_GEOMETRY
|
#endif // DEBUG_GEOMETRY
|
||||||
|
|
||||||
#endif // DEBUG_GEOMETRY_H
|
#endif // DEBUG_GEOMETRY_H
|
||||||
|
@ -6,6 +6,11 @@
|
|||||||
#include <boost/assert.hpp>
|
#include <boost/assert.hpp>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
// This Wrapper provides an easier access to a distance table that is given as an linear vector
|
// This Wrapper provides an easier access to a distance table that is given as an linear vector
|
||||||
|
|
||||||
template <typename T> class DistTableWrapper
|
template <typename T> class DistTableWrapper
|
||||||
@ -58,4 +63,7 @@ template <typename T> class DistTableWrapper
|
|||||||
const std::size_t number_of_nodes_;
|
const std::size_t number_of_nodes_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DIST_TABLE_WRAPPER_H
|
#endif // DIST_TABLE_WRAPPER_H
|
||||||
|
@ -15,13 +15,18 @@
|
|||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
template <typename EdgeDataT> class DynamicGraph
|
template <typename EdgeDataT> class DynamicGraph
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using EdgeData = EdgeDataT;
|
using EdgeData = EdgeDataT;
|
||||||
using NodeIterator = unsigned;
|
using NodeIterator = unsigned;
|
||||||
using EdgeIterator = unsigned;
|
using EdgeIterator = unsigned;
|
||||||
using EdgeRange = osrm::range<EdgeIterator>;
|
using EdgeRange = range<EdgeIterator>;
|
||||||
|
|
||||||
class InputEdge
|
class InputEdge
|
||||||
{
|
{
|
||||||
@ -72,7 +77,7 @@ template <typename EdgeDataT> class DynamicGraph
|
|||||||
node_array.resize(number_of_nodes + 1);
|
node_array.resize(number_of_nodes + 1);
|
||||||
EdgeIterator edge = 0;
|
EdgeIterator edge = 0;
|
||||||
EdgeIterator position = 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;
|
EdgeIterator last_edge = edge;
|
||||||
while (edge < number_of_edges && graph[edge].source == node)
|
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.reserve(static_cast<std::size_t>(edge_list.size() * 1.1));
|
||||||
edge_list.resize(position);
|
edge_list.resize(position);
|
||||||
edge = 0;
|
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))
|
node_array[node].first_edge + node_array[node].edges))
|
||||||
{
|
{
|
||||||
edge_list[i].target = graph[edge].target;
|
edge_list[i].target = graph[edge].target;
|
||||||
@ -111,7 +116,7 @@ template <typename EdgeDataT> class DynamicGraph
|
|||||||
unsigned GetDirectedOutDegree(const NodeIterator n) const
|
unsigned GetDirectedOutDegree(const NodeIterator n) const
|
||||||
{
|
{
|
||||||
unsigned degree = 0;
|
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)
|
if (!GetEdgeData(edge).reversed)
|
||||||
{
|
{
|
||||||
@ -141,7 +146,7 @@ template <typename EdgeDataT> class DynamicGraph
|
|||||||
|
|
||||||
EdgeRange GetAdjacentEdgeRange(const NodeIterator node) const
|
EdgeRange GetAdjacentEdgeRange(const NodeIterator node) const
|
||||||
{
|
{
|
||||||
return osrm::irange(BeginEdges(node), EndEdges(node));
|
return irange(BeginEdges(node), EndEdges(node));
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeIterator InsertNode()
|
NodeIterator InsertNode()
|
||||||
@ -175,12 +180,12 @@ template <typename EdgeDataT> class DynamicGraph
|
|||||||
edge_list.reserve(requiredCapacity * 1.1);
|
edge_list.reserve(requiredCapacity * 1.1);
|
||||||
}
|
}
|
||||||
edge_list.resize(edge_list.size() + newSize);
|
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];
|
edge_list[newFirstEdge + i] = edge_list[node.first_edge + i];
|
||||||
makeDummy(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);
|
makeDummy(newFirstEdge + i);
|
||||||
}
|
}
|
||||||
@ -235,7 +240,7 @@ template <typename EdgeDataT> class DynamicGraph
|
|||||||
// searches for a specific edge
|
// searches for a specific edge
|
||||||
EdgeIterator FindEdge(const NodeIterator from, const NodeIterator to) const
|
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)
|
if (to == edge_list[i].target)
|
||||||
{
|
{
|
||||||
@ -316,4 +321,7 @@ template <typename EdgeDataT> class DynamicGraph
|
|||||||
DeallocatingVector<Edge> edge_list;
|
DeallocatingVector<Edge> edge_list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif // DYNAMICGRAPH_HPP
|
#endif // DYNAMICGRAPH_HPP
|
||||||
|
@ -4,6 +4,11 @@
|
|||||||
#include <boost/uuid/uuid.hpp>
|
#include <boost/uuid/uuid.hpp>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
|
namespace osrm
|
||||||
|
{
|
||||||
|
namespace util
|
||||||
|
{
|
||||||
|
|
||||||
// implements a singleton, i.e. there is one and only one conviguration object
|
// implements a singleton, i.e. there is one and only one conviguration object
|
||||||
class FingerPrint
|
class FingerPrint
|
||||||
{
|
{
|
||||||
@ -29,4 +34,7 @@ class FingerPrint
|
|||||||
|
|
||||||
static_assert(std::is_trivial<FingerPrint>::value, "FingerPrint needs to be trivial.");
|
static_assert(std::is_trivial<FingerPrint>::value, "FingerPrint needs to be trivial.");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* FingerPrint_H */
|
#endif /* FingerPrint_H */
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user