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