mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
feat(#62838): refactor duplicated logic
This commit is contained in:
parent
90da1671e9
commit
320b3afd1c
@ -76,6 +76,14 @@ Returns the format name for cloud optimized formats
|
||||
QgsMimeDataUtils::Uri uri() const;
|
||||
%Docstring
|
||||
Returns a uri for the asset if it is a cloud optimized file like COG or
|
||||
COPC, empty auth configuration
|
||||
|
||||
.. versionadded:: 3.42
|
||||
%End
|
||||
|
||||
QgsMimeDataUtils::Uri uri( QString authcfg ) const;
|
||||
%Docstring
|
||||
Returns a uri for the asset if it is a cloud optimized file like COG or
|
||||
COPC
|
||||
|
||||
.. versionadded:: 3.42
|
||||
|
@ -76,6 +76,14 @@ Returns the format name for cloud optimized formats
|
||||
QgsMimeDataUtils::Uri uri() const;
|
||||
%Docstring
|
||||
Returns a uri for the asset if it is a cloud optimized file like COG or
|
||||
COPC, empty auth configuration
|
||||
|
||||
.. versionadded:: 3.42
|
||||
%End
|
||||
|
||||
QgsMimeDataUtils::Uri uri( QString authcfg ) const;
|
||||
%Docstring
|
||||
Returns a uri for the asset if it is a cloud optimized file like COG or
|
||||
COPC
|
||||
|
||||
.. versionadded:: 3.42
|
||||
|
@ -79,6 +79,12 @@ QString QgsStacAsset::formatName() const
|
||||
}
|
||||
|
||||
QgsMimeDataUtils::Uri QgsStacAsset::uri() const
|
||||
{
|
||||
return uri( QString() );
|
||||
}
|
||||
|
||||
|
||||
QgsMimeDataUtils::Uri QgsStacAsset::uri( QString authcfg ) const
|
||||
{
|
||||
QgsMimeDataUtils::Uri uri;
|
||||
QUrl url( href() );
|
||||
@ -90,6 +96,8 @@ QgsMimeDataUtils::Uri QgsStacAsset::uri() const
|
||||
href().startsWith( QLatin1String( "ftp" ), Qt::CaseInsensitive ) )
|
||||
{
|
||||
uri.uri = QStringLiteral( "/vsicurl/%1" ).arg( href() );
|
||||
if ( !authcfg.isEmpty() )
|
||||
uri.uri.append( QStringLiteral( " authcfg='%1'" ).arg( authcfg ) );
|
||||
}
|
||||
else if ( href().startsWith( QLatin1String( "s3://" ), Qt::CaseInsensitive ) )
|
||||
{
|
||||
@ -105,12 +113,16 @@ QgsMimeDataUtils::Uri QgsStacAsset::uri() const
|
||||
uri.layerType = QStringLiteral( "pointcloud" );
|
||||
uri.providerKey = QStringLiteral( "copc" );
|
||||
uri.uri = href();
|
||||
if ( !authcfg.isEmpty() )
|
||||
uri.uri.append( QStringLiteral( " authcfg='%1'" ).arg( authcfg ) );
|
||||
}
|
||||
else if ( formatName() == QLatin1String( "EPT" ) )
|
||||
{
|
||||
uri.layerType = QStringLiteral( "pointcloud" );
|
||||
uri.providerKey = QStringLiteral( "ept" );
|
||||
uri.uri = href();
|
||||
if ( !authcfg.isEmpty() )
|
||||
uri.uri.append( QStringLiteral( " authcfg='%1'" ).arg( authcfg ) );
|
||||
}
|
||||
else if ( formatName() == QLatin1String( "Zarr" ) )
|
||||
{
|
||||
@ -120,6 +132,8 @@ QgsMimeDataUtils::Uri QgsStacAsset::uri() const
|
||||
href().startsWith( QLatin1String( "ftp" ), Qt::CaseInsensitive ) )
|
||||
{
|
||||
uri.uri = QStringLiteral( "ZARR:\"/vsicurl/%1\"" ).arg( href() );
|
||||
if ( !authcfg.isEmpty() )
|
||||
uri.uri.append( QStringLiteral( " authcfg='%1'" ).arg( authcfg ) );
|
||||
}
|
||||
else if ( href().startsWith( QLatin1String( "s3://" ), Qt::CaseInsensitive ) )
|
||||
{
|
||||
|
@ -73,11 +73,17 @@ class CORE_EXPORT QgsStacAsset
|
||||
QString formatName() const;
|
||||
|
||||
/**
|
||||
* Returns a uri for the asset if it is a cloud optimized file like COG or COPC
|
||||
* Returns a uri for the asset if it is a cloud optimized file like COG or COPC, empty auth configuration
|
||||
* \since QGIS 3.42
|
||||
*/
|
||||
QgsMimeDataUtils::Uri uri() const;
|
||||
|
||||
/**
|
||||
* Returns a uri for the asset if it is a cloud optimized file like COG or COPC
|
||||
* \since QGIS 3.42
|
||||
*/
|
||||
QgsMimeDataUtils::Uri uri( QString authcfg ) const;
|
||||
|
||||
private:
|
||||
QString mHref;
|
||||
QString mTitle;
|
||||
|
@ -109,44 +109,10 @@ QgsMimeDataUtils::UriList QgsStacItemItem::mimeUris() const
|
||||
{
|
||||
uri.uri = it->href();
|
||||
}
|
||||
else if ( it->mediaType() == QLatin1String( "image/tiff; application=geotiff; profile=cloud-optimized" ) ||
|
||||
it->mediaType() == QLatin1String( "image/vnd.stac.geotiff; cloud-optimized=true" ) )
|
||||
else
|
||||
{
|
||||
uri.layerType = QStringLiteral( "raster" );
|
||||
uri.providerKey = QStringLiteral( "gdal" );
|
||||
if ( it->href().startsWith( QLatin1String( "http" ), Qt::CaseInsensitive ) ||
|
||||
it->href().startsWith( QLatin1String( "ftp" ), Qt::CaseInsensitive ) )
|
||||
{
|
||||
uri.uri = QStringLiteral( "/vsicurl/%1" ).arg( it->href() );
|
||||
if ( !authcfg.isEmpty() )
|
||||
uri.uri.append( QStringLiteral( " authcfg='%1'" ).arg( authcfg ) );
|
||||
}
|
||||
else if ( it->href().startsWith( QLatin1String( "s3://" ), Qt::CaseInsensitive ) )
|
||||
{
|
||||
uri.uri = QStringLiteral( "/vsis3/%1" ).arg( it->href().mid( 5 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
uri.uri = it->href();
|
||||
}
|
||||
uri = it->uri( authcfg );
|
||||
}
|
||||
else if ( it->mediaType() == QLatin1String( "application/vnd.laszip+copc" ) )
|
||||
{
|
||||
uri.layerType = QStringLiteral( "pointcloud" );
|
||||
uri.providerKey = QStringLiteral( "copc" );
|
||||
uri.uri = it->href();
|
||||
if ( !authcfg.isEmpty() )
|
||||
uri.uri.append( QStringLiteral( " authcfg='%1'" ).arg( authcfg ) );
|
||||
}
|
||||
else if ( it->href().endsWith( QLatin1String( "/ept.json" ) ) )
|
||||
{
|
||||
uri.layerType = QStringLiteral( "pointcloud" );
|
||||
uri.providerKey = QStringLiteral( "ept" );
|
||||
uri.uri = it->href();
|
||||
if ( !authcfg.isEmpty() )
|
||||
uri.uri.append( QStringLiteral( " authcfg='%1'" ).arg( authcfg ) );
|
||||
}
|
||||
uri.name = it->title().isEmpty() ? url.fileName() : it->title();
|
||||
uris.append( uri );
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user