QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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"
24 #include "qgsprocessingalgorithm.h"
25 #include "qgsapplication.h"
26 
28 
29 
33 class 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, QgsFeedback *feedback );
54 };
55 
56 
60 class QgsSelectByLocationAlgorithm : public QgsLocationBasedAlgorithm
61 {
62 
63  public:
64 
65  QgsSelectByLocationAlgorithm() = default;
66  void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
67  QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmSelectLocation.svg" ) ); }
68  QString svgIconPath() const override { return QgsApplication::iconPath( QStringLiteral( "/algorithms/mAlgorithmSelectLocation.svg" ) ); }
69  QString name() const override;
70  Flags flags() const override;
71  QString displayName() const override;
72  QStringList tags() const override;
73  QString group() const override;
74  QString groupId() const override;
75  QString shortHelpString() const override;
76  QgsSelectByLocationAlgorithm *createInstance() const override SIP_FACTORY;
77 
78  protected:
79 
80  QVariantMap processAlgorithm( const QVariantMap &parameters,
81  QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
82 
83 };
84 
88 class QgsExtractByLocationAlgorithm : public QgsLocationBasedAlgorithm
89 {
90 
91  public:
92 
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 
105  QVariantMap processAlgorithm( const QVariantMap &parameters,
106  QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
107 
108 };
109 
111 
112 #endif // QGSALGORITHMEXTRACTBYLOCATION_H
113 
114 
Base class for providing feedback from a processing algorithm.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:55
Abstract base class for processing algorithms.
Base class for feedback objects to be used for cancellation of something running in a worker thread...
Definition: qgsfeedback.h:44
#define SIP_FACTORY
Definition: qgis_sip.h:76
An interface for objects which provide features via a getFeatures method.
Contains information about the context in which a processing algorithm is executed.