QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
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
22#include "qgis_sip.h"
23#include "qgsapplication.h"
25
26#include <QString>
27
28#define SIP_NO_FILE
29
30using namespace Qt::StringLiterals;
31
33
34
38class QgsLocationBasedAlgorithm : public QgsProcessingAlgorithm
39{
40 protected:
41 enum Predicate
42 {
43 Intersects,
44 Contains,
45 Disjoint,
46 IsEqual,
47 Touches,
48 Overlaps,
49 Within,
50 Crosses,
51 };
52
53 void addPredicateParameter();
54 Predicate reversePredicate( Predicate predicate ) const;
55 QStringList predicateOptionsList() const;
56 void process(
57 const QgsProcessingContext &context,
58 QgsFeatureSource *targetSource,
59 QgsFeatureSource *intersectSource,
60 const QList<int> &selectedPredicates,
61 const std::function<void( const QgsFeature & )> &handleFeatureFunction,
62 bool onlyRequireTargetIds,
63 QgsProcessingFeedback *feedback,
64 const QgsFeatureIds &skipTargetFeatureIds = QgsFeatureIds()
65 );
66
67 protected:
69 long long mTargetFeatureCount = 0;
70 long long mIntersectFeatureCount = 0;
71
72 private:
73 void processByIteratingOverTargetSource(
74 const QgsProcessingContext &context,
75 QgsFeatureSource *targetSource,
76 QgsFeatureSource *intersectSource,
77 const QList<int> &selectedPredicates,
78 const std::function<void( const QgsFeature & )> &handleFeatureFunction,
79 bool onlyRequireTargetIds,
80 QgsProcessingFeedback *feedback,
81 const QgsFeatureIds &skipTargetFeatureIds
82 );
83 void processByIteratingOverIntersectSource(
84 const QgsProcessingContext &context,
85 QgsFeatureSource *targetSource,
86 QgsFeatureSource *intersectSource,
87 const QList<int> &selectedPredicates,
88 const std::function<void( const QgsFeature & )> &handleFeatureFunction,
89 bool onlyRequireTargetIds,
90 QgsProcessingFeedback *feedback,
91 const QgsFeatureIds &skipTargetFeatureIds
92 );
93};
94
95
99class QgsSelectByLocationAlgorithm : public QgsLocationBasedAlgorithm
100{
101 public:
102 QgsSelectByLocationAlgorithm() = default;
103 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
104 QIcon icon() const override { return QgsApplication::getThemeIcon( u"/algorithms/mAlgorithmSelectLocation.svg"_s ); }
105 QString svgIconPath() const override { return QgsApplication::iconPath( u"/algorithms/mAlgorithmSelectLocation.svg"_s ); }
106 QString name() const override;
107 Qgis::ProcessingAlgorithmFlags flags() const override;
108 QString displayName() const override;
109 QStringList tags() const override;
110 QString group() const override;
111 QString groupId() const override;
112 QString shortHelpString() const override;
113 QString shortDescription() const override;
114 QgsSelectByLocationAlgorithm *createInstance() const override SIP_FACTORY;
115
116 protected:
117 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
118};
119
123class QgsExtractByLocationAlgorithm : public QgsLocationBasedAlgorithm
124{
125 public:
126 QgsExtractByLocationAlgorithm() = default;
127 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
128 QString name() const override;
129 QString displayName() const override;
130 QStringList tags() const override;
131 QString group() const override;
132 QString groupId() const override;
133 QString shortHelpString() const override;
134 QString shortDescription() const override;
135 QgsExtractByLocationAlgorithm *createInstance() const override SIP_FACTORY;
136
137 protected:
138 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
139 bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
140};
141
143
144#endif // QGSALGORITHMEXTRACTBYLOCATION_H
QFlags< ProcessingAlgorithmFlag > ProcessingAlgorithmFlags
Flags indicating how and when an algorithm operates and should be exposed to users.
Definition qgis.h:3724
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.
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:60
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:83
QSet< QgsFeatureId > QgsFeatureIds