@@ -81,19 +81,27 @@ bool QgsPointDistanceRenderer::renderFeature( QgsFeature& feature, QgsRenderCont
8181 label = getLabel ( feature );
8282 }
8383
84+ QgsCoordinateTransform xform = context.coordinateTransform ();
85+ QgsFeature transformedFeature = feature;
86+ if ( xform.isValid () )
87+ {
88+ geom.transform ( xform );
89+ transformedFeature.setGeometry ( geom );
90+ }
91+
8492 double searchDistance = mTolerance * QgsSymbolLayerUtils::mapUnitScaleFactor ( context, mToleranceUnit , mToleranceMapUnitScale );
85- QgsPoint point = feature .geometry ().asPoint ();
93+ QgsPoint point = transformedFeature .geometry ().asPoint ();
8694 QList<QgsFeatureId> intersectList = mSpatialIndex ->intersects ( searchRect ( point, searchDistance ) );
8795 if ( intersectList.empty () )
8896 {
89- mSpatialIndex ->insertFeature ( feature );
97+ mSpatialIndex ->insertFeature ( transformedFeature );
9098 // create new group
9199 ClusteredGroup newGroup;
92- newGroup << GroupedFeature ( feature , symbol, selected, label );
100+ newGroup << GroupedFeature ( transformedFeature , symbol, selected, label );
93101 mClusteredGroups .push_back ( newGroup );
94102 // add to group index
95- mGroupIndex .insert ( feature .id (), mClusteredGroups .count () - 1 );
96- mGroupLocations .insert ( feature .id (), point );
103+ mGroupIndex .insert ( transformedFeature .id (), mClusteredGroups .count () - 1 );
104+ mGroupLocations .insert ( transformedFeature .id (), point );
97105 }
98106 else
99107 {
@@ -120,9 +128,9 @@ bool QgsPointDistanceRenderer::renderFeature( QgsFeature& feature, QgsRenderCont
120128 ( oldCenter.y () * group.size () + point.y () ) / ( group.size () + 1.0 ) );
121129
122130 // add to a group
123- group << GroupedFeature ( feature , symbol, selected, label );
131+ group << GroupedFeature ( transformedFeature , symbol, selected, label );
124132 // add to group index
125- mGroupIndex .insert ( feature .id (), groupIdx );
133+ mGroupIndex .insert ( transformedFeature .id (), groupIdx );
126134 }
127135
128136 return true ;
@@ -138,7 +146,8 @@ void QgsPointDistanceRenderer::drawGroup( const ClusteredGroup& group, QgsRender
138146 }
139147 QgsGeometry groupGeom ( groupMultiPoint );
140148 QgsGeometry centroid = groupGeom.centroid ();
141- QPointF pt = _getPoint ( context, *static_cast <QgsPointV2*>( centroid.geometry () ) );
149+ QPointF pt = centroid.asQPointF ();
150+ context.mapToPixel ().transformInPlace ( pt.rx (), pt.ry () );
142151
143152 context.expressionContext ().appendScope ( createGroupScope ( group ) );
144153 drawGroup ( pt, context, group );
0 commit comments