mirror of
https://github.com/qgis/QGIS.git
synced 2025-12-15 00:07:25 -05:00
Make more use of layer type hints to avoid trying to open raster/mesh
layers using the ogr provider
This commit is contained in:
parent
bee1231b3e
commit
c85f62a968
@ -911,7 +911,7 @@ a conversion in this case and will return the target layer name in the ``layerNa
|
||||
.. versionadded:: 3.10
|
||||
%End
|
||||
|
||||
static QgsMapLayer *parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
static QgsMapLayer *parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingUtils::LayerHint layerHint = QgsProcessingUtils::LayerHint::UnknownType );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` to a map layer.
|
||||
|
||||
@ -920,7 +920,7 @@ sources and stored temporarily in the ``context``. In either case, callers do no
|
||||
need to handle deletion of the returned layer.
|
||||
%End
|
||||
|
||||
static QgsMapLayer *parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
static QgsMapLayer *parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context, QgsProcessingUtils::LayerHint layerHint = QgsProcessingUtils::LayerHint::UnknownType );
|
||||
%Docstring
|
||||
Evaluates the parameter with matching ``definition`` and ``value`` to a map layer.
|
||||
|
||||
|
||||
@ -721,15 +721,15 @@ QString QgsProcessingParameters::parameterAsCompatibleSourceLayerPathAndLayerNam
|
||||
}
|
||||
|
||||
|
||||
QgsMapLayer *QgsProcessingParameters::parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context )
|
||||
QgsMapLayer *QgsProcessingParameters::parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingUtils::LayerHint layerHint )
|
||||
{
|
||||
if ( !definition )
|
||||
return nullptr;
|
||||
|
||||
return parameterAsLayer( definition, parameters.value( definition->name() ), context );
|
||||
return parameterAsLayer( definition, parameters.value( definition->name() ), context, layerHint );
|
||||
}
|
||||
|
||||
QgsMapLayer *QgsProcessingParameters::parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
|
||||
QgsMapLayer *QgsProcessingParameters::parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context, QgsProcessingUtils::LayerHint layerHint )
|
||||
{
|
||||
if ( !definition )
|
||||
return nullptr;
|
||||
@ -775,27 +775,27 @@ QgsMapLayer *QgsProcessingParameters::parameterAsLayer( const QgsProcessingParam
|
||||
if ( layerRef.isEmpty() )
|
||||
return nullptr;
|
||||
|
||||
return QgsProcessingUtils::mapLayerFromString( layerRef, context );
|
||||
return QgsProcessingUtils::mapLayerFromString( layerRef, context, true, layerHint );
|
||||
}
|
||||
|
||||
QgsRasterLayer *QgsProcessingParameters::parameterAsRasterLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context )
|
||||
{
|
||||
return qobject_cast< QgsRasterLayer *>( parameterAsLayer( definition, parameters, context ) );
|
||||
return qobject_cast< QgsRasterLayer *>( parameterAsLayer( definition, parameters, context, QgsProcessingUtils::LayerHint::Raster ) );
|
||||
}
|
||||
|
||||
QgsRasterLayer *QgsProcessingParameters::parameterAsRasterLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
|
||||
{
|
||||
return qobject_cast< QgsRasterLayer *>( parameterAsLayer( definition, value, context ) );
|
||||
return qobject_cast< QgsRasterLayer *>( parameterAsLayer( definition, value, context, QgsProcessingUtils::LayerHint::Raster ) );
|
||||
}
|
||||
|
||||
QgsMeshLayer *QgsProcessingParameters::parameterAsMeshLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context )
|
||||
{
|
||||
return qobject_cast< QgsMeshLayer *>( parameterAsLayer( definition, parameters, context ) );
|
||||
return qobject_cast< QgsMeshLayer *>( parameterAsLayer( definition, parameters, context, QgsProcessingUtils::LayerHint::Mesh ) );
|
||||
}
|
||||
|
||||
QgsMeshLayer *QgsProcessingParameters::parameterAsMeshLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
|
||||
{
|
||||
return qobject_cast< QgsMeshLayer *>( parameterAsLayer( definition, value, context ) );
|
||||
return qobject_cast< QgsMeshLayer *>( parameterAsLayer( definition, value, context, QgsProcessingUtils::LayerHint::Mesh ) );
|
||||
}
|
||||
|
||||
QString QgsProcessingParameters::parameterAsOutputLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context )
|
||||
@ -910,12 +910,12 @@ QString QgsProcessingParameters::parameterAsFileOutput( const QgsProcessingParam
|
||||
|
||||
QgsVectorLayer *QgsProcessingParameters::parameterAsVectorLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context )
|
||||
{
|
||||
return qobject_cast< QgsVectorLayer *>( parameterAsLayer( definition, parameters, context ) );
|
||||
return qobject_cast< QgsVectorLayer *>( parameterAsLayer( definition, parameters, context, QgsProcessingUtils::LayerHint::Vector ) );
|
||||
}
|
||||
|
||||
QgsVectorLayer *QgsProcessingParameters::parameterAsVectorLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context )
|
||||
{
|
||||
return qobject_cast< QgsVectorLayer *>( parameterAsLayer( definition, value, context ) );
|
||||
return qobject_cast< QgsVectorLayer *>( parameterAsLayer( definition, value, context, QgsProcessingUtils::LayerHint::Vector ) );
|
||||
}
|
||||
|
||||
QgsCoordinateReferenceSystem QgsProcessingParameters::parameterAsCrs( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context )
|
||||
|
||||
@ -999,7 +999,7 @@ class CORE_EXPORT QgsProcessingParameters
|
||||
* sources and stored temporarily in the \a context. In either case, callers do not
|
||||
* need to handle deletion of the returned layer.
|
||||
*/
|
||||
static QgsMapLayer *parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context );
|
||||
static QgsMapLayer *parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingUtils::LayerHint layerHint = QgsProcessingUtils::LayerHint::UnknownType );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition and \a value to a map layer.
|
||||
@ -1010,7 +1010,7 @@ class CORE_EXPORT QgsProcessingParameters
|
||||
*
|
||||
* \since QGIS 3.4
|
||||
*/
|
||||
static QgsMapLayer *parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context );
|
||||
static QgsMapLayer *parameterAsLayer( const QgsProcessingParameterDefinition *definition, const QVariant &value, QgsProcessingContext &context, QgsProcessingUtils::LayerHint layerHint = QgsProcessingUtils::LayerHint::UnknownType );
|
||||
|
||||
/**
|
||||
* Evaluates the parameter with matching \a definition to a raster layer.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user