mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
QgsFeatureStore is a QgsFeatureSink
Also clean up API for QgsFeatureStore, sipify
This commit is contained in:
parent
c4578c3c1d
commit
49d4b5eb2f
@ -117,7 +117,6 @@ core/qgsvectorsimplifymethod.sip
|
||||
core/qgscachedfeatureiterator.sip
|
||||
core/qgscacheindex.sip
|
||||
core/qgscacheindexfeatureid.sip
|
||||
core/qgsfeaturestore.sip
|
||||
core/qgsgeometrycache.sip
|
||||
core/qgslayerdefinition.sip
|
||||
core/qgsprojectfiletransform.sip
|
||||
|
@ -1,39 +1,92 @@
|
||||
class QgsFeatureStore
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/qgsfeaturestore.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
||||
class QgsFeatureStore : QgsFeatureSink
|
||||
{
|
||||
%Docstring
|
||||
A container for features with the same fields and crs.
|
||||
%End
|
||||
|
||||
%TypeHeaderCode
|
||||
#include <qgsfeaturestore.h>
|
||||
#include "qgsfeaturestore.h"
|
||||
%End
|
||||
public:
|
||||
//! Constructor
|
||||
QgsFeatureStore();
|
||||
%Docstring
|
||||
Constructor
|
||||
%End
|
||||
|
||||
//! Constructor
|
||||
QgsFeatureStore( const QgsFields& fields, const QgsCoordinateReferenceSystem& crs );
|
||||
QgsFeatureStore( const QgsFields &fields, const QgsCoordinateReferenceSystem &crs );
|
||||
%Docstring
|
||||
Constructor
|
||||
%End
|
||||
|
||||
/** Get fields list */
|
||||
QgsFields& fields();
|
||||
QgsFields fields() const;
|
||||
%Docstring
|
||||
Returns the store's field list.
|
||||
\see setFields()
|
||||
:rtype: QgsFields
|
||||
%End
|
||||
|
||||
/** Set fields. Resets feature's fields to pointer to new internal fields. */
|
||||
void setFields( const QgsFields & fields );
|
||||
void setFields( const QgsFields &fields );
|
||||
%Docstring
|
||||
Sets the store's ``fields``. Every contained feature's fields will be reset to match ``fields``.
|
||||
\see fields()
|
||||
%End
|
||||
|
||||
/** Get crs */
|
||||
QgsCoordinateReferenceSystem crs() const;
|
||||
%Docstring
|
||||
Returns the store's coordinate reference system.
|
||||
\see setCrs()
|
||||
:rtype: QgsCoordinateReferenceSystem
|
||||
%End
|
||||
|
||||
/** Set crs */
|
||||
void setCrs( const QgsCoordinateReferenceSystem& crs );
|
||||
void setCrs( const QgsCoordinateReferenceSystem &crs );
|
||||
%Docstring
|
||||
Sets the store's ``crs``.
|
||||
\see crs()
|
||||
%End
|
||||
|
||||
/** Add feature. Feature's fields will be set to pointer to the store fields.
|
||||
* @param feature
|
||||
* @note added in 2.1
|
||||
*/
|
||||
void addFeature( const QgsFeature& feature );
|
||||
virtual bool addFeature( QgsFeature &feature /In,Out/ );
|
||||
|
||||
/** Get features list reference */
|
||||
QgsFeatureList& features();
|
||||
virtual bool addFeatures( QgsFeatureList &features /In,Out/ );
|
||||
|
||||
/** Set map of optional parameters */
|
||||
void setParams( const QMap<QString, QVariant> ¶ms );
|
||||
|
||||
/** Get map of optional parameters */
|
||||
QgsFeatureList features() const;
|
||||
%Docstring
|
||||
Returns the list of features contained in the store.
|
||||
:rtype: QgsFeatureList
|
||||
%End
|
||||
|
||||
void setParams( const QMap<QString, QVariant> ¶meters );
|
||||
%Docstring
|
||||
Sets a map of optional ``parameters`` for the store.
|
||||
\see params()
|
||||
%End
|
||||
|
||||
QMap<QString, QVariant> params() const;
|
||||
%Docstring
|
||||
Returns the map of optional parameters.
|
||||
\see setParams()
|
||||
:rtype: QMap<str, QVariant>
|
||||
%End
|
||||
|
||||
};
|
||||
|
||||
typedef QList<QgsFeatureStore> QgsFeatureStoreList;
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
* src/core/qgsfeaturestore.h *
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
@ -1898,7 +1898,8 @@ void QgsIdentifyResultsDialog::copyFeature()
|
||||
}
|
||||
|
||||
QgsFeatureStore featureStore( item->fields(), item->crs() );
|
||||
featureStore.features().append( item->feature() );
|
||||
QgsFeature f( item->feature() );
|
||||
featureStore.addFeature( f );
|
||||
emit copyToClipboard( featureStore );
|
||||
}
|
||||
|
||||
|
@ -35,9 +35,20 @@ void QgsFeatureStore::setFields( const QgsFields &fields )
|
||||
}
|
||||
}
|
||||
|
||||
void QgsFeatureStore::addFeature( const QgsFeature &feature )
|
||||
bool QgsFeatureStore::addFeature( QgsFeature &feature )
|
||||
{
|
||||
QgsFeature f( feature );
|
||||
f.setFields( mFields );
|
||||
mFeatures.append( f );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool QgsFeatureStore::addFeatures( QgsFeatureList &features )
|
||||
{
|
||||
QgsFeatureList::iterator fIt = features.begin();
|
||||
for ( ; fIt != features.end(); ++fIt )
|
||||
{
|
||||
addFeature( *fIt );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -19,15 +19,16 @@
|
||||
#include "qgis.h"
|
||||
#include "qgsfeature.h"
|
||||
#include "qgsfields.h"
|
||||
#include "qgsfeaturesink.h"
|
||||
#include "qgscoordinatereferencesystem.h"
|
||||
#include <QList>
|
||||
#include <QMetaType>
|
||||
#include <QVariant>
|
||||
|
||||
/** \ingroup core
|
||||
* Container for features with the same fields and crs.
|
||||
* A container for features with the same fields and crs.
|
||||
*/
|
||||
class CORE_EXPORT QgsFeatureStore
|
||||
class CORE_EXPORT QgsFeatureStore : public QgsFeatureSink
|
||||
{
|
||||
public:
|
||||
//! Constructor
|
||||
@ -36,31 +37,48 @@ class CORE_EXPORT QgsFeatureStore
|
||||
//! Constructor
|
||||
QgsFeatureStore( const QgsFields &fields, const QgsCoordinateReferenceSystem &crs );
|
||||
|
||||
//! Get fields list
|
||||
QgsFields &fields() { return mFields; }
|
||||
/**
|
||||
* Returns the store's field list.
|
||||
* \see setFields()
|
||||
*/
|
||||
QgsFields fields() const { return mFields; }
|
||||
|
||||
//! Set fields. Resets feature's fields to pointer to new internal fields.
|
||||
/**
|
||||
* Sets the store's \a fields. Every contained feature's fields will be reset to match \a fields.
|
||||
* \see fields()
|
||||
*/
|
||||
void setFields( const QgsFields &fields );
|
||||
|
||||
//! Get crs
|
||||
/**
|
||||
* Returns the store's coordinate reference system.
|
||||
* \see setCrs()
|
||||
*/
|
||||
QgsCoordinateReferenceSystem crs() const { return mCrs; }
|
||||
|
||||
//! Set crs
|
||||
/**
|
||||
* Sets the store's \a crs.
|
||||
* \see crs()
|
||||
*/
|
||||
void setCrs( const QgsCoordinateReferenceSystem &crs ) { mCrs = crs; }
|
||||
|
||||
/** Add feature. Feature's fields will be set to pointer to the store fields.
|
||||
* \param feature
|
||||
* \since QGIS 2.1
|
||||
bool addFeature( QgsFeature &feature SIP_INOUT ) override;
|
||||
bool addFeatures( QgsFeatureList &features SIP_INOUT ) override;
|
||||
|
||||
/**
|
||||
* Returns the list of features contained in the store.
|
||||
*/
|
||||
void addFeature( const QgsFeature &feature );
|
||||
QgsFeatureList features() const { return mFeatures; }
|
||||
|
||||
//! Get features list reference
|
||||
QgsFeatureList &features() { return mFeatures; }
|
||||
/**
|
||||
* Sets a map of optional \a parameters for the store.
|
||||
* \see params()
|
||||
*/
|
||||
void setParams( const QMap<QString, QVariant> ¶meters ) { mParams = parameters; }
|
||||
|
||||
//! Set map of optional parameters
|
||||
void setParams( const QMap<QString, QVariant> ¶ms ) { mParams = params; }
|
||||
|
||||
//! Get map of optional parameters
|
||||
/**
|
||||
* Returns the map of optional parameters.
|
||||
* \see setParams()
|
||||
*/
|
||||
QMap<QString, QVariant> params() const { return mParams; }
|
||||
|
||||
private:
|
||||
|
@ -430,7 +430,7 @@ QgsRasterIdentifyResult QgsAmsProvider::identify( const QgsPoint &point, QgsRast
|
||||
params[QStringLiteral( "sublayer" )] = resultMap[QStringLiteral( "layerName" )].toString();
|
||||
params[QStringLiteral( "featureType" )] = attributesMap[resultMap[QStringLiteral( "displayFieldName" )].toString()].toString();
|
||||
store.setParams( params );
|
||||
store.features().append( feature );
|
||||
store.addFeature( feature );
|
||||
entries.insert( entries.size(), qVariantFromValue( QList<QgsFeatureStore>() << store ) );
|
||||
}
|
||||
}
|
||||
|
@ -2938,7 +2938,7 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPoint &point, QgsRast
|
||||
g.transform( coordinateTransform );
|
||||
feature->setGeometry( g );
|
||||
}
|
||||
featureStore.features().append( QgsFeature( *feature ) );
|
||||
featureStore.addFeature( *feature );
|
||||
}
|
||||
featureStoreList.append( featureStore );
|
||||
}
|
||||
@ -3073,7 +3073,7 @@ QgsRasterIdentifyResult QgsWmsProvider::identify( const QgsPoint &point, QgsRast
|
||||
featureStore.setParams( params );
|
||||
|
||||
feature.setValid( true );
|
||||
featureStore.features().append( feature );
|
||||
featureStore.addFeature( feature );
|
||||
|
||||
featureStoreList.append( featureStore );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user