Skip to content

Commit

Permalink
Inverted polygon renderer: make sure the each symbol category is alwa…
Browse files Browse the repository at this point in the history
…ys rendered in the same order
  • Loading branch information
Hugo Mercier committed May 26, 2014
1 parent 80ae9ef commit 230c050
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/core/symbology-ng/qgsinvertedpolygonrenderer.cpp
Expand Up @@ -154,18 +154,19 @@ bool QgsInvertedPolygonRenderer::renderFeature( QgsFeature& feature, QgsRenderCo
return false;
}

if ( ! mFeaturesCategoryMap.contains(catId) )
if ( ! mSymbolCategories.contains(catId) )
{
// the exterior ring must be a square in the destination CRS
CombinedFeature cFeat;
cFeat.multiPolygon.append( mExtentPolygon );
// store the first feature
cFeat.feature = feature;
mFeaturesCategoryMap.insert( catId, cFeat );
mSymbolCategories.insert( catId, mSymbolCategories.count() );
mFeaturesCategoryMap.append( cFeat );
}

// update the geometry
CombinedFeature& cFeat = mFeaturesCategoryMap[catId];
CombinedFeature& cFeat = mFeaturesCategoryMap[ mSymbolCategories[catId] ];
QgsMultiPolygon multi;
QgsGeometry* geom = feature.geometry();
if ( !geom )
Expand Down Expand Up @@ -261,11 +262,11 @@ void QgsInvertedPolygonRenderer::stopRender( QgsRenderContext& context )

for ( FeatureCategoryMap::iterator cit = mFeaturesCategoryMap.begin(); cit != mFeaturesCategoryMap.end(); ++cit)
{
QgsFeature feat( cit.value().feature );
QgsFeature feat( cit->feature );
if ( !mPreprocessingEnabled )
{
// no preprocessing - the final polygon has already been prepared
feat.setGeometry( QgsGeometry::fromMultiPolygon( cit.value().multiPolygon ) );
feat.setGeometry( QgsGeometry::fromMultiPolygon( cit->multiPolygon ) );
}
else
{
Expand Down
7 changes: 5 additions & 2 deletions src/core/symbology-ng/qgsinvertedpolygonrenderer.h
Expand Up @@ -129,10 +129,13 @@ class CORE_EXPORT QgsInvertedPolygonRenderer : public QgsFeatureRendererV2
QgsMultiPolygon multiPolygon; //< the final combined geometry
QgsFeature feature; //< one feature (for attriute-based rendering)
};
typedef QMap< QByteArray, CombinedFeature > FeatureCategoryMap;
/** where features are stored, based on their symbol category */
typedef QVector<CombinedFeature> FeatureCategoryMap;
/** where features are stored, based on the index of their symbol category @see mSymbolCategories */
FeatureCategoryMap mFeaturesCategoryMap;

/** maps a category to an index */
QMap<QByteArray, int> mSymbolCategories;

/** the polygon used as exterior ring that covers the current extent */
QgsPolygon mExtentPolygon;

Expand Down

0 comments on commit 230c050

Please sign in to comment.