Skip to content

Commit

Permalink
Also support MultiPoints
Browse files Browse the repository at this point in the history
  • Loading branch information
uclaros authored and nyalldawson committed Mar 15, 2021
1 parent ea7122b commit def9af6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/app/qgsmergeattributesdialog.cpp
Expand Up @@ -79,7 +79,8 @@ QgsMergeAttributesDialog::QgsMergeAttributesDialog( const QgsFeatureList &featur
mFromLargestPushButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionFromLargestFeature.svg" ) ) );
mRemoveFeatureFromSelectionButton->setIcon( QgsApplication::getThemeIcon( QStringLiteral( "mActionRemoveSelectedFeature.svg" ) ) );

mFromLargestPushButton->setEnabled( mVectorLayer->geometryType() == QgsWkbTypes::LineGeometry ||
mFromLargestPushButton->setEnabled( mVectorLayer->geometryType() == QgsWkbTypes::PointGeometry ||
mVectorLayer->geometryType() == QgsWkbTypes::LineGeometry ||
mVectorLayer->geometryType() == QgsWkbTypes::PolygonGeometry );
mTakeLargestAttributesLabel->setEnabled( mFromLargestPushButton->isEnabled() );

Expand Down Expand Up @@ -494,6 +495,21 @@ void QgsMergeAttributesDialog::mFromLargestPushButton_clicked()

switch ( mVectorLayer->geometryType() )
{
case QgsWkbTypes::PointGeometry:
{
QgsFeatureList::const_iterator f_it = mFeatureList.constBegin();
for ( ; f_it != mFeatureList.constEnd(); ++f_it )
{
const QgsAbstractGeometry *geom = f_it->geometry().constGet();
int partCount = geom ? geom->partCount() : 0;
if ( partCount > maxValue )
{
featureId = f_it->id();
maxValue = partCount;
}
}
break;
}
case QgsWkbTypes::LineGeometry:
{
QgsFeatureList::const_iterator f_it = mFeatureList.constBegin();
Expand Down
2 changes: 1 addition & 1 deletion src/ui/qgsmergeattributesdialogbase.ui
Expand Up @@ -65,7 +65,7 @@
<item>
<widget class="QPushButton" name="mFromLargestPushButton">
<property name="toolTip">
<string>Take all attributes from the Polygon with the largest area or Line with the longest length</string>
<string>Take all attributes from the Polygon with the largest area, Line with the longest length or MultiPoint with the most parts</string>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
Expand Down

0 comments on commit def9af6

Please sign in to comment.