QGIS API Documentation  3.0.2-Girona (307d082)
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  QString name() const override;
67  Flags flags() const override;
68  QString displayName() const override;
69  QStringList tags() const override;
70  QString group() const override;
71  QString groupId() const override;
72  QString shortHelpString() const override;
73  QgsSelectByLocationAlgorithm *createInstance() const override SIP_FACTORY;
74 
75  protected:
76 
77  QVariantMap processAlgorithm( const QVariantMap &parameters,
78  QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
79 
80 };
81 
85 class QgsExtractByLocationAlgorithm : public QgsLocationBasedAlgorithm
86 {
87 
88  public:
89 
90  QgsExtractByLocationAlgorithm() = default;
91  void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
92  QString name() const override;
93  QString displayName() const override;
94  QStringList tags() const override;
95  QString group() const override;
96  QString groupId() const override;
97  QString shortHelpString() const override;
98  QgsExtractByLocationAlgorithm *createInstance() const override SIP_FACTORY;
99 
100  protected:
101 
102  QVariantMap processAlgorithm( const QVariantMap &parameters,
103  QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
104 
105 };
106 
108 
109 #endif // QGSALGORITHMEXTRACTBYLOCATION_H
110 
111 
Base class for providing feedback from a processing algorithm.
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.