We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 466631c commit 6d5df6bCopy full SHA for 6d5df6b
src/providers/postgres/qgspostgresprovider.cpp
@@ -3093,7 +3093,14 @@ QgsVectorLayerImport::ImportError QgsPostgresProvider::createEmptyLayer(
3093
QgsCoordinateReferenceSystem QgsPostgresProvider::crs()
3094
{
3095
QgsCoordinateReferenceSystem srs;
3096
- srs.createFromSrid( mRequestedSrid.isEmpty() ? mDetectedSrid.toInt() : mRequestedSrid.toInt() );
+ int srid = mRequestedSrid.isEmpty() ? mDetectedSrid.toInt() : mRequestedSrid.toInt();
3097
+ srs.createFromSrid( srid );
3098
+ if ( !srs.isValid() )
3099
+ {
3100
+ QgsPostgresResult result = mConnectionRO->PQexec( QString( "SELECT proj4text FROM spatial_ref_sys WHERE srid=%1" ).arg( srid ) );
3101
+ if ( result.PQresultStatus() == PGRES_TUPLES_OK )
3102
+ srs.createFromProj4( result.PQgetvalue( 0, 0 ) );
3103
+ }
3104
return srs;
3105
}
3106
0 commit comments