QGIS API Documentation 3.41.0-Master (cea29feecf2)
Loading...
Searching...
No Matches
qgsalgorithmextractbylocation.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsalgorithmextractbylocation.h
3 ---------------------
4 begin : April 2017
5 copyright : (C) 2017 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSALGORITHMEXTRACTBYLOCATION_H
19#define QGSALGORITHMEXTRACTBYLOCATION_H
20
21#define SIP_NO_FILE
22
23#include "qgis_sip.h"
25#include "qgsapplication.h"
26
28
29
33class QgsLocationBasedAlgorithm : public QgsProcessingAlgorithm
34{
35 protected:
36 enum Predicate
37 {
38 Intersects,
39 Contains,
40 Disjoint,
41 IsEqual,
42 Touches,
43 Overlaps,
44 Within,
45 Crosses,
46 };
47
48 void addPredicateParameter();
49 Predicate reversePredicate( Predicate predicate ) const;
50 QStringList predicateOptionsList() const;
51 void process( const QgsProcessingContext &context, QgsFeatureSource *targetSource, QgsFeatureSource *intersectSource, const QList<int> &selectedPredicates, const std::function<void( const QgsFeature & )> &handleFeatureFunction, bool onlyRequireTargetIds, QgsProcessingFeedback *feedback, const QgsFeatureIds &skipTargetFeatureIds = QgsFeatureIds() );
52
53 protected:
55 long long mTargetFeatureCount = 0;
56 long long mIntersectFeatureCount = 0;
57
58 private:
59 void processByIteratingOverTargetSource( const QgsProcessingContext &context, QgsFeatureSource *targetSource, QgsFeatureSource *intersectSource, const QList<int> &selectedPredicates, const std::function<void( const QgsFeature & )> &handleFeatureFunction, bool onlyRequireTargetIds, QgsProcessingFeedback *feedback, const QgsFeatureIds &skipTargetFeatureIds );
60 void processByIteratingOverIntersectSource( const QgsProcessingContext &context, QgsFeatureSource *targetSource, QgsFeatureSource *intersectSource, const QList<int> &selectedPredicates, const std::function<void( const QgsFeature & )> &handleFeatureFunction, bool onlyRequireTargetIds, QgsProcessingFeedback *feedback, const QgsFeatureIds &skipTargetFeatureIds );
61};
62
63
67class QgsSelectByLocationAlgorithm : public QgsLocationBasedAlgorithm
68{
69 public:
70 QgsSelectByLocationAlgorithm() = default;
71 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
72 QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmSelectLocation.svg" ) ); }
73 QString svgIconPath() const override { return QgsApplication::iconPath( QStringLiteral( "/algorithms/mAlgorithmSelectLocation.svg" ) ); }
74 QString name() const override;
75 Qgis::ProcessingAlgorithmFlags flags() const override;
76 QString displayName() const override;
77 QStringList tags() const override;
78 QString group() const override;
79 QString groupId() const override;
80 QString shortHelpString() const override;
81 QgsSelectByLocationAlgorithm *createInstance() const override SIP_FACTORY;
82
83 protected:
84 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
85};
86
90class QgsExtractByLocationAlgorithm : public QgsLocationBasedAlgorithm
91{
92 public:
93 QgsExtractByLocationAlgorithm() = default;
94 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
95 QString name() const override;
96 QString displayName() const override;
97 QStringList tags() const override;
98 QString group() const override;
99 QString groupId() const override;
100 QString shortHelpString() const override;
101 QgsExtractByLocationAlgorithm *createInstance() const override SIP_FACTORY;
102
103 protected:
104 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
105 bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
106};
107
109
110#endif // QGSALGORITHMEXTRACTBYLOCATION_H
QFlags< ProcessingAlgorithmFlag > ProcessingAlgorithmFlags
Flags indicating how and when an algorithm operates and should be exposed to users.
Definition qgis.h:3392
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
This class represents a coordinate reference system (CRS).
An interface for objects which provide features via a getFeatures method.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
Abstract base class for processing algorithms.
Contains information about the context in which a processing algorithm is executed.
Base class for providing feedback from a processing algorithm.
#define SIP_FACTORY
Definition qgis_sip.h:76
QSet< QgsFeatureId > QgsFeatureIds