Skip to content

Commit

Permalink
spatialite provider: prefer auth_id over proj4 string (fix #4958)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 7, 2012
1 parent c5f7f1e commit 6878bf1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/providers/spatialite/qgsspatialiteprovider.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3350,7 +3350,11 @@ void QgsSpatiaLiteProvider::rewind()
QgsCoordinateReferenceSystem QgsSpatiaLiteProvider::crs() QgsCoordinateReferenceSystem QgsSpatiaLiteProvider::crs()
{ {
QgsCoordinateReferenceSystem srs; QgsCoordinateReferenceSystem srs;
srs.createFromProj4( mProj4text ); srs.createFromOgcWmsCrs( mAuthId );
if ( !srs.isValid() )
{
srs.createFromProj4( mProj4text );
}
return srs; return srs;
} }


Expand Down Expand Up @@ -4777,7 +4781,7 @@ bool QgsSpatiaLiteProvider::getSridDetails()
int columns; int columns;
char *errMsg = NULL; char *errMsg = NULL;


QString sql = QString( "SELECT proj4text FROM spatial_ref_sys WHERE srid=%1" ).arg( mSrid ); QString sql = QString( "SELECT auth_name||':'||auth_srid,proj4text FROM spatial_ref_sys WHERE srid=%1" ).arg( mSrid );


ret = sqlite3_get_table( sqliteHandle, sql.toUtf8().constData(), &results, &rows, &columns, &errMsg ); ret = sqlite3_get_table( sqliteHandle, sql.toUtf8().constData(), &results, &rows, &columns, &errMsg );
if ( ret != SQLITE_OK ) if ( ret != SQLITE_OK )
Expand All @@ -4788,7 +4792,8 @@ bool QgsSpatiaLiteProvider::getSridDetails()
{ {
for ( i = 1; i <= rows; i++ ) for ( i = 1; i <= rows; i++ )
{ {
mProj4text = results[( i * columns ) + 0]; mAuthId = results[( i * columns ) + 0];
mProj4text = results[( i * columns ) + 1];
} }
} }
sqlite3_free_table( results ); sqlite3_free_table( results );
Expand Down
4 changes: 4 additions & 0 deletions src/providers/spatialite/qgsspatialiteprovider.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -363,6 +363,10 @@ class QgsSpatiaLiteProvider: public QgsVectorDataProvider
* Spatial reference id of the layer * Spatial reference id of the layer
*/ */
int mSrid; int mSrid;
/**
* auth id
*/
QString mAuthId;
/** /**
* proj4text * proj4text
*/ */
Expand Down

0 comments on commit 6878bf1

Please sign in to comment.