本文整理汇总了C++中qgsattributemap::const_iterator类的典型用法代码示例。如果您正苦于以下问题:C++ const_iterator类的具体用法?C++ const_iterator怎么用?C++ const_iterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了const_iterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: canvasReleaseEvent
void QgsMapToolChangeLabelProperties::canvasReleaseEvent( QMouseEvent *e )
{
Q_UNUSED( e );
QgsVectorLayer* vlayer = currentLayer();
if ( mLabelRubberBand && mCanvas && vlayer )
{
QString labeltext = QString(); // NULL QString signifies no expression
bool settingsOk;
QgsPalLayerSettings& labelSettings = currentLabelSettings( &settingsOk );
if ( settingsOk && labelSettings.isExpression )
{
labeltext = mCurrentLabelPos.labelText;
}
QgsLabelPropertyDialog d( mCurrentLabelPos.layerID, mCurrentLabelPos.featureId, mCurrentLabelPos.labelFont, labeltext, 0 );
if ( d.exec() == QDialog::Accepted )
{
const QgsAttributeMap& changes = d.changedProperties();
if ( changes.size() > 0 )
{
vlayer->beginEditCommand( tr( "Changed properties for label" ) + QString( " '%1'" ).arg( currentLabelText( 24 ) ) );
QgsAttributeMap::const_iterator changeIt = changes.constBegin();
for ( ; changeIt != changes.constEnd(); ++changeIt )
{
vlayer->changeAttributeValue( mCurrentLabelPos.featureId, changeIt.key(), changeIt.value() );
}
vlayer->endEditCommand();
mCanvas->refresh();
}
}
deleteRubberBands();
}
}
示例2: canvasReleaseEvent
void QgsMapToolChangeLabelProperties::canvasReleaseEvent( QMouseEvent * e )
{
QgsVectorLayer* vlayer = currentLayer();
if ( mLabelRubberBand && mCanvas && vlayer )
{
QgsLabelPropertyDialog d( mCurrentLabelPos.layerID, mCurrentLabelPos.featureId, mCanvas->mapRenderer() );
if ( d.exec() == QDialog::Accepted )
{
const QgsAttributeMap& changes = d.changedProperties();
if ( changes.size() > 0 )
{
vlayer->beginEditCommand( tr( "Label properties changed" ) );
QgsAttributeMap::const_iterator changeIt = changes.constBegin();
for ( ; changeIt != changes.constEnd(); ++changeIt )
{
vlayer->changeAttributeValue( mCurrentLabelPos.featureId, changeIt.key(), changeIt.value(), false );
}
vlayer->endEditCommand();
mCanvas->refresh();
}
}
deleteRubberBands();
}
}
示例3: expandAction
QString QgsActionManager::expandAction( QString action, const QgsAttributeMap &attributes,
uint clickedOnValue )
{
// This function currently replaces all %% characters in the action
// with the value from values[clickedOnValue].second, and then
// searches for all strings that go %attribute_name, where
// attribute_name is found in values[x].first, and replaces any that
// it finds by values[s].second.
// Additional substitutions could include symbols for $CWD, $HOME,
// etc (and their OSX and Windows equivalents)
// This function will potentially fall apart if any of the
// substitutions produce text that could match another
// substitution. May be better to adopt a two pass approach - identify
// all matches and their substitutions and then do a second pass
// for the actual substitutions.
QString expanded_action;
if ( attributes.contains( clickedOnValue ) )
expanded_action = action.replace( "%%", attributes[clickedOnValue].toString() );
else
expanded_action = action;
const QgsFields &fields = mLayer->fields();
for ( int i = 0; i < 4; i++ )
{
for ( QgsAttributeMap::const_iterator it = attributes.begin(); it != attributes.end(); ++it )
{
int attrIdx = it.key();
if ( attrIdx < 0 || attrIdx >= fields.count() )
continue;
QString to_replace;
switch ( i )
{
case 0:
to_replace = "[%" + fields[attrIdx].name() + ']';
break;
case 1:
to_replace = "[%" + mLayer->attributeDisplayName( attrIdx ) + ']';
break;
case 2:
to_replace = '%' + fields[attrIdx].name();
break;
case 3:
to_replace = '%' + mLayer->attributeDisplayName( attrIdx );
break;
}
expanded_action = expanded_action.replace( to_replace, it.value().toString() );
}
}
return expanded_action;
}
示例4: createFeatureElem
QDomElement QgsWFSServer::createFeatureElem( QgsFeature* feat, QDomDocument& doc, QgsCoordinateReferenceSystem& crs, QMap< int, QgsField > fields, QSet<QString> hiddenAttributes ) /*const*/
{
//gml:FeatureMember
QDomElement featureElement = doc.createElement( "gml:featureMember"/*wfs:FeatureMember*/ );
//qgs:%TYPENAME%
QDomElement typeNameElement = doc.createElement( "qgs:" + mTypeName.replace( QString( " " ), QString( "_" ) )/*qgs:%TYPENAME%*/ );
typeNameElement.setAttribute( "fid", QString::number( feat->id() ) );
featureElement.appendChild( typeNameElement );
if ( mWithGeom )
{
//add geometry column (as gml)
QgsGeometry* geom = feat->geometry();
QDomElement geomElem = doc.createElement( "qgs:geometry" );
QDomElement gmlElem = createGeometryElem( geom, doc );
if ( !gmlElem.isNull() )
{
QgsRectangle box = geom->boundingBox();
QDomElement bbElem = doc.createElement( "gml:boundedBy" );
QDomElement boxElem = createBoxElem( &box, doc );
if ( crs.isValid() )
{
boxElem.setAttribute( "srsName", crs.authid() );
gmlElem.setAttribute( "srsName", crs.authid() );
}
bbElem.appendChild( boxElem );
typeNameElement.appendChild( bbElem );
geomElem.appendChild( gmlElem );
typeNameElement.appendChild( geomElem );
}
}
//read all attribute values from the feature
QgsAttributeMap featureAttributes = feat->attributeMap();
for ( QgsAttributeMap::const_iterator it = featureAttributes.begin(); it != featureAttributes.end(); ++it )
{
QString attributeName = fields[it.key()].name();
//skip attribute if it has edit type 'hidden'
if ( hiddenAttributes.contains( attributeName ) )
{
continue;
}
QDomElement fieldElem = doc.createElement( "qgs:" + attributeName.replace( QString( " " ), QString( "_" ) ) );
QDomText fieldText = doc.createTextNode( it->toString() );
fieldElem.appendChild( fieldText );
typeNameElement.appendChild( fieldElem );
}
return featureElement;
}
示例5: if
QgsSymbolV2* QgsCategorizedSymbolRendererV2::symbolForFeature( QgsFeature& feature )
{
const QgsAttributeMap& attrMap = feature.attributeMap();
QgsAttributeMap::const_iterator ita = attrMap.find( mAttrNum );
if ( ita == attrMap.end() )
{
QgsDebugMsg( "attribute '" + mAttrName + "' (index " + QString::number( mAttrNum ) + ") required by renderer not found" );
return NULL;
}
// find the right symbol for the category
QgsSymbolV2* symbol = symbolForValue( *ita );
if ( symbol == NULL )
{
// if no symbol found use default one
//return symbolForValue( QVariant( "" ) );
// What is default? Empty string may be a legal value, and features not found
// should not be rendered using empty string value category symbology.
// We also need to get NULL in that case so that willRenderFeature()
// may be used to count features.
return 0;
}
if ( mRotationFieldIdx == -1 && mSizeScaleFieldIdx == -1 )
return symbol; // no data-defined rotation/scaling - just return the symbol
// find out rotation, size scale
double rotation = 0;
double sizeScale = 1;
if ( mRotationFieldIdx != -1 )
rotation = attrMap[mRotationFieldIdx].toDouble();
if ( mSizeScaleFieldIdx != -1 )
sizeScale = attrMap[mSizeScaleFieldIdx].toDouble();
// take a temporary symbol (or create it if doesn't exist)
QgsSymbolV2* tempSymbol = mTempSymbols[ita->toString()];
// modify the temporary symbol and return it
if ( tempSymbol->type() == QgsSymbolV2::Marker )
{
QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>( tempSymbol );
if ( mRotationFieldIdx != -1 )
markerSymbol->setAngle( rotation );
if ( mSizeScaleFieldIdx != -1 )
markerSymbol->setSize( sizeScale * static_cast<QgsMarkerSymbolV2*>( symbol )->size() );
markerSymbol->setScaleMethod( mScaleMethod );
}
else if ( tempSymbol->type() == QgsSymbolV2::Line )
{
QgsLineSymbolV2* lineSymbol = static_cast<QgsLineSymbolV2*>( tempSymbol );
if ( mSizeScaleFieldIdx != -1 )
lineSymbol->setWidth( sizeScale * static_cast<QgsLineSymbolV2*>( symbol )->width() );
}
return tempSymbol;
}
示例6: updateAttributeMapIndex
void QgsVectorLayerEditBuffer::updateAttributeMapIndex( QgsAttributeMap& map, int index, int offset ) const
{
QgsAttributeMap updatedMap;
for ( QgsAttributeMap::const_iterator it = map.begin(); it != map.end(); ++it )
{
int attrIndex = it.key();
updatedMap.insert( attrIndex < index ? attrIndex : attrIndex + offset, it.value() );
}
map = updatedMap;
}
示例7: getLabel
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;
}
示例8: diagramSize
QSizeF QgsLinearlyInterpolatedDiagramRenderer::diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c )
{
Q_UNUSED( c );
QgsAttributeMap::const_iterator attIt = attributes.find( mClassificationAttribute );
if ( attIt == attributes.constEnd() )
{
return QSizeF(); //zero size if attribute is missing
}
double value = attIt.value().toDouble();
//interpolate size
double ratio = ( value - mLowerValue ) / ( mUpperValue - mLowerValue );
return QSizeF( mUpperSize.width() * ratio + mLowerSize.width() * ( 1 - ratio ),
mUpperSize.height() * ratio + mLowerSize.height() * ( 1 - ratio ) );
}
示例9: if
QgsSymbolV2* QgsCategorizedSymbolRendererV2::symbolForFeature( QgsFeature& feature )
{
const QgsAttributeMap& attrMap = feature.attributeMap();
QgsAttributeMap::const_iterator ita = attrMap.find( mAttrNum );
if ( ita == attrMap.end() )
{
QgsDebugMsg( "attribute '" + mAttrName + "' (index " + QString::number( mAttrNum ) + ") required by renderer not found" );
return NULL;
}
// find the right symbol for the category
QgsSymbolV2* symbol = symbolForValue( *ita );
if ( symbol == NULL )
return NULL;
if ( mRotationFieldIdx == -1 && mSizeScaleFieldIdx == -1 )
return symbol; // no data-defined rotation/scaling - just return the symbol
// find out rotation, size scale
double rotation = 0;
double sizeScale = 1;
if ( mRotationFieldIdx != -1 )
rotation = attrMap[mRotationFieldIdx].toDouble();
if ( mSizeScaleFieldIdx != -1 )
sizeScale = attrMap[mSizeScaleFieldIdx].toDouble();
// take a temporary symbol (or create it if doesn't exist)
QgsSymbolV2* tempSymbol = mTempSymbols[ita->toString()];
// modify the temporary symbol and return it
if ( tempSymbol->type() == QgsSymbolV2::Marker )
{
QgsMarkerSymbolV2* markerSymbol = static_cast<QgsMarkerSymbolV2*>( tempSymbol );
if ( mRotationFieldIdx != -1 )
markerSymbol->setAngle( rotation );
if ( mSizeScaleFieldIdx != -1 )
markerSymbol->setSize( sizeScale * static_cast<QgsMarkerSymbolV2*>( symbol )->size() );
}
else if ( tempSymbol->type() == QgsSymbolV2::Line )
{
QgsLineSymbolV2* lineSymbol = static_cast<QgsLineSymbolV2*>( tempSymbol );
if ( mSizeScaleFieldIdx != -1 )
lineSymbol->setWidth( sizeScale * static_cast<QgsLineSymbolV2*>( symbol )->width() );
}
return tempSymbol;
}
示例10: diagramSize
QSizeF QgsPieDiagram::diagramSize( const QgsAttributeMap& attributes, const QgsRenderContext& c, const QgsDiagramSettings& s, const QgsDiagramInterpolationSettings& is )
{
Q_UNUSED( c );
QgsAttributeMap::const_iterator attIt = attributes.find( is.classificationAttribute );
if ( attIt == attributes.constEnd() )
{
return QSizeF(); //zero size if attribute is missing
}
double scaledValue = attIt.value().toDouble();
double scaledLowerValue = is.lowerValue;
double scaledUpperValue = is.upperValue;
double scaledLowerSizeWidth = is.lowerSize.width();
double scaledLowerSizeHeight = is.lowerSize.height();
double scaledUpperSizeWidth = is.upperSize.width();
double scaledUpperSizeHeight = is.upperSize.height();
// interpolate the squared value if scale by area
if ( s.scaleByArea )
{
scaledValue = sqrt( scaledValue );
scaledLowerValue = sqrt( scaledLowerValue );
scaledUpperValue = sqrt( scaledUpperValue );
scaledLowerSizeWidth = sqrt( scaledLowerSizeWidth );
scaledLowerSizeHeight = sqrt( scaledLowerSizeHeight );
scaledUpperSizeWidth = sqrt( scaledUpperSizeWidth );
scaledUpperSizeHeight = sqrt( scaledUpperSizeHeight );
}
//interpolate size
double scaledRatio = ( scaledValue - scaledLowerValue ) / ( scaledUpperValue - scaledLowerValue );
QSizeF size = QSizeF( is.upperSize.width() * scaledRatio + is.lowerSize.width() * ( 1 - scaledRatio ),
is.upperSize.height() * scaledRatio + is.lowerSize.height() * ( 1 - scaledRatio ) );
// Scale, if extension is smaller than the specified minimum
if ( size.width() <= s.minimumSize && size.height() <= s.minimumSize )
{
size.scale( s.minimumSize, s.minimumSize, Qt::KeepAspectRatio );
}
return size;
}
示例11: fieldValue
QString QgsLabel::fieldValue( int attr, QgsFeature &feature )
{
if ( mLabelFieldIdx[attr] == -1 )
{
return QString();
}
const QgsAttributeMap& attrs = feature.attributeMap();
QgsAttributeMap::const_iterator it = attrs.find( mLabelFieldIdx[attr] );
if ( it != attrs.end() )
{
return it->toString();
}
else
{
return QString();
}
}
示例12: classificationValue
int QgsDiagramRenderer::classificationValue( const QgsFeature& f, QVariant& value ) const
{
//find out attribute value of the feature
QgsAttributeMap featureAttributes = f.attributeMap();
QgsAttributeMap::const_iterator iter;
if ( value.type() == QVariant::String ) //string type
{
//we can only handle one classification field for strings
if ( mClassificationAttributes.size() > 1 )
{
return 1;
}
iter = featureAttributes.find( mClassificationAttributes.first() );
if ( iter == featureAttributes.constEnd() )
{
return 2;
}
value = iter.value();
}
else //numeric type
{
double currentValue;
double totalValue = 0;
QList<int>::const_iterator list_it = mClassificationAttributes.constBegin();
for ( ; list_it != mClassificationAttributes.constEnd(); ++list_it )
{
QgsAttributeMap::const_iterator iter = featureAttributes.find( *list_it );
if ( iter == featureAttributes.constEnd() )
{
continue;
}
currentValue = iter.value().toDouble();
totalValue += currentValue;
}
value = QVariant( totalValue );
}
return 0;
}
示例13: applyChanges
void QgsMapToolChangeLabelProperties::applyChanges( const QgsAttributeMap& changes )
{
QgsVectorLayer* vlayer = mCurrentLabel.layer;
if ( !vlayer )
return;
if ( !changes.isEmpty() )
{
vlayer->beginEditCommand( tr( "Changed properties for label" ) + QStringLiteral( " '%1'" ).arg( currentLabelText( 24 ) ) );
QgsAttributeMap::const_iterator changeIt = changes.constBegin();
for ( ; changeIt != changes.constEnd(); ++changeIt )
{
vlayer->changeAttributeValue( mCurrentLabel.pos.featureId, changeIt.key(), changeIt.value() );
}
vlayer->endEditCommand();
vlayer->triggerRepaint();
}
}
示例14: updateChangedAttributes
void QgsVectorLayerFeatureIterator::updateChangedAttributes( QgsFeature &f )
{
QgsAttributes& attrs = f.attributes();
// remove all attributes that will disappear - from higher indices to lower
for ( int idx = mDeletedAttributeIds.count() - 1; idx >= 0; --idx )
{
attrs.remove( mDeletedAttributeIds[idx] );
}
// adjust size to accommodate added attributes
attrs.resize( attrs.count() + mAddedAttributes.count() );
// update changed attributes
if ( mChangedAttributeValues.contains( f.id() ) )
{
const QgsAttributeMap &map = mChangedAttributeValues[f.id()];
for ( QgsAttributeMap::const_iterator it = map.begin(); it != map.end(); it++ )
attrs[it.key()] = it.value();
}
}
示例15: applyFeaturesAdded
void QgsOfflineEditing::applyFeaturesAdded( QgsVectorLayer* offlineLayer, QgsVectorLayer* remoteLayer, sqlite3* db, int layerId )
{
QString sql = QString( "SELECT \"fid\" FROM 'log_added_features' WHERE \"layer_id\" = %1" ).arg( layerId );
QList<int> newFeatureIds = sqlQueryInts( db, sql );
// get new features from offline layer
QgsFeatureList features;
for ( int i = 0; i < newFeatureIds.size(); i++ )
{
QgsFeature feature;
if ( offlineLayer->featureAtId( newFeatureIds.at( i ), feature, true, true ) )
{
features << feature;
}
}
// copy features to remote layer
mProgressDialog->setupProgressBar( tr( "%v / %m features added" ), features.size() );
int i = 1;
for ( QgsFeatureList::iterator it = features.begin(); it != features.end(); ++it )
{
QgsFeature f = *it;
// NOTE: Spatialite provider ignores position of geometry column
// restore gap in QgsAttributeMap if geometry column is not last (WORKAROUND)
QMap<int, int> attrLookup = attributeLookup( offlineLayer, remoteLayer );
QgsAttributeMap newAttrMap;
QgsAttributeMap attrMap = f.attributeMap();
for ( QgsAttributeMap::const_iterator it = attrMap.begin(); it != attrMap.end(); ++it )
{
newAttrMap.insert( attrLookup[ it.key()], it.value() );
}
f.setAttributeMap( newAttrMap );
remoteLayer->addFeature( f, false );
mProgressDialog->setProgressValue( i++ );
}
}