Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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 11, 2018
1 parent 6ad50f7 commit 4d02041
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/providers/arcgisrest/qgsafsprovider.cpp
Expand Up @@ -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;
Expand Down
5 changes: 0 additions & 5 deletions src/providers/arcgisrest/qgsafssourceselect.cpp
Expand Up @@ -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 );
Expand Down
7 changes: 5 additions & 2 deletions src/providers/arcgisrest/qgsarcgisrestutils.cpp
Expand Up @@ -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;
}

Expand Down

0 comments on commit 4d02041

Please sign in to comment.