Commit cc4588e6 authored by Valentin Platzgummer's avatar Valentin Platzgummer

MeasurementArea.cc better randmomId

parent a4d09405
......@@ -19,7 +19,7 @@
#define MAX_TILES 1000
#endif
QString randomId();
QString randomId(std::size_t length = 10);
using namespace geometry;
namespace trans = bg::strategy::transform;
......@@ -726,13 +726,24 @@ bool getTiles(const FPolygon &area, Length tileHeight, Length tileWidth,
return true;
}
QString randomId() {
std::srand(std::time(nullptr));
std::int64_t r = 0;
QString randomId(std::size_t length) {
static const QString values(
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789");
static std::uint64_t counter = 0;
static auto firstCall = std::chrono::high_resolution_clock::now();
auto delta = std::chrono::duration_cast<std::chrono::nanoseconds>(
std::chrono::high_resolution_clock::now() - firstCall)
.count();
for (int i = 0; i < 10; ++i) {
r ^= std::rand();
std::srand((unsigned int)delta ^ counter);
QString str;
for (int i = 0; i < length; ++i) {
int index = std::rand() % values.length();
QChar c = values.at(index);
str.append(c);
}
return QString::number(r);
++counter;
return str;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment