Commit b49195d4 authored by Volker Krause's avatar Volker Krause

Better location request cache key generation

parent 0f75989d
......@@ -67,6 +67,20 @@ private slots:
QCOMPARE(entry.data[0].identifier(QLatin1String("uic")), QLatin1String("85xxxxx"));
QCOMPARE(entry.data[0].timeZone().isValid(), false);
}
void testLocationCacheKey()
{
{
LocationRequest req;
req.setCoordinate(-52.5, -13.5);
QCOMPARE(req.cacheKey(), QLatin1String("-52500000x-13500000_"));
}
{
LocationRequest req;
req.setName(QLatin1String("Randa"));
QCOMPARE(req.cacheKey(), QLatin1String("nanxnan_randa"));
}
}
};
QTEST_GUILESS_MAIN(CacheTest)
......
......@@ -80,10 +80,14 @@ QString LocationRequest::cacheKey() const
normalizedName.reserve(d->name.size());
for (const auto c : qAsConst(d->name)) {
if (c.isLetter() || c.isDigit()) {
normalizedName.push_back(c);
normalizedName.push_back(c.toCaseFolded());
}
}
return QString::number((int)(latitude() * 1000000)) + QLatin1Char('x') + QString::number((int)(longitude() * 1000000))
+ QLatin1Char('_') + normalizedName;
if (hasCoordinate()) {
return QString::number((int)(latitude() * 1000000)) + QLatin1Char('x') + QString::number((int)(longitude() * 1000000))
+ QLatin1Char('_') + normalizedName;
} else {
return QLatin1String("nanxnan_") + normalizedName;
}
}
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