📄 qgspostgresprovider.h
字号:
* provider. */ void fullExtentCalculated(); /** * This is emitted when this provider is satisfied that all objects * have had a chance to adjust themselves after they'd been notified that * the full extent is available. * * \note It currently isn't being emitted because we don't have an easy way * for the overview canvas to only be repainted. In the meantime * we are satisfied for the overview to reflect the new extent * when the user adjusts the extent of the main map canvas. */ void repaintRequested(); private: int providerId; // id to append to provider specific identified (like cursors) bool declareCursor(const QString &cursorName, const QgsAttributeList &fetchAttributes, bool fetchGeometry, QString whereClause); bool getFeature(PGresult *queryResult, int row, bool fetchGeometry, QgsFeature &feature, const QgsAttributeList &fetchAttributes); const QgsField &field(int index) const; /** Double quote a PostgreSQL identifier for placement in a SQL string. */ QString quotedIdentifier( QString ident ) const; /** Quote a value for placement in a SQL string. */ QString quotedValue( QString value ) const; /** Load the field list */ void loadFields(); bool mFetching; // true if a cursor was declared std::vector < QgsFeature > features; QgsFieldMap attributeFields; QString mDataComment; //! Data source URI struct for this layer QgsDataSourceURI mUri; //! Child thread for calculating extents. QgsPostgresExtentThread mExtentThread; //! Child thread for calculating count. QgsPostgresCountThread mCountThread; /** * Flag indicating if the layer data source is a valid PostgreSQL layer */ bool valid; /** * Name of the table with no schema */ QString mTableName; /** * Name of the table with schema included */ QString mSchemaTableName; /** * Name of the schema */ QString mSchemaName; /** * Name of the current schema */ QString mCurrentSchema; /** * SQL statement used to limit the features retrieved */ QString sqlWhereClause; /** * Primary key column for fetching features. If there is no primary key * the oid is used to fetch features. */ QString primaryKey; /** * Data type for the primary key */ QString primaryKeyType; /** * Name of the geometry column in the table */ QString geometryColumn; /** * Geometry type */ QGis::WKBTYPE geomType; /** * Connection pointer */ PGconn *connection; /** * Spatial reference id of the layer */ QString srid; /** * Rectangle that contains the extent (bounding box) of the layer */ QgsRect layerExtent; /** * Number of features in the layer */ long numberFeatures; /** * Feature queue that GetNextFeature will retrieve from * before the next fetch from PostgreSQL */ std::queue<QgsFeature> mFeatureQueue; /** * Maximal size of the feature queue */ int mFeatureQueueSize; /** * Flag indicating whether data from binary cursors must undergo an * endian conversion prior to use @note XXX Umm, it'd be helpful to know what we're swapping from and to. XXX Presumably this means swapping from big-endian (network) byte order XXX to little-endian; but the inverse transaction is possible, too, and XXX that's not reflected in this variable */ bool swapEndian; bool deduceEndian(); bool getGeometryDetails(); PGresult* executeDbCommand(PGconn* connection, const QString& sql); // Produces a QMessageBox with the given title and text. Doesn't // return until the user has dismissed the dialog box. static void showMessageBox(const QString& title, const QString& text); static void showMessageBox(const QString& title, const QStringList& text); // A simple class to store the rows of the sql executed in the // findColumns() function. class TT { public: TT() {}; QString view_schema; QString view_name; QString view_column_name; QString table_schema; QString table_name; QString column_name; QString table_type; QString column_type; }; struct PGFieldNotFound { }; struct PGException { PGException(PGresult *r) : result(r) { } PGException(const PGException &e) : result(e.result) { } ~PGException() { if(result) PQclear(result); } QString errorMessage() const { return result ? QString::fromUtf8(PQresultErrorMessage(result)) : tr("unexpected PostgreSQL error"); } void showErrorMessage(QString title) const { showMessageBox(title, errorMessage() ); } private: PGresult *result; }; // A simple class to store four strings class SRC { public: SRC() {}; SRC(QString s, QString r, QString c, QString t) : schema(s), relation(r), column(c), type(t) {}; QString schema, relation, column, type; }; // A structure to store the underlying schema.table.column for // each column in mSchemaName.mTableName typedef std::map<QString, SRC> tableCols; // A function that chooses a view column that is suitable for use // a the qgis key column. QString chooseViewColumn(const tableCols& cols); // A function that determines if the given schema.table.column // contains unqiue entries bool uniqueData(QString schemaName, QString tableName, QString colName); // Function that populates the given cols structure. void findColumns(tableCols& cols); /**Helper function that collects information about the origin and type of a view column. Inputs are information about the column in the underlying table (from information_schema.view_column_usage), the attribute name in the view and the view definition. For view columns that refer to other views, this function calls itself until a table entry is found. @param ns namespace of underlying table @param relname name of underlying relation @param attname attribute name in underlying table @param viewDefinition definition of this view @param result @return 0 in case of success*/ int SRCFromViewColumn(const QString& ns, const QString& relname, const QString& attname_table, const QString& attname_view, const QString& viewDefinition, SRC& result) const; //! PostGIS version string QString postgisVersionInfo; //! Are postgisVersionMajor, postgisVersionMinor, geosAvailable, gistAvailable, projAvailable valid? bool gotPostgisVersion; //! PostGIS major version int postgisVersionMajor; //! PostGIS minor version int postgisVersionMinor; //! GEOS capability bool geosAvailable; //! GIST capability bool gistAvailable; //! PROJ4 capability bool projAvailable; int enabledCapabilities; /**Returns the maximum value of the primary key attribute @note You should run this inside of a PostgreSQL transaction so that you can safely increment the value returned for use in newly added features. */ int maxPrimaryKeyValue(); //! Get the feature count based on the where clause long getFeatureCount(); //! Calculate the extents of the layer void calculateExtents(); /** * Event sink for events from threads */ void customEvent ( QCustomEvent *e ); PGconn *connectDb(const QString &conninfo); void disconnectDb(); bool useWkbHex; void appendGeomString(QgsGeometry *geom, QString &geomParam) const; QByteArray paramValue(QString fieldvalue, const QString &defaultValue) const; // run a query and check for errors static PGresult *PQexec(PGconn *conn, const char *query); // run a query and free result buffer static bool PQexecNR(PGconn *conn, const char *query); struct Conn { Conn(PGconn *connection) : ref(1), conn(connection) {} int ref; PGconn *conn; }; static QMap<QString, Conn *> connections; static int providerIds;};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -