mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
[FEATURE] Detect topology support
This commit is contained in:
parent
5543a89bb0
commit
cbf63027db
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user