Skip to content
Permalink
Browse files
update postgis capabilities detection
git-svn-id: http://svn.osgeo.org/qgis/trunk@15596 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Mar 25, 2011
1 parent af88da9 commit 9b114c800bd5bfe423480a0d5d0289d398c0b019
Showing with 32 additions and 18 deletions.
  1. +32 −18 src/providers/postgres/qgspostgresprovider.cpp
@@ -2207,29 +2207,43 @@ QString QgsPostgresProvider::Conn::postgisVersion()
postgisVersionMajor = postgisVersionParts[0].toInt();
postgisVersionMinor = postgisVersionParts[1].toInt();

// assume no capabilities
geosAvailable = false;
gistAvailable = false;
projAvailable = false;
mUseWkbHex = postgisVersionMajor < 1;

// parse out the capabilities and store them
QStringList geos = postgisParts.filter( "GEOS" );
if ( geos.size() == 1 )
{
geosAvailable = ( geos[0].indexOf( "=1" ) > -1 );
}
QStringList gist = postgisParts.filter( "STATS" );
if ( gist.size() == 1 )
// apparently postgis 1.5.2 doesn't report capabilities in postgis_version() anymore
if ( postgisVersionMajor > 1 || ( postgisVersionMajor == 1 && postgisVersionMinor >= 5 ) )
{
gistAvailable = ( geos[0].indexOf( "=1" ) > -1 );
result = PQexec( "select postgis_geos_version(),postgis_proj_version()" );
geosAvailable = PQntuples( result ) == 1 && !PQgetisnull( result, 0, 0 );
projAvailable = PQntuples( result ) == 1 && !PQgetisnull( result, 0, 1 );
QgsDebugMsg( QString( "geos:%1 proj:%2" )
.arg( geosAvailable ? PQgetvalue( result, 0, 0 ) : "none" )
.arg( projAvailable ? PQgetvalue( result, 0, 1 ) : "none" ) );
gistAvailable = true;
}
QStringList proj = postgisParts.filter( "PROJ" );
if ( proj.size() == 1 )
else
{
projAvailable = ( proj[0].indexOf( "=1" ) > -1 );
}
// assume no capabilities
geosAvailable = false;
gistAvailable = false;
projAvailable = false;

mUseWkbHex = postgisVersionMajor < 1;
// parse out the capabilities and store them
QStringList geos = postgisParts.filter( "GEOS" );
if ( geos.size() == 1 )
{
geosAvailable = ( geos[0].indexOf( "=1" ) > -1 );
}
QStringList gist = postgisParts.filter( "STATS" );
if ( gist.size() == 1 )
{
gistAvailable = ( geos[0].indexOf( "=1" ) > -1 );
}
QStringList proj = postgisParts.filter( "PROJ" );
if ( proj.size() == 1 )
{
projAvailable = ( proj[0].indexOf( "=1" ) > -1 );
}
}

gotPostgisVersion = true;

0 comments on commit 9b114c8

Please sign in to comment.