void QgsOverlayAnalyzer::combineAttributeMaps( QgsAttributeMap& attributeMapA, QgsAttributeMap attributeMapB )
{
  QMap<int, QVariant>::const_iterator i = attributeMapB.constBegin();
  QVariant attribute;
  int fcount = attributeMapA.size();
  while ( i != attributeMapB.constEnd() )
  {
    attribute = i.value();
    attributeMapA.insert( fcount, attribute );
    ++i;
    ++fcount;
  }
}
QString QgsPointDisplacementRenderer::getLabel( const QgsFeature& f )
{
  QString attribute;
  QgsAttributeMap attMap = f.attributeMap();
  if ( attMap.size() > 0 )
  {
    QgsAttributeMap::const_iterator valIt = attMap.find( mLabelIndex );
    if ( valIt != attMap.constEnd() )
    {
      attribute = valIt->toString();
    }
  }
  return attribute;
}
Exemple #3
0
void QgsGrassEdit::addCat( int line )
{
  int mode = mCatModeBox->currentIndex();
  int field = mFieldBox->currentText().toInt();
  int cat = mCatEntry->text().toInt();

  int type = mProvider->readLine( mPoints, mCats, line );
  if ( mode == CAT_MODE_NEXT || mode == CAT_MODE_MANUAL )
  {
    Vect_cat_set( mCats, field, cat );
  }

  line = mProvider->rewriteLine( line, type, mPoints, mCats );
  mSelectedLine = line;
  if ( mAttributes )
    mAttributes->setLine( line );
  updateSymb();
  increaseMaxCat();

  // Insert new DB record if link is defined and the record for this cat does not exist
  QString *key = mProvider->key( field );

  if ( !key->isEmpty() )   // Database link defined
  {
    QgsAttributeMap *atts = mProvider->attributes( field, cat );

    if ( atts->size() == 0 )   // Nothing selected
    {
      QString *error = mProvider->insertAttributes( field, cat );

      if ( !error->isEmpty() )
      {
        QMessageBox::warning( 0, tr( "Warning" ), *error );
      }
      delete error;
    }

    delete atts;
  }

  addAttributes( field, cat );
}