⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qgsgrassprovider.h

📁 一个非常好的GIS开源新版本
💻 H
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************    qgsgrassprovider.h  -  Data provider for GRASS format                             -------------------    begin                : March, 2004    copyright            : (C) 2004 by Gary E.Sherman, Radim Blazek    email                : sherman@mrcc.com, blazek@itc.it ***************************************************************************//*************************************************************************** *                                                                         * *   This program is free software; you can redistribute it and/or modify  * *   it under the terms of the GNU General Public License as published by  * *   the Free Software Foundation; either version 2 of the License, or     * *   (at your option) any later version.                                   * *                                                                         * ***************************************************************************/#ifndef QGSGRASSPROVIDER_H#define QGSGRASSPROVIDER_Hclass QgsFeature;class QgsField;#include <QDateTime>#include "qgsvectordataprovider.h"/* Update. * Vectors are updated (reloaded) if: * 1) Vector was find to be outdated on some occasion. Currently the only occasion is the beginning *    of QgsGrassProvider::select()  *    Note that if the vector was rewritten by GRASS module and it was not yet updated in QGIS, *    it should read without problems from old (deleted file), at least on local disk on *nix system. *    (NFS - cache, Cygwin?) * * 2) Editing is closed by closeEdit *  * Member variables which must be updated after updateMap() are marked !UPDATE! in this file. *//* Freezing. * Because open file cannot be deleted on Windows it is necessary to * close output vector from GRASS tools before a module is run. * This is not however solution for multiple instances of QGIS. */ /* Editing. * If editing is started by startEdit, vector map is reopened in update mode, and GMAP.update  * is set to true. All data loaded from the map to QgsGrassProvider remain unchanged * untill closeEdit is called.  * During editing: * getNextFeature() and getFirstFeature() returns 0 * featureCount() returns 0 * fieldCount() returns original (old) number of fields *//* Attributes. Cache of database attributes (because selection from database is slow). */struct GATT{  int cat;       // category  char **values; // pointer to array of pointers to values};/* Grass layer (unique vector+field). */struct GLAYER{  QString path;                  // path to the layer gisdbase+location+mapset+mapName  int     field;                 // field number  bool    valid;                 // valid is true if layer is opened, once the layer is closed,  // valid is set to false and no more used  int     mapId;                 // map ID in maps vector  struct  Map_info   *map;       // map header  struct  field_info *fieldInfo; // field info  int     nColumns;              // number of columns in database table, if 0, attributes are not available  // and category (column name 'cat') is used instead  int     keyColumn;             // number of key column  QgsFieldMap fields;  // description of layer fields  int     nAttributes;           // number of attributes read to the memory (may be < nRecords)  GATT    *attributes;           // vector of attributes  double  (*minmax)[2];          // minimum and maximum values of attributes  int     nUsers;                // number of instances using this layer, increased by open(),  // decreased by close()};/* Grass vector map. */struct GMAP{  QString gisdbase;      // map gisdabase  QString location;      // map location name (not path!)  QString mapset;        // map mapset  QString mapName;       // map name  QString path;          // path to the layer gisdbase+location+mapset+mapName  bool    valid;         // true if map is opened, once the map is closed,  // valid is set to false and no more used    // Vector temporally disabled. Necessary for GRASS Tools on Windows  bool frozen;	  struct  Map_info *map; // map header  int     nUsers;        // number layers using this map  int     update;        // true if the map is opened in update mode -> disabled standard reading  // through getNextFeature(), featureCount() returns 0  QDateTime lastModified; // last modified time of the vector directory, when the map was opened  QDateTime lastAttributesModified; // last modified time of the vector 'dbln' file, when the map was opened                            // or attributes were updated. The 'dbln' file is updated by v.to.db etc.                            // when attributes are changed  int     version;       // version, increased by each closeEdit() and updateMap()};/**  \class QgsGrassProvider  \brief Data provider for GRASS vectors*/class GRASS_EXPORT QgsGrassProvider : public QgsVectorDataProvider{public:  QgsGrassProvider(QString uri = QString());  virtual ~QgsGrassProvider();  /**    *   Returns the permanent storage type for this layer as a friendly name.    */  virtual QString storageType() const;    /** Select features based on a bounding rectangle. Features can be retrieved with calls to getNextFeature.   *  @param fetchAttributes list of attributes which should be fetched   *  @param rect spatial filter   *  @param fetchGeometry true if the feature geometry should be fetched   *  @param useIntersect true if an accurate intersection test should be used,   *                     false if a test based on bounding box is sufficient   *   * @note This function works only until first edit operation! (category index used)   */  virtual void select(QgsAttributeList fetchAttributes = QgsAttributeList(),                      QgsRect rect = QgsRect(),                      bool fetchGeometry = true,                      bool useIntersect = false);  /**   * Get the next feature resulting from a select operation.   * @param feature feature which will receive data from the provider   * @return true when there was a feature to fetch, false when end was hit   */  virtual bool getNextFeature(QgsFeature& feature);      /**    * Get the feature type as defined in WKBTYPE (qgis.h).    * @return int representing the feature type   */  QGis::WKBTYPE geometryType() const;  /**    * Get the number of features in the layer   */  long featureCount() const;  /**    * Get the number of fields in the layer   */  uint fieldCount() const;	  /** Return the extent for this data layer   */  virtual QgsRect extent();  /**   * Get the field information for the layer   */  const QgsFieldMap & fields() const;  // ! Key (category) field index  int keyField();	   /** Restart reading features from previous select operation */  void reset();  /** Returns the minimum value of an attributs   *  @param index the index of the attribute */  QVariant minValue(int index);  /** Returns the maximum value of an attributs   *  @param index the index of the attribute */  QVariant maxValue(int index);  /** Update (reload) non static members (marked !UPDATE!) from the static layer and the map.   *   This method MUST be called whenever lastUpdate of the map is later then mapLastUpdate    *   of the instance.   */  void update();  /**Returns true if this is a valid layer   */  bool isValid();  QgsSpatialRefSys getSRS();    // ----------------------------------- Edit ----------------------------------	  /** Is the layer editable? I.e. the layer is valid and current user is owner of the mapset   *   @return true the layer editable   *   @return false the is not editable   */  bool isGrassEditable();  /** Returns true if the layer is currently edited (opened in update mode)   *   @return true in update mode   *   @return false not edited   */  bool isEdited();  /** Returns true if the layer is currently froze, i.e. a module   *  from GRASS Tools is writing to this vector   *   @return true in update mode   *   @return false not edited   */  bool isFrozen();  /** Start editing. Reopen the vector for update and set GMAP.update = true   *   @return true is frozen    *   @return false is not frozen   */  bool startEdit();  /** Freeze vector.    */  void freeze();  /** Thaw vector.    */  void thaw();  /** Close editing. Rebuild topology, GMAP.update = false    *   @param newMap set to true if a new map was created   *          and it is not yet used as layer    *   @return true success   *   @return false failed to close vector or vector was not in update mode   */  bool closeEdit( bool newMap=false );  /** Get current number of lines.    *   @return number of lines   */  int numLines ( void );  /** Get current number of nodes.    *   @return number of nodes   */  int numNodes ( void );  /** Read line    *   @param Points pointer to existing structure or NULL   *   @param Cats pointer to existing structure or NULL   *   @param line line number   *   @return line type   *   @return <0 deadline or error   */  int readLine ( struct line_pnts * Points, struct line_cats * Cats, int line );  /** Read node coordinates    *   @param line line number   *   @return true node is alive   *   @return false node is dead   */  bool nodeCoor ( int node, double *x, double *y );  /** Read line nodes    *   @param line line number   *   @return true line is alive   *   @return false line is dead   */  bool lineNodes ( int line, int *node1, int *node2 );  /** Read boundary areas    *   @param line line number   *   @return true line is alive   *   @return false line is dead   */  bool lineAreas ( int line, int *left, int *right );  /** Get centroid area    *   @param centroid line number   *   @return area number (negative for island)   */  int centroidArea ( int centroid );  /** Get number of lines at node    *   @param node node number   *   @return number of lines at node (including dead lines)   */  int nodeNLines ( int node );  /** Get line number of line at node for given line index   *   @param node node number   *   @param idx line index   *   @return line number   */  int nodeLine ( int node, int idx );  /** True if line is alive   *   @param line line number   *   @return true alive   *   @return false dead   */  int lineAlive ( int line );  /** True if node is alive   *   @param node node number   *   @return true alive   *   @return false dead   */  int nodeAlive ( int node );  /** Write a new line into vector.    *   @return line number   *   @return -1 error   */  int writeLine ( int type, struct line_pnts *Points, struct line_cats *Cats );  /** Rewrite line.    *   @return line number   *   @return -1 error   */  int rewriteLine ( int line, int type, struct line_pnts *Points, struct line_cats *Cats );  /** Delete line    *   @return 0 OK   *   @return -1 error   */  int deleteLine ( int line );  /** Number of updated lines    */  int numUpdatedLines ( void );  /** Number of updated nodes    */  int numUpdatedNodes ( void );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -