QGIS API Documentation  3.2.0-Bonn (bc43194)
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.h"
24 #include "qgsprocessingalgorithm.h"
25 
27 
28 
32 class QgsLocationBasedAlgorithm : public QgsProcessingAlgorithm
33 {
34 
35  protected:
36 
37  enum Predicate
38  {
39  Intersects,
40  Contains,
41  Disjoint,
42  IsEqual,
43  Touches,
44  Overlaps,
45  Within,
46  Crosses,
47  };
48 
49  void addPredicateParameter();
50  Predicate reversePredicate( Predicate predicate ) const;
51  QStringList predicateOptionsList() const;
52  void process( const QgsProcessingContext &context, QgsFeatureSource *targetSource, QgsFeatureSource *intersectSource, const QList<int> &selectedPredicates, const std::function< void( const QgsFeature & )> &handleFeatureFunction, bool onlyRequireTargetIds, QgsFeedback *feedback );
53 };
54 
55 
59 class QgsSelectByLocationAlgorithm : public QgsLocationBasedAlgorithm
60 {
61 
62  public:
63 
64  QgsSelectByLocationAlgorithm() = default;
65  void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
66  QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmSelectLocation.svg" ) ); }
67  QString svgIconPath() const override { return QgsApplication::iconPath( QStringLiteral( "/algorithms/mAlgorithmSelectLocation.svg" ) ); }
68  QString name() const override;
69  Flags flags() const override;
70  QString displayName() const override;
71  QStringList tags() const override;
72  QString group() const override;
73  QString groupId() const override;
74  QString shortHelpString() const override;
75  QgsSelectByLocationAlgorithm *createInstance() const override SIP_FACTORY;
76 
77  protected:
78 
79  QVariantMap processAlgorithm( const QVariantMap &parameters,
80  QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
81 
82 };
83 
87 class QgsExtractByLocationAlgorithm : public QgsLocationBasedAlgorithm
88 {
89 
90  public:
91 
92  QgsExtractByLocationAlgorithm() = default;
93  void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
94  QString name() const override;
95  QString displayName() const override;
96  QStringList tags() const override;
97  QString group() const override;
98  QString groupId() const override;
99  QString shortHelpString() const override;
100  QgsExtractByLocationAlgorithm *createInstance() const override SIP_FACTORY;
101 
102  protected:
103 
104  QVariantMap processAlgorithm( const QVariantMap &parameters,
105  QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
106 
107 };
108 
110 
111 #endif // QGSALGORITHMEXTRACTBYLOCATION_H
112 
113 
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:62
Abstract base class for processing algorithms.
Base class for feedback objects to be used for cancelation of something running in a worker thread...
Definition: qgsfeedback.h:44
#define SIP_FACTORY
Definition: qgis_sip.h:69
An interface for objects which provide features via a getFeatures method.
Contains information about the context in which a processing algorithm is executed.