@@ -81,19 +81,27 @@ bool QgsPointDistanceRenderer::renderFeature( QgsFeature& feature, QgsRenderCont
81
81
label = getLabel ( feature );
82
82
}
83
83
84
+ QgsCoordinateTransform xform = context.coordinateTransform ();
85
+ QgsFeature transformedFeature = feature;
86
+ if ( xform.isValid () )
87
+ {
88
+ geom.transform ( xform );
89
+ transformedFeature.setGeometry ( geom );
90
+ }
91
+
84
92
double searchDistance = mTolerance * QgsSymbolLayerUtils::mapUnitScaleFactor ( context, mToleranceUnit , mToleranceMapUnitScale );
85
- QgsPoint point = feature .geometry ().asPoint ();
93
+ QgsPoint point = transformedFeature .geometry ().asPoint ();
86
94
QList<QgsFeatureId> intersectList = mSpatialIndex ->intersects ( searchRect ( point, searchDistance ) );
87
95
if ( intersectList.empty () )
88
96
{
89
- mSpatialIndex ->insertFeature ( feature );
97
+ mSpatialIndex ->insertFeature ( transformedFeature );
90
98
// create new group
91
99
ClusteredGroup newGroup;
92
- newGroup << GroupedFeature ( feature , symbol, selected, label );
100
+ newGroup << GroupedFeature ( transformedFeature , symbol, selected, label );
93
101
mClusteredGroups .push_back ( newGroup );
94
102
// 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 );
97
105
}
98
106
else
99
107
{
@@ -120,9 +128,9 @@ bool QgsPointDistanceRenderer::renderFeature( QgsFeature& feature, QgsRenderCont
120
128
( oldCenter.y () * group.size () + point.y () ) / ( group.size () + 1.0 ) );
121
129
122
130
// add to a group
123
- group << GroupedFeature ( feature , symbol, selected, label );
131
+ group << GroupedFeature ( transformedFeature , symbol, selected, label );
124
132
// add to group index
125
- mGroupIndex .insert ( feature .id (), groupIdx );
133
+ mGroupIndex .insert ( transformedFeature .id (), groupIdx );
126
134
}
127
135
128
136
return true ;
@@ -138,7 +146,8 @@ void QgsPointDistanceRenderer::drawGroup( const ClusteredGroup& group, QgsRender
138
146
}
139
147
QgsGeometry groupGeom ( groupMultiPoint );
140
148
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 () );
142
151
143
152
context.expressionContext ().appendScope ( createGroupScope ( group ) );
144
153
drawGroup ( pt, context, group );
0 commit comments