Skip to content
Permalink
Browse files
Inverted polygon renderer: make sure the each symbol category is alwa…
…ys rendered in the same order
  • Loading branch information
Hugo Mercier committed May 26, 2014
1 parent 80ae9ef commit 230c0504ec4e7337135c2f516616d8d5ec1503cc
Showing with 11 additions and 7 deletions.
  1. +6 −5 src/core/symbology-ng/qgsinvertedpolygonrenderer.cpp
  2. +5 −2 src/core/symbology-ng/qgsinvertedpolygonrenderer.h
@@ -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 )
@@ -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
{
@@ -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;

0 comments on commit 230c050

Please sign in to comment.