Implementation of internal data storage
This commit is contained in:
parent
0b0fb249bf
commit
b343a17b29
@ -203,7 +203,7 @@ private:
|
|||||||
std::vector<unsigned> m_name_ID_list;
|
std::vector<unsigned> m_name_ID_list;
|
||||||
std::vector<TurnInstruction> m_turn_instruction_list;
|
std::vector<TurnInstruction> m_turn_instruction_list;
|
||||||
|
|
||||||
StaticRTree<EdgeBasedGraphFactory::EdgeBasedNode> * m_ro_rtree_ptr;
|
StaticRTree<EdgeBasedGraphFactorRTreeLeafRTreeLeafy::EdgeBasedNode> * m_ro_rtree_ptr;
|
||||||
const unsigned m_number_of_nodes;
|
const unsigned m_number_of_nodes;
|
||||||
const unsigned m_check_sum;
|
const unsigned m_check_sum;
|
||||||
};
|
};
|
||||||
|
@ -22,7 +22,6 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
#define SEARCHENGINE_H
|
#define SEARCHENGINE_H
|
||||||
|
|
||||||
#include "Coordinate.h"
|
#include "Coordinate.h"
|
||||||
#include "NodeInformationHelpDesk.h"
|
|
||||||
#include "SearchEngineData.h"
|
#include "SearchEngineData.h"
|
||||||
#include "PhantomNodes.h"
|
#include "PhantomNodes.h"
|
||||||
#include "QueryEdge.h"
|
#include "QueryEdge.h"
|
||||||
|
@ -137,32 +137,32 @@ public:
|
|||||||
return _numEdges;
|
return _numEdges;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned GetOutDegree( const NodeIterator &n ) const {
|
unsigned GetOutDegree( const NodeIterator n ) const {
|
||||||
return BeginEdges(n)-EndEdges(n) - 1;
|
return BeginEdges(n)-EndEdges(n) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline NodeIterator GetTarget( const EdgeIterator &e ) const {
|
inline NodeIterator GetTarget( const EdgeIterator e ) const {
|
||||||
return NodeIterator( _edges[e].target );
|
return NodeIterator( _edges[e].target );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline EdgeDataT &GetEdgeData( const EdgeIterator &e ) {
|
inline EdgeDataT &GetEdgeData( const EdgeIterator e ) {
|
||||||
return _edges[e].data;
|
return _edges[e].data;
|
||||||
}
|
}
|
||||||
|
|
||||||
const EdgeDataT &GetEdgeData( const EdgeIterator &e ) const {
|
const EdgeDataT &GetEdgeData( const EdgeIterator e ) const {
|
||||||
return _edges[e].data;
|
return _edges[e].data;
|
||||||
}
|
}
|
||||||
|
|
||||||
EdgeIterator BeginEdges( const NodeIterator &n ) const {
|
EdgeIterator BeginEdges( const NodeIterator n ) const {
|
||||||
return EdgeIterator( _nodes[n].firstEdge );
|
return EdgeIterator( _nodes[n].firstEdge );
|
||||||
}
|
}
|
||||||
|
|
||||||
EdgeIterator EndEdges( const NodeIterator &n ) const {
|
EdgeIterator EndEdges( const NodeIterator n ) const {
|
||||||
return EdgeIterator( _nodes[n+1].firstEdge );
|
return EdgeIterator( _nodes[n+1].firstEdge );
|
||||||
}
|
}
|
||||||
|
|
||||||
//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 {
|
||||||
EdgeIterator smallestEdge = SPECIAL_EDGEID;
|
EdgeIterator smallestEdge = SPECIAL_EDGEID;
|
||||||
EdgeWeight smallestWeight = UINT_MAX;
|
EdgeWeight smallestWeight = UINT_MAX;
|
||||||
for ( EdgeIterator edge = BeginEdges( from ); edge < EndEdges(from); edge++ ) {
|
for ( EdgeIterator edge = BeginEdges( from ); edge < EndEdges(from); edge++ ) {
|
||||||
@ -175,12 +175,12 @@ public:
|
|||||||
return smallestEdge;
|
return smallestEdge;
|
||||||
}
|
}
|
||||||
|
|
||||||
EdgeIterator FindEdgeInEitherDirection( const NodeIterator &from, const NodeIterator &to ) const {
|
EdgeIterator FindEdgeInEitherDirection( const NodeIterator from, const NodeIterator to ) const {
|
||||||
EdgeIterator tmp = FindEdge( from, to );
|
EdgeIterator tmp = FindEdge( from, to );
|
||||||
return (UINT_MAX != tmp ? tmp : FindEdge( to, from ));
|
return (UINT_MAX != tmp ? tmp : FindEdge( to, from ));
|
||||||
}
|
}
|
||||||
|
|
||||||
EdgeIterator FindEdgeIndicateIfReverse( const NodeIterator &from, const NodeIterator &to, bool & result ) const {
|
EdgeIterator FindEdgeIndicateIfReverse( const NodeIterator from, const NodeIterator to, bool & result ) const {
|
||||||
EdgeIterator tmp = FindEdge( from, to );
|
EdgeIterator tmp = FindEdge( from, to );
|
||||||
if(UINT_MAX == tmp) {
|
if(UINT_MAX == tmp) {
|
||||||
tmp = FindEdge( to, from );
|
tmp = FindEdge( to, from );
|
||||||
|
@ -410,11 +410,10 @@ public:
|
|||||||
|
|
||||||
//Read-only operation for queries
|
//Read-only operation for queries
|
||||||
explicit StaticRTree(
|
explicit StaticRTree(
|
||||||
const std::string & node_filename,
|
const boost::filesystem::path & node_file,
|
||||||
const std::string & leaf_filename
|
const boost::filesystem::path & leaf_file
|
||||||
) : m_leaf_node_filename(leaf_filename) {
|
) : m_leaf_node_filename(leaf_file.string()) {
|
||||||
//open tree node file and load into RAM.
|
//open tree node file and load into RAM.
|
||||||
boost::filesystem::path node_file(node_filename);
|
|
||||||
|
|
||||||
if ( !boost::filesystem::exists( node_file ) ) {
|
if ( !boost::filesystem::exists( node_file ) ) {
|
||||||
throw OSRMException("ram index file does not exist");
|
throw OSRMException("ram index file does not exist");
|
||||||
@ -432,7 +431,6 @@ public:
|
|||||||
tree_node_file.close();
|
tree_node_file.close();
|
||||||
|
|
||||||
//open leaf node file and store thread specific pointer
|
//open leaf node file and store thread specific pointer
|
||||||
boost::filesystem::path leaf_file(leaf_filename);
|
|
||||||
if ( !boost::filesystem::exists( leaf_file ) ) {
|
if ( !boost::filesystem::exists( leaf_file ) ) {
|
||||||
throw OSRMException("mem index file does not exist");
|
throw OSRMException("mem index file does not exist");
|
||||||
}
|
}
|
||||||
|
@ -20,74 +20,26 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
|
|
||||||
#include "OSRM.h"
|
#include "OSRM.h"
|
||||||
|
|
||||||
OSRM::OSRM(const char * server_ini_path, const bool use_shared_memory)
|
OSRM::OSRM(const char * server_ini_path, const bool use_shared_memory) :
|
||||||
: use_shared_memory(use_shared_memory)
|
use_shared_memory(use_shared_memory)
|
||||||
{
|
{
|
||||||
if( !use_shared_memory ) {
|
|
||||||
if( !testDataFile(server_ini_path) ){
|
if( !testDataFile(server_ini_path) ){
|
||||||
std::string error_message(server_ini_path);
|
std::string error_message(server_ini_path);
|
||||||
error_message += " not found";
|
error_message += " not found";
|
||||||
throw OSRMException(error_message);
|
throw OSRMException(error_message);
|
||||||
}
|
}
|
||||||
|
boost::filesystem::path base_path = boost::filesystem::absolute(server_ini_path).parent_path();
|
||||||
|
IniFile server_config(server_ini_path);
|
||||||
|
|
||||||
IniFile serverConfig(server_ini_path);
|
if( !use_shared_memory ) {
|
||||||
|
query_data_facade = new InternalDataFacade<QueryEdge::EdgeData>(
|
||||||
boost::filesystem::path base_path =
|
server_config, base_path
|
||||||
boost::filesystem::absolute(server_ini_path).parent_path();
|
|
||||||
|
|
||||||
if ( !serverConfig.Holds("hsgrData")) {
|
|
||||||
throw OSRMException("no ram index file name in server ini");
|
|
||||||
}
|
|
||||||
if ( !serverConfig.Holds("ramIndex") ) {
|
|
||||||
throw OSRMException("no mem index file name in server ini");
|
|
||||||
}
|
|
||||||
if ( !serverConfig.Holds("fileIndex") ) {
|
|
||||||
throw OSRMException("no nodes file name in server ini");
|
|
||||||
}
|
|
||||||
if ( !serverConfig.Holds("nodesData") ) {
|
|
||||||
throw OSRMException("no nodes file name in server ini");
|
|
||||||
}
|
|
||||||
if ( !serverConfig.Holds("edgesData") ) {
|
|
||||||
throw OSRMException("no edges file name in server ini");
|
|
||||||
}
|
|
||||||
|
|
||||||
boost::filesystem::path hsgr_path = boost::filesystem::absolute(
|
|
||||||
serverConfig.GetParameter("hsgrData"),
|
|
||||||
base_path
|
|
||||||
);
|
);
|
||||||
|
|
||||||
boost::filesystem::path ram_index_path = boost::filesystem::absolute(
|
|
||||||
serverConfig.GetParameter("ramIndex"),
|
|
||||||
base_path
|
|
||||||
);
|
|
||||||
|
|
||||||
boost::filesystem::path file_index_path = boost::filesystem::absolute(
|
|
||||||
serverConfig.GetParameter("fileIndex"),
|
|
||||||
base_path
|
|
||||||
);
|
|
||||||
|
|
||||||
boost::filesystem::path node_data_path = boost::filesystem::absolute(
|
|
||||||
serverConfig.GetParameter("nodesData"),
|
|
||||||
base_path
|
|
||||||
);
|
|
||||||
boost::filesystem::path edge_data_path = boost::filesystem::absolute(
|
|
||||||
serverConfig.GetParameter("edgesData"),
|
|
||||||
base_path
|
|
||||||
);
|
|
||||||
boost::filesystem::path name_data_path = boost::filesystem::absolute(
|
|
||||||
serverConfig.GetParameter("namesData"),
|
|
||||||
base_path
|
|
||||||
);
|
|
||||||
boost::filesystem::path timestamp_path = boost::filesystem::absolute(
|
|
||||||
serverConfig.GetParameter("timestamp"),
|
|
||||||
base_path
|
|
||||||
);
|
|
||||||
|
|
||||||
query_data_facade = new InternalDataFacade<QueryEdge::EdgeData>();
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
//TODO: fetch pointers from shared memory
|
query_data_facade = new SharedDataFacade<QueryEdge::EdgeData>(
|
||||||
query_data_facade = new SharedDataFacade<QueryEdge::EdgeData>();
|
server_config, base_path
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//The following plugins handle all requests.
|
//The following plugins handle all requests.
|
||||||
|
@ -63,7 +63,6 @@ private:
|
|||||||
|
|
||||||
PluginMap plugin_map;
|
PluginMap plugin_map;
|
||||||
const bool use_shared_memory;
|
const bool use_shared_memory;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //OSRM_H
|
#endif //OSRM_H
|
||||||
|
@ -22,8 +22,6 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
#define LOCATEPLUGIN_H_
|
#define LOCATEPLUGIN_H_
|
||||||
|
|
||||||
#include "BasePlugin.h"
|
#include "BasePlugin.h"
|
||||||
#include "../DataStructures/NodeInformationHelpDesk.h"
|
|
||||||
#include "../Server/DataStructures/QueryObjectsStorage.h"
|
|
||||||
#include "../Util/StringUtil.h"
|
#include "../Util/StringUtil.h"
|
||||||
|
|
||||||
//locates the nearest node in the road network for a given coordinate.
|
//locates the nearest node in the road network for a given coordinate.
|
||||||
|
@ -22,8 +22,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
#define NearestPlugin_H_
|
#define NearestPlugin_H_
|
||||||
|
|
||||||
#include "BasePlugin.h"
|
#include "BasePlugin.h"
|
||||||
|
#include "../DataStructures/PhantomNodes.h"
|
||||||
#include "../DataStructures/NodeInformationHelpDesk.h"
|
|
||||||
#include "../Util/StringUtil.h"
|
#include "../Util/StringUtil.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -115,7 +115,7 @@ public:
|
|||||||
( routeParameters.alternateRoute ) &&
|
( routeParameters.alternateRoute ) &&
|
||||||
(1 == rawRoute.segmentEndCoordinates.size())
|
(1 == rawRoute.segmentEndCoordinates.size())
|
||||||
) {
|
) {
|
||||||
search_engine_ptr->alternative_paths(
|
search_engine_ptr->alternative_path(
|
||||||
rawRoute.segmentEndCoordinates[0],
|
rawRoute.segmentEndCoordinates[0],
|
||||||
rawRoute
|
rawRoute
|
||||||
);
|
);
|
||||||
|
@ -74,14 +74,20 @@ public:
|
|||||||
std::vector<SearchSpaceEdge> reverse_search_space;
|
std::vector<SearchSpaceEdge> reverse_search_space;
|
||||||
|
|
||||||
//Initialize Queues, semi-expensive because access to TSS invokes a system call
|
//Initialize Queues, semi-expensive because access to TSS invokes a system call
|
||||||
super::_queryData.InitializeOrClearFirstThreadLocalStorage();
|
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
|
||||||
super::_queryData.InitializeOrClearSecondThreadLocalStorage();
|
super::facade->GetNumberOfNodes()
|
||||||
super::_queryData.InitializeOrClearThirdThreadLocalStorage();
|
);
|
||||||
|
engine_working_data.InitializeOrClearSecondThreadLocalStorage(
|
||||||
|
super::facade->GetNumberOfNodes()
|
||||||
|
);
|
||||||
|
engine_working_data.InitializeOrClearThirdThreadLocalStorage(
|
||||||
|
super::facade->GetNumberOfNodes()
|
||||||
|
);
|
||||||
|
|
||||||
QueryHeap & forward_heap1 = *(super::_queryData.forwardHeap);
|
QueryHeap & forward_heap1 = *(engine_working_data.forwardHeap);
|
||||||
QueryHeap & reverse_heap1 = *(super::_queryData.backwardHeap);
|
QueryHeap & reverse_heap1 = *(engine_working_data.backwardHeap);
|
||||||
QueryHeap & forward_heap2 = *(super::_queryData.forwardHeap2);
|
QueryHeap & forward_heap2 = *(engine_working_data.forwardHeap2);
|
||||||
QueryHeap & reverse_heap2 = *(super::_queryData.backwardHeap2);
|
QueryHeap & reverse_heap2 = *(engine_working_data.backwardHeap2);
|
||||||
|
|
||||||
int upper_bound_to_shortest_path_distance = INT_MAX;
|
int upper_bound_to_shortest_path_distance = INT_MAX;
|
||||||
NodeID middle_node = UINT_MAX;
|
NodeID middle_node = UINT_MAX;
|
||||||
@ -219,12 +225,14 @@ private:
|
|||||||
const int offset, const std::vector<NodeID> & packed_shortest_path) {
|
const int offset, const std::vector<NodeID> & packed_shortest_path) {
|
||||||
//compute and unpack <s,..,v> and <v,..,t> by exploring search spaces from v and intersecting against queues
|
//compute and unpack <s,..,v> and <v,..,t> by exploring search spaces from v and intersecting against queues
|
||||||
//only half-searches have to be done at this stage
|
//only half-searches have to be done at this stage
|
||||||
super::_queryData.InitializeOrClearSecondThreadLocalStorage();
|
engine_working_data.InitializeOrClearSecondThreadLocalStorage(
|
||||||
|
super::facade->GetNumberOfNodes()
|
||||||
|
);
|
||||||
|
|
||||||
QueryHeap & existingForwardHeap = *super::_queryData.forwardHeap;
|
QueryHeap & existingForwardHeap = *engine_working_data.forwardHeap;
|
||||||
QueryHeap & existingBackwardHeap = *super::_queryData.backwardHeap;
|
QueryHeap & existingBackwardHeap = *engine_working_data.backwardHeap;
|
||||||
QueryHeap & newForwardHeap = *super::_queryData.forwardHeap2;
|
QueryHeap & newForwardHeap = *engine_working_data.forwardHeap2;
|
||||||
QueryHeap & newBackwardHeap = *super::_queryData.backwardHeap2;
|
QueryHeap & newBackwardHeap = *engine_working_data.backwardHeap2;
|
||||||
|
|
||||||
std::vector < NodeID > packed_s_v_path;
|
std::vector < NodeID > packed_s_v_path;
|
||||||
std::vector < NodeID > packed_v_t_path;
|
std::vector < NodeID > packed_v_t_path;
|
||||||
@ -517,10 +525,12 @@ private:
|
|||||||
|
|
||||||
lengthOfPathT_Test_Path += unpackedUntilDistance;
|
lengthOfPathT_Test_Path += unpackedUntilDistance;
|
||||||
//Run actual T-Test query and compare if distances equal.
|
//Run actual T-Test query and compare if distances equal.
|
||||||
super::_queryData.InitializeOrClearThirdThreadLocalStorage();
|
engine_working_data.InitializeOrClearThirdThreadLocalStorage(
|
||||||
|
super::facade->GetNumberOfNodes()
|
||||||
|
);
|
||||||
|
|
||||||
QueryHeap& forward_heap3 = *super::_queryData.forwardHeap3;
|
QueryHeap& forward_heap3 = *engine_working_data.forwardHeap3;
|
||||||
QueryHeap& backward_heap3 = *super::_queryData.backwardHeap3;
|
QueryHeap& backward_heap3 = *engine_working_data.backwardHeap3;
|
||||||
int _upperBound = INT_MAX;
|
int _upperBound = INT_MAX;
|
||||||
NodeID middle = UINT_MAX;
|
NodeID middle = UINT_MAX;
|
||||||
forward_heap3.Insert(s_P, 0, s_P);
|
forward_heap3.Insert(s_P, 0, s_P);
|
||||||
|
@ -125,7 +125,9 @@ public:
|
|||||||
|
|
||||||
//We have to push the path in reverse order onto the stack because it's LIFO.
|
//We have to push the path in reverse order onto the stack because it's LIFO.
|
||||||
for(unsigned i = packed_path_size-1; i > 0; --i){
|
for(unsigned i = packed_path_size-1; i > 0; --i){
|
||||||
recursion_stack.push(std::make_pair(packed_path[i-1], packed_path[i]));
|
recursion_stack.push(
|
||||||
|
std::make_pair(packed_path[i-1], packed_path[i])
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<NodeID, NodeID> edge;
|
std::pair<NodeID, NodeID> edge;
|
||||||
|
@ -54,14 +54,20 @@ public:
|
|||||||
std::vector<NodeID> packedPath1;
|
std::vector<NodeID> packedPath1;
|
||||||
std::vector<NodeID> packedPath2;
|
std::vector<NodeID> packedPath2;
|
||||||
|
|
||||||
super::_queryData.InitializeOrClearFirstThreadLocalStorage();
|
engine_working_data.InitializeOrClearFirstThreadLocalStorage(
|
||||||
super::_queryData.InitializeOrClearSecondThreadLocalStorage();
|
super::facade->GetNumberOfNodes()
|
||||||
super::_queryData.InitializeOrClearThirdThreadLocalStorage();
|
);
|
||||||
|
engine_working_data.InitializeOrClearSecondThreadLocalStorage(
|
||||||
|
super::facade->GetNumberOfNodes()
|
||||||
|
);
|
||||||
|
engine_working_data.InitializeOrClearThirdThreadLocalStorage(
|
||||||
|
super::facade->GetNumberOfNodes()
|
||||||
|
);
|
||||||
|
|
||||||
QueryHeap & forward_heap1 = *(super::_queryData.forwardHeap);
|
QueryHeap & forward_heap1 = *(engine_working_data.forwardHeap);
|
||||||
QueryHeap & reverse_heap1 = *(super::_queryData.backwardHeap);
|
QueryHeap & reverse_heap1 = *(engine_working_data.backwardHeap);
|
||||||
QueryHeap & forward_heap2 = *(super::_queryData.forwardHeap2);
|
QueryHeap & forward_heap2 = *(engine_working_data.forwardHeap2);
|
||||||
QueryHeap & reverse_heap2 = *(super::_queryData.backwardHeap2);
|
QueryHeap & reverse_heap2 = *(engine_working_data.backwardHeap2);
|
||||||
|
|
||||||
//Get distance to next pair of target nodes.
|
//Get distance to next pair of target nodes.
|
||||||
BOOST_FOREACH(const PhantomNodes & phantomNodePair, phantomNodesVector) {
|
BOOST_FOREACH(const PhantomNodes & phantomNodePair, phantomNodesVector) {
|
||||||
|
@ -23,6 +23,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
|
|
||||||
//Exposes all data access interfaces to the algorithms via base class ptr
|
//Exposes all data access interfaces to the algorithms via base class ptr
|
||||||
|
|
||||||
|
#include "../../Contractor/EdgeBasedGraphFactory.h"
|
||||||
#include "../../DataStructures/Coordinate.h"
|
#include "../../DataStructures/Coordinate.h"
|
||||||
#include "../../DataStructures/PhantomNodes.h"
|
#include "../../DataStructures/PhantomNodes.h"
|
||||||
#include "../../DataStructures/TurnInstructions.h"
|
#include "../../DataStructures/TurnInstructions.h"
|
||||||
@ -35,6 +36,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
template<class EdgeDataT>
|
template<class EdgeDataT>
|
||||||
class BaseDataFacade {
|
class BaseDataFacade {
|
||||||
public:
|
public:
|
||||||
|
typedef EdgeBasedGraphFactory::EdgeBasedNode RTreeLeaf;
|
||||||
typedef EdgeDataT EdgeData;
|
typedef EdgeDataT EdgeData;
|
||||||
BaseDataFacade( ) { }
|
BaseDataFacade( ) { }
|
||||||
virtual ~BaseDataFacade() { }
|
virtual ~BaseDataFacade() { }
|
||||||
|
@ -25,67 +25,300 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
|
|
||||||
#include "BaseDataFacade.h"
|
#include "BaseDataFacade.h"
|
||||||
|
|
||||||
|
#include "../../DataStructures/Coordinate.h"
|
||||||
|
#include "../../DataStructures/QueryNode.h"
|
||||||
|
#include "../../DataStructures/QueryEdge.h"
|
||||||
#include "../../DataStructures/StaticGraph.h"
|
#include "../../DataStructures/StaticGraph.h"
|
||||||
|
#include "../../DataStructures/StaticRTree.h"
|
||||||
|
#include "../../Util/BoostFilesystemFix.h"
|
||||||
|
#include "../../Util/GraphLoader.h"
|
||||||
|
#include "../../Util/IniFile.h"
|
||||||
|
#include "../../Util/SimpleLogger.h"
|
||||||
|
|
||||||
template<class EdgeDataT>
|
template<class EdgeDataT>
|
||||||
class InternalDataFacade : public BaseDataFacade<EdgeDataT> {
|
class InternalDataFacade : public BaseDataFacade<EdgeDataT> {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
typedef BaseDataFacade<EdgeDataT> super;
|
||||||
|
typedef StaticGraph<typename super::EdgeData> QueryGraph;
|
||||||
|
typedef typename QueryGraph::InputEdge InputEdge;
|
||||||
|
typedef typename super::RTreeLeaf RTreeLeaf;
|
||||||
|
|
||||||
|
InternalDataFacade() { }
|
||||||
|
|
||||||
|
unsigned m_check_sum;
|
||||||
|
unsigned m_number_of_nodes;
|
||||||
|
QueryGraph * m_query_graph;
|
||||||
|
std::string m_timestamp;
|
||||||
|
|
||||||
|
std::vector<FixedPointCoordinate> m_coordinate_list;
|
||||||
|
std::vector<NodeID> m_via_node_list;
|
||||||
|
std::vector<unsigned> m_name_ID_list;
|
||||||
|
std::vector<TurnInstruction> m_turn_instruction_list;
|
||||||
|
StaticRTree<RTreeLeaf> * m_static_rtree;
|
||||||
|
|
||||||
|
|
||||||
|
void LoadTimestamp(const boost::filesystem::path & timestamp_path) {
|
||||||
|
if( boost::filesystem::exists(timestamp_path) ) {
|
||||||
|
SimpleLogger().Write() << "Loading Timestamp";
|
||||||
|
boost::filesystem::ifstream timestampInStream( timestamp_path );
|
||||||
|
if(!timestampInStream) {
|
||||||
|
SimpleLogger().Write(logWARNING) << timestamp_path << " not found";
|
||||||
|
}
|
||||||
|
getline(timestampInStream, m_timestamp);
|
||||||
|
timestampInStream.close();
|
||||||
|
}
|
||||||
|
if(m_timestamp.empty()) {
|
||||||
|
m_timestamp = "n/a";
|
||||||
|
}
|
||||||
|
if(25 < m_timestamp.length()) {
|
||||||
|
m_timestamp.resize(25);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadGraph(const boost::filesystem::path & hsgr_path) {
|
||||||
|
ShMemVector<typename QueryGraph::_StrNode> node_list;
|
||||||
|
ShMemVector< typename QueryGraph::_StrEdge> edge_list;
|
||||||
|
|
||||||
|
m_number_of_nodes = readHSGRFromStream(
|
||||||
|
hsgr_path,
|
||||||
|
node_list,
|
||||||
|
edge_list,
|
||||||
|
&m_check_sum
|
||||||
|
);
|
||||||
|
BOOST_ASSERT_MSG(0 == node_list.size(), "node list not flushed");
|
||||||
|
BOOST_ASSERT_MSG(0 == edge_list.size(), "edge list not flushed");
|
||||||
|
|
||||||
|
m_query_graph = new QueryGraph(node_list, edge_list);
|
||||||
|
SimpleLogger().Write() << "Data checksum is " << m_check_sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadNodeAndEdgeInformation(
|
||||||
|
const boost::filesystem::path nodes_file,
|
||||||
|
const boost::filesystem::path edges_file
|
||||||
|
) {
|
||||||
|
boost::filesystem::ifstream nodes_input_stream(
|
||||||
|
nodes_file,
|
||||||
|
std::ios::binary
|
||||||
|
);
|
||||||
|
boost::filesystem::ifstream edges_input_stream(
|
||||||
|
edges_file,
|
||||||
|
std::ios::binary
|
||||||
|
);
|
||||||
|
|
||||||
|
SimpleLogger().Write(logDEBUG) << "Loading node data";
|
||||||
|
NodeInfo current_node;
|
||||||
|
while(!nodes_input_stream.eof()) {
|
||||||
|
nodes_input_stream.read((char *)¤t_node, sizeof(NodeInfo));
|
||||||
|
m_coordinate_list.push_back(
|
||||||
|
FixedPointCoordinate(
|
||||||
|
current_node.lat,
|
||||||
|
current_node.lon
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
std::vector<FixedPointCoordinate>(m_coordinate_list).swap(m_coordinate_list);
|
||||||
|
nodes_input_stream.close();
|
||||||
|
|
||||||
|
SimpleLogger().Write(logDEBUG)
|
||||||
|
<< "Loading edge data";
|
||||||
|
unsigned number_of_edges = 0;
|
||||||
|
edges_input_stream.read((char*)&number_of_edges, sizeof(unsigned));
|
||||||
|
m_via_node_list.resize(number_of_edges);
|
||||||
|
m_name_ID_list.resize(number_of_edges);
|
||||||
|
m_turn_instruction_list.resize(number_of_edges);
|
||||||
|
|
||||||
|
OriginalEdgeData current_edge_data;
|
||||||
|
for(unsigned i = 0; i < number_of_edges; ++i) {
|
||||||
|
edges_input_stream.read(
|
||||||
|
(char*)&(current_edge_data),
|
||||||
|
sizeof(OriginalEdgeData)
|
||||||
|
);
|
||||||
|
m_via_node_list[i] = current_edge_data.viaNode;
|
||||||
|
m_name_ID_list[i] = current_edge_data.nameID;
|
||||||
|
m_turn_instruction_list[i] = current_edge_data.turnInstruction;
|
||||||
|
}
|
||||||
|
edges_input_stream.close();
|
||||||
|
SimpleLogger().Write(logDEBUG)
|
||||||
|
<< "Loaded " << number_of_edges << " orig edges";
|
||||||
|
SimpleLogger().Write(logDEBUG) << "Opening NN indices";
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoadRTree(
|
||||||
|
const boost::filesystem::path & ram_index_path,
|
||||||
|
const boost::filesystem::path & file_index_path
|
||||||
|
) {
|
||||||
|
m_static_rtree = new StaticRTree<RTreeLeaf>(
|
||||||
|
ram_index_path,
|
||||||
|
file_index_path
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
~InternalDataFacade() {
|
||||||
|
delete m_query_graph;
|
||||||
|
delete m_static_rtree;
|
||||||
|
}
|
||||||
|
|
||||||
|
InternalDataFacade(
|
||||||
|
const IniFile & server_config,
|
||||||
|
const boost::filesystem::path & base_path
|
||||||
|
) {
|
||||||
|
//check contents of config file
|
||||||
|
if ( !server_config.Holds("hsgrData")) {
|
||||||
|
throw OSRMException("no ram index file name in server ini");
|
||||||
|
}
|
||||||
|
if ( !server_config.Holds("ramIndex") ) {
|
||||||
|
throw OSRMException("no mem index file name in server ini");
|
||||||
|
}
|
||||||
|
if ( !server_config.Holds("fileIndex") ) {
|
||||||
|
throw OSRMException("no nodes file name in server ini");
|
||||||
|
}
|
||||||
|
if ( !server_config.Holds("nodesData") ) {
|
||||||
|
throw OSRMException("no nodes file name in server ini");
|
||||||
|
}
|
||||||
|
if ( !server_config.Holds("edgesData") ) {
|
||||||
|
throw OSRMException("no edges file name in server ini");
|
||||||
|
}
|
||||||
|
|
||||||
|
//generate paths of data files
|
||||||
|
boost::filesystem::path hsgr_path = boost::filesystem::absolute(
|
||||||
|
server_config.GetParameter("hsgrData"),
|
||||||
|
base_path
|
||||||
|
);
|
||||||
|
boost::filesystem::path ram_index_path = boost::filesystem::absolute(
|
||||||
|
server_config.GetParameter("ramIndex"),
|
||||||
|
base_path
|
||||||
|
);
|
||||||
|
boost::filesystem::path file_index_path = boost::filesystem::absolute(
|
||||||
|
server_config.GetParameter("fileIndex"),
|
||||||
|
base_path
|
||||||
|
);
|
||||||
|
boost::filesystem::path node_data_path = boost::filesystem::absolute(
|
||||||
|
server_config.GetParameter("nodesData"),
|
||||||
|
base_path
|
||||||
|
);
|
||||||
|
boost::filesystem::path edge_data_path = boost::filesystem::absolute(
|
||||||
|
server_config.GetParameter("edgesData"),
|
||||||
|
base_path
|
||||||
|
);
|
||||||
|
boost::filesystem::path name_data_path = boost::filesystem::absolute(
|
||||||
|
server_config.GetParameter("namesData"),
|
||||||
|
base_path
|
||||||
|
);
|
||||||
|
boost::filesystem::path timestamp_path = boost::filesystem::absolute(
|
||||||
|
server_config.GetParameter("timestamp"),
|
||||||
|
base_path
|
||||||
|
);
|
||||||
|
|
||||||
|
// check if data files empty
|
||||||
|
if ( 0 == boost::filesystem::file_size( node_data_path ) ) {
|
||||||
|
throw OSRMException("nodes file is empty");
|
||||||
|
}
|
||||||
|
if ( 0 == boost::filesystem::file_size( edge_data_path ) ) {
|
||||||
|
throw OSRMException("edges file is empty");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//load data
|
||||||
|
SimpleLogger().Write() << "loading graph data";
|
||||||
|
LoadGraph(hsgr_path);
|
||||||
|
LoadNodeAndEdgeInformation(node_data_path, edge_data_path);
|
||||||
|
LoadRTree(ram_index_path, file_index_path);
|
||||||
|
LoadTimestamp(hsgr_path);
|
||||||
|
}
|
||||||
|
|
||||||
//search graph access
|
//search graph access
|
||||||
unsigned GetNumberOfNodes() const { return 0; }
|
unsigned GetNumberOfNodes() const {
|
||||||
|
return m_query_graph->GetNumberOfNodes();
|
||||||
|
}
|
||||||
|
|
||||||
unsigned GetNumberOfEdges() const { return 0; }
|
unsigned GetNumberOfEdges() const {
|
||||||
|
return m_query_graph->GetNumberOfEdges();
|
||||||
|
}
|
||||||
|
|
||||||
unsigned GetOutDegree( const NodeID n ) const { return 0; }
|
unsigned GetOutDegree( const NodeID n ) const {
|
||||||
|
return m_query_graph->GetOutDegree(n);
|
||||||
|
}
|
||||||
|
|
||||||
NodeID GetTarget( const EdgeID e ) const { return 0; }
|
NodeID GetTarget( const EdgeID e ) const {
|
||||||
|
return m_query_graph->GetTarget(e); }
|
||||||
|
|
||||||
EdgeDataT &GetEdgeData( const EdgeID e ) { return EdgeDataT(); }
|
EdgeDataT &GetEdgeData( const EdgeID e ) {
|
||||||
|
return m_query_graph->GetEdgeData(e);
|
||||||
|
}
|
||||||
|
|
||||||
const EdgeDataT &GetEdgeData( const EdgeID e ) const { return EdgeDataT(); }
|
const EdgeDataT &GetEdgeData( const EdgeID e ) const {
|
||||||
|
return m_query_graph->GetEdgeData(e);
|
||||||
|
}
|
||||||
|
|
||||||
EdgeID BeginEdges( const NodeID n ) const { return 0; }
|
EdgeID BeginEdges( const NodeID n ) const {
|
||||||
|
return m_query_graph->BeginEdges(n);
|
||||||
|
}
|
||||||
|
|
||||||
EdgeID EndEdges( const NodeID n ) const { return 0; }
|
EdgeID EndEdges( const NodeID n ) const {
|
||||||
|
return m_query_graph->EndEdges(n);
|
||||||
|
}
|
||||||
|
|
||||||
//searches for a specific edge
|
//searches for a specific edge
|
||||||
EdgeID FindEdge( const NodeID from, const NodeID to ) const { return 0; }
|
EdgeID FindEdge( const NodeID from, const NodeID to ) const {
|
||||||
|
return m_query_graph->FindEdge(from, to);
|
||||||
|
}
|
||||||
|
|
||||||
EdgeID FindEdgeInEitherDirection(
|
EdgeID FindEdgeInEitherDirection(
|
||||||
const NodeID from,
|
const NodeID from,
|
||||||
const NodeID to
|
const NodeID to
|
||||||
) const { return 0; }
|
) const {
|
||||||
|
return m_query_graph->FindEdgeInEitherDirection(from, to);
|
||||||
|
}
|
||||||
|
|
||||||
EdgeID FindEdgeIndicateIfReverse(
|
EdgeID FindEdgeIndicateIfReverse(
|
||||||
const NodeID from,
|
const NodeID from,
|
||||||
const NodeID to,
|
const NodeID to,
|
||||||
bool & result
|
bool & result
|
||||||
) const { return 0; }
|
) const {
|
||||||
|
return m_query_graph->FindEdgeIndicateIfReverse(from, to, result);
|
||||||
|
}
|
||||||
|
|
||||||
//node and edge information access
|
//node and edge information access
|
||||||
FixedPointCoordinate GetCoordinateOfNode(
|
FixedPointCoordinate GetCoordinateOfNode(
|
||||||
const unsigned id
|
const unsigned id
|
||||||
) const { return FixedPointCoordinate(); };
|
) const {
|
||||||
|
const NodeID node = m_via_node_list.at(id);
|
||||||
|
return m_coordinate_list.at(node);
|
||||||
|
};
|
||||||
|
|
||||||
TurnInstruction GetTurnInstructionForEdgeID(
|
TurnInstruction GetTurnInstructionForEdgeID(
|
||||||
const unsigned id
|
const unsigned id
|
||||||
) const { return 0; }
|
) const {
|
||||||
|
return m_turn_instruction_list.at(id);
|
||||||
|
}
|
||||||
|
|
||||||
bool LocateClosestEndPointForCoordinate(
|
bool LocateClosestEndPointForCoordinate(
|
||||||
const FixedPointCoordinate& input_coordinate,
|
const FixedPointCoordinate& input_coordinate,
|
||||||
FixedPointCoordinate& result,
|
FixedPointCoordinate& result,
|
||||||
const unsigned zoom_level = 18
|
const unsigned zoom_level = 18
|
||||||
) const { return false; }
|
) const {
|
||||||
|
return m_static_rtree->LocateClosestEndPointForCoordinate(
|
||||||
|
input_coordinate,
|
||||||
|
result,
|
||||||
|
zoom_level
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
bool FindPhantomNodeForCoordinate(
|
bool FindPhantomNodeForCoordinate(
|
||||||
const FixedPointCoordinate & input_coordinate,
|
const FixedPointCoordinate & input_coordinate,
|
||||||
PhantomNode & resulting_phantom_node,
|
PhantomNode & resulting_phantom_node,
|
||||||
const unsigned zoom_level
|
const unsigned zoom_level
|
||||||
) const { return false; }
|
) const {
|
||||||
|
return m_static_rtree->FindPhantomNodeForCoordinate(
|
||||||
|
input_coordinate,
|
||||||
|
resulting_phantom_node,
|
||||||
|
zoom_level
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
unsigned GetCheckSum() const { return 0; }
|
unsigned GetCheckSum() const { return m_check_sum; }
|
||||||
|
|
||||||
unsigned GetNameIndexFromEdgeID(const unsigned id) const { return 0; };
|
unsigned GetNameIndexFromEdgeID(const unsigned id) const { return 0; };
|
||||||
|
|
||||||
@ -95,7 +328,7 @@ public:
|
|||||||
) const { return; };
|
) const { return; };
|
||||||
|
|
||||||
std::string GetTimestamp() const {
|
std::string GetTimestamp() const {
|
||||||
return "";
|
return m_timestamp;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -26,13 +26,22 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
#include "BaseDataFacade.h"
|
#include "BaseDataFacade.h"
|
||||||
|
|
||||||
#include "../../DataStructures/StaticGraph.h"
|
#include "../../DataStructures/StaticGraph.h"
|
||||||
|
#include "../../Util/BoostFilesystemFix.h"
|
||||||
|
#include "../../Util/IniFile.h"
|
||||||
|
#include "../../Util/SimpleLogger.h"
|
||||||
|
|
||||||
template<class EdgeDataT>
|
template<class EdgeDataT>
|
||||||
class SharedDataFacade : public BaseDataFacade<EdgeDataT> {
|
class SharedDataFacade : public BaseDataFacade<EdgeDataT> {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
SharedDataFacade() { }
|
||||||
public:
|
public:
|
||||||
|
SharedDataFacade(
|
||||||
|
const IniFile & configuration,
|
||||||
|
const boost::filesystem::path base_path
|
||||||
|
) {
|
||||||
|
//TODO: load data
|
||||||
|
}
|
||||||
|
|
||||||
//search graph access
|
//search graph access
|
||||||
unsigned GetNumberOfNodes() const { return 0; }
|
unsigned GetNumberOfNodes() const { return 0; }
|
||||||
|
@ -403,12 +403,11 @@ NodeID readDDSGGraphFromStream(std::istream &in, std::vector<EdgeT>& edgeList, s
|
|||||||
|
|
||||||
template<typename NodeT, typename EdgeT>
|
template<typename NodeT, typename EdgeT>
|
||||||
unsigned readHSGRFromStream(
|
unsigned readHSGRFromStream(
|
||||||
const std::string & hsgr_filename,
|
const boost::filesystem::path & hsgr_file,
|
||||||
std::vector<NodeT> & node_list,
|
std::vector<NodeT> & node_list,
|
||||||
std::vector<EdgeT> & edge_list,
|
std::vector<EdgeT> & edge_list,
|
||||||
unsigned * check_sum
|
unsigned * check_sum
|
||||||
) {
|
) {
|
||||||
boost::filesystem::path hsgr_file(hsgr_filename);
|
|
||||||
if ( !boost::filesystem::exists( hsgr_file ) ) {
|
if ( !boost::filesystem::exists( hsgr_file ) ) {
|
||||||
throw OSRMException("hsgr file does not exist");
|
throw OSRMException("hsgr file does not exist");
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,10 @@ public:
|
|||||||
return parameters.Find(key);
|
return parameters.Find(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string GetParameter(const std::string & key) const {
|
||||||
|
return parameters.Find(key);
|
||||||
|
}
|
||||||
|
|
||||||
bool Holds(const std::string & key) const {
|
bool Holds(const std::string & key) const {
|
||||||
return parameters.Holds(key);
|
return parameters.Holds(key);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user