コード例 #1
0
bool QgsZonalStatisticsDialog::prefixIsValid( const QString& prefix ) const
{
  QgsVectorLayer* vl = polygonLayer();
  if ( !vl )
  {
    return false;
  }
  QgsVectorDataProvider* dp = vl->dataProvider();
  if ( !dp )
  {
    return false;
  }

  const QgsFields& providerFields = dp->fields();
  QString currentFieldName;

  for ( int idx = 0; idx < providerFields.count(); ++idx )
  {
    currentFieldName = providerFields[idx].name();
    if ( currentFieldName == ( prefix + "mean" ) || currentFieldName == ( prefix + "sum" ) || currentFieldName == ( prefix + "count" ) )
    {
      return false;
    }
  }
  return true;
}
コード例 #2
0
bool QgsZonalStatisticsDialog::prefixIsValid( const QString& prefix ) const
{
  QgsVectorLayer* vl = polygonLayer();
  if ( !vl )
  {
    return false;
  }
  QgsVectorDataProvider* dp = vl->dataProvider();
  if ( !dp )
  {
    return false;
  }

  QgsFieldMap providerFieldMap = dp->fields();
  QgsFieldMap::const_iterator it = providerFieldMap.constBegin();
  QString currentFieldName;

  for ( ; it != providerFieldMap.constEnd(); ++it )
  {
    currentFieldName = it.value().name();
    if ( currentFieldName == ( prefix + "mean" ) || currentFieldName == ( prefix + "sum" ) || currentFieldName == ( prefix + "count" ) )
    {
      return false;
    }
  }
  return true;
}
コード例 #3
0
bool QgsZonalStatisticsDialog::prefixIsValid( const QString& prefix ) const
{
    QgsVectorLayer* vl = polygonLayer();
    if ( !vl )
    {
        return false;
    }
    QgsVectorDataProvider* dp = vl->dataProvider();
    if ( !dp )
    {
        return false;
    }

    QString currentFieldName;

    Q_FOREACH ( const QgsField& field, dp->fields() )
    {
        currentFieldName = field.name();
        if ( currentFieldName == ( prefix + "mean" ) || currentFieldName == ( prefix + "sum" ) || currentFieldName == ( prefix + "count" ) )
        {
            return false;
        }
    }
    return true;
}
コード例 #4
0
QString QgsZonalStatisticsDialog::proposeAttributePrefix() const
{
  if ( !polygonLayer() )
  {
    return "";
  }

  QString proposedPrefix = "";
  while ( !prefixIsValid( proposedPrefix ) )
  {
    proposedPrefix.prepend( "_" );
  }
  return proposedPrefix;
}