Skip to content

Commit 3aeef8d

Browse files
committed
Use group centroid for nearest group test
1 parent 36e276f commit 3aeef8d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/core/symbology-ng/qgspointdistancerenderer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ bool QgsPointDistanceRenderer::renderFeature( QgsFeature& feature, QgsRenderCont
114114
int groupIdx = mGroupIndex[ minDistFeatureId ];
115115
ClusteredGroup& group = mClusteredGroups[groupIdx];
116116

117+
// calculate new centroid of group
118+
QgsPoint oldCenter = mGroupLocations.value( minDistFeatureId );
119+
mGroupLocations[ minDistFeatureId ] = QgsPoint(( oldCenter.x() * group.size() + point.x() ) / ( group.size() + 1.0 ),
120+
( oldCenter.y() * group.size() + point.y() ) / ( group.size() + 1.0 ) );
121+
117122
// add to a group
118123
group << GroupedFeature( feature, symbol, selected, label );
119124
// add to group index

0 commit comments

Comments
 (0)