Skip to content
Permalink
Browse files

Higher limit for number of layers in WMS project, use hash instead of…

… map in layer cache

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15260 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent
mhugent committed Feb 24, 2011
1 parent ef37b2f commit daf8fbda2b8ddb95520473382ba006deb8b06062
Showing with 9 additions and 8 deletions.
  1. +7 −6 src/mapserver/qgsmslayercache.cpp
  2. +2 −2 src/mapserver/qgsmslayercache.h
@@ -19,7 +19,8 @@
#include "qgsvectorlayer.h"
#include "qgsmapserverlogger.h"

#define MAX_N_LAYERS 50
//maximum number of layers in the cache (and upper limit for layers in one published project)
#define MAX_N_LAYERS 100

QgsMSLayerCache* QgsMSLayerCache::mInstance = 0;

@@ -40,7 +41,7 @@ QgsMSLayerCache::QgsMSLayerCache()
QgsMSLayerCache::~QgsMSLayerCache()
{
QgsMSDebugMsg( "removing all entries" );
QMap<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it;
QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it;
for ( it = mEntries.begin(); it != mEntries.end(); ++it )
{
delete it->layerPointer;
@@ -57,7 +58,7 @@ void QgsMSLayerCache::insertLayer( const QString& url, const QString& layerName,
}

QPair<QString, QString> urlLayerPair = qMakePair( url, layerName );
QMap<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.find( urlLayerPair );
QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.find( urlLayerPair );
if ( it != mEntries.end() )
{
delete it->layerPointer;
@@ -76,7 +77,7 @@ void QgsMSLayerCache::insertLayer( const QString& url, const QString& layerName,
QgsMapLayer* QgsMSLayerCache::searchLayer( const QString& url, const QString& layerName )
{
QPair<QString, QString> urlNamePair = qMakePair( url, layerName );
QMap<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.find( urlNamePair );
QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.find( urlNamePair );
if ( it == mEntries.end() )
{
QgsMSDebugMsg( "Layer not found in cache" );
@@ -121,8 +122,8 @@ void QgsMSLayerCache::removeLeastUsedEntry()
return;
}
QgsMSDebugMsg( "removeLeastUsedEntry" );
QMap<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.begin();
QMap<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator lowest_it = it;
QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator it = mEntries.begin();
QHash<QPair<QString, QString>, QgsMSLayerCacheEntry>::iterator lowest_it = it;
time_t lowest_time = it->lastUsedTime;

for ( ; it != mEntries.end(); ++it )
@@ -19,7 +19,7 @@
#define QGSMSLAYERCACHE_H

#include <time.h>
#include <QMap>
#include <QHash>
#include <QPair>
#include <QString>

@@ -69,7 +69,7 @@ class QgsMSLayerCache
/**Cash entries with pair url/layer name as a key. The layer name is necessary for cases where the same
url is used several time in a request. It ensures that different layer instances are created for different
layer names*/
QMap<QPair<QString, QString>, QgsMSLayerCacheEntry> mEntries;
QHash<QPair<QString, QString>, QgsMSLayerCacheEntry> mEntries;
};

#endif

0 comments on commit daf8fbd

Please sign in to comment.
You can’t perform that action at this time.