CRC32 of data is written to file and loaded into NodeInfoHelpDesk.
This commit is contained in:
parent
ac41c3b06c
commit
e034733ac6
@ -31,7 +31,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
|
|
||||||
class NodeInformationHelpDesk{
|
class NodeInformationHelpDesk{
|
||||||
public:
|
public:
|
||||||
NodeInformationHelpDesk(const char* ramIndexInput, const char* fileIndexInput, const unsigned _numberOfNodes) : numberOfNodes(_numberOfNodes) {
|
NodeInformationHelpDesk(const char* ramIndexInput, const char* fileIndexInput, const unsigned _numberOfNodes, const unsigned crc) : numberOfNodes(_numberOfNodes), checkSum(crc) {
|
||||||
readOnlyGrid = new ReadOnlyGrid(ramIndexInput,fileIndexInput);
|
readOnlyGrid = new ReadOnlyGrid(ramIndexInput,fileIndexInput);
|
||||||
coordinateVector.reserve(numberOfNodes);
|
coordinateVector.reserve(numberOfNodes);
|
||||||
assert(0 == coordinateVector.size());
|
assert(0 == coordinateVector.size());
|
||||||
@ -72,10 +72,15 @@ public:
|
|||||||
readOnlyGrid->FindNearestPointOnEdge(input, output);
|
readOnlyGrid->FindNearestPointOnEdge(input, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline unsigned GetCheckSum() const {
|
||||||
|
return checkSum;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<_Coordinate> coordinateVector;
|
std::vector<_Coordinate> coordinateVector;
|
||||||
ReadOnlyGrid * readOnlyGrid;
|
ReadOnlyGrid * readOnlyGrid;
|
||||||
unsigned numberOfNodes;
|
unsigned numberOfNodes;
|
||||||
|
unsigned checkSum;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*NODEINFORMATIONHELPDESK_H_*/
|
#endif /*NODEINFORMATIONHELPDESK_H_*/
|
||||||
|
@ -36,6 +36,7 @@ struct ObjectsForQueryStruct {
|
|||||||
NodeInformationHelpDesk * nodeHelpDesk;
|
NodeInformationHelpDesk * nodeHelpDesk;
|
||||||
std::vector<std::string> * names;
|
std::vector<std::string> * names;
|
||||||
QueryGraph * graph;
|
QueryGraph * graph;
|
||||||
|
unsigned checkSum;
|
||||||
|
|
||||||
ObjectsForQueryStruct(std::string hsgrPath, std::string ramIndexPath, std::string fileIndexPath, std::string nodesPath, std::string namesPath, std::string psd = "route") {
|
ObjectsForQueryStruct(std::string hsgrPath, std::string ramIndexPath, std::string fileIndexPath, std::string nodesPath, std::string namesPath, std::string psd = "route") {
|
||||||
INFO("loading graph data");
|
INFO("loading graph data");
|
||||||
@ -43,14 +44,15 @@ struct ObjectsForQueryStruct {
|
|||||||
//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;
|
||||||
const int n = readHSGRFromStream(hsgrInStream, nodeList, edgeList);
|
const int n = readHSGRFromStream(hsgrInStream, nodeList, edgeList, &checkSum);
|
||||||
|
INFO("Data checksum is " << checkSum);
|
||||||
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 nearest neighbor indices");
|
||||||
//Init nearest neighbor data structure
|
//Init nearest neighbor data structure
|
||||||
std::ifstream nodesInStream(nodesPath.c_str(), ios::binary);
|
std::ifstream nodesInStream(nodesPath.c_str(), ios::binary);
|
||||||
nodeHelpDesk = new NodeInformationHelpDesk(ramIndexPath.c_str(), fileIndexPath.c_str(), n);
|
nodeHelpDesk = new NodeInformationHelpDesk(ramIndexPath.c_str(), fileIndexPath.c_str(), n, checkSum);
|
||||||
nodeHelpDesk->initNNGrid(nodesInStream);
|
nodeHelpDesk->initNNGrid(nodesInStream);
|
||||||
|
|
||||||
//deserialize street name list
|
//deserialize street name list
|
||||||
|
@ -361,8 +361,9 @@ NodeID readDDSGGraphFromStream(istream &in, vector<EdgeT>& edgeList, vector<Node
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<typename NodeT, typename EdgeT>
|
template<typename NodeT, typename EdgeT>
|
||||||
unsigned readHSGRFromStream(istream &in, vector<NodeT>& nodeList, vector<EdgeT> & edgeList) {
|
unsigned readHSGRFromStream(istream &in, vector<NodeT>& nodeList, vector<EdgeT> & edgeList, unsigned * checkSum) {
|
||||||
unsigned numberOfNodes = 0;
|
unsigned numberOfNodes = 0;
|
||||||
|
in.read((char*) checkSum, sizeof(unsigned));
|
||||||
in.read((char*) & numberOfNodes, sizeof(unsigned));
|
in.read((char*) & numberOfNodes, sizeof(unsigned));
|
||||||
nodeList.resize(numberOfNodes + 1);
|
nodeList.resize(numberOfNodes + 1);
|
||||||
NodeT currentNode;
|
NodeT currentNode;
|
||||||
|
@ -37,6 +37,7 @@ or see http://www.gnu.org/licenses/agpl.txt.
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "Algorithms/CRC32.h"
|
||||||
#include "Util/OpenMPReplacement.h"
|
#include "Util/OpenMPReplacement.h"
|
||||||
#include "typedefs.h"
|
#include "typedefs.h"
|
||||||
#include "Contractor/Contractor.h"
|
#include "Contractor/Contractor.h"
|
||||||
@ -129,27 +130,32 @@ int main (int argc, char *argv[]) {
|
|||||||
std::vector<EdgeBasedGraphFactory::EdgeBasedNode> nodeBasedEdgeList;
|
std::vector<EdgeBasedGraphFactory::EdgeBasedNode> nodeBasedEdgeList;
|
||||||
edgeBasedGraphFactory->GetEdgeBasedNodes(nodeBasedEdgeList);
|
edgeBasedGraphFactory->GetEdgeBasedNodes(nodeBasedEdgeList);
|
||||||
DELETE(edgeBasedGraphFactory);
|
DELETE(edgeBasedGraphFactory);
|
||||||
|
|
||||||
double expansionHasFinishedTime = get_timestamp() - startupTime;
|
double expansionHasFinishedTime = get_timestamp() - startupTime;
|
||||||
|
|
||||||
WritableGrid * writeableGrid = new WritableGrid();
|
WritableGrid * writeableGrid = new WritableGrid();
|
||||||
INFO("building grid ...");
|
INFO("building grid ...");
|
||||||
writeableGrid->ConstructGrid(nodeBasedEdgeList, ramIndexOut, fileIndexOut);
|
writeableGrid->ConstructGrid(nodeBasedEdgeList, ramIndexOut, fileIndexOut);
|
||||||
DELETE( writeableGrid );
|
DELETE( writeableGrid );
|
||||||
|
CRC32 crc32;
|
||||||
|
unsigned crc32OfNodeBasedEdgeList = crc32((char *)&(nodeBasedEdgeList[0]), nodeBasedEdgeList.size()*sizeof(EdgeBasedGraphFactory::EdgeBasedNode));
|
||||||
|
// INFO("CRC32 of data is " << crc32OfNodeBasedEdgeList);
|
||||||
|
|
||||||
nodeBasedEdgeList.clear();
|
nodeBasedEdgeList.clear();
|
||||||
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, ios::binary);
|
||||||
BOOST_FOREACH(NodeInfo & info, internalToExternaleNodeMapping) {
|
mapOutFile.write((char *)&(internalToExternaleNodeMapping[0]), internalToExternaleNodeMapping.size()*sizeof(NodeInfo));
|
||||||
mapOutFile.write((char *)&(info), sizeof(NodeInfo));
|
|
||||||
}
|
|
||||||
mapOutFile.close();
|
mapOutFile.close();
|
||||||
internalToExternaleNodeMapping.clear();
|
|
||||||
|
|
||||||
std::vector<NodeInfo>().swap(internalToExternaleNodeMapping);
|
std::vector<NodeInfo>().swap(internalToExternaleNodeMapping);
|
||||||
inputRestrictions.clear();
|
inputRestrictions.clear();
|
||||||
std::vector<_Restriction>().swap(inputRestrictions);
|
std::vector<_Restriction>().swap(inputRestrictions);
|
||||||
|
|
||||||
|
// unsigned crc32OfNodeBasedEdgeList = crc32((char*)&edgeBasedEdgeList[0], edgeBasedEdgeList.size());
|
||||||
|
// INFO("CRC32 of data is " << crc32OfNodeBasedEdgeList);
|
||||||
|
|
||||||
INFO("initializing contractor");
|
INFO("initializing contractor");
|
||||||
Contractor* contractor = new Contractor( edgeBasedNodeNumber, edgeBasedEdgeList );
|
Contractor* contractor = new Contractor( edgeBasedNodeNumber, edgeBasedEdgeList );
|
||||||
double contractionStartedTimestamp(get_timestamp());
|
double contractionStartedTimestamp(get_timestamp());
|
||||||
@ -199,6 +205,7 @@ int main (int argc, char *argv[]) {
|
|||||||
position += edge - lastEdge; //remove
|
position += edge - lastEdge; //remove
|
||||||
}
|
}
|
||||||
//Serialize numberOfNodes, nodes
|
//Serialize numberOfNodes, nodes
|
||||||
|
edgeOutFile.write((char*) &crc32OfNodeBasedEdgeList, sizeof(unsigned));
|
||||||
edgeOutFile.write((char*) &numberOfNodes, sizeof(unsigned));
|
edgeOutFile.write((char*) &numberOfNodes, sizeof(unsigned));
|
||||||
edgeOutFile.write((char*) &_nodes[0], sizeof(StaticGraph<EdgeData>::_StrNode)*(numberOfNodes+1));
|
edgeOutFile.write((char*) &_nodes[0], sizeof(StaticGraph<EdgeData>::_StrNode)*(numberOfNodes+1));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user