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