mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
Implement sinkProperties for QgsProcessingFeatureBasedAlgorithm subclasses
This commit is contained in:
parent
2d8da255a2
commit
b2ca789ba4
@ -1191,6 +1191,11 @@ Read the source from ``parameters`` and ``context`` and set it
|
||||
.. versionadded:: 3.4
|
||||
%End
|
||||
|
||||
virtual QgsProcessingAlgorithm::VectorProperties sinkProperties( const QString &sink,
|
||||
const QVariantMap ¶meters,
|
||||
QgsProcessingContext &context,
|
||||
const QMap< QString, QgsProcessingAlgorithm::VectorProperties > &sourceProperties ) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1031,3 +1031,34 @@ void QgsProcessingFeatureBasedAlgorithm::prepareSource( const QVariantMap ¶m
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QgsProcessingAlgorithm::VectorProperties QgsProcessingFeatureBasedAlgorithm::sinkProperties( const QString &sink, const QVariantMap ¶meters, QgsProcessingContext &context, const QMap<QString, QgsProcessingAlgorithm::VectorProperties> &sourceProperties ) const
|
||||
{
|
||||
QgsProcessingAlgorithm::VectorProperties result;
|
||||
if ( sink == QStringLiteral( "OUTPUT" ) )
|
||||
{
|
||||
if ( sourceProperties.value( QStringLiteral( "INPUT" ) ).availability == QgsProcessingAlgorithm::Available )
|
||||
{
|
||||
const VectorProperties inputProps = sourceProperties.value( QStringLiteral( "INPUT" ) );
|
||||
result.fields = outputFields( inputProps.fields );
|
||||
result.crs = outputCrs( inputProps.crs );
|
||||
result.wkbType = outputWkbType( inputProps.wkbType );
|
||||
result.availability = Available;
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::unique_ptr< QgsProcessingFeatureSource > source( parameterAsSource( parameters, QStringLiteral( "INPUT" ), context ) );
|
||||
if ( source )
|
||||
{
|
||||
result.fields = outputFields( source->fields() );
|
||||
result.crs = outputCrs( source->sourceCrs() );
|
||||
result.wkbType = outputWkbType( source->wkbType() );
|
||||
result.availability = Available;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@ -1199,6 +1199,11 @@ class CORE_EXPORT QgsProcessingFeatureBasedAlgorithm : public QgsProcessingAlgor
|
||||
*/
|
||||
void prepareSource( const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
|
||||
QgsProcessingAlgorithm::VectorProperties sinkProperties( const QString &sink,
|
||||
const QVariantMap ¶meters,
|
||||
QgsProcessingContext &context,
|
||||
const QMap< QString, QgsProcessingAlgorithm::VectorProperties > &sourceProperties ) const override;
|
||||
|
||||
private:
|
||||
|
||||
std::unique_ptr< QgsProcessingFeatureSource > mSource;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user