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)" ) );
|
"GEOS support (http://geos.refractions.net)" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( conn->hasTopology() )
|
||||||
|
{
|
||||||
|
QgsDebugMsg( "Topology support available!" );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return conn;
|
return conn;
|
||||||
@ -3008,9 +3013,22 @@ bool QgsPostgresProvider::Conn::hasGEOS()
|
|||||||
return geosAvailable;
|
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 */
|
/* Functions for determining available features in postGIS */
|
||||||
QString QgsPostgresProvider::Conn::postgisVersion()
|
QString QgsPostgresProvider::Conn::postgisVersion()
|
||||||
{
|
{
|
||||||
|
if ( gotPostgisVersion ) return postgisVersionInfo;
|
||||||
|
|
||||||
postgresqlVersion = PQserverVersion( conn );
|
postgresqlVersion = PQserverVersion( conn );
|
||||||
|
|
||||||
Result result = PQexec( "select postgis_version()" );
|
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;
|
gotPostgisVersion = true;
|
||||||
|
|
||||||
return postgisVersionInfo;
|
return postgisVersionInfo;
|
||||||
|
@ -644,6 +644,9 @@ class QgsPostgresProvider : public QgsVectorDataProvider
|
|||||||
//! get status of GEOS capability
|
//! get status of GEOS capability
|
||||||
bool hasGEOS();
|
bool hasGEOS();
|
||||||
|
|
||||||
|
//! get status of topology capability
|
||||||
|
bool hasTopology();
|
||||||
|
|
||||||
//! get status of GIST capability
|
//! get status of GIST capability
|
||||||
bool hasGIST();
|
bool hasGIST();
|
||||||
|
|
||||||
@ -693,10 +696,13 @@ class QgsPostgresProvider : public QgsVectorDataProvider
|
|||||||
//! GEOS capability
|
//! GEOS capability
|
||||||
bool geosAvailable;
|
bool geosAvailable;
|
||||||
|
|
||||||
|
//! Topology capability
|
||||||
|
bool topologyAvailable;
|
||||||
|
|
||||||
//! PostGIS version string
|
//! PostGIS version string
|
||||||
QString postgisVersionInfo;
|
QString postgisVersionInfo;
|
||||||
|
|
||||||
//! Are postgisVersionMajor, postgisVersionMinor, geosAvailable, gistAvailable, projAvailable valid?
|
//! Are postgisVersionMajor, postgisVersionMinor, geosAvailable, gistAvailable, projAvailable, topologyAvailable valid?
|
||||||
bool gotPostgisVersion;
|
bool gotPostgisVersion;
|
||||||
|
|
||||||
//! PostgreSQL version
|
//! PostgreSQL version
|
||||||
|
Loading…
x
Reference in New Issue
Block a user