Skip to content

Commit 9f57650

Browse files
committedMar 18, 2012
Fix for zonal statistics (ticket #4972)
1 parent c5769bf commit 9f57650

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed
 

‎src/analysis/vector/qgszonalstatistics.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ int QgsZonalStatistics::calculateStatistics( QProgressDialog* p )
109109

110110
//add the new count, sum, mean fields to the provider
111111
QList<QgsField> newFieldList;
112-
QgsField countField( mAttributePrefix + "count", QVariant::Double );
113-
QgsField sumField( mAttributePrefix + "sum", QVariant::Double );
114-
QgsField meanField( mAttributePrefix + "mean", QVariant::Double );
112+
QgsField countField( mAttributePrefix + "count", QVariant::Double, "double precision" );
113+
QgsField sumField( mAttributePrefix + "sum", QVariant::Double, "double precision" );
114+
QgsField meanField( mAttributePrefix + "mean", QVariant::Double, "double precision" );
115115
newFieldList.push_back( countField );
116116
newFieldList.push_back( sumField );
117117
newFieldList.push_back( meanField );

‎src/plugins/zonal_statistics/qgszonalstatisticsdialog.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ void QgsZonalStatisticsDialog::insertAvailableLayers()
6868
QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( layer_it.value() );
6969
if ( vl && vl->geometryType() == QGis::Polygon )
7070
{
71-
mPolygonLayerComboBox->addItem( vl->name(), QVariant( vl->id() ) );
71+
QgsVectorDataProvider* provider = vl->dataProvider();
72+
if ( provider->capabilities() & QgsVectorDataProvider::AddAttributes )
73+
{
74+
mPolygonLayerComboBox->addItem( vl->name(), QVariant( vl->id() ) );
75+
}
7276
}
7377
}
7478
}

0 commit comments

Comments
 (0)
Please sign in to comment.