This commit is contained in:
Patrick Brosi 2021-07-24 10:07:27 +02:00
parent cea4474631
commit deaaf23caf

View file

@ -2,8 +2,8 @@
// Chair of Algorithms and Data Structures. // Chair of Algorithms and Data Structures.
// Authors: Patrick Brosi <brosi@informatik.uni-freiburg.de> // Authors: Patrick Brosi <brosi@informatik.uni-freiburg.de>
#include <string>
#include <iostream> #include <iostream>
#include <string>
// ____________________________________________________________________________ // ____________________________________________________________________________
template <typename T> template <typename T>
@ -15,8 +15,7 @@ ShapeContainer<T>::ShapeContainer() : _lastBuff(0) {
unlink(f.c_str()); unlink(f.c_str());
if (!_storage.good()) { if (!_storage.good()) {
std::cerr << "Could not open temporary file " << f std::cerr << "Could not open temporary file " << f << std::endl;
<< std::endl;
exit(1); exit(1);
} }
} }
@ -83,12 +82,13 @@ std::string ShapeContainer<T>::add(const ad::cppgtfs::gtfs::Shape& s) {
for (const auto& p : s.getPoints()) { for (const auto& p : s.getPoints()) {
_writeBuffer.write(reinterpret_cast<const char*>(&p.lat), sizeof(p.lat)); _writeBuffer.write(reinterpret_cast<const char*>(&p.lat), sizeof(p.lat));
_writeBuffer.write(reinterpret_cast<const char*>(&p.lng), sizeof(p.lng)); _writeBuffer.write(reinterpret_cast<const char*>(&p.lng), sizeof(p.lng));
_writeBuffer.write(reinterpret_cast<const char*>(&p.travelDist), sizeof(p.travelDist)); _writeBuffer.write(reinterpret_cast<const char*>(&p.travelDist),
sizeof(p.travelDist));
} }
if (_writeBuffer.tellp() - _lastBuff > 1000 * 5000) { if (_writeBuffer.tellp() - _lastBuff > 1000 * 5000) {
_lastBuff = _writeBuffer.tellp(); _lastBuff = _writeBuffer.tellp();
_storage << _writeBuffer.rdbuf(); _storage << _writeBuffer.rdbuf();
_writeBuffer.clear(); _writeBuffer.clear();
} }
@ -124,7 +124,8 @@ bool ShapeContainer<T>::nextStoragePt(
_storage.read(reinterpret_cast<char*>(&ret->lat), sizeof(ret->lat)); _storage.read(reinterpret_cast<char*>(&ret->lat), sizeof(ret->lat));
_storage.read(reinterpret_cast<char*>(&ret->lng), sizeof(ret->lng)); _storage.read(reinterpret_cast<char*>(&ret->lng), sizeof(ret->lng));
_storage.read(reinterpret_cast<char*>(&ret->travelDist), sizeof(ret->travelDist)); _storage.read(reinterpret_cast<char*>(&ret->travelDist),
sizeof(ret->travelDist));
ret->seq = _ptr + 1; ret->seq = _ptr + 1;
ret->id = _curId; ret->id = _curId;