Space requirements are better now

This commit is contained in:
DennisOSRM
2011-11-25 12:02:52 +01:00
parent d32734af0b
commit 8d008f9dcc
4 changed files with 56 additions and 93 deletions
+15 -24
View File
@@ -51,7 +51,7 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory(int nodes, std::vector<NodeBasedEdg
assert( edge.data.distance > 0 );
edge.data.shortcut = false;
edge.data.roundabout = i->isRoundabout();
edge.data.middleName.nameID = i->name();
edge.data.nameID = i->name();
edge.data.type = i->type();
edge.data.forward = i->isForward();
edge.data.backward = i->isBackward();
@@ -66,7 +66,6 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory(int nodes, std::vector<NodeBasedEdg
}
}
INFO("edges.size()=" << edges.size());
#ifdef _GLIBCXX_PARALLEL
__gnu_parallel::sort( edges.begin(), edges.end() );
@@ -79,14 +78,12 @@ EdgeBasedGraphFactory::EdgeBasedGraphFactory(int nodes, std::vector<NodeBasedEdg
}
template<>
void EdgeBasedGraphFactory::GetEdgeBasedEdges( std::vector< EdgeBasedEdge >& edges ) {
void EdgeBasedGraphFactory::GetEdgeBasedEdges( std::vector< EdgeBasedEdge >& outputEdgeList ) {
GUARANTEE(0 == edges.size(), "Vector passed to " << __FUNCTION__ << " is not empty");
GUARANTEE(0 == outputEdgeList.size(), "Vector passed to EdgeBasedGraphFactory::GetEdgeBasedEdges(..) is not empty");
GUARANTEE(0 != edgeBasedEdges.size(), "No edges in edge based graph");
BOOST_FOREACH ( EdgeBasedEdge currentEdge, edgeBasedEdges) {
edges.push_back(currentEdge);
}
edgeBasedEdges.swap(outputEdgeList);
}
void EdgeBasedGraphFactory::GetEdgeBasedNodes( std::vector< EdgeBasedNode> & nodes) {
@@ -97,8 +94,6 @@ void EdgeBasedGraphFactory::GetEdgeBasedNodes( std::vector< EdgeBasedNode> & nod
void EdgeBasedGraphFactory::Run() {
INFO("Generating Edge based representation of input data");
_edgeBasedGraph.reset(new _EdgeBasedDynamicGraph(_nodeBasedGraph->GetNumberOfEdges() ) );
std::vector<_Restriction>::iterator restrictionIterator = inputRestrictions.begin();
Percent p(_nodeBasedGraph->GetNumberOfNodes());
int numberOfResolvedRestrictions(0);
@@ -141,25 +136,21 @@ void EdgeBasedGraphFactory::Run() {
ERR("edgeBasedTarget" << edgeBasedTarget << ">" << _nodeBasedGraph->GetNumberOfEdges());
}
_EdgeBasedEdge newEdge;
newEdge.source = edgeBasedSource;
newEdge.target = edgeBasedTarget;
//incorporate turn costs, this is just a simple model and can (read: must) be extended
double angle = GetAngleBetweenTwoEdges(inputNodeInfoList[u], inputNodeInfoList[v], inputNodeInfoList[w]);
newEdge.data.distance = (int)( _nodeBasedGraph->GetEdgeData(e1).distance *(1+std::abs((angle-180.)/180.)));
newEdge.data.forward = true;
newEdge.data.backward = false;
newEdge.data.via = v;
newEdge.data.nameID = _nodeBasedGraph->GetEdgeData(e2).middleName.nameID;
newEdge.data.turnInstruction = AnalyzeTurn(u, v, w);
//create Edge for NearestNeighborlookup
unsigned distance = (int)( _nodeBasedGraph->GetEdgeData(e1).distance *(1+std::abs((angle-180.)/180.)));
unsigned nameID = _nodeBasedGraph->GetEdgeData(e2).nameID;
short turnInstruction = AnalyzeTurn(u, v, w);
//create edge-based graph edge
//EdgeBasedEdge(NodeID s, NodeID t, NodeID v, unsigned n1, EdgeWeight w, bool f, bool b, short ty)
EdgeBasedEdge newEdge(edgeBasedSource, edgeBasedTarget, v, nameID, distance, true, false, turnInstruction);
edgeBasedEdges.push_back(newEdge);
EdgeBasedNode currentNode;
if(_nodeBasedGraph->GetEdgeData(e1).type != 14) {
currentNode.nameID = _nodeBasedGraph->GetEdgeData(e1).middleName.nameID;
currentNode.nameID = _nodeBasedGraph->GetEdgeData(e1).nameID;
currentNode.lat1 = inputNodeInfoList[u].lat;
currentNode.lon1 = inputNodeInfoList[u].lon;
currentNode.lat2 = inputNodeInfoList[v].lat;
@@ -188,8 +179,8 @@ short EdgeBasedGraphFactory::AnalyzeTurn(const NodeID u, const NodeID v, const N
_NodeBasedDynamicGraph::EdgeIterator edge1 = _nodeBasedGraph->FindEdge(u, v);
_NodeBasedDynamicGraph::EdgeIterator edge2 = _nodeBasedGraph->FindEdge(v, w);
_NodeBasedDynamicGraph::EdgeData data1 = _nodeBasedGraph->GetEdgeData(edge1);
_NodeBasedDynamicGraph::EdgeData data2 = _nodeBasedGraph->GetEdgeData(edge2);
_NodeBasedDynamicGraph::EdgeData & data1 = _nodeBasedGraph->GetEdgeData(edge1);
_NodeBasedDynamicGraph::EdgeData & data2 = _nodeBasedGraph->GetEdgeData(edge2);
double angle = GetAngleBetweenTwoEdges(inputNodeInfoList[u], inputNodeInfoList[v], inputNodeInfoList[w]);
@@ -214,7 +205,7 @@ short EdgeBasedGraphFactory::AnalyzeTurn(const NodeID u, const NodeID v, const N
}
//If street names stay the same and if we are certain that it is not a roundabout, we skip it.
if(data1.middleName.nameID == data2.middleName.nameID)
if(data1.nameID == data2.nameID)
return TurnInstructions.NoTurn;
return TurnInstructions.GetTurnDirectionOfInstruction(angle);
+6 -15
View File
@@ -37,21 +37,15 @@
class EdgeBasedGraphFactory {
private:
union _MiddleName {
unsigned middle;
unsigned nameID;
};
struct _NodeBasedEdgeData {
int distance;
unsigned edgeBasedNodeID;
unsigned originalEdges;
bool shortcut;
bool forward;
bool backward;
bool roundabout;
unsigned nameID;
bool shortcut:1;
bool forward:1;
bool backward:1;
bool roundabout:1;
short type;
_MiddleName middleName;
} data;
struct _EdgeBasedEdgeData {
@@ -83,16 +77,13 @@ public:
unsigned weight;
};
typedef DynamicGraph< _EdgeBasedEdgeData> _EdgeBasedDynamicGraph;
typedef _EdgeBasedDynamicGraph::InputEdge _EdgeBasedEdge;
private:
boost::shared_ptr<_NodeBasedDynamicGraph> _nodeBasedGraph;
boost::shared_ptr<_EdgeBasedDynamicGraph> _edgeBasedGraph;
std::vector<_Restriction> & inputRestrictions;
std::vector<NodeInfo> & inputNodeInfoList;
std::vector<_EdgeBasedEdge> edgeBasedEdges;
std::vector<EdgeBasedEdge> edgeBasedEdges;
std::vector<EdgeBasedNode> edgeBasedNodes;
template<class CoordinateT>