Saving 4 bytes on each original edge. Simplifying handling of original
edge data
This commit is contained in:
parent
0f03beb2b5
commit
f780aa6160
@ -234,6 +234,9 @@ void EdgeBasedGraphFactory::Run(const char * originalEdgeDataFilename) {
|
|||||||
std::vector<NodeID>().swap(vectorOfComponentSizes);
|
std::vector<NodeID>().swap(vectorOfComponentSizes);
|
||||||
std::vector<NodeID>().swap(componentsIndex);
|
std::vector<NodeID>().swap(componentsIndex);
|
||||||
|
|
||||||
|
std::vector<OriginalEdgeData> original_edge_data_vector;
|
||||||
|
original_edge_data_vector.reserve(10000);
|
||||||
|
|
||||||
//Loop over all turns and generate new set of edges.
|
//Loop over all turns and generate new set of edges.
|
||||||
//Three nested loop look super-linear, but we are dealing with a linear number of turns only.
|
//Three nested loop look super-linear, but we are dealing with a linear number of turns only.
|
||||||
for(_NodeBasedDynamicGraph::NodeIterator u = 0; u < _nodeBasedGraph->GetNumberOfNodes(); ++u ) {
|
for(_NodeBasedDynamicGraph::NodeIterator u = 0; u < _nodeBasedGraph->GetNumberOfNodes(); ++u ) {
|
||||||
@ -271,8 +274,9 @@ void EdgeBasedGraphFactory::Run(const char * originalEdgeDataFilename) {
|
|||||||
distance += speedProfile.trafficSignalPenalty;
|
distance += speedProfile.trafficSignalPenalty;
|
||||||
}
|
}
|
||||||
TurnInstruction turnInstruction = AnalyzeTurn(u, v, w);
|
TurnInstruction turnInstruction = AnalyzeTurn(u, v, w);
|
||||||
if(turnInstruction == TurnInstructions.UTurn)
|
if(TurnInstructions.UTurn == turnInstruction) {
|
||||||
distance += speedProfile.uTurnPenalty;
|
distance += speedProfile.uTurnPenalty;
|
||||||
|
}
|
||||||
// if(!edgeData1.isAccessRestricted && edgeData2.isAccessRestricted) {
|
// if(!edgeData1.isAccessRestricted && edgeData2.isAccessRestricted) {
|
||||||
// distance += TurnInstructions.AccessRestrictionPenalty;
|
// distance += TurnInstructions.AccessRestrictionPenalty;
|
||||||
// turnInstruction |= TurnInstructions.AccessRestrictionFlag;
|
// turnInstruction |= TurnInstructions.AccessRestrictionFlag;
|
||||||
@ -282,17 +286,16 @@ void EdgeBasedGraphFactory::Run(const char * originalEdgeDataFilename) {
|
|||||||
//distance += heightPenalty;
|
//distance += heightPenalty;
|
||||||
//distance += ComputeTurnPenalty(u, v, w);
|
//distance += ComputeTurnPenalty(u, v, w);
|
||||||
assert(edgeData1.edgeBasedNodeID != edgeData2.edgeBasedNodeID);
|
assert(edgeData1.edgeBasedNodeID != edgeData2.edgeBasedNodeID);
|
||||||
if(originalEdgeData.size() == originalEdgeData.capacity()-3) {
|
|
||||||
originalEdgeData.reserve(originalEdgeData.size()*1.2);
|
|
||||||
}
|
|
||||||
OriginalEdgeData oed(v,edgeData2.nameID, turnInstruction);
|
OriginalEdgeData oed(v,edgeData2.nameID, turnInstruction);
|
||||||
EdgeBasedEdge newEdge(edgeData1.edgeBasedNodeID, edgeData2.edgeBasedNodeID, edgeBasedEdges.size(), distance, true, false );
|
original_edge_data_vector.push_back(oed);
|
||||||
originalEdgeData.push_back(oed);
|
|
||||||
if(originalEdgeData.size() > 100000) {
|
|
||||||
originalEdgeDataOutFile.write((char*)&(originalEdgeData[0]), originalEdgeData.size()*sizeof(OriginalEdgeData));
|
|
||||||
originalEdgeData.clear();
|
|
||||||
}
|
|
||||||
++numberOfOriginalEdges;
|
++numberOfOriginalEdges;
|
||||||
|
|
||||||
|
if(original_edge_data_vector.size() > 100000) {
|
||||||
|
originalEdgeDataOutFile.write((char*)&(original_edge_data_vector[0]), original_edge_data_vector.size()*sizeof(OriginalEdgeData));
|
||||||
|
original_edge_data_vector.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
EdgeBasedEdge newEdge(edgeData1.edgeBasedNodeID, edgeData2.edgeBasedNodeID, edgeBasedEdges.size(), distance, true, false );
|
||||||
edgeBasedEdges.push_back(newEdge);
|
edgeBasedEdges.push_back(newEdge);
|
||||||
} else {
|
} else {
|
||||||
++numberOfSkippedTurns;
|
++numberOfSkippedTurns;
|
||||||
@ -302,7 +305,7 @@ void EdgeBasedGraphFactory::Run(const char * originalEdgeDataFilename) {
|
|||||||
}
|
}
|
||||||
p.printIncrement();
|
p.printIncrement();
|
||||||
}
|
}
|
||||||
originalEdgeDataOutFile.write((char*)&(originalEdgeData[0]), originalEdgeData.size()*sizeof(OriginalEdgeData));
|
originalEdgeDataOutFile.write((char*)&(original_edge_data_vector[0]), original_edge_data_vector.size()*sizeof(OriginalEdgeData));
|
||||||
originalEdgeDataOutFile.seekp(std::ios::beg);
|
originalEdgeDataOutFile.seekp(std::ios::beg);
|
||||||
originalEdgeDataOutFile.write((char*)&numberOfOriginalEdges, sizeof(unsigned));
|
originalEdgeDataOutFile.write((char*)&numberOfOriginalEdges, sizeof(unsigned));
|
||||||
originalEdgeDataOutFile.close();
|
originalEdgeDataOutFile.close();
|
||||||
|
@ -82,13 +82,13 @@ private:
|
|||||||
unsigned edgeBasedNodeID;
|
unsigned edgeBasedNodeID;
|
||||||
unsigned nameID;
|
unsigned nameID;
|
||||||
short type;
|
short type;
|
||||||
bool isAccessRestricted;
|
bool isAccessRestricted:1;
|
||||||
bool shortcut:1;
|
bool shortcut:1;
|
||||||
bool forward:1;
|
bool forward:1;
|
||||||
bool backward:1;
|
bool backward:1;
|
||||||
bool roundabout:1;
|
bool roundabout:1;
|
||||||
bool ignoreInGrid:1;
|
bool ignoreInGrid:1;
|
||||||
bool contraFlow;
|
bool contraFlow:1;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _EdgeBasedEdgeData {
|
struct _EdgeBasedEdgeData {
|
||||||
@ -118,7 +118,6 @@ private:
|
|||||||
|
|
||||||
DeallocatingVector<EdgeBasedEdge> edgeBasedEdges;
|
DeallocatingVector<EdgeBasedEdge> edgeBasedEdges;
|
||||||
DeallocatingVector<EdgeBasedNode> edgeBasedNodes;
|
DeallocatingVector<EdgeBasedNode> edgeBasedNodes;
|
||||||
std::vector<OriginalEdgeData> originalEdgeData;
|
|
||||||
|
|
||||||
NodeID CheckForEmanatingIsOnlyTurn(const NodeID u, const NodeID v) const;
|
NodeID CheckForEmanatingIsOnlyTurn(const NodeID u, const NodeID v) const;
|
||||||
bool CheckIfTurnIsRestricted(const NodeID u, const NodeID v, const NodeID w) const;
|
bool CheckIfTurnIsRestricted(const NodeID u, const NodeID v, const NodeID w) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user