QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
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
36 protected:
37
38 enum Predicate
39 {
40 Intersects,
41 Contains,
42 Disjoint,
43 IsEqual,
44 Touches,
45 Overlaps,
46 Within,
47 Crosses,
48 };
49
50 void addPredicateParameter();
51 Predicate reversePredicate( Predicate predicate ) const;
52 QStringList predicateOptionsList() const;
53 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() );
54
55
56 private:
57
58 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 );
59 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 );
60};
61
62
66class QgsSelectByLocationAlgorithm : public QgsLocationBasedAlgorithm
67{
68
69 public:
70
71 QgsSelectByLocationAlgorithm() = default;
72 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
73 QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmSelectLocation.svg" ) ); }
74 QString svgIconPath() const override { return QgsApplication::iconPath( QStringLiteral( "/algorithms/mAlgorithmSelectLocation.svg" ) ); }
75 QString name() const override;
76 Flags flags() const override;
77 QString displayName() const override;
78 QStringList tags() const override;
79 QString group() const override;
80 QString groupId() const override;
81 QString shortHelpString() const override;
82 QgsSelectByLocationAlgorithm *createInstance() const override SIP_FACTORY;
83
84 protected:
85
86 QVariantMap processAlgorithm( const QVariantMap &parameters,
87 QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
88
89};
90
94class QgsExtractByLocationAlgorithm : public QgsLocationBasedAlgorithm
95{
96
97 public:
98
99 QgsExtractByLocationAlgorithm() = default;
100 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
101 QString name() const override;
102 QString displayName() const override;
103 QStringList tags() const override;
104 QString group() const override;
105 QString groupId() const override;
106 QString shortHelpString() const override;
107 QgsExtractByLocationAlgorithm *createInstance() const override SIP_FACTORY;
108
109 protected:
110
111 QVariantMap processAlgorithm( const QVariantMap &parameters,
112 QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
113
114};
115
117
118#endif // QGSALGORITHMEXTRACTBYLOCATION_H
119
120
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.
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:56
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
Definition: qgsfeatureid.h:37