QGIS-Documentation icon indicating copy to clipboard operation
QGIS-Documentation copied to clipboard

FEATURE: Source select configure from uri (Request in QGIS)

Open qgis-bot opened this issue 1 year ago • 0 comments

Request for documentation

From pull request QGIS/qgis#54844 Author: @elpaso QGIS version: 3.34

FEATURE: Source select configure from uri

PR Description:

This PR adds an API for source select widgets and data source manager that allows to open and configure the data source manager from a data source URI.

For instance:

registry = QgsGui.sourceSelectProviderRegistry()
# Check for capability
registry.providers()[0].name()
'ogr'
bool(registry.providers()[0].capabilities() & QgsSourceSelectProvider.Capability.ConfigureFromUri)
True
source_select_provider = registry.providers()[0]
widget = source_select_provider.createDataSourceWidget()
widget.configureFromUri('/path/to/file.gpkg|layername=points')
True

The datasource manager dialog has also a C++ API:

    /**
     * Shows the page \a pageName and configure the source select widget from the layer \a uri.
     * \since QGIS 3.38
     */
    void configureFromUri( const QString &pageName, const QString &uri );

The dialog will open on the correct page with pre-filled values to open the layer.

This feature is for now implemented for OGR (including the dedicated GPKG source select), GDAL and Spatialite and it is accessible from the context menu in the browser.

The purpose is to allow the user to set opening options when adding a layer from the browser but it could be eventually expanded to include a more sophisticated replace data source functionality where opening options can be specified.

Here is the exposed UI

configure_from_uri_gpkg_vector

configure_from_uri_gpkg_raster

A secondary patch (for GDAL >= 3.8 only, and part of the same work package) in this PR is related to a very peculiar use case when opening VR BAG (variable resolution) files, in case no opening options are explicitly specified by the user the MODE=INTERPOLATED option is used as a default.

configure_from_uri_bag

Funded by: NOAA

Commits tagged with [need-docs] or [FEATURE]

qgis-bot avatar Feb 27 '24 06:02 qgis-bot