Skip to content

Commit

Permalink
postgres provider: retrieve srs from postgis
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed May 5, 2014
1 parent 466631c commit 6d5df6b
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -3093,7 +3093,14 @@ QgsVectorLayerImport::ImportError QgsPostgresProvider::createEmptyLayer(
QgsCoordinateReferenceSystem QgsPostgresProvider::crs()
{
QgsCoordinateReferenceSystem srs;
srs.createFromSrid( mRequestedSrid.isEmpty() ? mDetectedSrid.toInt() : mRequestedSrid.toInt() );
int srid = mRequestedSrid.isEmpty() ? mDetectedSrid.toInt() : mRequestedSrid.toInt();
srs.createFromSrid( srid );
if ( !srs.isValid() )
{
QgsPostgresResult result = mConnectionRO->PQexec( QString( "SELECT proj4text FROM spatial_ref_sys WHERE srid=%1" ).arg( srid ) );
if ( result.PQresultStatus() == PGRES_TUPLES_OK )
srs.createFromProj4( result.PQgetvalue( 0, 0 ) );
}
return srs;
}

Expand Down

0 comments on commit 6d5df6b

Please sign in to comment.