40 #include <QRegularExpression>
45 return compatibleMapLayers< QgsRasterLayer >( project, sort );
51 return QList<QgsVectorLayer *>();
53 QList<QgsVectorLayer *> layers;
57 if ( canUseLayer( l, geometryTypes ) )
65 return QString::localeAwareCompare( a->name(), b->name() ) < 0;
73 return compatibleMapLayers< QgsMeshLayer >( project, sort );
78 return compatibleMapLayers< QgsPluginLayer >( project, sort );
83 return compatibleMapLayers< QgsPointCloudLayer >( project, sort );
89 QList<QgsAnnotationLayer *> res = compatibleMapLayers< QgsAnnotationLayer >( project,
false );
97 return QString::localeAwareCompare( a->name(), b->name() ) < 0;
104 template<
typename T> QList<T *> QgsProcessingUtils::compatibleMapLayers(
QgsProject *project,
bool sort )
110 const auto projectLayers = project->
layers<T *>();
111 for ( T *l : projectLayers )
113 if ( canUseLayer( l ) )
119 std::sort( layers.begin(), layers.end(), [](
const T * a,
const T * b ) ->
bool
121 return QString::localeAwareCompare( a->name(), b->name() ) < 0;
130 return QList<QgsMapLayer *>();
132 QList<QgsMapLayer *> layers;
134 const auto rasterLayers = compatibleMapLayers< QgsRasterLayer >( project,
false );
142 const auto meshLayers = compatibleMapLayers< QgsMeshLayer >( project,
false );
146 const auto pointCloudLayers = compatibleMapLayers< QgsPointCloudLayer >( project,
false );
150 const auto annotationLayers = compatibleMapLayers< QgsAnnotationLayer >( project,
false );
155 const auto pluginLayers = compatibleMapLayers< QgsPluginLayer >( project,
false );
163 return QString::localeAwareCompare( a->name(), b->name() ) < 0;
171 return QStringLiteral(
"%1://%2" ).arg( providerKey, uri );
176 QRegularExpression re( QStringLiteral(
"^(\\w+?):\\/\\/(.+)$" ) );
177 const QRegularExpressionMatch match = re.match(
string );
178 if ( !match.hasMatch() )
181 providerKey = match.captured( 1 );
182 uri = match.captured( 2 );
190 if ( !store ||
string.isEmpty() )
193 QList< QgsMapLayer * > layers = store->
mapLayers().values();
195 layers.erase( std::remove_if( layers.begin(), layers.end(), [](
QgsMapLayer * layer )
197 switch ( layer->type() )
199 case QgsMapLayerType::VectorLayer:
200 return !canUseLayer( qobject_cast< QgsVectorLayer * >( layer ) );
201 case QgsMapLayerType::RasterLayer:
202 return !canUseLayer( qobject_cast< QgsRasterLayer * >( layer ) );
203 case QgsMapLayerType::PluginLayer:
205 case QgsMapLayerType::MeshLayer:
206 return !canUseLayer( qobject_cast< QgsMeshLayer * >( layer ) );
207 case QgsMapLayerType::VectorTileLayer:
208 return !canUseLayer( qobject_cast< QgsVectorTileLayer * >( layer ) );
209 case QgsMapLayerType::PointCloudLayer:
210 return !canUseLayer( qobject_cast< QgsPointCloudLayer * >( layer ) );
211 case QgsMapLayerType::AnnotationLayer:
212 return !canUseLayer( qobject_cast< QgsAnnotationLayer * >( layer ) );
217 auto isCompatibleType = [typeHint](
QgsMapLayer * l ) ->
bool
221 case LayerHint::UnknownType:
224 case LayerHint::Vector:
227 case LayerHint::Raster:
230 case LayerHint::Mesh:
233 case LayerHint::PointCloud:
236 case LayerHint::Annotation:
244 if ( isCompatibleType( l ) && l->id() == string )
249 if ( isCompatibleType( l ) && l->name() == string )
254 if ( isCompatibleType( l ) && normalizeLayerSource( l->source() ) == normalizeLayerSource(
string ) )
270 if ( !useProvider || ( provider == QLatin1String(
"ogr" ) || provider == QLatin1String(
"gdal" ) || provider == QLatin1String(
"mdal" ) || provider == QLatin1String(
"pdal" ) || provider == QLatin1String(
"ept" ) ) )
272 QStringList components = uri.split(
'|' );
273 if ( components.isEmpty() )
277 if ( QFileInfo::exists( uri ) )
278 fi = QFileInfo( uri );
279 else if ( QFileInfo::exists( components.at( 0 ) ) )
280 fi = QFileInfo( components.at( 0 ) );
283 name = fi.baseName();
294 options.loadDefaultStyle =
false;
295 options.skipCrsValidation =
true;
297 std::unique_ptr< QgsVectorLayer > layer;
300 layer = std::make_unique<QgsVectorLayer>( uri, name, provider, options );
305 layer = std::make_unique<QgsVectorLayer>( uri, name, QStringLiteral(
"ogr" ), options );
307 if ( layer->isValid() )
309 return layer.release();
318 std::unique_ptr< QgsRasterLayer > rasterLayer;
321 rasterLayer = std::make_unique< QgsRasterLayer >( uri, name, provider, rasterOptions );
326 rasterLayer = std::make_unique< QgsRasterLayer >( uri, name, QStringLiteral(
"gdal" ), rasterOptions );
329 if ( rasterLayer->isValid() )
331 return rasterLayer.release();
339 std::unique_ptr< QgsMeshLayer > meshLayer;
342 meshLayer = std::make_unique< QgsMeshLayer >( uri, name, provider, meshOptions );
346 meshLayer = std::make_unique< QgsMeshLayer >( uri, name, QStringLiteral(
"mdal" ), meshOptions );
348 if ( meshLayer->isValid() )
350 return meshLayer.release();
358 std::unique_ptr< QgsPointCloudLayer > pointCloudLayer;
361 pointCloudLayer = std::make_unique< QgsPointCloudLayer >( uri, name, provider, pointCloudOptions );
365 pointCloudLayer = std::make_unique< QgsPointCloudLayer >( uri, name, QStringLiteral(
"pointcloud" ), pointCloudOptions );
367 if ( pointCloudLayer->isValid() )
369 return pointCloudLayer.release();
377 if (
string.isEmpty() )
385 if (
auto *lProject = context.
project() )
387 QgsMapLayer *layer = mapLayerFromStore(
string, lProject->layerStore(), typeHint );
396 if ( !allowLoadingNewLayers )
399 layer = loadMapLayerFromString(
string, context.
transformContext(), typeHint );
413 QVariant val = value;
414 bool selectedFeaturesOnly =
false;
415 long long featureLimit = -1;
416 bool overrideGeometryCheck =
false;
425 overrideGeometryCheck = fromVar.
flags & QgsProcessingFeatureSourceDefinition::Flag::FlagOverrideDefaultGeometryCheck;
435 if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( val ) ) )
437 std::unique_ptr< QgsProcessingFeatureSource> source = std::make_unique< QgsProcessingFeatureSource >( layer, context,
false, featureLimit );
438 if ( overrideGeometryCheck )
439 source->setInvalidGeometryCheck( geometryCheck );
440 return source.release();
448 else if ( !val.isValid() || val.toString().isEmpty() )
451 if (
QgsVectorLayer *layer = qobject_cast< QgsVectorLayer * >( qvariant_cast<QObject *>( fallbackValue ) ) )
453 std::unique_ptr< QgsProcessingFeatureSource> source = std::make_unique< QgsProcessingFeatureSource >( layer, context,
false, featureLimit );
454 if ( overrideGeometryCheck )
455 source->setInvalidGeometryCheck( geometryCheck );
456 return source.release();
459 layerRef = fallbackValue.toString();
463 layerRef = val.toString();
466 if ( layerRef.isEmpty() )
473 std::unique_ptr< QgsProcessingFeatureSource> source;
474 if ( selectedFeaturesOnly )
480 source = std::make_unique< QgsProcessingFeatureSource >( vl, context,
false, featureLimit );
483 if ( overrideGeometryCheck )
484 source->setInvalidGeometryCheck( geometryCheck );
485 return source.release();
490 QVariant val = value;
516 if (
QgsMapLayer *layer = qobject_cast< QgsMapLayer * >( qvariant_cast<QObject *>( val ) ) )
522 if ( !val.isValid() )
528 QString crsText = val.toString();
529 if ( crsText.isEmpty() )
530 crsText = fallbackValue.toString();
532 if ( crsText.isEmpty() )
536 if ( context.
project() && crsText.compare( QLatin1String(
"ProjectCrs" ), Qt::CaseInsensitive ) == 0 )
549 bool QgsProcessingUtils::canUseLayer(
const QgsMeshLayer *layer )
554 bool QgsProcessingUtils::canUseLayer(
const QgsPluginLayer *layer )
556 return layer && layer->
isValid();
561 return layer && layer->
isValid();
564 bool QgsProcessingUtils::canUseLayer(
const QgsRasterLayer *layer )
566 return layer && layer->
isValid();
571 return layer && layer->
isValid();
576 return layer && layer->
isValid();
579 bool QgsProcessingUtils::canUseLayer(
const QgsVectorLayer *layer,
const QList<int> &sourceTypes )
581 return layer && layer->
isValid() &&
582 ( sourceTypes.isEmpty()
593 QString normalized = source;
594 normalized.replace(
'\\',
'/' );
595 return normalized.trimmed();
600 if ( !value.isValid() )
601 return QStringLiteral(
"None" );
604 return QStringLiteral(
"QgsProperty.fromExpression('%1')" ).arg( value.value<
QgsProperty >().
asExpression() );
608 return QStringLiteral(
"QgsCoordinateReferenceSystem()" );
642 switch ( value.type() )
645 return value.toBool() ? QStringLiteral(
"True" ) : QStringLiteral(
"False" );
647 case QVariant::Double:
648 return QString::number( value.toDouble() );
652 return QString::number( value.toInt() );
654 case QVariant::LongLong:
655 case QVariant::ULongLong:
656 return QString::number( value.toLongLong() );
661 const QVariantList vl = value.toList();
662 for (
const QVariant &v : vl )
666 return parts.join(
',' ).prepend(
'[' ).append(
']' );
671 const QVariantMap map = value.toMap();
673 parts.reserve( map.size() );
674 for (
auto it = map.constBegin(); it != map.constEnd(); ++it )
678 return parts.join(
',' ).prepend(
'{' ).append(
'}' );
681 case QVariant::DateTime:
683 const QDateTime dateTime = value.toDateTime();
684 return QStringLiteral(
"QDateTime(QDate(%1, %2, %3), QTime(%4, %5, %6))" )
685 .arg( dateTime.date().year() )
686 .arg( dateTime.date().month() )
687 .arg( dateTime.date().day() )
688 .arg( dateTime.time().hour() )
689 .arg( dateTime.time().minute() )
690 .arg( dateTime.time().second() );
703 s.replace(
'\\', QLatin1String(
"\\\\" ) );
704 s.replace(
'\n', QLatin1String(
"\\n" ) );
705 s.replace(
'\r', QLatin1String(
"\\r" ) );
706 s.replace(
'\t', QLatin1String(
"\\t" ) );
708 if ( s.contains(
'\'' ) && !s.contains(
'\"' ) )
710 s = s.prepend(
'"' ).append(
'"' );
714 s.replace(
'\'', QLatin1String(
"\\\'" ) );
715 s = s.prepend(
'\'' ).append(
'\'' );
720 void QgsProcessingUtils::parseDestinationString( QString &destination, QString &providerKey, QString &uri, QString &layerName, QString &format, QMap<QString, QVariant> &options,
bool &useWriter, QString &extension )
727 QRegularExpression splitRx( QStringLiteral(
"^(.{3,}?):(.*)$" ) );
728 QRegularExpressionMatch match = splitRx.match( destination );
729 if ( match.hasMatch() )
731 providerKey = match.captured( 1 );
732 uri = match.captured( 2 );
739 if ( providerKey == QLatin1String(
"postgis" ) )
741 providerKey = QStringLiteral(
"postgres" );
743 if ( providerKey == QLatin1String(
"ogr" ) )
746 if ( !dsUri.database().isEmpty() )
748 if ( !dsUri.table().isEmpty() )
750 layerName = dsUri.table();
751 options.insert( QStringLiteral(
"layerName" ), layerName );
753 uri = dsUri.database();
754 extension = QFileInfo( uri ).completeSuffix();
756 options.insert( QStringLiteral(
"driverName" ), format );
760 extension = QFileInfo( uri ).completeSuffix();
763 options.insert( QStringLiteral(
"update" ),
true );
770 providerKey = QStringLiteral(
"ogr" );
772 QRegularExpression splitRx( QStringLiteral(
"^(.*)\\.(.*?)$" ) );
773 QRegularExpressionMatch match = splitRx.match( destination );
774 if ( match.hasMatch() )
776 extension = match.captured( 2 );
780 if ( format.isEmpty() )
782 format = QStringLiteral(
"GPKG" );
783 destination = destination + QStringLiteral(
".gpkg" );
786 options.insert( QStringLiteral(
"driverName" ), format );
793 QVariantMap options = createOptions;
794 if ( !options.contains( QStringLiteral(
"fileEncoding" ) ) )
800 if ( destination.isEmpty() || destination.startsWith( QLatin1String(
"memory:" ) ) )
803 if ( destination.startsWith( QLatin1String(
"memory:" ) ) )
804 destination = destination.mid( 7 );
806 if ( destination.isEmpty() )
807 destination = QStringLiteral(
"output" );
811 if ( !layer || !layer->isValid() )
819 destination = layer->id();
822 std::unique_ptr< QgsProcessingFeatureSink > sink(
new QgsProcessingFeatureSink( layer->dataProvider(), destination, context ) );
825 return sink.release();
834 bool useWriter =
false;
835 parseDestinationString( destination, providerKey, uri, layerName, format, options, useWriter, extension );
838 if ( useWriter && providerKey == QLatin1String(
"ogr" ) )
842 QString finalFileName;
843 QString finalLayerName;
845 saveOptions.
fileEncoding = options.value( QStringLiteral(
"fileEncoding" ) ).toString();
846 saveOptions.
layerName = !layerName.isEmpty() ? layerName : options.value( QStringLiteral(
"layerName" ) ).toString();
851 if ( remappingDefinition )
855 std::unique_ptr< QgsVectorLayer > vl = std::make_unique< QgsVectorLayer >( destination );
860 newFields = vl->fields();
870 if ( writer->hasError() )
872 throw QgsProcessingException( QObject::tr(
"Could not create layer %1: %2" ).arg( destination, writer->errorMessage() ) );
874 destination = finalFileName;
875 if ( !saveOptions.
layerName.isEmpty() && !finalLayerName.isEmpty() )
876 destination += QStringLiteral(
"|layername=%1" ).arg( finalLayerName );
878 if ( remappingDefinition )
880 std::unique_ptr< QgsRemappingProxyFeatureSink > remapSink = std::make_unique< QgsRemappingProxyFeatureSink >( *remappingDefinition, writer.release(),
true );
891 if ( remappingDefinition )
896 if ( !layerName.isEmpty() )
899 parts.insert( QStringLiteral(
"layerName" ), layerName );
903 std::unique_ptr< QgsVectorLayer > layer = std::make_unique<QgsVectorLayer>( uri, destination, providerKey, layerOptions );
905 destination = layer->id();
906 if ( layer->isValid() )
913 std::unique_ptr< QgsRemappingProxyFeatureSink > remapSink = std::make_unique< QgsRemappingProxyFeatureSink >( *remappingDefinition, layer->dataProvider(),
false );
923 std::unique_ptr< QgsVectorLayerExporter > exporter = std::make_unique<QgsVectorLayerExporter>( uri, providerKey, newFields, geometryType,
crs,
true, options, sinkFlags );
924 if ( exporter->errorCode() != Qgis::VectorExportResult::Success )
926 throw QgsProcessingException( QObject::tr(
"Could not create layer %1: %2" ).arg( destination, exporter->errorMessage() ) );
930 if ( !layerName.isEmpty() )
932 uri += QStringLiteral(
"|layername=%1" ).arg( layerName );
991 if ( !input.isValid() )
992 return QStringLiteral(
"memory:%1" ).arg(
id.toString() );
1008 QString res = input.toString();
1014 else if ( res.startsWith( QLatin1String(
"memory:" ) ) )
1016 return QString( res +
'_' +
id.toString() );
1022 int lastIndex = res.lastIndexOf(
'.' );
1023 return QString( res.left( lastIndex ) +
'_' +
id.toString() + res.mid( lastIndex ) );
1034 static std::vector< std::unique_ptr< QTemporaryDir > > sTempFolders;
1035 static QString sFolder;
1036 static QMutex sMutex;
1037 QMutexLocker locker( &sMutex );
1039 if ( basePath.isEmpty() )
1042 if ( sTempFolders.empty() )
1044 const QString templatePath = QStringLiteral(
"%1/processing_XXXXXX" ).arg( QDir::tempPath() );
1045 std::unique_ptr< QTemporaryDir >
tempFolder = std::make_unique< QTemporaryDir >( templatePath );
1047 sTempFolders.emplace_back( std::move(
tempFolder ) );
1050 else if ( sFolder.isEmpty() || !sFolder.startsWith( basePath ) || sTempFolders.empty() )
1052 if ( !QDir().exists( basePath ) )
1053 QDir().mkpath( basePath );
1055 const QString templatePath = QStringLiteral(
"%1/processing_XXXXXX" ).arg( basePath );
1056 std::unique_ptr< QTemporaryDir >
tempFolder = std::make_unique< QTemporaryDir >( templatePath );
1058 sTempFolders.emplace_back( std::move(
tempFolder ) );
1065 QString subPath = QUuid::createUuid().toString().remove(
'-' ).remove(
'{' ).remove(
'}' );
1067 if ( !QDir( path ).exists() )
1070 tmpDir.mkdir( path );
1077 auto getText = [map](
const QString & key )->QString
1079 if ( map.contains( key ) )
1080 return map.value( key ).toString();
1085 s += QStringLiteral(
"<html><body><p>" ) + getText( QStringLiteral(
"ALG_DESC" ) ) + QStringLiteral(
"</p>\n" );
1094 if ( !getText( def->name() ).isEmpty() )
1096 inputs += QStringLiteral(
"<h3>" ) + def->description() + QStringLiteral(
"</h3>\n" );
1097 inputs += QStringLiteral(
"<p>" ) + getText( def->name() ) + QStringLiteral(
"</p>\n" );
1100 if ( !inputs.isEmpty() )
1101 s += QStringLiteral(
"<h2>" ) + QObject::tr(
"Input parameters" ) + QStringLiteral(
"</h2>\n" ) + inputs;
1107 if ( !getText( def->name() ).isEmpty() )
1109 outputs += QStringLiteral(
"<h3>" ) + def->description() + QStringLiteral(
"</h3>\n" );
1110 outputs += QStringLiteral(
"<p>" ) + getText( def->name() ) + QStringLiteral(
"</p>\n" );
1113 if ( !outputs.isEmpty() )
1114 s += QStringLiteral(
"<h2>" ) + QObject::tr(
"Outputs" ) + QStringLiteral(
"</h2>\n" ) + outputs;
1116 s += QLatin1String(
"<br>" );
1117 if ( !map.value( QStringLiteral(
"ALG_CREATOR" ) ).toString().isEmpty() )
1118 s += QStringLiteral(
"<p align=\"right\">" ) + QObject::tr(
"Algorithm author:" ) + QStringLiteral(
" " ) + getText( QStringLiteral(
"ALG_CREATOR" ) ) + QStringLiteral(
"</p>" );
1119 if ( !map.value( QStringLiteral(
"ALG_HELP_CREATOR" ) ).toString().isEmpty() )
1120 s += QStringLiteral(
"<p align=\"right\">" ) + QObject::tr(
"Help author:" ) + QStringLiteral(
" " ) + getText( QStringLiteral(
"ALG_HELP_CREATOR" ) ) + QStringLiteral(
"</p>" );
1121 if ( !map.value( QStringLiteral(
"ALG_VERSION" ) ).toString().isEmpty() )
1122 s += QStringLiteral(
"<p align=\"right\">" ) + QObject::tr(
"Algorithm version:" ) + QStringLiteral(
" " ) + getText( QStringLiteral(
"ALG_VERSION" ) ) + QStringLiteral(
"</p>" );
1124 s += QLatin1String(
"</body></html>" );
1129 long long featureLimit )
1131 bool requiresTranslation =
false;
1135 requiresTranslation = requiresTranslation || selectedFeaturesOnly;
1138 requiresTranslation = requiresTranslation || featureLimit != -1;
1143 requiresTranslation = requiresTranslation || vl->
providerType() != QLatin1String(
"ogr" );
1147 requiresTranslation = requiresTranslation || !vl->
subsetString().isEmpty();
1151 requiresTranslation = requiresTranslation || vl->
source().startsWith( QLatin1String(
"/vsi" ) );
1155 if ( !requiresTranslation )
1158 if ( parts.contains( QStringLiteral(
"path" ) ) )
1160 diskPath = parts.value( QStringLiteral(
"path" ) ).toString();
1161 QFileInfo fi( diskPath );
1162 requiresTranslation = !compatibleFormats.contains( fi.suffix(), Qt::CaseInsensitive );
1166 const QString srcLayerName = parts.value( QStringLiteral(
"layerName" ) ).toString();
1170 *layerName = srcLayerName;
1175 requiresTranslation = requiresTranslation || ( !srcLayerName.isEmpty() && srcLayerName != fi.baseName() );
1180 requiresTranslation =
true;
1184 if ( requiresTranslation )
1194 if ( featureLimit != -1 )
1196 if ( selectedFeaturesOnly )
1203 if ( selectedFeaturesOnly )
1231 return convertToCompatibleFormatInternal( layer, selectedFeaturesOnly, baseName, compatibleFormats, preferredFormat, context, feedback, &layerName, featureLimit );
1237 QSet< QString > usedNames;
1238 for (
const QgsField &f : fieldsA )
1240 usedNames.insert( f.name().toLower() );
1243 for (
const QgsField &f : fieldsB )
1246 newField.
setName( fieldsBPrefix + f.name() );
1247 if ( usedNames.contains( newField.
name().toLower() ) )
1250 QString newName = newField.
name() +
'_' + QString::number( idx );
1251 while ( usedNames.contains( newName.toLower() ) )
1254 newName = newField.
name() +
'_' + QString::number( idx );
1257 outFields.
append( newField );
1261 outFields.
append( newField );
1263 usedNames.insert( newField.
name() );
1273 if ( !fieldNames.isEmpty() )
1275 indices.reserve( fieldNames.count() );
1276 for (
const QString &f : fieldNames )
1280 indices.append( idx );
1285 indices.reserve( fields.
count() );
1286 for (
int i = 0; i < fields.
count(); ++i )
1287 indices.append( i );
1296 for (
int i : indices )
1297 fieldsSubset.
append( fields.
at( i ) );
1298 return fieldsSubset;
1304 if ( setting == -1 )
1305 return QStringLiteral(
"gpkg" );
1312 if ( setting == -1 )
1313 return QStringLiteral(
"tif" );
1322 : mSource( originalSource )
1323 , mOwnsSource( ownsOriginalSource )
1326 : context.invalidGeometryCheck() )
1327 , mInvalidGeometryCallback( context.invalidGeometryCallback( originalSource ) )
1328 , mTransformErrorCallback( context.transformErrorCallback() )
1329 , mInvalidGeometryCallbackSkip( context.defaultInvalidGeometryCallbackForCheck(
QgsFeatureRequest::GeometrySkipInvalid, originalSource ) )
1330 , mInvalidGeometryCallbackAbort( context.defaultInvalidGeometryCallbackForCheck(
QgsFeatureRequest::GeometryAbortOnInvalid, originalSource ) )
1331 , mFeatureLimit( featureLimit )
1353 if ( mFeatureLimit != -1 && req.
limit() != -1 )
1354 req.
setLimit( std::min(
static_cast< long long >( req.
limit() ), mFeatureLimit ) );
1355 else if ( mFeatureLimit != -1 )
1367 return sourceAvailability;
1380 if ( mFeatureLimit != -1 && req.
limit() != -1 )
1381 req.
setLimit( std::min(
static_cast< long long >( req.
limit() ), mFeatureLimit ) );
1382 else if ( mFeatureLimit != -1 )
1395 return mSource->
fields();
1405 if ( mFeatureLimit == -1 )
1408 return std::min( mFeatureLimit, mSource->
featureCount() );
1455 return expressionContextScope;
1460 mInvalidGeometryCheck = method;
1461 switch ( mInvalidGeometryCheck )
1464 mInvalidGeometryCallback =
nullptr;
1468 mInvalidGeometryCallback = mInvalidGeometryCallbackSkip;
1472 mInvalidGeometryCallback = mInvalidGeometryCallbackAbort;
1484 , mContext( context )
1485 , mSinkName( sinkName )
1486 , mOwnsSink( ownsOriginalSink )
1498 if ( !result && mContext.
feedback() )
1501 if ( !error.isEmpty() )
1502 mContext.
feedback()->
reportError( QObject::tr(
"Feature could not be written to %1: %2" ).arg( mSinkName, error ) );
1504 mContext.
feedback()->
reportError( QObject::tr(
"Feature could not be written to %1" ).arg( mSinkName ) );
1512 if ( !result && mContext.
feedback() )
1515 if ( !error.isEmpty() )
1516 mContext.
feedback()->
reportError( QObject::tr(
"%1 feature(s) could not be written to %2: %3" ).arg( features.count() ).arg( mSinkName, error ) );
1518 mContext.
feedback()->
reportError( QObject::tr(
"%1 feature(s) could not be written to %2" ).arg( features.count() ).arg( mSinkName ) );
1526 if ( !result && mContext.
feedback() )
1529 if ( !error.isEmpty() )
1530 mContext.
feedback()->
reportError( QObject::tr(
"Features could not be written to %1: %2" ).arg( mSinkName, error ) );
1532 mContext.
feedback()->
reportError( QObject::tr(
"Features could not be written to %1" ).arg( mSinkName ) );
Represents a map layer containing a set of georeferenced annotations, e.g.
This class represents a coordinate reference system (CRS).
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
bool createFromString(const QString &definition)
Set up this CRS from a string definition.
QString authid() const
Returns the authority identifier for the CRS.
Contains information about the context in which a coordinate transform is executed.
Custom exception class for Coordinate Reference System related exceptions.
Class for storing the component parts of a RDBMS data source URI (e.g.
QString table() const
Returns the table name stored in the URI.
Abstract interface for generating an expression context scope.
virtual QgsExpressionContextScope * createExpressionContextScope() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Single scope for storing variables and functions for use within a QgsExpressionContext.
void setFields(const QgsFields &fields)
Convenience function for setting a fields for the context.
Wrapper for iterator of features from vector data provider or vector layer.
bool nextFeature(QgsFeature &f)
This class wraps a request for features to a vector layer (or directly its vector data provider).
QgsFeatureRequest & setLimit(long long limit)
Set the maximum number of features to request.
InvalidGeometryCheck
Handling of features with invalid geometries.
@ GeometryNoCheck
No invalid geometry checking.
@ GeometryAbortOnInvalid
Close iterator on encountering any features with invalid geometry. This requires a slow geometry vali...
@ GeometrySkipInvalid
Skip any features with invalid geometry. This requires a slow geometry validity check for every featu...
long long limit() const
Returns the maximum number of features to request, or -1 if no limit set.
QgsFeatureRequest & setInvalidGeometryCallback(const std::function< void(const QgsFeature &)> &callback)
Sets a callback function to use when encountering an invalid geometry and invalidGeometryCheck() is s...
QgsFeatureRequest & setInvalidGeometryCheck(InvalidGeometryCheck check)
Sets invalid geometry checking behavior.
QgsFeatureRequest & setTransformErrorCallback(const std::function< void(const QgsFeature &)> &callback)
Sets a callback function to use when encountering a transform error when iterating features and a des...
An interface for objects which accept features via addFeature(s) methods.
@ FastInsert
Use faster inserts, at the cost of updating the passed features to reflect changes made at the provid...
@ RegeneratePrimaryKey
This flag indicates, that a primary key field cannot be guaranteed to be unique and the sink should i...
An interface for objects which provide features via a getFeatures method.
virtual QgsFields fields() const =0
Returns the fields associated with features in the source.
virtual QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const
Returns the set of unique values contained within the specified fieldIndex from this source.
virtual QgsCoordinateReferenceSystem sourceCrs() const =0
Returns the coordinate reference system for features in the source.
SpatialIndexPresence
Enumeration of spatial index presence states.
virtual QgsWkbTypes::Type wkbType() const =0
Returns the geometry type for features returned by this source.
virtual FeatureAvailability hasFeatures() const
Determines if there are any features available in the source.
FeatureAvailability
Possible return value for hasFeatures() to determine if a source is empty.
@ FeaturesMaybeAvailable
There may be features available in this source.
@ NoFeaturesAvailable
There are certainly no features available in this source.
virtual QVariant minimumValue(int fieldIndex) const
Returns the minimum value for an attribute column or an invalid variant in case of error.
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const =0
Returns an iterator for the features in the source.
virtual QString sourceName() const =0
Returns a friendly display name for the source.
virtual QVariant maximumValue(int fieldIndex) const
Returns the maximum value for an attribute column or an invalid variant in case of error.
virtual long long featureCount() const =0
Returns the number of features contained in the source, or -1 if the feature count is unknown.
virtual QgsFeatureIds allFeatureIds() const
Returns a list of all feature IDs for features present in the source.
virtual SpatialIndexPresence hasSpatialIndex() const
Returns an enum value representing the presence of a valid spatial index on the source,...
virtual QgsRectangle sourceExtent() const
Returns the extent of all geometries from the source.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
bool isCanceled() const SIP_HOLDGIL
Tells whether the operation has been canceled already.
Encapsulate a field in an attribute table or data source.
void setName(const QString &name)
Set the field name.
Container of fields for a vector layer.
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Appends a field. The field must have unique name, otherwise it is rejected (returns false)
int count() const
Returns number of items.
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
static QString stringToSafeFilename(const QString &string)
Converts a string to a safe filename, replacing characters which are not safe for filenames with an '...
A storage object for map layers, in which the layers are owned by the store and have their lifetime b...
QMap< QString, QgsMapLayer * > mapLayers() const
Returns a map of all layers by layer ID.
QgsMapLayer * addMapLayer(QgsMapLayer *layer, bool takeOwnership=true)
Add a layer to the store.
Base class for all map layer types.
QString source() const
Returns the source for the layer.
QString providerType() const
Returns the provider type (provider key) for this layer.
QgsCoordinateReferenceSystem crs
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext)=0
Sets the coordinate transform context to transformContext.
static QgsVectorLayer * createMemoryLayer(const QString &name, const QgsFields &fields, QgsWkbTypes::Type geometryType=QgsWkbTypes::NoGeometry, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem()) SIP_FACTORY
Creates a new memory layer using the specified parameters.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
QgsMeshDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
Base class for plugin layers.
Represents a map layer supporting display of point clouds.
A class to represent a 2D point.
Abstract base class for processing algorithms.
QgsProcessingOutputDefinitions outputDefinitions() const
Returns an ordered list of output definitions utilized by the algorithm.
QgsProcessingParameterDefinitions parameterDefinitions() const
Returns an ordered list of parameter definitions utilized by the algorithm.
Contains information about the context in which a processing algorithm is executed.
QString defaultEncoding() const
Returns the default encoding to use for newly created files.
QgsMapLayerStore * temporaryLayerStore()
Returns a reference to the layer store used for storing temporary layers during algorithm execution.
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context.
QgsExpressionContext & expressionContext()
Returns the expression context.
QgsProject * project() const
Returns the project in which the algorithm is being executed.
QgsProcessingFeedback * feedback()
Returns the associated feedback object.
Custom exception class for processing related exceptions.
QgsProxyFeatureSink subclass which reports feature addition errors to a QgsProcessingContext.
~QgsProcessingFeatureSink() override
QgsProcessingFeatureSink(QgsFeatureSink *originalSink, const QString &sinkName, QgsProcessingContext &context, bool ownsOriginalSink=false)
Constructor for QgsProcessingFeatureSink, accepting an original feature sink originalSink and process...
bool addFeatures(QgsFeatureList &features, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
Adds a list of features to the sink.
bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
Adds a single feature to the sink.
Encapsulates settings relating to a feature source input to a processing algorithm.
Flags flags
Flags which dictate source behavior.
bool selectedFeaturesOnly
true if only selected features in the source should be used by algorithms.
QgsFeatureRequest::InvalidGeometryCheck geometryCheck
Geometry check method to apply to this source.
QgsProperty source
Source definition.
long long featureLimit
If set to a value > 0, places a limit on the maximum number of features which will be read from the s...
QgsFeatureSource subclass which proxies methods to an underlying QgsFeatureSource,...
QgsRectangle sourceExtent() const override
Returns the extent of all geometries from the source.
QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const override
Returns the set of unique values contained within the specified fieldIndex from this source.
QgsExpressionContextScope * createExpressionContextScope() const
Returns an expression context scope suitable for this source.
QgsFeatureSource::FeatureAvailability hasFeatures() const override
Determines if there are any features available in the source.
QVariant maximumValue(int fieldIndex) const override
Returns the maximum value for an attribute column or an invalid variant in case of error.
~QgsProcessingFeatureSource() override
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request, Flags flags) const
Returns an iterator for the features in the source, respecting the supplied feature flags.
QgsCoordinateReferenceSystem sourceCrs() const override
Returns the coordinate reference system for features in the source.
QVariant minimumValue(int fieldIndex) const override
Returns the minimum value for an attribute column or an invalid variant in case of error.
long long featureCount() const override
Returns the number of features contained in the source, or -1 if the feature count is unknown.
QgsWkbTypes::Type wkbType() const override
Returns the geometry type for features returned by this source.
@ FlagSkipGeometryValidityChecks
Invalid geometry checks should always be skipped. This flag can be useful for algorithms which always...
QString sourceName() const override
Returns a friendly display name for the source.
SpatialIndexPresence hasSpatialIndex() const override
Returns an enum value representing the presence of a valid spatial index on the source,...
QgsFeatureIds allFeatureIds() const override
Returns a list of all feature IDs for features present in the source.
QgsProcessingFeatureSource(QgsFeatureSource *originalSource, const QgsProcessingContext &context, bool ownsOriginalSource=false, long long featureLimit=-1)
Constructor for QgsProcessingFeatureSource, accepting an original feature source originalSource and p...
QgsFields fields() const override
Returns the fields associated with features in the source.
void setInvalidGeometryCheck(QgsFeatureRequest::InvalidGeometryCheck method)
Overrides the default geometry check method for the source.
Base class for providing feedback from a processing algorithm.
virtual void reportError(const QString &error, bool fatalError=false)
Reports that the algorithm encountered an error while executing.
Base class for the definition of processing outputs.
Encapsulates settings relating to a feature sink or output raster layer for a processing algorithm.
QgsProperty sink
Sink/layer definition.
Base class for the definition of processing parameters.
@ FlagHidden
Parameter is hidden and should not be shown to users.
static QString convertToCompatibleFormat(const QgsVectorLayer *layer, bool selectedFeaturesOnly, const QString &baseName, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingContext &context, QgsProcessingFeedback *feedback, long long featureLimit=-1)
Converts a source vector layer to a file path of a vector layer of compatible format.
static QString stringToPythonLiteral(const QString &string)
Converts a string to a Python string literal.
static QString defaultVectorExtension()
Returns the default vector extension to use, in the absence of all other constraints (e....
static QVariant generateIteratingDestination(const QVariant &input, const QVariant &id, QgsProcessingContext &context)
Converts an input parameter value for use in source iterating mode, where one individual sink is crea...
static QgsFields indicesToFields(const QList< int > &indices, const QgsFields &fields)
Returns a subset of fields based on the indices of desired fields.
static QList< int > fieldNamesToIndices(const QStringList &fieldNames, const QgsFields &fields)
Returns a list of field indices parsed from the given list of field names.
static QList< QgsAnnotationLayer * > compatibleAnnotationLayers(QgsProject *project, bool sort=true)
Returns a list of annotation layers from a project which are compatible with the processing framework...
static QString normalizeLayerSource(const QString &source)
Normalizes a layer source string for safe comparison across different operating system environments.
static QString formatHelpMapAsHtml(const QVariantMap &map, const QgsProcessingAlgorithm *algorithm)
Returns a HTML formatted version of the help text encoded in a variant map for a specified algorithm.
static QgsFeatureSink * createFeatureSink(QString &destination, QgsProcessingContext &context, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, const QVariantMap &createOptions=QVariantMap(), const QStringList &datasourceOptions=QStringList(), const QStringList &layerOptions=QStringList(), QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags(), QgsRemappingSinkDefinition *remappingDefinition=nullptr)
Creates a feature sink ready for adding features.
static QgsFields combineFields(const QgsFields &fieldsA, const QgsFields &fieldsB, const QString &fieldsBPrefix=QString())
Combines two field lists, avoiding duplicate field names (in a case-insensitive manner).
static QString encodeProviderKeyAndUri(const QString &providerKey, const QString &uri)
Encodes a provider key and layer uri to a single string, for use with decodeProviderKeyAndUri()
static QString tempFolder()
Returns a session specific processing temporary folder for use in processing algorithms.
LayerHint
Layer type hints.
@ Annotation
Annotation layer type, since QGIS 3.22.
@ Vector
Vector layer type.
@ Mesh
Mesh layer type, since QGIS 3.6.
@ Raster
Raster layer type.
@ UnknownType
Unknown layer type.
@ PointCloud
Point cloud layer type, since QGIS 3.22.
static QString generateTempFilename(const QString &basename)
Returns a temporary filename for a given file, putting it into a temporary folder (creating that fold...
static QgsProcessingFeatureSource * variantToSource(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a new feature source.
static QList< QgsRasterLayer * > compatibleRasterLayers(QgsProject *project, bool sort=true)
Returns a list of raster layers from a project which are compatible with the processing framework.
static void createFeatureSinkPython(QgsFeatureSink **sink, QString &destination, QgsProcessingContext &context, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &crs, const QVariantMap &createOptions=QVariantMap()) SIP_THROW(QgsProcessingException)
Creates a feature sink ready for adding features.
static QString convertToCompatibleFormatAndLayerName(const QgsVectorLayer *layer, bool selectedFeaturesOnly, const QString &baseName, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingContext &context, QgsProcessingFeedback *feedback, QString &layerName, long long featureLimit=-1)
Converts a source vector layer to a file path and layer name of a vector layer of compatible format.
static QgsRectangle combineLayerExtents(const QList< QgsMapLayer * > &layers, const QgsCoordinateReferenceSystem &crs, QgsProcessingContext &context)
Combines the extent of several map layers.
static QList< QgsPluginLayer * > compatiblePluginLayers(QgsProject *project, bool sort=true)
Returns a list of plugin layers from a project which are compatible with the processing framework.
static QString variantToPythonLiteral(const QVariant &value)
Converts a variant to a Python literal.
static QgsCoordinateReferenceSystem variantToCrs(const QVariant &value, QgsProcessingContext &context, const QVariant &fallbackValue=QVariant())
Converts a variant value to a coordinate reference system.
static QList< QgsVectorLayer * > compatibleVectorLayers(QgsProject *project, const QList< int > &sourceTypes=QList< int >(), bool sort=true)
Returns a list of vector layers from a project which are compatible with the processing framework.
static QgsMapLayer * mapLayerFromString(const QString &string, QgsProcessingContext &context, bool allowLoadingNewLayers=true, QgsProcessingUtils::LayerHint typeHint=QgsProcessingUtils::LayerHint::UnknownType)
Interprets a string as a map layer within the supplied context.
static bool decodeProviderKeyAndUri(const QString &string, QString &providerKey, QString &uri)
Decodes a provider key and layer uri from an encoded string, for use with encodeProviderKeyAndUri()
static QList< QgsMapLayer * > compatibleLayers(QgsProject *project, bool sort=true)
Returns a list of map layers from a project which are compatible with the processing framework.
static QString defaultRasterExtension()
Returns the default raster extension to use, in the absence of all other constraints (e....
static QList< QgsPointCloudLayer * > compatiblePointCloudLayers(QgsProject *project, bool sort=true)
Returns a list of point cloud layers from a project which are compatible with the processing framewor...
static QList< QgsMeshLayer * > compatibleMeshLayers(QgsProject *project, bool sort=true)
Returns a list of mesh layers from a project which are compatible with the processing framework.
static const QgsSettingsEntryInteger settingsDefaultOutputRasterLayerExt
Settings entry default output raster layer ext.
static const QgsSettingsEntryInteger settingsDefaultOutputVectorLayerExt
Settings entry default output vector layer ext.
static const QString TEMPORARY_OUTPUT
Constant used to indicate that a Processing algorithm output should be a temporary layer/file.
@ TypeVectorLine
Vector line layers.
@ TypeVectorPolygon
Vector polygon layers.
@ TypeVector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
@ TypeVectorPoint
Vector point layers.
@ TypeVectorAnyGeometry
Any vector layer with geometry.
static const QgsSettingsEntryString settingsTempPath
Settings entry temp path.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
QgsAnnotationLayer * mainAnnotationLayer()
Returns the main annotation layer associated with the project.
QVector< T > layers() const
Returns a list of registered map layers with a specified layer type.
QgsCoordinateReferenceSystem crs
A store for object properties.
@ StaticProperty
Static property (QgsStaticProperty)
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
QVariant value(const QgsExpressionContext &context, const QVariant &defaultValue=QVariant(), bool *ok=nullptr) const
Calculates the current value of the property, including any transforms which are set for the property...
Type propertyType() const
Returns the property type.
static QgsProperty fromValue(const QVariant &value, bool isActive=true)
Returns a new StaticProperty created from the specified value.
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
QString encodeUri(const QString &providerKey, const QVariantMap &parts)
Reassembles a provider data source URI from its component paths (e.g.
QgsProviderMetadata * providerMetadata(const QString &providerKey) const
Returns metadata of the provider or nullptr if not found.
A simple feature sink which proxies feature addition on to another feature sink.
bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
Adds a single feature to the sink.
QString lastError() const override
Returns the most recent error encountered by the sink, e.g.
QgsFeatureSink * destinationSink()
Returns the destination QgsFeatureSink which the proxy will forward features to.
bool addFeatures(QgsFeatureList &features, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
Adds a list of features to the sink.
static QStringList supportedFormatExtensions(RasterFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats.
Represents a raster layer.
A rectangle specified with double values.
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle.
QgsCoordinateReferenceSystem crs() const
Returns the associated coordinate reference system, or an invalid CRS if no reference system is set.
A QgsPointXY with associated coordinate reference system.
A QgsRectangle with associated coordinate reference system.
Defines the parameters used to remap features when creating a QgsRemappingProxyFeatureSink.
void setDestinationCrs(const QgsCoordinateReferenceSystem &destination)
Sets the destination crs used for reprojecting incoming features to the sink's destination CRS.
void setDestinationWkbType(QgsWkbTypes::Type type)
Sets the WKB geometry type for the destination.
void setDestinationFields(const QgsFields &fields)
Sets the fields for the destination sink.
qlonglong value(const QString &dynamicKeyPart=QString(), bool useDefaultValueOverride=false, qlonglong defaultValueOverride=0) const
Returns settings value.
QString value(const QString &dynamicKeyPart=QString(), bool useDefaultValueOverride=false, const QString &defaultValueOverride=QString()) const
Returns settings value.
Options to pass to writeAsVectorFormat()
QString fileEncoding
Encoding to use.
QString driverName
OGR driver to use.
QString layerName
Layer name. If let empty, it will be derived from the filename.
QStringList layerOptions
List of OGR layer creation options.
QgsVectorFileWriter::SymbologyExport symbologyExport
Symbology to export.
QgsVectorFileWriter::ActionOnExistingFile actionOnExistingFile
Action on existing file.
QStringList datasourceOptions
List of OGR data source creation options.
static QgsVectorFileWriter * create(const QString &fileName, const QgsFields &fields, QgsWkbTypes::Type geometryType, const QgsCoordinateReferenceSystem &srs, const QgsCoordinateTransformContext &transformContext, const QgsVectorFileWriter::SaveVectorOptions &options, QgsFeatureSink::SinkFlags sinkFlags=QgsFeatureSink::SinkFlags(), QString *newFilename=nullptr, QString *newLayer=nullptr)
Create a new vector file writer.
static QStringList defaultLayerOptions(const QString &driverName)
Returns a list of the default layer options for a specified driver.
static QString driverForExtension(const QString &extension)
Returns the OGR driver name for a specified file extension.
static QStringList defaultDatasetOptions(const QString &driverName)
Returns a list of the default dataset options for a specified driver.
static QStringList supportedFormatExtensions(VectorFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats, e.g "shp", "gpkg".
@ CreateOrOverwriteFile
Create or overwrite file.
@ AppendToLayerNoNewFields
Append features to existing layer, but do not create new fields.
QgsFeatureSource subclass for the selected features from a QgsVectorLayer.
Represents a vector layer which manages a vector based data sets.
Q_INVOKABLE QgsWkbTypes::Type wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
bool isSpatial() const FINAL
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
QgsFields fields() const FINAL
Returns the list of fields of this layer.
QgsFeatureIterator getSelectedFeatures(QgsFeatureRequest request=QgsFeatureRequest()) const
Returns an iterator of the selected features.
QgsRectangle extent() const FINAL
Returns the extent of the layer.
Implements a map layer that is dedicated to rendering of vector tiles.
Handles storage of information regarding WKB types and their properties.
Type
The WKB type describes the number of dimensions a geometry has.
@ PointCloudLayer
Added in 3.18.
@ AnnotationLayer
Contains freeform, georeferenced annotations. Added in QGIS 3.16.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into allowing algorithms to be written in pure substantial changes are required in order to port existing x Processing algorithms for QGIS x The most significant changes are outlined not GeoAlgorithm For algorithms which operate on features one by consider subclassing the QgsProcessingFeatureBasedAlgorithm class This class allows much of the boilerplate code for looping over features from a vector layer to be bypassed and instead requires implementation of a processFeature method Ensure that your algorithm(or algorithm 's parent class) implements the new pure virtual createInstance(self) call
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
QList< QgsFeature > QgsFeatureList
QSet< QgsFeatureId > QgsFeatureIds
QString convertToCompatibleFormatInternal(const QgsVectorLayer *vl, bool selectedFeaturesOnly, const QString &baseName, const QStringList &compatibleFormats, const QString &preferredFormat, QgsProcessingContext &context, QgsProcessingFeedback *feedback, QString *layerName, long long featureLimit)
const QgsCoordinateReferenceSystem & crs
Setting options for loading mesh layers.
bool skipCrsValidation
Controls whether the layer is allowed to have an invalid/unknown CRS.
Setting options for loading point cloud layers.
bool skipCrsValidation
Controls whether the layer is allowed to have an invalid/unknown CRS.
Setting options for loading raster layers.
bool skipCrsValidation
Controls whether the layer is allowed to have an invalid/unknown CRS.
bool loadDefaultStyle
Sets to true if the default layer style should be loaded.
Setting options for loading vector layers.