QGIS API Documentation 3.99.0-Master (357b655ed83)
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"
24#include "qgsapplication.h"
26
27#include <QString>
28
29using namespace Qt::StringLiterals;
30
32
33
37class QgsLocationBasedAlgorithm : public QgsProcessingAlgorithm
38{
39 protected:
40 enum Predicate
41 {
42 Intersects,
43 Contains,
44 Disjoint,
45 IsEqual,
46 Touches,
47 Overlaps,
48 Within,
49 Crosses,
50 };
51
52 void addPredicateParameter();
53 Predicate reversePredicate( Predicate predicate ) const;
54 QStringList predicateOptionsList() const;
55 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() );
56
57 protected:
59 long long mTargetFeatureCount = 0;
60 long long mIntersectFeatureCount = 0;
61
62 private:
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
71class QgsSelectByLocationAlgorithm : public QgsLocationBasedAlgorithm
72{
73 public:
74 QgsSelectByLocationAlgorithm() = default;
75 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
76 QIcon icon() const override { return QgsApplication::getThemeIcon( u"/algorithms/mAlgorithmSelectLocation.svg"_s ); }
77 QString svgIconPath() const override { return QgsApplication::iconPath( u"/algorithms/mAlgorithmSelectLocation.svg"_s ); }
78 QString name() const override;
79 Qgis::ProcessingAlgorithmFlags flags() const override;
80 QString displayName() const override;
81 QStringList tags() const override;
82 QString group() const override;
83 QString groupId() const override;
84 QString shortHelpString() const override;
85 QString shortDescription() const override;
86 QgsSelectByLocationAlgorithm *createInstance() const override SIP_FACTORY;
87
88 protected:
89 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
90};
91
95class QgsExtractByLocationAlgorithm : public QgsLocationBasedAlgorithm
96{
97 public:
98 QgsExtractByLocationAlgorithm() = default;
99 void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
100 QString name() const override;
101 QString displayName() const override;
102 QStringList tags() const override;
103 QString group() const override;
104 QString groupId() const override;
105 QString shortHelpString() const override;
106 QString shortDescription() const override;
107 QgsExtractByLocationAlgorithm *createInstance() const override SIP_FACTORY;
108
109 protected:
110 QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
111 bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
112};
113
115
116#endif // QGSALGORITHMEXTRACTBYLOCATION_H
QFlags< ProcessingAlgorithmFlag > ProcessingAlgorithmFlags
Flags indicating how and when an algorithm operates and should be exposed to users.
Definition qgis.h:3680
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:84
QSet< QgsFeatureId > QgsFeatureIds