diff --git a/Util/GraphLoader.h b/Util/GraphLoader.h index 6b664a696..6fdcd3228 100644 --- a/Util/GraphLoader.h +++ b/Util/GraphLoader.h @@ -25,6 +25,7 @@ or see http://www.gnu.org/licenses/agpl.txt. #include "../DataStructures/ImportEdge.h" #include "../DataStructures/NodeCoords.h" #include "../DataStructures/Restriction.h" +#include "../Util/UUID.h" #include "../typedefs.h" #include @@ -50,6 +51,21 @@ struct _ExcessRemover { template NodeID readBinaryOSRMGraphFromStream(std::istream &in, std::vector& edgeList, std::vector &bollardNodes, std::vector &trafficLightNodes, std::vector * int2ExtNodeMap, std::vector<_Restriction> & inputRestrictions) { + const UUID uuid_orig; + UUID uuid_loaded; + in.read((char *) &uuid_loaded, sizeof(UUID)); + if(!uuid_loaded.IsMagicNumberOK()) { + ERR("hsgr input file misses magic number. Check or reprocess the file"); + } + + if( uuid_loaded.TestHSGR(uuid_orig) ) { + WARN( + ".hsgr was prepared with different build.\n" + "Reprocess to get rid of this warning." + ) + } + + NodeID n, source, target; EdgeID m; short dir;// direction (0 = open, 1 = forward, 2+ = open) diff --git a/Util/UUID.cpp.in b/Util/UUID.cpp.in index 621c59cfc..c5b522af7 100644 --- a/Util/UUID.cpp.in +++ b/Util/UUID.cpp.in @@ -54,3 +54,11 @@ UUID::~UUID() { const boost::uuids::uuid & UUID::GetUUID() const { return named_uuid; } + +const bool UUID::IsMagicNumberOK() const { + return 1297240911 == magic_number; +} + +const bool UUID::TestHSGR(const UUID & other) const { + return std::equal(md5_graph, md5_graph+32, other.md5_graph); +} \ No newline at end of file diff --git a/Util/UUID.h b/Util/UUID.h index 5dfce34cf..354540e07 100644 --- a/Util/UUID.h +++ b/Util/UUID.h @@ -35,14 +35,12 @@ or see http://www.gnu.org/licenses/agpl.txt. //implements a singleton, i.e. there is one and only one conviguration object class UUID : boost::noncopyable { public: - static UUID & GetInstance() { - static UUID instance; - return instance; - } + UUID(); ~UUID(); const boost::uuids::uuid & GetUUID() const; + const bool IsMagicNumberOK() const; + const bool TestHSGR(const UUID & other) const; private: - UUID(); const unsigned magic_number; char md5_prepare[33]; char md5_tree[33];