22QString QgsExtractByExtentAlgorithm::name()
const
24 return QStringLiteral(
"extractbyextent" );
27QString QgsExtractByExtentAlgorithm::displayName()
const
29 return QObject::tr(
"Extract/clip by extent" );
32QStringList QgsExtractByExtentAlgorithm::tags()
const
34 return QObject::tr(
"clip,extract,intersect,intersection,mask,extent" ).split(
',' );
37QString QgsExtractByExtentAlgorithm::group()
const
39 return QObject::tr(
"Vector overlay" );
42QString QgsExtractByExtentAlgorithm::groupId()
const
44 return QStringLiteral(
"vectoroverlay" );
46void QgsExtractByExtentAlgorithm::initAlgorithm(
const QVariantMap & )
54QString 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." );
62QgsExtractByExtentAlgorithm *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 const QgsRectangle extent = parameterAsExtent( parameters, QStringLiteral(
"EXTENT" ), context, featureSource->sourceCrs() );
77 const 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 const QgsGeometry clipGeom = parameterAsExtentGeometry( parameters, QStringLiteral(
"EXTENT" ), context, featureSource->sourceCrs() );
90 const double step = featureSource->featureCount() > 0 ? 100.0 / featureSource->featureCount() : 1;
122 outputs.insert( QStringLiteral(
"OUTPUT" ), dest );
WkbType
The WKB type describes the number of dimensions a geometry has.
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
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 QgsGeometryParameters ¶meters=QgsGeometryParameters()) 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.
static Qgis::WkbType promoteNonPointTypesToMulti(Qgis::WkbType type)
Promotes a WKB geometry type to its multi-type equivalent, with the exception of point geometry types...