本文整理汇总了C++中qgsfeaturelist::iterator::constGeometry方法的典型用法代码示例。如果您正苦于以下问题:C++ iterator::constGeometry方法的具体用法?C++ iterator::constGeometry怎么用?C++ iterator::constGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类qgsfeaturelist::iterator
的用法示例。
在下文中一共展示了iterator::constGeometry方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addFeatures
bool QgsWFSProvider::addFeatures( QgsFeatureList &flist )
{
//create <Transaction> xml
QDomDocument transactionDoc;
QDomElement transactionElem = createTransactionElement( transactionDoc );
transactionDoc.appendChild( transactionElem );
//find out typename from uri and strip namespace prefix
QString tname = mShared->mURI.typeName();
if ( tname.isNull() )
{
return false;
}
removeNamespacePrefix( tname );
//Add the features
QgsFeatureList::iterator featureIt = flist.begin();
for ( ; featureIt != flist.end(); ++featureIt )
{
//Insert element
QDomElement insertElem = transactionDoc.createElementNS( QgsWFSConstants::WFS_NAMESPACE, "Insert" );
transactionElem.appendChild( insertElem );
QDomElement featureElem = transactionDoc.createElementNS( mApplicationNamespace, tname );
QgsAttributes featureAttributes = featureIt->attributes();
int nAttrs = featureAttributes.size();
for ( int i = 0; i < nAttrs; ++i )
{
const QVariant& value = featureAttributes.at( i );
if ( value.isValid() && !value.isNull() )
{
QDomElement fieldElem = transactionDoc.createElementNS( mApplicationNamespace, mShared->mFields.at( i ).name() );
QDomText fieldText = transactionDoc.createTextNode( value.toString() );
fieldElem.appendChild( fieldText );
featureElem.appendChild( fieldElem );
}
}
//add geometry column (as gml)
const QgsGeometry* geometry = featureIt->constGeometry();
if ( geometry != nullptr )
{
QDomElement geomElem = transactionDoc.createElementNS( mApplicationNamespace, mShared->mGeometryAttribute );
QgsGeometry the_geom( *geometry );
// convert to multi if the layer geom type is multi and the geom is not
if ( QGis::isMultiType( this->geometryType( ) ) && ! the_geom.isMultipart( ) )
{
the_geom.convertToMultiType();
}
QDomElement gmlElem = QgsOgcUtils::geometryToGML( &the_geom, transactionDoc );
if ( !gmlElem.isNull() )
{
gmlElem.setAttribute( "srsName", crs().authid() );
geomElem.appendChild( gmlElem );
featureElem.appendChild( geomElem );
}
}
insertElem.appendChild( featureElem );
}
QDomDocument serverResponse;
bool success = sendTransactionDocument( transactionDoc, serverResponse );
if ( !success )
{
return false;
}
if ( transactionSuccess( serverResponse ) )
{
//transaction successful. Add the features to the cache
QStringList idList = insertedFeatureIds( serverResponse );
QStringList::const_iterator idIt = idList.constBegin();
featureIt = flist.begin();
QVector<QgsWFSFeatureGmlIdPair> serializedFeatureList;
for ( ; idIt != idList.constEnd() && featureIt != flist.end(); ++idIt, ++featureIt )
{
serializedFeatureList.push_back( QgsWFSFeatureGmlIdPair( *featureIt, *idIt ) );
}
mShared->serializeFeatures( serializedFeatureList );
// And now set the feature id from the one got from the database
QMap< QString, QgsFeatureId > map;
for ( int idx = 0; idx < serializedFeatureList.size(); idx++ )
map[ serializedFeatureList[idx].second ] = serializedFeatureList[idx].first.id();
idIt = idList.constBegin();
featureIt = flist.begin();
for ( ; idIt != idList.constEnd() && featureIt != flist.end(); ++idIt, ++featureIt )
{
if ( map.find( *idIt ) != map.end() )
featureIt->setFeatureId( map[*idIt] );
}
return true;
}
else
{
//.........这里部分代码省略.........
示例2: setSystemClipboard
void QgsClipboard::setSystemClipboard()
{
// Replace the system clipboard.
QSettings settings;
bool copyWKT = settings.value( "qgis/copyGeometryAsWKT", true ).toBool();
QStringList textLines;
QStringList textFields;
// first do the field names
if ( copyWKT )
{
textFields += "wkt_geom";
}
for ( int idx = 0; idx < mFeatureFields.count(); ++idx )
{
textFields += mFeatureFields[idx].name();
}
textLines += textFields.join( "\t" );
textFields.clear();
// then the field contents
for ( QgsFeatureList::iterator it = mFeatureClipboard.begin(); it != mFeatureClipboard.end(); ++it )
{
QgsAttributes attributes = it->attributes();
// TODO: Set up Paste Transformations to specify the order in which fields are added.
if ( copyWKT )
{
if ( it->constGeometry() )
textFields += it->constGeometry()->exportToWkt();
else
{
textFields += settings.value( "qgis/nullValue", "NULL" ).toString();
}
}
// QgsDebugMsg("about to traverse fields.");
for ( int idx = 0; idx < attributes.count(); ++idx )
{
// QgsDebugMsg(QString("inspecting field '%1'.").arg(it2->toString()));
textFields += attributes[idx].toString();
}
textLines += textFields.join( "\t" );
textFields.clear();
}
QString textCopy = textLines.join( "\n" );
QClipboard *cb = QApplication::clipboard();
// Copy text into the clipboard
// With qgis running under Linux, but with a Windows based X
// server (Xwin32), ::Selection was necessary to get the data into
// the Windows clipboard (which seems contrary to the Qt
// docs). With a Linux X server, ::Clipboard was required.
// The simple solution was to put the text into both clipboards.
#ifndef Q_OS_WIN
cb->setText( textCopy, QClipboard::Selection );
#endif
cb->setText( textCopy, QClipboard::Clipboard );
QgsDebugMsg( QString( "replaced system clipboard with: %1." ).arg( textCopy ) );
}