Skip to content
Permalink
Browse files
[FEATURE] Detect topology support
  • Loading branch information
Sandro Santilli authored and jef-n committed Nov 25, 2011
1 parent 5543a89 commit cbf63027dbb06fc4b25e67eeaa6a3b477c2481f9
Showing with 37 additions and 1 deletion.
  1. +30 −0 src/providers/postgres/qgspostgresprovider.cpp
  2. +7 −1 src/providers/postgres/qgspostgresprovider.h
@@ -674,6 +674,11 @@ QgsPostgresProvider::Conn *QgsPostgresProvider::Conn::connectDb( const QString &
"GEOS support (http://geos.refractions.net)" ) );
}

if ( conn->hasTopology() )
{
QgsDebugMsg( "Topology support available!" );
}



return conn;
@@ -3008,9 +3013,22 @@ bool QgsPostgresProvider::Conn::hasGEOS()
return geosAvailable;
}

/**
* Check to see if topology is available
*/
bool QgsPostgresProvider::Conn::hasTopology()
{
// make sure info is up to date for the current connection
postgisVersion();
// get topology capability
return topologyAvailable;
}

/* Functions for determining available features in postGIS */
QString QgsPostgresProvider::Conn::postgisVersion()
{
if ( gotPostgisVersion ) return postgisVersionInfo;

postgresqlVersion = PQserverVersion( conn );

Result result = PQexec( "select postgis_version()" );
@@ -3075,6 +3093,18 @@ QString QgsPostgresProvider::Conn::postgisVersion()
}
}

// checking for topology support
QgsDebugMsg( "Checking for topology support" );
topologyAvailable = false;
if ( postgisVersionMajor > 1 )
{
Result result = PQexec( "select count(c.oid) from pg_class as c join pg_namespace as n on c.relnamespace = n.oid where n.nspname = 'topology' and c.relname = 'topology'" );
if ( PQntuples( result ) >= 1 )
{
topologyAvailable = true;
}
}

gotPostgisVersion = true;

return postgisVersionInfo;
@@ -644,6 +644,9 @@ class QgsPostgresProvider : public QgsVectorDataProvider
//! get status of GEOS capability
bool hasGEOS();

//! get status of topology capability
bool hasTopology();

//! get status of GIST capability
bool hasGIST();

@@ -693,10 +696,13 @@ class QgsPostgresProvider : public QgsVectorDataProvider
//! GEOS capability
bool geosAvailable;

//! Topology capability
bool topologyAvailable;

//! PostGIS version string
QString postgisVersionInfo;

//! Are postgisVersionMajor, postgisVersionMinor, geosAvailable, gistAvailable, projAvailable valid?
//! Are postgisVersionMajor, postgisVersionMinor, geosAvailable, gistAvailable, projAvailable, topologyAvailable valid?
bool gotPostgisVersion;

//! PostgreSQL version

0 comments on commit cbf6302

Please sign in to comment.