diff --git a/src/core/qgscoordinatereferencesystem.cpp b/src/core/qgscoordinatereferencesystem.cpp index b95e251fe4df..4bd82cd9e848 100644 --- a/src/core/qgscoordinatereferencesystem.cpp +++ b/src/core/qgscoordinatereferencesystem.cpp @@ -314,6 +314,15 @@ bool QgsCoordinateReferenceSystem::createFromWkt( QString theWkt ) return mIsValidFlag; } + if ( OSRAutoIdentifyEPSG( mCRS ) == OGRERR_NONE ) + { + QString authid = QString( "%1:%2" ) + .arg( OSRGetAuthorityName( mCRS, NULL ) ) + .arg( OSRGetAuthorityCode( mCRS, NULL ) ); + QgsDebugMsg( "authid recognized as " + authid ); + return createFromOgcWmsCrs( authid ); + } + // always morph from esri as it doesn't hurt anything // FW: Hey, that's not right! It can screw stuff up! Disable //myOgrSpatialRef.morphFromESRI(); diff --git a/src/providers/ogr/qgsogrprovider.cpp b/src/providers/ogr/qgsogrprovider.cpp index b9825d919037..306362eff5ac 100644 --- a/src/providers/ogr/qgsogrprovider.cpp +++ b/src/providers/ogr/qgsogrprovider.cpp @@ -2020,44 +2020,6 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri, return true; } -bool QgsOgrProvider::crsFromWkt( QgsCoordinateReferenceSystem &srs, const char *wkt ) -{ - void *hCRS = OSRNewSpatialReference( NULL ); - - if ( OSRImportFromWkt( hCRS, ( char ** ) &wkt ) == OGRERR_NONE ) - { - if ( OSRAutoIdentifyEPSG( hCRS ) == OGRERR_NONE ) - { - QString authid = QString( "%1:%2" ) - .arg( OSRGetAuthorityName( hCRS, NULL ) ) - .arg( OSRGetAuthorityCode( hCRS, NULL ) ); - QgsDebugMsg( "authid recognized as " + authid ); - srs.createFromOgcWmsCrs( authid ); - } - else - { - // get the proj4 text - char *pszProj4; - OSRExportToProj4( hCRS, &pszProj4 ); - QgsDebugMsg( pszProj4 ); - OGRFree( pszProj4 ); - - char *pszWkt = NULL; - OSRExportToWkt( hCRS, &pszWkt ); - QString myWktString = QString( pszWkt ); - OGRFree( pszWkt ); - - // create CRS from Wkt - srs.createFromWkt( myWktString ); - } - } - - OSRRelease( hCRS ); - - return srs.isValid(); -} - - QgsCoordinateReferenceSystem QgsOgrProvider::crs() { QgsDebugMsg( "entering." ); @@ -2078,7 +2040,7 @@ QgsCoordinateReferenceSystem QgsOgrProvider::crs() QString myWktString = prjStream.readLine(); prjFile.close(); - if ( crsFromWkt( srs, myWktString.toUtf8().constData() ) ) + if ( srs.createFromWkt( myWktString.toUtf8().constData() ) ) return srs; } } @@ -2095,7 +2057,8 @@ QgsCoordinateReferenceSystem QgsOgrProvider::crs() char *pszWkt = NULL; OSRExportToWkt( mySpatialRefSys, &pszWkt ); - crsFromWkt( srs, pszWkt ); + + srs.createFromWkt( pszWkt ); OGRFree( pszWkt ); } else diff --git a/src/providers/ogr/qgsogrprovider.h b/src/providers/ogr/qgsogrprovider.h index 6bb81de469f7..b09e97e5eff9 100644 --- a/src/providers/ogr/qgsogrprovider.h +++ b/src/providers/ogr/qgsogrprovider.h @@ -296,7 +296,6 @@ class QgsOgrProvider : public QgsVectorDataProvider static bool convertField( QgsField &field, const QTextCodec &encoding ); private: - bool crsFromWkt( QgsCoordinateReferenceSystem &srs, const char *wkt ); unsigned char *getGeometryPointer( OGRFeatureH fet ); QgsFieldMap mAttributeFields; OGRDataSourceH ogrDataSource;