Skip to content

Commit

Permalink
update postgis capabilities detection
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15596 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Mar 25, 2011
1 parent 5f0d92b commit a3e94e1
Showing 1 changed file with 32 additions and 18 deletions.
50 changes: 32 additions & 18 deletions src/providers/postgres/qgspostgresprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit a3e94e1

Please sign in to comment.