Skip to content
Permalink
Browse files

[afs] Fix handling of custom projections

Don't treat all unknown projections as WGS84

Fixes #18881

(cherry-picked from ea38c73)
  • Loading branch information
nyalldawson committed May 7, 2018
1 parent 6ad50f7 commit 4d02041687147397ddcb75db7c92cd49394353e2
@@ -47,7 +47,7 @@ QgsAfsProvider::QgsAfsProvider( const QString &uri )
mSharedData->mDataSource = QgsDataSourceUri( uri );

// Set CRS
mSharedData->mSourceCRS = QgsCoordinateReferenceSystem::fromOgcWmsCrs( mSharedData->mDataSource.param( QStringLiteral( "crs" ) ) );
mSharedData->mSourceCRS.createFromString( mSharedData->mDataSource.param( QStringLiteral( "crs" ) ) );

// Get layer info
QString errorTitle, errorMessage;
@@ -90,11 +90,6 @@ bool QgsAfsSourceSelect::connectToService( const QgsOwsConnection &connection )
cachedItem->setCheckState( Qt::Checked );

QgsCoordinateReferenceSystem crs = QgsArcGisRestUtils::parseSpatialReference( serviceInfoMap[QStringLiteral( "spatialReference" )].toMap() );
if ( !crs.isValid() )
{
// If not spatial reference, just use WGS84
crs.createFromString( QStringLiteral( "EPSG:4326" ) );
}
mAvailableCRS[layerData[QStringLiteral( "name" )].toString()] = QList<QString>() << crs.authid();

mModel->appendRow( QList<QStandardItem *>() << idItem << nameItem << abstractItem << cachedItem << filterItem );
@@ -335,8 +335,11 @@ QgsCoordinateReferenceSystem QgsArcGisRestUtils::parseSpatialReference( const QV
spatialReference = QStringLiteral( "EPSG:%1" ).arg( spatialReference );
QgsCoordinateReferenceSystem crs;
crs.createFromString( spatialReference );
if ( crs.authid().startsWith( QLatin1String( "USER:" ) ) )
crs.createFromString( QStringLiteral( "EPSG:4326" ) ); // If we can't recognize the SRS, fall back to WGS84
if ( !crs.isValid() )
{
// If not spatial reference, just use WGS84
crs.createFromString( QStringLiteral( "EPSG:4326" ) );
}
return crs;
}

0 comments on commit 4d02041

Please sign in to comment.
You can’t perform that action at this time.