QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
85 static QString writeFeatureError()
87 return QObject::tr(
"Could not write feature" );
95 if ( outputAttrs != OutputBA )
104 attrs.resize( outputAttrs == OutputA ? fieldsCountA : ( fieldsCountA + fieldsCountB ) );
106 if ( totalCount == 0 )
112 if ( outputAttrs == OutputBA )
128 if ( outputAttrs != OutputBA )
131 std::unique_ptr< QgsGeometryEngine > engine;
132 if ( !intersects.isEmpty() )
136 engine->prepareGeometry();
139 QVector<QgsGeometry> geometriesB;
151 if ( !geometriesB.isEmpty() )
166 if ( !geom.
isNull() && !sanitizeDifferenceResult( geom, geometryType ) )
170 switch ( outputAttrs )
176 for (
int i = 0; i < fieldsCountA; ++i )
177 attrs[i] = attrsA[i];
180 for (
int i = 0; i < fieldsCountA; ++i )
181 attrs[i + fieldsCountB] = attrsA[i];
199 feedback->
setProgress( count /
static_cast< double >( totalCount ) * 100. );
207 const int attrCount = fieldIndicesA.count() + fieldIndicesB.count();
218 if ( totalCount == 0 )
239 std::unique_ptr< QgsGeometryEngine > engine;
240 if ( !intersects.isEmpty() )
244 engine->prepareGeometry();
249 for (
int i = 0; i < fieldIndicesA.count(); ++i )
250 outAttributes[i] = attrsA[fieldIndicesA[i]];
260 if ( !engine->intersects( tmpGeom.constGet() ) )
264 if ( !sanitizeIntersectionResult( intGeom, geometryType ) )
268 for (
int i = 0; i < fieldIndicesB.count(); ++i )
269 outAttributes[fieldIndicesA.count() + i] = attrsB[fieldIndicesB[i]];
278 feedback->
setProgress( count /
static_cast<double >( totalCount ) * 100. );
286 if ( totalCount == 0 )
305 QSet<QgsFeatureId> fids;
312 fids.insert( f.
id() );
315 QHash<QgsFeatureId, QgsGeometry> geometries;
317 QHash<QgsFeatureId, QList<QgsFeatureId> > intersectingIds;
329 std::unique_ptr< QgsGeometryEngine > g1engine;
331 geometries.insert( fid1, g1 );
335 const QList<QgsFeatureId> ids = index.
intersects( bbox );
345 g1engine->prepareGeometry();
349 if ( !g1engine->intersects( g2.
constGet() ) )
353 if ( !sanitizeIntersectionResult( geomIntersection, geometryType ) )
361 while ( fids.contains( newFid ) )
363 fids.insert( newFid );
365 geometries.insert( newFid, geomIntersection );
367 fx.setGeometry( geomIntersection );
373 QList<QgsFeatureId> lst;
374 if ( intersectingIds.contains( fid1 ) )
375 lst << intersectingIds.value( fid1 );
378 if ( intersectingIds.contains( fid2 ) )
379 lst << intersectingIds.value( fid2 );
382 intersectingIds.insert( newFid, lst );
391 geometries.remove( fid1 );
393 if ( sanitizeDifferenceResult( g12, geometryType ) )
395 geometries.insert( fid1, g12 );
398 f1x.setGeometry( g12 );
409 f2old.setGeometry( g2 );
412 geometries.remove( fid2 );
414 if ( sanitizeDifferenceResult( g21, geometryType ) )
416 geometries.insert( fid2, g21 );
419 f2x.setGeometry( g21 );
429 feedback->
setProgress( count /
static_cast< double >( totalCount ) * 100. );
441 QHash<QgsFeatureId, QgsAttributes> attributesHash;
453 for (
auto i = geometries.constBegin(); i != geometries.constEnd(); ++i )
459 outFeature.setGeometry( i.value() );
461 if ( intersectingIds.contains( i.key() ) )
463 const QList<QgsFeatureId> ids = intersectingIds.value( i.key() );
466 outFeature.setAttributes( attributesHash.value(
id ) );
473 outFeature.setAttributes( attributesHash.value( i.key() ) );
@ NoGeometry
Geometry is not required. It may still be returned if e.g. required for a filter condition.
QString lastError() const SIP_HOLDGIL
Returns an error string referring to the last error encountered either when this geometry was created...
void setProgress(double progress)
Sets the current progress for the feedback object.
bool deleteFeature(const QgsFeature &feature)
Removes a feature from the index.
virtual QgsCoordinateReferenceSystem sourceCrs() const =0
Returns the coordinate reference system for features in the source.
QgsFeatureRequest & setInvalidGeometryCheck(InvalidGeometryCheck check)
Sets invalid geometry checking behavior.
bool convertGeometryCollectionToSubclass(QgsWkbTypes::GeometryType geomType)
Converts geometry collection to a the desired geometry type subclass (multi-point,...
Base class for providing feedback from a processing algorithm.
static Type flatType(Type type) SIP_HOLDGIL
Returns the flat type for a WKB type.
virtual bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags())
Adds a single feature to the sink.
int count() const
Returns number of items.
bool isCanceled() const SIP_HOLDGIL
Tells whether the operation has been canceled already.
An interface for objects which provide features via a getFeatures method.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
static Type multiType(Type type) SIP_HOLDGIL
Returns the multi type for a WKB type.
A rectangle specified with double values.
QgsGeometry intersection(const QgsGeometry &geometry) const
Returns a geometry representing the points shared by this geometry and other.
This class wraps a request for features to a vector layer (or directly its vector data provider).
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
QgsFeatureRequest::InvalidGeometryCheck invalidGeometryCheck() const
Returns the behavior used for checking invalid geometries in input layers.
Contains information about the context in which a processing algorithm is executed.
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const =0
Returns an iterator for the features in the source.
virtual long long featureCount() const =0
Returns the number of features contained in the source, or -1 if the feature count is unknown.
A spatial index for QgsFeature objects.
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Sets the feature IDs that should be fetched.
bool isEmpty() const
Returns true if the geometry is empty (eg a linestring with no vertices, or a collection with no geom...
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
QgsFeatureRequest & setNoAttributes()
Set that no attributes will be fetched.
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QSet< QgsFeatureId > QgsFeatureIds
virtual QgsFields fields() const =0
Returns the fields associated with features in the source.
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry)
Creates and returns a new geometry engine representing the specified geometry.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
bool nextFeature(QgsFeature &f)
A geometry is the spatial representation of a feature.
virtual QgsWkbTypes::Type wkbType() const =0
Returns the geometry type for features returned by this source.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
bool convertToMultiType()
Converts single type geometry into multitype geometry e.g.
static GeometryType geometryType(Type type) SIP_HOLDGIL
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
QList< QgsFeatureId > intersects(const QgsRectangle &rectangle) const
Returns a list of features with a bounding box which intersects the specified rectangle.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
A vector of attributes. Mostly equal to QVector<QVariant>.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
QgsFeatureRequest & setDestinationCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets the destination crs for feature's geometries.
void setAttributes(const QgsAttributes &attrs)
Sets the feature's attributes.
Wrapper for iterator of features from vector data provider or vector layer.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
Adds a feature to the index.
Custom exception class for processing related exceptions.
QgsGeometry difference(const QgsGeometry &geometry) const
Returns a geometry representing the points making up this geometry that do not make up other.
An interface for objects which accept features via addFeature(s) methods.
QgsWkbTypes::Type wkbType() const SIP_HOLDGIL
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
static QgsGeometry unaryUnion(const QVector< QgsGeometry > &geometries)
Compute the unary union on a list of geometries.
@ FastInsert
Use faster inserts, at the cost of updating the passed features to reflect changes made at the provid...
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features