Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow adding AMS layers even if project has no CRS #38893

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5343,26 +5343,28 @@ QString QgisApp::crsAndFormatAdjustedLayerUri( const QString &uri, const QString

// Adjust layer CRS to project CRS
QgsCoordinateReferenceSystem testCrs;
const auto constSupportedCrs = supportedCrs;
for ( const QString &c : constSupportedCrs )

QRegularExpression crsRe( QStringLiteral( "crs=[^& ]+" ) );
for ( const QString &c : supportedCrs )
{
testCrs.createFromOgcWmsCrs( c );
if ( testCrs == mMapCanvas->mapSettings().destinationCrs() )
{
newuri.replace( QRegExp( "crs=[^&]+" ), "crs=" + c );
newuri.replace( crsRe, QStringLiteral( "crs=" ) + c );
QgsDebugMsg( QStringLiteral( "Changing layer crs to %1, new uri: %2" ).arg( c, uri ) );
break;
}
}

// Use the last used image format
QString lastImageEncoding = QgsSettings().value( QStringLiteral( "/qgis/lastWmsImageEncoding" ), "image/png" ).toString();
const auto constSupportedFormats = supportedFormats;
for ( const QString &fmt : constSupportedFormats )

QRegularExpression formatRe( QStringLiteral( "format=[^& ]+" ) );
for ( const QString &fmt : supportedFormats )
{
if ( fmt == lastImageEncoding )
{
newuri.replace( QRegExp( "format=[^&]+" ), "format=" + fmt );
newuri.replace( formatRe, QStringLiteral( "format=" ) + fmt );
QgsDebugMsg( QStringLiteral( "Changing layer format to %1, new uri: %2" ).arg( fmt, uri ) );
break;
}
Expand Down