[QGIS Commit] r15596 - trunk/qgis/src/providers/postgres
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Fri Mar 25 02:45:35 EDT 2011
Author: jef
Date: 2011-03-24 23:45:35 -0700 (Thu, 24 Mar 2011)
New Revision: 15596
Modified:
trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp
Log:
update postgis capabilities detection
Modified: trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp
===================================================================
--- trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp 2011-03-25 06:43:27 UTC (rev 15595)
+++ trunk/qgis/src/providers/postgres/qgspostgresprovider.cpp 2011-03-25 06:45:35 UTC (rev 15596)
@@ -2207,30 +2207,44 @@
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 )
+ // apparently postgis 1.5.2 doesn't report capabilities in postgis_version() anymore
+ if ( postgisVersionMajor > 1 || ( postgisVersionMajor == 1 && postgisVersionMinor >= 5 ) )
{
- geosAvailable = ( 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 gist = postgisParts.filter( "STATS" );
- if ( gist.size() == 1 )
+ else
{
- gistAvailable = ( geos[0].indexOf( "=1" ) > -1 );
+ // assume no capabilities
+ geosAvailable = false;
+ gistAvailable = false;
+ projAvailable = false;
+
+ // 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 );
+ }
}
- QStringList proj = postgisParts.filter( "PROJ" );
- if ( proj.size() == 1 )
- {
- projAvailable = ( proj[0].indexOf( "=1" ) > -1 );
- }
- mUseWkbHex = postgisVersionMajor < 1;
-
gotPostgisVersion = true;
return postgisVersionInfo;
More information about the QGIS-commit
mailing list