QGIS API Documentation 3.41.0-Master (45a0abf3bec)
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#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 protected:
56
58 long long mTargetFeatureCount = 0;
59 long long mIntersectFeatureCount = 0;
60
61 private:
62
63 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 );
64 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 );
65
66};
67
68
72class QgsSelectByLocationAlgorithm : public QgsLocationBasedAlgorithm
73{
74
75 public:
76
77 QgsSelectByLocationAlgorithm() = default;
78 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
79 QIcon icon() const override { return QgsApplication::getThemeIcon( QStringLiteral( "/algorithms/mAlgorithmSelectLocation.svg" ) ); }
80 QString svgIconPath() const override { return QgsApplication::iconPath( QStringLiteral( "/algorithms/mAlgorithmSelectLocation.svg" ) ); }
81 QString name() const override;
82 Qgis::ProcessingAlgorithmFlags flags() const override;
83 QString displayName() const override;
84 QStringList tags() const override;
85 QString group() const override;
86 QString groupId() const override;
87 QString shortHelpString() const override;
88 QgsSelectByLocationAlgorithm *createInstance() const override SIP_FACTORY;
89
90 protected:
91
92 QVariantMap processAlgorithm( const QVariantMap &parameters,
93 QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
94};
95
99class QgsExtractByLocationAlgorithm : public QgsLocationBasedAlgorithm
100{
101
102 public:
103
104 QgsExtractByLocationAlgorithm() = default;
105 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
106 QString name() const override;
107 QString displayName() const override;
108 QStringList tags() const override;
109 QString group() const override;
110 QString groupId() const override;
111 QString shortHelpString() const override;
112 QgsExtractByLocationAlgorithm *createInstance() const override SIP_FACTORY;
113
114 protected:
115
116 QVariantMap processAlgorithm( const QVariantMap &parameters,
117 QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
118 bool prepareAlgorithm( const QVariantMap &parameters,
119 QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
120
121};
122
124
125#endif // QGSALGORITHMEXTRACTBYLOCATION_H
126
127
QFlags< ProcessingAlgorithmFlag > ProcessingAlgorithmFlags
Flags indicating how and when an algorithm operates and should be exposed to users.
Definition qgis.h:3347
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.
This class 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:58
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