Skip to content

Commit acae4d6

Browse files
committedNov 7, 2011
when intializing from WKT favourize EPSG instead of PROJ.4
1 parent 4b12e5c commit acae4d6

File tree

3 files changed

+12
-41
lines changed

3 files changed

+12
-41
lines changed
 

‎src/core/qgscoordinatereferencesystem.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,15 @@ bool QgsCoordinateReferenceSystem::createFromWkt( QString theWkt )
314314
return mIsValidFlag;
315315
}
316316

317+
if ( OSRAutoIdentifyEPSG( mCRS ) == OGRERR_NONE )
318+
{
319+
QString authid = QString( "%1:%2" )
320+
.arg( OSRGetAuthorityName( mCRS, NULL ) )
321+
.arg( OSRGetAuthorityCode( mCRS, NULL ) );
322+
QgsDebugMsg( "authid recognized as " + authid );
323+
return createFromOgcWmsCrs( authid );
324+
}
325+
317326
// always morph from esri as it doesn't hurt anything
318327
// FW: Hey, that's not right! It can screw stuff up! Disable
319328
//myOgrSpatialRef.morphFromESRI();

‎src/providers/ogr/qgsogrprovider.cpp

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,44 +2020,6 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
20202020
return true;
20212021
}
20222022

2023-
bool QgsOgrProvider::crsFromWkt( QgsCoordinateReferenceSystem &srs, const char *wkt )
2024-
{
2025-
void *hCRS = OSRNewSpatialReference( NULL );
2026-
2027-
if ( OSRImportFromWkt( hCRS, ( char ** ) &wkt ) == OGRERR_NONE )
2028-
{
2029-
if ( OSRAutoIdentifyEPSG( hCRS ) == OGRERR_NONE )
2030-
{
2031-
QString authid = QString( "%1:%2" )
2032-
.arg( OSRGetAuthorityName( hCRS, NULL ) )
2033-
.arg( OSRGetAuthorityCode( hCRS, NULL ) );
2034-
QgsDebugMsg( "authid recognized as " + authid );
2035-
srs.createFromOgcWmsCrs( authid );
2036-
}
2037-
else
2038-
{
2039-
// get the proj4 text
2040-
char *pszProj4;
2041-
OSRExportToProj4( hCRS, &pszProj4 );
2042-
QgsDebugMsg( pszProj4 );
2043-
OGRFree( pszProj4 );
2044-
2045-
char *pszWkt = NULL;
2046-
OSRExportToWkt( hCRS, &pszWkt );
2047-
QString myWktString = QString( pszWkt );
2048-
OGRFree( pszWkt );
2049-
2050-
// create CRS from Wkt
2051-
srs.createFromWkt( myWktString );
2052-
}
2053-
}
2054-
2055-
OSRRelease( hCRS );
2056-
2057-
return srs.isValid();
2058-
}
2059-
2060-
20612023
QgsCoordinateReferenceSystem QgsOgrProvider::crs()
20622024
{
20632025
QgsDebugMsg( "entering." );
@@ -2078,7 +2040,7 @@ QgsCoordinateReferenceSystem QgsOgrProvider::crs()
20782040
QString myWktString = prjStream.readLine();
20792041
prjFile.close();
20802042

2081-
if ( crsFromWkt( srs, myWktString.toUtf8().constData() ) )
2043+
if ( srs.createFromWkt( myWktString.toUtf8().constData() ) )
20822044
return srs;
20832045
}
20842046
}
@@ -2095,7 +2057,8 @@ QgsCoordinateReferenceSystem QgsOgrProvider::crs()
20952057

20962058
char *pszWkt = NULL;
20972059
OSRExportToWkt( mySpatialRefSys, &pszWkt );
2098-
crsFromWkt( srs, pszWkt );
2060+
2061+
srs.createFromWkt( pszWkt );
20992062
OGRFree( pszWkt );
21002063
}
21012064
else

‎src/providers/ogr/qgsogrprovider.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,6 @@ class QgsOgrProvider : public QgsVectorDataProvider
296296
static bool convertField( QgsField &field, const QTextCodec &encoding );
297297

298298
private:
299-
bool crsFromWkt( QgsCoordinateReferenceSystem &srs, const char *wkt );
300299
unsigned char *getGeometryPointer( OGRFeatureH fet );
301300
QgsFieldMap mAttributeFields;
302301
OGRDataSourceH ogrDataSource;

0 commit comments

Comments
 (0)
Please sign in to comment.