Skip to content
Permalink
Browse files

postgres provider: retrieve srs from postgis

  • Loading branch information
jef-n committed May 5, 2014
1 parent 466631c commit 6d5df6b8fda676e0fa911824c8db71a26c16bb80
Showing with 8 additions and 1 deletion.
  1. +8 −1 src/providers/postgres/qgspostgresprovider.cpp
@@ -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;
}

0 comments on commit 6d5df6b

Please sign in to comment.
You can’t perform that action at this time.