22 QString QgsExtractByExtentAlgorithm::name()
const
24 return QStringLiteral(
"extractbyextent" );
27 QString QgsExtractByExtentAlgorithm::displayName()
const
29 return QObject::tr(
"Extract/clip by extent" );
32 QStringList QgsExtractByExtentAlgorithm::tags()
const
34 return QObject::tr(
"clip,extract,intersect,intersection,mask,extent" ).split(
',' );
37 QString QgsExtractByExtentAlgorithm::group()
const
39 return QObject::tr(
"Vector overlay" );
42 QString QgsExtractByExtentAlgorithm::groupId()
const
44 return QStringLiteral(
"vectoroverlay" );
46 void QgsExtractByExtentAlgorithm::initAlgorithm(
const QVariantMap & )
54 QString QgsExtractByExtentAlgorithm::shortHelpString()
const
56 return QObject::tr(
"This algorithm creates a new vector layer that only contains features which fall within a specified extent. "
57 "Any features which intersect the extent will be included.\n\n"
58 "Optionally, feature geometries can also be clipped to the extent. If this option is selected, then the output "
59 "geometries will automatically be converted to multi geometries to ensure uniform output geometry types." );
62 QgsExtractByExtentAlgorithm *QgsExtractByExtentAlgorithm::createInstance()
const
64 return new QgsExtractByExtentAlgorithm();
69 std::unique_ptr< QgsFeatureSource > featureSource( parameterAsSource( parameters, QStringLiteral(
"INPUT" ), context ) );
74 feedback->
pushWarning( QObject::tr(
"No spatial index exists for input layer, performance will be severely degraded" ) );
76 QgsRectangle extent = parameterAsExtent( parameters, QStringLiteral(
"EXTENT" ), context, featureSource->sourceCrs() );
77 bool clip = parameterAsBoolean( parameters, QStringLiteral(
"CLIP" ), context );
83 std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral(
"OUTPUT" ), context, dest, featureSource->fields(), outType, featureSource->sourceCrs() ) );
88 QgsGeometry clipGeom = parameterAsExtentGeometry( parameters, QStringLiteral(
"EXTENT" ), context, featureSource->sourceCrs() );
90 double step = featureSource->featureCount() > 0 ? 100.0 / featureSource->featureCount() : 1;
114 outputs.insert( QStringLiteral(
"OUTPUT" ), dest );
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
This class wraps a request for features to a vector layer (or directly its vector data provider).
@ ExactIntersect
Use exact geometry intersection (slower) instead of bounding boxes.
@ FastInsert
Use faster inserts, at the cost of updating the passed features to reflect changes made at the provid...
@ SpatialIndexNotPresent
No spatial index exists for the source.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
bool isCanceled() const SIP_HOLDGIL
Tells whether the operation has been canceled already.
void setProgress(double progress)
Sets the current progress for the feedback object.
A geometry is the spatial representation of a feature.
QgsGeometry intersection(const QgsGeometry &geometry) const
Returns a geometry representing the points shared by this geometry and other.
bool convertToMultiType()
Converts single type geometry into multitype geometry e.g.
Contains information about the context in which a processing algorithm is executed.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
virtual void pushWarning(const QString &warning)
Pushes a warning informational message from the algorithm.
A boolean parameter for processing algorithms.
A rectangular map extent parameter for processing algorithms.
A feature sink output for processing algorithms.
An input feature source (such as vector layers) parameter for processing algorithms.
A rectangle specified with double values.
Type
The WKB type describes the number of dimensions a geometry has.
static Type multiType(Type type) SIP_HOLDGIL
Returns the multi type for a WKB type.