18 #ifndef QGSPROCESSINGUTILS_H
19 #define QGSPROCESSINGUTILS_H
21 #include "qgis_core.h"
64 static QList< QgsRasterLayer * > compatibleRasterLayers(
QgsProject *project,
bool sort =
true );
81 static QList< QgsVectorLayer * > compatibleVectorLayers(
QgsProject *project,
82 const QList< int > &sourceTypes = QList< int >(),
98 static QList<QgsMeshLayer *> compatibleMeshLayers(
QgsProject *project,
bool sort =
true );
109 static QList< QgsMapLayer * > compatibleLayers(
QgsProject *project,
bool sort =
true );
117 static QString encodeProviderKeyAndUri(
const QString &providerKey,
const QString &uri );
130 static bool decodeProviderKeyAndUri(
const QString &
string, QString &providerKey
SIP_OUT, QString &uri
SIP_OUT );
185 static QString normalizeLayerSource( const QString &source );
193 static QString variantToPythonLiteral( const QVariant &value );
200 static QString stringToPythonLiteral( const QString &
string );
225 const QVariantMap &createOptions = QVariantMap(),
226 QgsFeatureSink::SinkFlags sinkFlags = QgsFeatureSink::SinkFlags(),
273 static QVariant generateIteratingDestination( const QVariant &input, const QVariant &
id,
QgsProcessingContext &context );
279 static QString tempFolder();
287 static QString generateTempFilename( const QString &basename );
314 static QString convertToCompatibleFormat( const
QgsVectorLayer *layer,
315 bool selectedFeaturesOnly,
316 const QString &baseName,
317 const QStringList &compatibleFormats,
318 const QString &preferredFormat,
355 static QString convertToCompatibleFormatAndLayerName( const
QgsVectorLayer *layer,
356 bool selectedFeaturesOnly,
357 const QString &baseName,
358 const QStringList &compatibleFormats,
359 const QString &preferredFormat,
362 QString &layerName
SIP_OUT,
long long featureLimit = -1 );
381 static QList<
int> fieldNamesToIndices( const QStringList &fieldNames, const
QgsFields &fields );
387 static
QgsFields indicesToFields( const QList<
int> &indices, const
QgsFields &fields );
399 static QString defaultVectorExtension();
411 static QString defaultRasterExtension();
418 const QList<
int > &sourceTypes = QList<
int >() );
452 Q_DECL_DEPRECATED static
QgsMapLayer *loadMapLayerFromString( const QString &
string, LayerHint typeHint = LayerHint::UnknownType )
SIP_DEPRECATED ;
454 static
void parseDestinationString( QString &destination, QString &providerKey, QString &uri, QString &layerName, QString &format, QMap<QString, QVariant> &options,
bool &useWriter, QString &extension );
456 friend class TestQgsProcessing;
475 FlagSkipGeometryValidityChecks = 1 << 1,
477 Q_DECLARE_FLAGS( Flags, Flag )
490 long long featureLimit = -1 );
507 long featureCount()
const override;
508 QString sourceName()
const override;
509 QSet<QVariant> uniqueValues(
int fieldIndex,
int limit = -1 )
const override;
510 QVariant minimumValue(
int fieldIndex )
const override;
511 QVariant maximumValue(
int fieldIndex )
const override;
514 SpatialIndexPresence hasSpatialIndex()
const override;
531 bool mOwnsSource = false;
533 std::function<
void( const
QgsFeature & ) > mInvalidGeometryCallback;
534 std::function<
void( const
QgsFeature & ) > mTransformErrorCallback;
536 std::function<
void( const
QgsFeature & ) > mInvalidGeometryCallbackSkip;
537 std::function<
void( const
QgsFeature & ) > mInvalidGeometryCallbackAbort;
539 long long mFeatureLimit = -1;
572 bool addFeature(
QgsFeature &feature, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() )
override;
580 bool mOwnsSink =
false;
585 #endif // QGSPROCESSINGUTILS_H