Commit 0615c0b7 authored by Don Gagne's avatar Don Gagne

Merge pull request #1894 from dogmaphobic/mapCaching

Fixed QtLocation Caching
parents 9e967dc9 50650e7d
......@@ -48,10 +48,10 @@ const QString ProviderStrings::kLevelsForSigPacSpainMap[] =
ProviderStrings::ProviderStrings()
{
// Google version strings
VersionGoogleMap = "m@296306248";
VersionGoogleSatellite = "s@168";
VersionGoogleLabels = "h@296000000";
VersionGoogleTerrain = "t@132,r@296000000";
VersionGoogleMap = "m@313";
VersionGoogleSatellite = "s@177";
VersionGoogleLabels = "h@313";
VersionGoogleTerrain = "t@132,r@313";
SecGoogleWord = "Galileo";
// Google (China) version strings
......@@ -196,7 +196,13 @@ void UrlFactory::_tryCorrectGoogleVersions()
_network->setProxy(tProxy);
QString url = "http://maps.google.com/maps?output=classic";
qheader.setUrl(QUrl(url));
#if defined Q_OS_MACX
QByteArray userAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0";
#elif defined Q_OS_WIN32
QByteArray userAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7";
#else
QByteArray userAgent = "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20130331 Firefox/21.0";
#endif
qheader.setRawHeader("User-Agent", userAgent);
_googleReply = _network->get(qheader);
connect(_googleReply, SIGNAL(finished()), this, SLOT(_googleVersionCompleted()));
......
......@@ -95,13 +95,11 @@ void QGeoMapReplyQGC::networkReplyFinished()
{
if (!m_reply)
{
qWarning() << "NULL Map request reply";
return;
}
if (m_reply->error() != QNetworkReply::NoError)
{
qWarning() << "Map request reply error:" << m_reply->error();
return;
}
......@@ -146,14 +144,12 @@ void QGeoMapReplyQGC::networkReplyError(QNetworkReply::NetworkError error)
{
if (!m_reply)
{
qWarning() << "NULL Map request error";
return;
}
if (error != QNetworkReply::OperationCanceledError)
{
setError(QGeoTiledMapReply::CommunicationError, m_reply->errorString());
qWarning() << "Map request reply error:" << m_reply->errorString();
}
setFinished(true);
......
......@@ -121,45 +121,44 @@ QGeoTiledMappingManagerEngineQGC::QGeoTiledMappingManagerEngineQGC(const QVarian
// qDebug() << "Mapping cache directory:" << cacheDir;
//}
QGeoTileCache *tileCache = createTileCacheWithDir(cacheDir);
int cacheLimit = 0;
if (parameters.contains(QStringLiteral("mapping.cache.disk.size"))) {
bool ok = false;
cacheLimit = parameters.value(QStringLiteral("mapping.cache.disk.size")).toString().toInt(&ok);
if (!ok)
cacheLimit = 0;
}
if(!cacheLimit)
// QGC Default
cacheLimit = 1024 * 1024 * 1024;
tileCache->setMaxDiskUsage(cacheLimit);
//qDebug() << "Disk caching limit:" << cacheLimit;
cacheLimit = 0;
if (parameters.contains(QStringLiteral("mapping.cache.memory.size"))) {
bool ok = false;
cacheLimit = parameters.value(QStringLiteral("mapping.cache.memory.size")).toString().toInt(&ok);
if (!ok)
cacheLimit = 0;
}
if(!cacheLimit)
// QGC Default
cacheLimit = 10 * 1024 * 1024;
tileCache->setMaxMemoryUsage(cacheLimit);
//qDebug() << "Memory caching limit:" << cacheLimit;
cacheLimit = 0;
if (parameters.contains(QStringLiteral("mapping.cache.texture.size"))) {
bool ok = false;
cacheLimit = parameters.value(QStringLiteral("mapping.cache.texture.size")).toString().toInt(&ok);
if (!ok)
cacheLimit = 0;
QGeoTileCache* pTileCache = tileCache();
if(pTileCache)
{
int cacheLimit = 0;
//-- Disk Cache
if (parameters.contains(QStringLiteral("mapping.cache.disk.size"))) {
bool ok = false;
cacheLimit = parameters.value(QStringLiteral("mapping.cache.disk.size")).toString().toInt(&ok);
if (!ok)
cacheLimit = 0;
}
if(!cacheLimit)
{
#ifdef __mobile__
cacheLimit = 128 * 1024 * 1024;
#else
cacheLimit = 1024 * 1024 * 1024;
#endif
}
pTileCache->setMaxDiskUsage(cacheLimit);
//-- Memory Cache
cacheLimit = 0;
if (parameters.contains(QStringLiteral("mapping.cache.memory.size"))) {
bool ok = false;
cacheLimit = parameters.value(QStringLiteral("mapping.cache.memory.size")).toString().toInt(&ok);
if (!ok)
cacheLimit = 0;
}
if(!cacheLimit)
{
#ifdef __mobile__
cacheLimit = 16 * 1024 * 1024;
#else
cacheLimit = 128 * 1024 * 1024;
#endif
}
pTileCache->setMaxMemoryUsage(cacheLimit);
}
if(!cacheLimit)
// QGC Default
cacheLimit = 10 * 1024 * 1024;
tileCache->setExtraTextureUsage(cacheLimit);
*error = QGeoServiceProvider::NoError;
errorString->clear();
......
......@@ -55,7 +55,13 @@
QGeoTileFetcherQGC::QGeoTileFetcherQGC(QGeoTiledMappingManagerEngine *parent)
: QGeoTileFetcher(parent)
, m_networkManager(new QNetworkAccessManager(this))
, m_userAgent("Qt Application")
#if defined Q_OS_MACX
, m_userAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:21.0) Gecko/20100101 Firefox/21.0")
#elif defined Q_OS_WIN32
, m_userAgent("Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7")
#else
, m_userAgent("Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:21.0) Gecko/20130331 Firefox/21.0")
#endif
, m_UrlFactory(NULL)
{
QStringList langs = QLocale::system().uiLanguages();
......
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