Skip to content
Permalink
Browse files
Remove QgsGeometryCache class
The geometry cache was only used for few geometry editing operations anyway. In earlier versions
of QGIS the geometry cache was also used by old snapping classes which have been replaced
by QgsPointLocator that also keeps a spatial index of geometries and it is not rebuilt on every re-render.

Reasons for removal:
- geometry cache was repopulated on every redraw of layers in editing mode, slowing down rendering
- data structure for the cache was a simple map with features accessed by their ID (no spatial index)
- the cache was only getting refreshed for the current view of the main map canvas (not a generic cache)
- not used for snapping anymore where caching was important to avoid roundtrips to data provider
  • Loading branch information
wonder-sk committed May 6, 2017
1 parent 5e3c6e5 commit 0a0c33d
Show file tree
Hide file tree
Showing 22 changed files with 47 additions and 344 deletions.
@@ -264,6 +264,7 @@ should now call QgsCoordinateReferenceSystem::invalidateCache() and QgsCoordinat
- QgsHtmlAnnotationItem. Use QgsHtmlAnnotation instead.
- QgsHttpTransaction. This class was outdated and code should be ported to native Qt or Python implementations.
- QgsGenericProjectionSelector. Use QgsProjectionSelectionTreeWidget instead.
- QgsGeometryCache. It got redundant after removal of old snapping classes (QgsSnapper + friends).
- QgsLabel and QgsLabelAttributes. Replaced by labeling based on PAL library, see QgsLabelingEngine.
- QgsLabelingEngineInterface. Replaced by QgsLabelingEngine.
- QgsLegendInterface was removed. It was replaced by layer tree API (QgsLayerTreeNode class and others).
@@ -1446,6 +1447,7 @@ and subclasses are not designed to be subclassed in PyQGIS.
be used instead of a null pointer if no transformation is required.
- prepareJobs() and drawLabeling() (neither available in PyQGIS) do not take QgsPalLabeling parameter anymore. All drawing of labels is done by QgsLabelingEngine.
- drawOldLabeling(), drawNewLabeling() were removed. The method drawLabeling() should be used instead.
- setRequestedGeometryCacheForLayers() was removed. There is no extra caching done during rendering job.


QgsMapTool {#qgis_api_break_3_0_QgsMapTool}
@@ -2146,6 +2148,7 @@ QgsVectorLayerEditUtils {#qgis_api_break_3_0_QgsVectorLayerEditUtils}

- addTopologicalPoints() now accepts a geometry reference, not a pointer.
- insertSegmentVerticesForSnap() has been removed.
- cache() has been removed.


QgsVectorLayerImport {#qgis_api_break_3_0_QgsVectorLayerImport}
@@ -2168,6 +2171,7 @@ QgsVectorLayerUndoCommand {#qgis_api_break_3_0_QgsVectorLayerUndoCommand}
-------------------------

- QgsVectorLayerUndoCommandChangeGeometry constructor now accepts a geometry reference, not a pointer.
- cache() has been removed.


QgsVisibilityPresetCollection {#qgis_api_break_3_0_QgsVisibilityPresetCollection}
@@ -176,7 +176,6 @@
%Include qgscacheindex.sip
%Include qgscacheindexfeatureid.sip
%Include qgsfeaturestore.sip
%Include qgsgeometrycache.sip
%Include qgslayerdefinition.sip
%Include qgsprojectfiletransform.sip
%Include qgsvectorlayereditutils.sip

This file was deleted.

@@ -61,10 +61,6 @@ class QgsMapRendererJob : QObject
//! Does not take ownership of the object.
void setCache( QgsMapRendererCache *cache );

//! Set which vector layers should be cached while rendering
//! @note The way how geometries are cached is really suboptimal - this method may be removed in future releases
void setRequestedGeometryCacheForLayers( const QStringList &layerIds );

//! Find out how long it took to finish the job (in milliseconds)
int renderingTime() const;

@@ -1590,7 +1590,6 @@ Returns the current transparency for the vector layer
virtual QString htmlMetadata() const;



void setSimplifyMethod( const QgsVectorSimplifyMethod &simplifyMethod );
%Docstring
Set the simplification settings for fast rendering of features
@@ -6,9 +6,6 @@ class QgsVectorLayerEditUtils
public:
QgsVectorLayerEditUtils( QgsVectorLayer *layer );

QgsGeometryCache *cache();


/** Insert a new vertex before the given vertex number,
* in the given ring, item (first number is index 0), and feature
* Not meaningful for Point geometries
@@ -17,7 +17,6 @@ class QgsVectorLayerUndoCommand : QUndoCommand

//! Returns the layer associated with the undo command
QgsVectorLayer *layer();
QgsGeometryCache *cache();

virtual int id() const;
virtual bool mergeWith( QUndoCommand * );
@@ -155,7 +155,6 @@ SET(QGIS_CORE_SRCS
qgsfieldproxymodel.cpp
qgsfields.cpp
qgsfontutils.cpp
qgsgeometrycache.cpp
qgsgeometrysimplifier.cpp
qgsgeometryvalidator.cpp
qgsgml.cpp
@@ -735,7 +734,6 @@ SET(QGIS_CORE_HDRS
qgsfield_p.h
qgsfields.h
qgsfontutils.h
qgsgeometrycache.h
qgshistogram.h
qgsindexedfeature.h
qgsinterval.h

This file was deleted.

This file was deleted.

@@ -341,19 +341,6 @@ void QgsMapRendererJob::drawLabeling( const QgsMapSettings &settings, QgsRenderC
}


void QgsMapRendererJob::updateLayerGeometryCaches()
{
QMap<QString, QgsGeometryCache>::const_iterator it = mGeometryCaches.constBegin();
for ( ; it != mGeometryCaches.constEnd(); ++it )
{
const QgsGeometryCache &cache = it.value();
if ( QgsVectorLayer *vl = qobject_cast<QgsVectorLayer *>( QgsProject::instance()->mapLayer( it.key() ) ) )
* vl->cache() = cache;
}
mGeometryCaches.clear();
}


bool QgsMapRendererJob::needTemporaryImage( QgsMapLayer *ml )
{
if ( ml->type() == QgsMapLayer::VectorLayer )
@@ -226,8 +226,6 @@ LayerRenderJobs QgsMapRendererJob::prepareJobs( QPainter *painter, QgsLabelingEn

bool requiresLabelRedraw = !( mCache && mCache->hasCacheImage( LABEL_CACHE_ID ) );

mGeometryCaches.clear();

while ( li.hasPrevious() )
{
QgsMapLayer *ml = li.previous();
@@ -341,14 +339,6 @@ LayerRenderJobs QgsMapRendererJob::prepareJobs( QPainter *painter, QgsLabelingEn
if ( hasStyleOverride )
ml->styleManager()->restoreOverrideStyle();

if ( mRequestedGeomCacheForLayers.contains( ml->id() ) )
{
if ( QgsVectorLayerRenderer *vlr = dynamic_cast<QgsVectorLayerRenderer *>( job.renderer ) )
{
vlr->setGeometryCachePointer( &mGeometryCaches[ ml->id()] );
}
}

} // while (li.hasPrevious())

return layerJobs;
@@ -428,8 +418,6 @@ void QgsMapRendererJob::cleanupJobs( LayerRenderJobs &jobs )


jobs.clear();

updateLayerGeometryCaches();
}

void QgsMapRendererJob::cleanupLabelJob( LabelRenderJob &job )
@@ -30,7 +30,6 @@

#include "qgsmapsettings.h"

#include "qgsgeometrycache.h"

class QgsLabelingEngine;
class QgsLabelingResults;
@@ -186,10 +185,6 @@ class CORE_EXPORT QgsMapRendererJob : public QObject
//! Does not take ownership of the object.
void setCache( QgsMapRendererCache *cache );

//! Set which vector layers should be cached while rendering
//! \note The way how geometries are cached is really suboptimal - this method may be removed in future releases
void setRequestedGeometryCacheForLayers( const QStringList &layerIds ) { mRequestedGeomCacheForLayers = layerIds; }

//! Find out how long it took to finish the job (in milliseconds)
int renderingTime() const { return mRenderingTime; }

@@ -279,14 +274,6 @@ class CORE_EXPORT QgsMapRendererJob : public QObject

bool needTemporaryImage( QgsMapLayer *ml );

//! called when rendering has finished to update all layers' geometry caches
void updateLayerGeometryCaches();

//! list of layer IDs for which the geometry cache should be updated
QStringList mRequestedGeomCacheForLayers;
//! map of geometry caches
QMap<QString, QgsGeometryCache> mGeometryCaches;

const QgsFeatureFilterProvider *mFeatureFilterProvider = nullptr;
};

@@ -49,7 +49,6 @@
#include "qgsfeature.h"
#include "qgsfeaturerequest.h"
#include "qgsfields.h"
#include "qgsgeometrycache.h"
#include "qgsgeometry.h"
#include "qgslogger.h"
#include "qgsmaplayerlegend.h"
@@ -142,7 +141,6 @@ QgsVectorLayer::QgsVectorLayer( const QString &vectorLayerPath,
, mFeatureBlendMode( QPainter::CompositionMode_SourceOver ) // Default to normal feature blending
, mLayerTransparency( 0 )
, mVertexMarkerOnlyForSelection( false )
, mCache( new QgsGeometryCache() )
, mEditBuffer( nullptr )
, mJoinBuffer( nullptr )
, mExpressionFieldBuffer( nullptr )
@@ -190,7 +188,6 @@ QgsVectorLayer::~QgsVectorLayer()
delete mEditBuffer;
delete mJoinBuffer;
delete mExpressionFieldBuffer;
delete mCache;
delete mLabeling;
delete mDiagramLayerSettings;
delete mDiagramRenderer;
@@ -2438,11 +2435,6 @@ bool QgsVectorLayer::commitChanges()
QgsMessageLog::logMessage( tr( "Commit errors:\n %1" ).arg( mCommitErrors.join( QStringLiteral( "\n " ) ) ) );
}

if ( mCache )
{
mCache->deleteCachedGeometries();
}

updateFields();
mDataProvider->updateExtents();

@@ -2490,11 +2482,6 @@ bool QgsVectorLayer::rollBack( bool deleteBuffer )
}
emit editingStopped();

if ( mCache )
{
mCache->deleteCachedGeometries();
}

if ( rollbackExtent )
updateExtents();

@@ -54,7 +54,6 @@ class QgsEditorWidgetWrapper;
class QgsExpressionFieldBuffer;
class QgsFeatureRenderer;
class QgsGeometry;
class QgsGeometryCache;
class QgsGeometryVertexIndex;
class QgsMapToPixel;
class QgsRectangle;
@@ -1487,9 +1486,6 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte

QString htmlMetadata() const override;

//! \note not available in Python bindings
inline QgsGeometryCache *cache() SIP_SKIP { return mCache; }

/** Set the simplification settings for fast rendering of features
* \since QGIS 2.2
*/
@@ -1971,9 +1967,6 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
//! Annotation form for this layer
QString mAnnotationForm;

//! cache for some vector layer data - currently only geometries for faster editing
QgsGeometryCache *mCache = nullptr;

//! stores information about uncommitted changes to layer
QgsVectorLayerEditBuffer *mEditBuffer = nullptr;
friend class QgsVectorLayerEditBuffer;

0 comments on commit 0a0c33d

Please sign in to comment.