Skip to content

Commit 230c050

Browse files
author
Hugo Mercier
committed
Inverted polygon renderer: make sure the each symbol category is always rendered in the same order
1 parent 80ae9ef commit 230c050

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

src/core/symbology-ng/qgsinvertedpolygonrenderer.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,18 +154,19 @@ bool QgsInvertedPolygonRenderer::renderFeature( QgsFeature& feature, QgsRenderCo
154154
return false;
155155
}
156156

157-
if ( ! mFeaturesCategoryMap.contains(catId) )
157+
if ( ! mSymbolCategories.contains(catId) )
158158
{
159159
// the exterior ring must be a square in the destination CRS
160160
CombinedFeature cFeat;
161161
cFeat.multiPolygon.append( mExtentPolygon );
162162
// store the first feature
163163
cFeat.feature = feature;
164-
mFeaturesCategoryMap.insert( catId, cFeat );
164+
mSymbolCategories.insert( catId, mSymbolCategories.count() );
165+
mFeaturesCategoryMap.append( cFeat );
165166
}
166167

167168
// update the geometry
168-
CombinedFeature& cFeat = mFeaturesCategoryMap[catId];
169+
CombinedFeature& cFeat = mFeaturesCategoryMap[ mSymbolCategories[catId] ];
169170
QgsMultiPolygon multi;
170171
QgsGeometry* geom = feature.geometry();
171172
if ( !geom )
@@ -261,11 +262,11 @@ void QgsInvertedPolygonRenderer::stopRender( QgsRenderContext& context )
261262

262263
for ( FeatureCategoryMap::iterator cit = mFeaturesCategoryMap.begin(); cit != mFeaturesCategoryMap.end(); ++cit)
263264
{
264-
QgsFeature feat( cit.value().feature );
265+
QgsFeature feat( cit->feature );
265266
if ( !mPreprocessingEnabled )
266267
{
267268
// no preprocessing - the final polygon has already been prepared
268-
feat.setGeometry( QgsGeometry::fromMultiPolygon( cit.value().multiPolygon ) );
269+
feat.setGeometry( QgsGeometry::fromMultiPolygon( cit->multiPolygon ) );
269270
}
270271
else
271272
{

src/core/symbology-ng/qgsinvertedpolygonrenderer.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,13 @@ class CORE_EXPORT QgsInvertedPolygonRenderer : public QgsFeatureRendererV2
129129
QgsMultiPolygon multiPolygon; //< the final combined geometry
130130
QgsFeature feature; //< one feature (for attriute-based rendering)
131131
};
132-
typedef QMap< QByteArray, CombinedFeature > FeatureCategoryMap;
133-
/** where features are stored, based on their symbol category */
132+
typedef QVector<CombinedFeature> FeatureCategoryMap;
133+
/** where features are stored, based on the index of their symbol category @see mSymbolCategories */
134134
FeatureCategoryMap mFeaturesCategoryMap;
135135

136+
/** maps a category to an index */
137+
QMap<QByteArray, int> mSymbolCategories;
138+
136139
/** the polygon used as exterior ring that covers the current extent */
137140
QgsPolygon mExtentPolygon;
138141

0 commit comments

Comments
 (0)