Routing datastructure more seperated from data of original edges

This commit is contained in:
DennisOSRM 2012-04-25 10:51:16 +02:00
parent ff0eae40ea
commit f8761ecea0
19 changed files with 223 additions and 75 deletions

View File

@ -22,9 +22,10 @@ or see http://www.gnu.org/licenses/agpl.txt.
#define DOUGLASPEUCKER_H_ #define DOUGLASPEUCKER_H_
#include <cfloat> #include <cfloat>
#include <stack> #include <stack>
#include "../DataStructures/ExtractorStructs.h"
/*This class object computes the bitvector of indicating generalized input points /*This class object computes the bitvector of indicating generalized input points
* according to the (Ramer-)Douglas-Peucker algorithm. * according to the (Ramer-)Douglas-Peucker algorithm.
* *

View File

@ -41,14 +41,14 @@ class Contractor {
private: private:
struct _EdgeBasedContractorEdgeData { struct _EdgeBasedContractorEdgeData {
_EdgeBasedContractorEdgeData() : _EdgeBasedContractorEdgeData() :
distance(0), originalEdges(0), via(0), nameID(0), turnInstruction(0), shortcut(0), forward(0), backward(0) {} distance(0), originalEdges(0), id(0)/*, nameID(0), turnInstruction(0)*/, shortcut(0), forward(0), backward(0) {}
_EdgeBasedContractorEdgeData( unsigned _distance, unsigned _originalEdges, unsigned _via, unsigned _nameID, short _turnInstruction, bool _shortcut, bool _forward, bool _backward) : _EdgeBasedContractorEdgeData( unsigned _distance, unsigned _originalEdges, unsigned _id/*, unsigned _nameID, short _turnInstruction*/, bool _shortcut, bool _forward, bool _backward) :
distance(_distance), originalEdges(_originalEdges), via(_via), nameID(_nameID), turnInstruction(_turnInstruction), shortcut(_shortcut), forward(_forward), backward(_backward), originalViaNodeID(false) {} distance(_distance), originalEdges(_originalEdges), id(_id)/*, nameID(_nameID), turnInstruction(_turnInstruction)*/, shortcut(_shortcut), forward(_forward), backward(_backward), originalViaNodeID(false) {}
unsigned distance; unsigned distance;
unsigned originalEdges; unsigned originalEdges;
unsigned via; unsigned id;
unsigned nameID; // unsigned nameID;
short turnInstruction; // short turnInstruction;
bool shortcut:1; bool shortcut:1;
bool forward:1; bool forward:1;
bool backward:1; bool backward:1;
@ -104,7 +104,7 @@ public:
_ImportEdge edge; _ImportEdge edge;
edge.source = currentEdge.source(); edge.source = currentEdge.source();
edge.target = currentEdge.target(); edge.target = currentEdge.target();
edge.data = _EdgeBasedContractorEdgeData( (std::max)((int)currentEdge.weight(), 1 ), 1, currentEdge.via(), currentEdge.getNameIDOfTurnTarget(), currentEdge.turnInstruction(), false, currentEdge.isForward(), currentEdge.isBackward()); edge.data = _EdgeBasedContractorEdgeData( (std::max)((int)currentEdge.weight(), 1 ), 1, currentEdge.id()/*, currentEdge.getNameIDOfTurnTarget(), currentEdge.turnInstruction()*/, false, currentEdge.isForward(), currentEdge.isBackward());
assert( edge.data.distance > 0 ); assert( edge.data.distance > 0 );
#ifdef NDEBUG #ifdef NDEBUG
@ -127,8 +127,8 @@ public:
for ( NodeID i = 0; i < edges.size(); ) { for ( NodeID i = 0; i < edges.size(); ) {
const NodeID source = edges[i].source; const NodeID source = edges[i].source;
const NodeID target = edges[i].target; const NodeID target = edges[i].target;
const NodeID via = edges[i].data.via; const NodeID id = edges[i].data.id;
const short turnType = edges[i].data.turnInstruction; // const short turnType = edges[i].data.turnInstruction;
//remove eigenloops //remove eigenloops
if ( source == target ) { if ( source == target ) {
i++; i++;
@ -140,10 +140,10 @@ public:
forwardEdge.target = backwardEdge.target = target; forwardEdge.target = backwardEdge.target = target;
forwardEdge.data.forward = backwardEdge.data.backward = true; forwardEdge.data.forward = backwardEdge.data.backward = true;
forwardEdge.data.backward = backwardEdge.data.forward = false; forwardEdge.data.backward = backwardEdge.data.forward = false;
forwardEdge.data.turnInstruction = backwardEdge.data.turnInstruction = turnType; // forwardEdge.data.turnInstruction = backwardEdge.data.turnInstruction = turnType;
forwardEdge.data.nameID = backwardEdge.data.nameID = edges[i].data.nameID; // forwardEdge.data.nameID = backwardEdge.data.nameID = edges[i].data.nameID;
forwardEdge.data.shortcut = backwardEdge.data.shortcut = false; forwardEdge.data.shortcut = backwardEdge.data.shortcut = false;
forwardEdge.data.via = backwardEdge.data.via = via; forwardEdge.data.id = backwardEdge.data.id = id;
forwardEdge.data.originalEdges = backwardEdge.data.originalEdges = 1; forwardEdge.data.originalEdges = backwardEdge.data.originalEdges = 1;
forwardEdge.data.distance = backwardEdge.data.distance = std::numeric_limits< int >::max(); forwardEdge.data.distance = backwardEdge.data.distance = std::numeric_limits< int >::max();
//remove parallel edges //remove parallel edges
@ -441,13 +441,13 @@ public:
newEdge.data.distance = data.distance; newEdge.data.distance = data.distance;
newEdge.data.shortcut = data.shortcut; newEdge.data.shortcut = data.shortcut;
if(!data.originalViaNodeID) if(!data.originalViaNodeID)
newEdge.data.via = oldNodeIDFromNewNodeIDMap[data.via]; newEdge.data.id = oldNodeIDFromNewNodeIDMap[data.id];
else else
newEdge.data.via = data.via; newEdge.data.id = data.id;
assert(newEdge.data.via != UINT_MAX); assert(newEdge.data.via != UINT_MAX);
newEdge.data.nameID = data.nameID; // newEdge.data.nameID = data.nameID;
newEdge.data.turnInstruction = data.turnInstruction; // newEdge.data.turnInstruction = data.turnInstruction;
newEdge.data.forward = data.forward; newEdge.data.forward = data.forward;
newEdge.data.backward = data.backward; newEdge.data.backward = data.backward;
edges.push_back( newEdge ); edges.push_back( newEdge );
@ -470,9 +470,9 @@ public:
newEdge.target = target; newEdge.target = target;
newEdge.data.distance = data.distance; newEdge.data.distance = data.distance;
newEdge.data.shortcut = data.shortcut; newEdge.data.shortcut = data.shortcut;
newEdge.data.via = data.via; newEdge.data.id = data.id;
newEdge.data.nameID = data.nameID; // newEdge.data.nameID = data.nameID;
newEdge.data.turnInstruction = data.turnInstruction; // newEdge.data.turnInstruction = data.turnInstruction;
newEdge.data.forward = data.forward; newEdge.data.forward = data.forward;
newEdge.data.backward = data.backward; newEdge.data.backward = data.backward;
edges.push_back( newEdge ); edges.push_back( newEdge );
@ -604,7 +604,7 @@ private:
_ImportEdge newEdge; _ImportEdge newEdge;
newEdge.source = source; newEdge.source = source;
newEdge.target = target; newEdge.target = target;
newEdge.data = _EdgeBasedContractorEdgeData( pathDistance, outData.originalEdges + inData.originalEdges, node, 0, inData.turnInstruction, true, true, false);; newEdge.data = _EdgeBasedContractorEdgeData( pathDistance, outData.originalEdges + inData.originalEdges, node/*, 0, inData.turnInstruction*/, true, true, false);;
insertedEdges.push_back( newEdge ); insertedEdges.push_back( newEdge );
std::swap( newEdge.source, newEdge.target ); std::swap( newEdge.source, newEdge.target );
newEdge.data.forward = false; newEdge.data.forward = false;

View File

@ -145,6 +145,10 @@ void EdgeBasedGraphFactory::GetEdgeBasedNodes( std::vector< EdgeBasedNode> & nod
nodes.swap(edgeBasedNodes); nodes.swap(edgeBasedNodes);
} }
void EdgeBasedGraphFactory::GetOriginalEdgeData( std::vector< OriginalEdgeData> & oed) {
oed.swap(originalEdgeData);
}
NodeID EdgeBasedGraphFactory::CheckForEmanatingIsOnlyTurn(const NodeID u, const NodeID v) const { NodeID EdgeBasedGraphFactory::CheckForEmanatingIsOnlyTurn(const NodeID u, const NodeID v) const {
std::pair < NodeID, NodeID > restrictionSource = std::make_pair(u, v); std::pair < NodeID, NodeID > restrictionSource = std::make_pair(u, v);
RestrictionMap::const_iterator restrIter = _restrictionMap.find(restrictionSource); RestrictionMap::const_iterator restrIter = _restrictionMap.find(restrictionSource);
@ -250,7 +254,10 @@ void EdgeBasedGraphFactory::Run() {
//distance += heightPenalty; //distance += heightPenalty;
//distance += ComputeTurnPenalty(u, v, w); //distance += ComputeTurnPenalty(u, v, w);
assert(edgeData1.edgeBasedNodeID != edgeData2.edgeBasedNodeID); assert(edgeData1.edgeBasedNodeID != edgeData2.edgeBasedNodeID);
EdgeBasedEdge newEdge(edgeData1.edgeBasedNodeID, edgeData2.edgeBasedNodeID, v, edgeData2.nameID, distance, true, false, turnInstruction); OriginalEdgeData oed(v,edgeData2.nameID, turnInstruction);
//TODO: replace v by pointer to oed-list
EdgeBasedEdge newEdge(edgeData1.edgeBasedNodeID, edgeData2.edgeBasedNodeID, edgeBasedEdges.size(), distance, true, false );
originalEdgeData.push_back(oed);
edgeBasedEdges.push_back(newEdge); edgeBasedEdges.push_back(newEdge);
} else { } else {
++numberOfSkippedTurns; ++numberOfSkippedTurns;

View File

@ -38,6 +38,7 @@
#include "../DataStructures/ExtractorStructs.h" #include "../DataStructures/ExtractorStructs.h"
#include "../DataStructures/HashTable.h" #include "../DataStructures/HashTable.h"
#include "../DataStructures/ImportEdge.h" #include "../DataStructures/ImportEdge.h"
#include "../DataStructures/QueryEdge.h"
#include "../DataStructures/Percent.h" #include "../DataStructures/Percent.h"
#include "../DataStructures/TurnInstructions.h" #include "../DataStructures/TurnInstructions.h"
#include "../Util/BaseConfiguration.h" #include "../Util/BaseConfiguration.h"
@ -104,6 +105,7 @@ private:
std::vector<EdgeBasedEdge> edgeBasedEdges; std::vector<EdgeBasedEdge> edgeBasedEdges;
std::vector<EdgeBasedNode> edgeBasedNodes; std::vector<EdgeBasedNode> edgeBasedNodes;
std::vector<OriginalEdgeData> originalEdgeData;
std::vector<NodeInfo> inputNodeInfoList; std::vector<NodeInfo> inputNodeInfoList;
NodeID CheckForEmanatingIsOnlyTurn(const NodeID u, const NodeID v) const; NodeID CheckForEmanatingIsOnlyTurn(const NodeID u, const NodeID v) const;
@ -128,6 +130,7 @@ public:
template< class ImportEdgeT > template< class ImportEdgeT >
void GetEdgeBasedEdges( std::vector< ImportEdgeT >& edges ); void GetEdgeBasedEdges( std::vector< ImportEdgeT >& edges );
void GetEdgeBasedNodes( std::vector< EdgeBasedNode> & nodes); void GetEdgeBasedNodes( std::vector< EdgeBasedNode> & nodes);
void GetOriginalEdgeData( std::vector< OriginalEdgeData> & originalEdgeData);
short AnalyzeTurn(const NodeID u, const NodeID v, const NodeID w) const; short AnalyzeTurn(const NodeID u, const NodeID v, const NodeID w) const;
unsigned GetNumberOfNodes() const; unsigned GetNumberOfNodes() const;
}; };

View File

@ -93,38 +93,39 @@ public:
EdgeBasedEdge(const EdgeT & myEdge ) : EdgeBasedEdge(const EdgeT & myEdge ) :
_source(myEdge.source), _source(myEdge.source),
_target(myEdge.target), _target(myEdge.target),
_via(myEdge.data.via), _edgeID(myEdge.data.via),
_nameID1(myEdge.data.nameID), // _nameID1(myEdge.data.nameID),
_weight(myEdge.data.distance), _weight(myEdge.data.distance),
_forward(myEdge.data.forward), _forward(myEdge.data.forward),
_backward(myEdge.data.backward), _backward(myEdge.data.backward)//,
_turnInstruction(myEdge.data.turnInstruction) { } // _turnInstruction(myEdge.data.turnInstruction)
{ }
/** Default constructor. target and weight are set to 0.*/ /** Default constructor. target and weight are set to 0.*/
EdgeBasedEdge() : EdgeBasedEdge() :
_source(0), _target(0), _via(0), _nameID1(0), _weight(0), _forward(0), _backward(0), _turnInstruction(0) { assert(false); } //shall not be used. _source(0), _target(0), _edgeID(0)/*, _nameID1(0)*/, _weight(0), _forward(0), _backward(0)/*, _turnInstruction(0)*/ { assert(false); } //shall not be used.
explicit EdgeBasedEdge(NodeID s, NodeID t, NodeID v, unsigned n1, EdgeWeight w, bool f, bool b, short ty) : explicit EdgeBasedEdge(NodeID s, NodeID t, NodeID v, /*unsigned n1,*/ EdgeWeight w, bool f, bool b/*, short ty*/) :
_source(s), _target(t), _via(v), _nameID1(n1), _weight(w), _forward(f), _backward(b), _turnInstruction(ty) { assert(ty >= 0); } _source(s), _target(t), _edgeID(v), /*_nameID1(n1),*/ _weight(w), _forward(f), _backward(b)/*, _turnInstruction(ty)*/ { assert(ty >= 0); }
NodeID target() const {return _target; } NodeID target() const {return _target; }
NodeID source() const {return _source; } NodeID source() const {return _source; }
EdgeWeight weight() const {return _weight; } EdgeWeight weight() const {return _weight; }
NodeID via() const { return _via; } NodeID id() const { return _edgeID; }
short turnInstruction() const { assert(_turnInstruction >= 0); return _turnInstruction; } // short turnInstruction() const { assert(_turnInstruction >= 0); return _turnInstruction; }
bool isBackward() const { return _backward; } bool isBackward() const { return _backward; }
bool isForward() const { return _forward; } bool isForward() const { return _forward; }
unsigned getNameIDOfTurnTarget() const { return _nameID1; } // unsigned getNameIDOfTurnTarget() const { return _nameID1; }
NodeID _source; NodeID _source;
NodeID _target; NodeID _target;
NodeID _via; NodeID _edgeID;
unsigned _nameID1; // unsigned _nameID1;
EdgeWeight _weight; EdgeWeight _weight;
bool _forward; bool _forward;
bool _backward; bool _backward;
short _turnInstruction; // short _turnInstruction;
}; };

View File

@ -26,6 +26,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include <vector> #include <vector>
#include "../typedefs.h" #include "../typedefs.h"
#include "../DataStructures/QueryEdge.h"
#include "NNGrid.h" #include "NNGrid.h"
#include "PhantomNodes.h" #include "PhantomNodes.h"
@ -44,15 +45,25 @@ public:
~NodeInformationHelpDesk() { ~NodeInformationHelpDesk() {
delete readOnlyGrid; delete readOnlyGrid;
} }
void initNNGrid(std::ifstream& in) { void initNNGrid(std::ifstream& nodesInstream, std::ifstream& edgesInStream) {
INFO("Loading node data");
NodeInfo b; NodeInfo b;
while(!in.eof()) { while(!nodesInstream.eof()) {
in.read((char *)&b, sizeof(NodeInfo)); nodesInstream.read((char *)&b, sizeof(NodeInfo));
coordinateVector.push_back(_Coordinate(b.lat, b.lon)); coordinateVector.push_back(_Coordinate(b.lat, b.lon));
} }
std::vector<_Coordinate>(coordinateVector).swap(coordinateVector); std::vector<_Coordinate>(coordinateVector).swap(coordinateVector);
numberOfNodes = coordinateVector.size(); numberOfNodes = coordinateVector.size();
in.close(); nodesInstream.close();
INFO("Loading edge data");
unsigned numberOfOrigEdges(0);
edgesInStream.read((char*)&numberOfOrigEdges, sizeof(unsigned));
origEdgeData.resize(numberOfOrigEdges);
edgesInStream.read((char*)&(origEdgeData[0]), numberOfOrigEdges*sizeof(OriginalEdgeData));
edgesInStream.close();
INFO("Loaded " << numberOfOrigEdges << " orig edges");
INFO("Opening NN indices");
readOnlyGrid->OpenIndexFiles(); readOnlyGrid->OpenIndexFiles();
} }
@ -60,9 +71,23 @@ public:
readOnlyGrid->OpenIndexFiles(); readOnlyGrid->OpenIndexFiles();
} }
inline int getLatitudeOfNode(const NodeID node) const { return coordinateVector.at(node).lat; } inline int getLatitudeOfNode(const unsigned id) const {
const NodeID node = origEdgeData.at(id).viaNode;
return coordinateVector.at(node).lat;
}
inline int getLongitudeOfNode(const NodeID node) const { return coordinateVector.at(node).lon; } inline int getLongitudeOfNode(const unsigned id) const {
const NodeID node = origEdgeData.at(id).viaNode;
return coordinateVector.at(node).lon;
}
inline unsigned getNameIndexFromEdgeID(const unsigned id) const {
return origEdgeData.at(id).nameID;
}
inline short getTurnInstructionFromEdgeID(const unsigned id) const {
return origEdgeData.at(id).turnInstruction;
}
inline NodeID getNumberOfNodes() const { return numberOfNodes; } inline NodeID getNumberOfNodes() const { return numberOfNodes; }
inline NodeID getNumberOfNodes2() const { return coordinateVector.size(); } inline NodeID getNumberOfNodes2() const { return coordinateVector.size(); }
@ -88,6 +113,8 @@ public:
private: private:
std::vector<_Coordinate> coordinateVector; std::vector<_Coordinate> coordinateVector;
std::vector<OriginalEdgeData> origEdgeData;
ReadOnlyGrid * readOnlyGrid; ReadOnlyGrid * readOnlyGrid;
unsigned numberOfNodes; unsigned numberOfNodes;
unsigned checkSum; unsigned checkSum;

View File

@ -0,0 +1,77 @@
/*
open source routing machine
Copyright (C) Dennis Luxen, others 2010
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU AFFERO General Public License as published by
the Free Software Foundation; either version 3 of the License, or
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or see http://www.gnu.org/licenses/agpl.txt.
*/
#ifndef QUERYEDGE_H_
#define QUERYEDGE_H_
#include <climits>
#include "../typedefs.h"
struct OriginalEdgeData{
explicit OriginalEdgeData(NodeID v, unsigned n, short t) : viaNode(v), nameID(n), turnInstruction(t) {}
OriginalEdgeData() : viaNode(UINT_MAX), nameID(UINT_MAX), turnInstruction(SHRT_MAX) {}
NodeID viaNode;
unsigned nameID;
short turnInstruction;
};
struct QueryEdge {
NodeID source;
NodeID target;
struct EdgeData {
NodeID id;
int distance;
bool shortcut:1;
bool forward:1;
bool backward:1;
} data;
bool operator<( const QueryEdge& right ) const {
if ( source != right.source )
return source < right.source;
return target < right.target;
}
//sorts by source and other attributes
static bool CompareBySource( const QueryEdge& left, const QueryEdge& right ) {
if ( left.source != right.source )
return left.source < right.source;
int l = ( left.data.forward ? -1 : 0 ) + ( left.data.backward ? -1 : 0 );
int r = ( right.data.forward ? -1 : 0 ) + ( right.data.backward ? -1 : 0 );
if ( l != r )
return l < r;
if ( left.target != right.target )
return left.target < right.target;
return left.data.distance < right.data.distance;
}
bool operator== ( const QueryEdge& right ) const {
return ( source == right.source && target == right.target && data.distance == right.data.distance &&
data.shortcut == right.data.shortcut && data.forward == right.data.forward && data.backward == right.data.backward
&& data.id == right.data.id
);
}
};
#endif /* QUERYEDGE_H_ */

View File

@ -28,6 +28,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include "BinaryHeap.h" #include "BinaryHeap.h"
#include "NodeInformationHelpDesk.h"
#include "PhantomNodes.h" #include "PhantomNodes.h"
#include "../Util/StringUtil.h" #include "../Util/StringUtil.h"
#include "../typedefs.h" #include "../typedefs.h"
@ -376,7 +377,8 @@ public:
return ed.via; return ed.via;
} }
inline std::string GetEscapedNameForNameID(const NodeID nameID) const { inline std::string GetEscapedNameForNameID(const unsigned nameID) const {
INFO("Getting name for ID: " << nameID);
return ((nameID >= _names.size() || nameID == 0) ? std::string("") : HTMLEntitize(_names.at(nameID))); return ((nameID >= _names.size() || nameID == 0) ? std::string("") : HTMLEntitize(_names.at(nameID)));
} }
@ -517,13 +519,14 @@ private:
const EdgeData& ed = _graph->GetEdgeData(smallestEdge); const EdgeData& ed = _graph->GetEdgeData(smallestEdge);
if(ed.shortcut) {//unpack if(ed.shortcut) {//unpack
const NodeID middle = ed.via; const NodeID middle = ed.id;
//again, we need to this in reversed order //again, we need to this in reversed order
recursionStack.push(std::make_pair(middle, edge.second)); recursionStack.push(std::make_pair(middle, edge.second));
recursionStack.push(std::make_pair(edge.first, middle)); recursionStack.push(std::make_pair(edge.first, middle));
} else { } else {
assert(!ed.shortcut); assert(!ed.shortcut);
unpackedPath.push_back(_PathData(ed.via, ed.nameID, ed.turnInstruction, ed.distance) ); //TODO: Hier die lookups in den nodehelpdeks machen
unpackedPath.push_back(_PathData(ed.id, nodeHelpDesk->getNameIndexFromEdgeID(ed.id), nodeHelpDesk->getTurnInstructionFromEdgeID(ed.id), ed.distance) );
} }
} }
} }

View File

@ -27,6 +27,7 @@
#include "../Algorithms/DouglasPeucker.h" #include "../Algorithms/DouglasPeucker.h"
#include "../Algorithms/PolylineCompressor.h" #include "../Algorithms/PolylineCompressor.h"
#include "../DataStructures/ExtractorStructs.h" #include "../DataStructures/ExtractorStructs.h"
#include "../DataStructures/QueryEdge.h"
#include "../DataStructures/SearchEngine.h" #include "../DataStructures/SearchEngine.h"
#include "../DataStructures/SegmentInformation.h" #include "../DataStructures/SegmentInformation.h"
#include "../DataStructures/TurnInstructions.h" #include "../DataStructures/TurnInstructions.h"
@ -39,7 +40,7 @@ class DescriptionFactory {
PolylineCompressor pc; PolylineCompressor pc;
PhantomNode startPhantom, targetPhantom; PhantomNode startPhantom, targetPhantom;
typedef SearchEngine<ContractionCleanup::Edge::EdgeData, StaticGraph<ContractionCleanup::Edge::EdgeData> > SearchEngineT; typedef SearchEngine<QueryEdge::EdgeData, StaticGraph<QueryEdge::EdgeData> > SearchEngineT;
public: public:
struct _RouteSummary { struct _RouteSummary {
std::string lengthString; std::string lengthString;

View File

@ -37,6 +37,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include "../Descriptors/JSONDescriptor.h" #include "../Descriptors/JSONDescriptor.h"
#include "../DataStructures/HashTable.h" #include "../DataStructures/HashTable.h"
#include "../DataStructures/QueryEdge.h"
#include "../DataStructures/StaticGraph.h" #include "../DataStructures/StaticGraph.h"
#include "../DataStructures/SearchEngine.h" #include "../DataStructures/SearchEngine.h"
@ -48,17 +49,17 @@ class ViaRoutePlugin : public BasePlugin {
private: private:
NodeInformationHelpDesk * nodeHelpDesk; NodeInformationHelpDesk * nodeHelpDesk;
std::vector<std::string> & names; std::vector<std::string> & names;
StaticGraph<EdgeData> * graph; StaticGraph<QueryEdge::EdgeData> * graph;
HashTable<std::string, unsigned> descriptorTable; HashTable<std::string, unsigned> descriptorTable;
std::string pluginDescriptorString; std::string pluginDescriptorString;
SearchEngine<EdgeData, StaticGraph<EdgeData> > * searchEngine; SearchEngine<QueryEdge::EdgeData, StaticGraph<QueryEdge::EdgeData> > * searchEngine;
public: public:
ViaRoutePlugin(QueryObjectsStorage * objects, std::string psd = "viaroute") : names(objects->names), pluginDescriptorString(psd) { ViaRoutePlugin(QueryObjectsStorage * objects, std::string psd = "viaroute") : names(objects->names), pluginDescriptorString(psd) {
nodeHelpDesk = objects->nodeHelpDesk; nodeHelpDesk = objects->nodeHelpDesk;
graph = objects->graph; graph = objects->graph;
searchEngine = new SearchEngine<EdgeData, StaticGraph<EdgeData> >(graph, nodeHelpDesk, names); searchEngine = new SearchEngine<QueryEdge::EdgeData, StaticGraph<QueryEdge::EdgeData> >(graph, nodeHelpDesk, names);
descriptorTable.Set("", 0); //default descriptor descriptorTable.Set("", 0); //default descriptor
descriptorTable.Set("json", 0); descriptorTable.Set("json", 0);
@ -139,7 +140,7 @@ public:
reply.status = http::Reply::ok; reply.status = http::Reply::ok;
//TODO: Move to member as smart pointer //TODO: Move to member as smart pointer
BaseDescriptor<SearchEngine<EdgeData, StaticGraph<EdgeData> > > * desc; BaseDescriptor<SearchEngine<QueryEdge::EdgeData, StaticGraph<QueryEdge::EdgeData> > > * desc;
std::string JSONParameter = routeParameters.options.Find("jsonp"); std::string JSONParameter = routeParameters.options.Find("jsonp");
if("" != JSONParameter) { if("" != JSONParameter) {
reply.content += JSONParameter; reply.content += JSONParameter;
@ -166,15 +167,15 @@ public:
} }
switch(descriptorType){ switch(descriptorType){
case 0: case 0:
desc = new JSONDescriptor<SearchEngine<EdgeData, StaticGraph<EdgeData> > >(); desc = new JSONDescriptor<SearchEngine<QueryEdge::EdgeData, StaticGraph<QueryEdge::EdgeData> > >();
break; break;
case 1: case 1:
desc = new GPXDescriptor<SearchEngine<EdgeData, StaticGraph<EdgeData> > >(); desc = new GPXDescriptor<SearchEngine<QueryEdge::EdgeData, StaticGraph<QueryEdge::EdgeData> > >();
break; break;
default: default:
desc = new JSONDescriptor<SearchEngine<EdgeData, StaticGraph<EdgeData> > >(); desc = new JSONDescriptor<SearchEngine<QueryEdge::EdgeData, StaticGraph<QueryEdge::EdgeData> > >();
break; break;
} }

View File

@ -22,9 +22,9 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include "QueryObjectsStorage.h" #include "QueryObjectsStorage.h"
#include "../../Util/GraphLoader.h" #include "../../Util/GraphLoader.h"
QueryObjectsStorage::QueryObjectsStorage(std::string hsgrPath, std::string ramIndexPath, std::string fileIndexPath, std::string nodesPath, std::string namesPath, std::string psd) { QueryObjectsStorage::QueryObjectsStorage(std::string hsgrPath, std::string ramIndexPath, std::string fileIndexPath, std::string nodesPath, std::string edgesPath, std::string namesPath, std::string psd) {
INFO("loading graph data"); INFO("loading graph data");
std::ifstream hsgrInStream(hsgrPath.c_str(), ios::binary); std::ifstream hsgrInStream(hsgrPath.c_str(), std::ios::binary);
//Deserialize road network graph //Deserialize road network graph
std::vector< QueryGraph::_StrNode> nodeList; std::vector< QueryGraph::_StrNode> nodeList;
std::vector< QueryGraph::_StrEdge> edgeList; std::vector< QueryGraph::_StrEdge> edgeList;
@ -34,15 +34,18 @@ QueryObjectsStorage::QueryObjectsStorage(std::string hsgrPath, std::string ramIn
graph = new QueryGraph(nodeList, edgeList); graph = new QueryGraph(nodeList, edgeList);
assert(0 == nodeList.size()); assert(0 == nodeList.size());
assert(0 == edgeList.size()); assert(0 == edgeList.size());
INFO("Loading nearest neighbor indices");
INFO("Loading auxiliary information");
//Init nearest neighbor data structure //Init nearest neighbor data structure
std::ifstream nodesInStream(nodesPath.c_str(), ios::binary); std::ifstream nodesInStream(nodesPath.c_str(), std::ios::binary);
std::ifstream edgesInStream(edgesPath.c_str(), std::ios::binary);
nodeHelpDesk = new NodeInformationHelpDesk(ramIndexPath.c_str(), fileIndexPath.c_str(), n, checkSum); nodeHelpDesk = new NodeInformationHelpDesk(ramIndexPath.c_str(), fileIndexPath.c_str(), n, checkSum);
nodeHelpDesk->initNNGrid(nodesInStream); nodeHelpDesk->initNNGrid(nodesInStream, edgesInStream);
//deserialize street name list //deserialize street name list
INFO("Loading names index"); INFO("Loading names index");
std::ifstream namesInStream(namesPath.c_str(), ios::binary); std::ifstream namesInStream(namesPath.c_str(), std::ios::binary);
unsigned size(0); unsigned size(0);
namesInStream.read((char *)&size, sizeof(unsigned)); namesInStream.read((char *)&size, sizeof(unsigned));
// names = new std::vector<std::string>(); // names = new std::vector<std::string>();

View File

@ -25,10 +25,12 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include<vector> #include<vector>
#include<string> #include<string>
#include "../../DataStructures/NodeInformationHelpDesk.h"
#include "../../DataStructures/QueryEdge.h"
#include "../../DataStructures/StaticGraph.h" #include "../../DataStructures/StaticGraph.h"
struct QueryObjectsStorage { struct QueryObjectsStorage {
typedef StaticGraph<EdgeData> QueryGraph; typedef StaticGraph<QueryEdge::EdgeData> QueryGraph;
typedef QueryGraph::InputEdge InputEdge; typedef QueryGraph::InputEdge InputEdge;
NodeInformationHelpDesk * nodeHelpDesk; NodeInformationHelpDesk * nodeHelpDesk;
@ -36,7 +38,7 @@ struct QueryObjectsStorage {
QueryGraph * graph; QueryGraph * graph;
unsigned checkSum; unsigned checkSum;
QueryObjectsStorage(std::string hsgrPath, std::string ramIndexPath, std::string fileIndexPath, std::string nodesPath, std::string namesPath, std::string psd = "route"); QueryObjectsStorage(std::string hsgrPath, std::string ramIndexPath, std::string fileIndexPath, std::string nodesPath, std::string edgesPath, std::string namesPath, std::string psd = "route");
~QueryObjectsStorage(); ~QueryObjectsStorage();
}; };

View File

@ -31,6 +31,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include "ServerConfiguration.h" #include "ServerConfiguration.h"
#include "../Util/InputFileUtil.h" #include "../Util/InputFileUtil.h"
#include "../Util/OpenMPReplacement.h"
typedef http::Server Server; typedef http::Server Server;

View File

@ -32,6 +32,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include <boost/unordered_map.hpp> #include <boost/unordered_map.hpp>
#include "../DataStructures/ExtractorStructs.h"
#include "../DataStructures/ImportEdge.h" #include "../DataStructures/ImportEdge.h"
#include "../typedefs.h" #include "../typedefs.h"

View File

@ -17,7 +17,10 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or see http://www.gnu.org/licenses/agpl.txt. or see http://www.gnu.org/licenses/agpl.txt.
*/ */
#include <iomanip>
#include <errno.h>
#include <zip.h>
#include "NASAGridSquare.h" #include "NASAGridSquare.h"

View File

@ -21,9 +21,12 @@ or see http://www.gnu.org/licenses/agpl.txt.
#ifndef STRINGUTIL_H_ #ifndef STRINGUTIL_H_
#define STRINGUTIL_H_ #define STRINGUTIL_H_
#include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <string> #include <string>
#include "../DataStructures/ExtractorStructs.h"
// precision: position after decimal point // precision: position after decimal point
// length: maximum number of digits including comma and decimals // length: maximum number of digits including comma and decimals
template< int length, int precision > template< int length, int precision >

View File

@ -43,11 +43,11 @@ or see http://www.gnu.org/licenses/agpl.txt.
#include "Util/OpenMPReplacement.h" #include "Util/OpenMPReplacement.h"
#include "typedefs.h" #include "typedefs.h"
#include "Contractor/Contractor.h" #include "Contractor/Contractor.h"
#include "Contractor/ContractionCleanup.h"
#include "Contractor/EdgeBasedGraphFactory.h" #include "Contractor/EdgeBasedGraphFactory.h"
#include "DataStructures/BinaryHeap.h" #include "DataStructures/BinaryHeap.h"
#include "DataStructures/ExtractorStructs.h" #include "DataStructures/ExtractorStructs.h"
#include "DataStructures/NNGrid.h" #include "DataStructures/NNGrid.h"
#include "DataStructures/QueryEdge.h"
#include "Util/BaseConfiguration.h" #include "Util/BaseConfiguration.h"
#include "Util/InputFileUtil.h" #include "Util/InputFileUtil.h"
#include "Util/GraphLoader.h" #include "Util/GraphLoader.h"
@ -55,6 +55,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
using namespace std; using namespace std;
typedef QueryEdge::EdgeData EdgeData;
typedef DynamicGraph<EdgeData>::InputEdge InputEdge; typedef DynamicGraph<EdgeData>::InputEdge InputEdge;
typedef StaticGraph<EdgeData>::InputEdge StaticEdge; typedef StaticGraph<EdgeData>::InputEdge StaticEdge;
typedef BaseConfiguration ContractorConfiguration; typedef BaseConfiguration ContractorConfiguration;
@ -105,7 +106,8 @@ int main (int argc, char *argv[]) {
} }
char nodeOut[1024]; strcpy(nodeOut, argv[1]); strcat(nodeOut, ".nodes"); char nodeOut[1024]; strcpy(nodeOut, argv[1]); strcat(nodeOut, ".nodes");
char edgeOut[1024]; strcpy(edgeOut, argv[1]); strcat(edgeOut, ".hsgr"); char edgeOut[1024]; strcpy(edgeOut, argv[1]); strcat(edgeOut, ".edges");
char graphOut[1024]; strcpy(graphOut, argv[1]); strcat(graphOut, ".hsgr");
char ramIndexOut[1024]; strcpy(ramIndexOut, argv[1]); strcat(ramIndexOut, ".ramIndex"); char ramIndexOut[1024]; strcpy(ramIndexOut, argv[1]); strcat(ramIndexOut, ".ramIndex");
char fileIndexOut[1024]; strcpy(fileIndexOut, argv[1]); strcat(fileIndexOut, ".fileIndex"); char fileIndexOut[1024]; strcpy(fileIndexOut, argv[1]); strcat(fileIndexOut, ".fileIndex");
char levelInfoOut[1024]; strcpy(levelInfoOut, argv[1]); strcat(levelInfoOut, ".levels"); char levelInfoOut[1024]; strcpy(levelInfoOut, argv[1]); strcat(levelInfoOut, ".levels");
@ -129,6 +131,17 @@ int main (int argc, char *argv[]) {
std::vector<EdgeBasedEdge> edgeBasedEdgeList; std::vector<EdgeBasedEdge> edgeBasedEdgeList;
edgeBasedGraphFactory->GetEdgeBasedEdges(edgeBasedEdgeList); edgeBasedGraphFactory->GetEdgeBasedEdges(edgeBasedEdgeList);
std::vector<OriginalEdgeData> originalEdgeData;
edgeBasedGraphFactory->GetOriginalEdgeData(originalEdgeData);
INFO("writing info on original edges");
std::ofstream oedOutFile(edgeOut, std::ios::binary);
unsigned numberOfOrigEdges = originalEdgeData.size();
oedOutFile.write((char*)&numberOfOrigEdges, sizeof(unsigned));
oedOutFile.write((char*)&(originalEdgeData[0]), originalEdgeData.size()*sizeof(OriginalEdgeData));
oedOutFile.close();
std::vector<OriginalEdgeData>().swap(originalEdgeData);
std::vector<EdgeBasedGraphFactory::EdgeBasedNode> nodeBasedEdgeList; std::vector<EdgeBasedGraphFactory::EdgeBasedNode> nodeBasedEdgeList;
edgeBasedGraphFactory->GetEdgeBasedNodes(nodeBasedEdgeList); edgeBasedGraphFactory->GetEdgeBasedNodes(nodeBasedEdgeList);
delete edgeBasedGraphFactory; delete edgeBasedGraphFactory;
@ -144,10 +157,9 @@ int main (int argc, char *argv[]) {
std::vector<EdgeBasedGraphFactory::EdgeBasedNode>().swap(nodeBasedEdgeList); std::vector<EdgeBasedGraphFactory::EdgeBasedNode>().swap(nodeBasedEdgeList);
INFO("writing node map ..."); INFO("writing node map ...");
std::ofstream mapOutFile(nodeOut, ios::binary); std::ofstream mapOutFile(nodeOut, std::ios::binary);
mapOutFile.write((char *)&(internalToExternalNodeMapping[0]), internalToExternalNodeMapping.size()*sizeof(NodeInfo)); mapOutFile.write((char *)&(internalToExternalNodeMapping[0]), internalToExternalNodeMapping.size()*sizeof(NodeInfo));
mapOutFile.close(); mapOutFile.close();
std::vector<NodeInfo>().swap(internalToExternalNodeMapping); std::vector<NodeInfo>().swap(internalToExternalNodeMapping);
INFO("initializing contractor"); INFO("initializing contractor");
@ -156,7 +168,7 @@ int main (int argc, char *argv[]) {
contractor->Run(); contractor->Run();
INFO("Contraction took " << get_timestamp() - contractionStartedTimestamp << " sec"); INFO("Contraction took " << get_timestamp() - contractionStartedTimestamp << " sec");
std::vector< ContractionCleanup::Edge > contractedEdgeList; std::vector< QueryEdge > contractedEdgeList;
contractor->GetEdges( contractedEdgeList ); contractor->GetEdges( contractedEdgeList );
delete contractor; delete contractor;
@ -165,9 +177,9 @@ int main (int argc, char *argv[]) {
unsigned numberOfNodes = 0; unsigned numberOfNodes = 0;
unsigned numberOfEdges = contractedEdgeList.size(); unsigned numberOfEdges = contractedEdgeList.size();
INFO("Serializing compacted graph"); INFO("Serializing compacted graph");
ofstream edgeOutFile(edgeOut, ios::binary); ofstream edgeOutFile(graphOut, ios::binary);
BOOST_FOREACH(ContractionCleanup::Edge & edge, contractedEdgeList) { BOOST_FOREACH(QueryEdge & edge, contractedEdgeList) {
if(edge.source > numberOfNodes) { if(edge.source > numberOfNodes) {
numberOfNodes = edge.source; numberOfNodes = edge.source;
} }

View File

@ -92,6 +92,7 @@ int main (int argc, char *argv[]) {
serverConfig.GetParameter("ramIndex"), serverConfig.GetParameter("ramIndex"),
serverConfig.GetParameter("fileIndex"), serverConfig.GetParameter("fileIndex"),
serverConfig.GetParameter("nodesData"), serverConfig.GetParameter("nodesData"),
serverConfig.GetParameter("edgesData"),
serverConfig.GetParameter("namesData")); serverConfig.GetParameter("namesData"));
h.RegisterPlugin(new HelloWorldPlugin()); h.RegisterPlugin(new HelloWorldPlugin());

View File

@ -26,6 +26,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
#endif #endif
#include <climits> #include <climits>
#include <iostream>
using namespace std; using namespace std;
@ -64,8 +65,8 @@ static const EdgeID SPECIAL_EDGEID = UINT_MAX;
#include "DataStructures/NodeCoords.h" #include "DataStructures/NodeCoords.h"
typedef NodeCoords<NodeID> NodeInfo; typedef NodeCoords<NodeID> NodeInfo;
#include "DataStructures/NodeInformationHelpDesk.h" //#include "DataStructures/NodeInformationHelpDesk.h"
#include "Contractor/ContractionCleanup.h" //#include "Contractor/ContractionCleanup.h"
typedef ContractionCleanup::Edge::EdgeData EdgeData; //typedef ContractionCleanup::Edge::EdgeData EdgeData;
#endif /* TYPEDEFS_H_ */ #endif /* TYPEDEFS_H_ */