47
47
/* Attributes. Cache of database attributes (because selection from database is slow). */
50
char **values; // pointer to array of pointers to values
51
char **values; // pointer to array of pointers to values
53
54
/* Grass layer (unique vector+field). */
55
QString path; // path to the layer gisdbase+location+mapset+mapName
56
int field; // field number
57
bool valid; // valid is true if layer is opened, once the layer is closed,
58
// valid is set to false and no more used
59
int mapId; // map ID in maps vector
60
struct Map_info *map; // map header
61
struct field_info *fieldInfo; // field info
62
int nColumns; // number of columns in database table, if 0, attributes are not available
63
// and category (column name 'cat') is used instead
64
int keyColumn; // number of key column
65
std::vector<QgsField> fields; // description of layer fields
66
int nAttributes; // number of attributes read to the memory (may be < nRecords)
67
GATT *attributes; // vector of attributes
68
double (*minmax)[2]; // minimum and maximum values of attributes
69
int nUsers; // number of instances using this layer, increased by open(),
70
// decreased by close()
57
QString path; // path to the layer gisdbase+location+mapset+mapName
58
int field; // field number
59
bool valid; // valid is true if layer is opened, once the layer is closed,
60
// valid is set to false and no more used
61
int mapId; // map ID in maps vector
62
struct Map_info *map; // map header
63
struct field_info *fieldInfo; // field info
64
int nColumns; // number of columns in database table, if 0, attributes are not available
65
// and category (column name 'cat') is used instead
66
int keyColumn; // number of key column
67
std::vector<QgsField> fields; // description of layer fields
68
int nAttributes; // number of attributes read to the memory (may be < nRecords)
69
GATT *attributes; // vector of attributes
70
double (*minmax)[2]; // minimum and maximum values of attributes
71
int nUsers; // number of instances using this layer, increased by open(),
72
// decreased by close()
73
75
/* Grass vector map. */
75
QString gisdbase; // map gisdabase
76
QString location; // map location name (not path!)
77
QString mapset; // map mapset
78
QString mapName; // map name
79
QString path; // path to the layer gisdbase+location+mapset+mapName
80
bool valid; // true if map is opened, once the map is closed,
81
// valid is set to false and no more used
82
struct Map_info *map; // map header
83
int nUsers; // number layers using this map
84
int update; // true if the map is opened in update mode -> disabled standard reading
85
// through getNextFeature(), featureCount() returns 0
86
QDateTime lastModified; // lastModified time of the vector directory, when the map was opened
87
int version; // version, increased by each closeEdit() and updateMap()
78
QString gisdbase; // map gisdabase
79
QString location; // map location name (not path!)
80
QString mapset; // map mapset
81
QString mapName; // map name
82
QString path; // path to the layer gisdbase+location+mapset+mapName
83
bool valid; // true if map is opened, once the map is closed,
84
// valid is set to false and no more used
85
struct Map_info *map; // map header
86
int nUsers; // number layers using this map
87
int update; // true if the map is opened in update mode -> disabled standard reading
88
// through getNextFeature(), featureCount() returns 0
89
QDateTime lastModified; // last modified time of the vector directory, when the map was opened
90
QDateTime lastAttributesModified; // last modified time of the vector 'dbln' file, when the map was opened
91
// or attributes were updated. The 'dbln' file is updated by v.to.db etc.
92
// when attributes are changed
93
int version; // version, increased by each closeEdit() and updateMap()
91
97
\class QgsGrassProvider
92
98
\brief Data provider for GRASS vectors
94
class QgsGrassProvider : public QgsVectorDataProvider {
100
class QgsGrassProvider : public QgsVectorDataProvider
96
QgsGrassProvider(QString uri=0);
97
virtual ~QgsGrassProvider();
100
* Get the first feature resulting from a select operation
103
QgsFeature * getFirstFeature(bool fetchAttributes=false);
106
* Get the next feature resutling from a select operation
109
QgsFeature * getNextFeature(bool fetchAttributes=false);
110
bool getNextFeature(QgsFeature &feature, bool fetchAttributes=false);
111
QgsFeature* getNextFeature(std::list<int>& attlist);
114
* Get the feature type as defined in WKBTYPE (qgis.h).
115
* @return int representing the feature type
120
* Get the number of features in the layer
125
* Get the number of fields in the layer
130
* Select features based on a bounding rectangle. Features can be retrieved
131
* with calls to getFirstFeature and getNextFeature.
132
* @param mbr QgsRect containing the extent to use in selecting features
134
void select(QgsRect *mbr, bool useIntersect=false);
137
* Set the data source specification. This may be a path or database
139
* @uri data source specification
141
void setDataSourceUri(QString uri);
144
* Get the data source specification. This may be a path or database
146
* @return data source specification
148
QString getDataSourceUri();
151
* Identify features within the search radius specified by rect
152
* @param rect Bounding rectangle of search radius
153
* @return std::vector containing QgsFeature objects that intersect rect
155
virtual std::vector<QgsFeature>& identify(QgsRect *rect);
157
/** Return endian-ness for this layer
161
/** Return the extent for this data layer
163
virtual QgsRect *extent();
166
* Get the field information for the layer
168
std::vector<QgsField>& fields();
104
QgsGrassProvider(QString uri=0);
106
virtual ~QgsGrassProvider();
108
/** Used to ask the layer for its projection as a WKT string. Implements
109
* virtual method of same name in QgsDataProvider. */
110
QString getProjectionWKT(void);
112
/* Following functions work only until first edit operation! (category index used) */
115
* Get the first feature resulting from a select operation
118
QgsFeature * getFirstFeature(bool fetchAttributes=false);
121
* Get the next feature resutling from a select operation
124
QgsFeature * getNextFeature(bool fetchAttributes=false);
125
bool getNextFeature(QgsFeature &feature, bool fetchAttributes=false);
126
QgsFeature* getNextFeature(std::list<int> const & attlist);
129
* Get the feature type as defined in WKBTYPE (qgis.h).
130
* @return int representing the feature type
132
int geometryType() const;
135
* Get the number of features in the layer
137
long featureCount() const;
140
* Get the number of fields in the layer
142
int fieldCount() const;
145
* Select features based on a bounding rectangle. Features can be retrieved
146
* with calls to getFirstFeature and getNextFeature.
147
* @param mbr QgsRect containing the extent to use in selecting features
149
void select(QgsRect *mbr, bool useIntersect=false);
152
* Set the data source specification. This may be a path or database
154
* @uri data source specification
156
void setDataSourceUri(QString uri);
159
* Get the data source specification. This may be a path or database
161
* @return data source specification
163
QString getDataSourceUri();
166
* Identify features within the search radius specified by rect
167
* @param rect Bounding rectangle of search radius
168
* @return std::vector containing QgsFeature objects that intersect rect
170
virtual std::vector<QgsFeature>& identify(QgsRect *rect);
172
/** Return the extent for this data layer
174
virtual QgsRect *extent();
177
* Get the field information for the layer
179
std::vector<QgsField> const& fields() const;
170
/* Reset the layer - for an OGRLayer, this means clearing the
171
* spatial filter and calling ResetReading
175
/**Returns the minimum value of an attribut
176
@param position the number of the attribute*/
177
QString minValue(int position);
179
/**Returns the maximum value of an attribut
180
@param position the number of the attribute*/
181
QString maxValue(int position);
183
/** Update (reload) non static members (marked !UPDATE!) from the static layer and the map.
184
* This method MUST be called whenever lastUpdate of the map is later then mapLastUpdate
189
/**Returns true if this is a valid layer
193
// ----------------------------------- Edit ----------------------------------
195
/** Is the layer editable? I.e. the layer is valid and current user is owner of the mapset
196
* @return true the layer editable
197
* @return false the is not editable
199
bool isGrassEditable();
201
/** Returns true if the layer is currently edited (opened in update mode)
202
* @return true in update mode
203
* @return false not edited
207
/** Start editing. Reopen the vector for update and set GMAP.update = true
208
* @return true success
209
* @return false failed to reopen success
213
/** Close editing. Rebuild topology, GMAP.update = false
214
* @return true success
215
* @return false failed to close vector or vector was not in update mode
219
/** Get current number of lines.
220
* @return number of lines
222
int numLines ( void );
224
/** Get current number of nodes.
225
* @return number of nodes
227
int numNodes ( void );
230
* @param Points pointer to existing structure or NULL
231
* @param Cats pointer to existing structure or NULL
232
* @param line line number
234
* @return <0 deadline or error
236
int readLine ( struct line_pnts * Points, struct line_cats * Cats, int line );
238
/** Read node coordinates
239
* @param line line number
240
* @return true node is alive
241
* @return false node is dead
243
bool nodeCoor ( int node, double *x, double *y );
246
* @param line line number
247
* @return true line is alive
248
* @return false line is dead
250
bool lineNodes ( int line, int *node1, int *node2 );
252
/** Read boundary areas
253
* @param line line number
254
* @return true line is alive
255
* @return false line is dead
257
bool lineAreas ( int line, int *left, int *right );
259
/** Get centroid area
260
* @param centroid line number
261
* @return area number (negative for island)
263
int centroidArea ( int centroid );
265
/** Get number of lines at node
266
* @param node node number
267
* @return number of lines at node (including dead lines)
269
int nodeNLines ( int node );
271
/** Get line number of line at node for given line index
272
* @param node node number
273
* @param idx line index
274
* @return line number
276
int nodeLine ( int node, int idx );
278
/** True if line is alive
279
* @param line line number
283
int lineAlive ( int line );
285
/** True if node is alive
286
* @param node node number
290
int nodeAlive ( int node );
292
/** Write a new line into vector.
293
* @return line number
296
int writeLine ( int type, struct line_pnts *Points, struct line_cats *Cats );
299
* @return line number
302
int rewriteLine ( int line, int type, struct line_pnts *Points, struct line_cats *Cats );
308
int deleteLine ( int line );
310
/** Number of updated lines
312
int numUpdatedLines ( void );
314
/** Number of updated nodes
316
int numUpdatedNodes ( void );
320
int updatedLine ( int idx );
324
int updatedNode ( int idx );
326
/** Find nearest line
327
* @param threshold maximum distance
328
* @return line number
329
* @return 0 nothing found
331
int findLine ( double x, double y, int type, double threshold );
333
/** Find nearest node
334
* @param threshold maximum distance
335
* @return node number
336
* @return 0 nothing found
338
int findNode ( double x, double y, double threshold );
340
/** Get columns' definitions
343
* @return vector of attributes
345
std::vector<QgsField> *columns ( int field );
347
/** Read attributes from DB
350
* @return vector of attributes
352
std::vector<QgsFeatureAttribute> *attributes ( int field, int cat );
354
/** Key (cat) column name
356
* @return Key column name or empty string
358
QString *key ( int field );
360
/** Get number of db links
361
* @return number of links
363
int numDbLinks ( void );
365
/** Get db link field
367
* @return field number or 0
369
int dbLinkField ( int link );
371
/** Update attributes
374
* @param update comma separated update string, e.g.: col1 = 5, col2 = 'Val d''Aosta'
375
* @return empty string or error message
377
QString *updateAttributes ( int field, int cat, const QString &values );
379
/** Insert new attributes to the table (it does not check if attributes already exists)
382
* @return empty string or error message
384
QString *insertAttributes ( int field, int cat );
386
/** Create table and link vector to this table
388
* @param columns SQL definition for columns, e.g. cat integer, label varchar(10)
389
* @return empty string or error message
391
QString *createTable ( int field, const QString &key, const QString &columns );
393
/** Add column to table
395
* @param column SQL definition for columns, e.g. label varchar(10)
396
* @return empty string or error message
398
QString *addColumn ( int field, const QString &column );
400
/* Following functions work only until first edit operation! (category index used) */
402
/** Get number of fields in category index */
403
int cidxGetNumFields ( void );
405
/** Get field number for index */
406
int cidxGetFieldNumber ( int idx );
408
/** Get maximum category for field index */
409
int cidxGetMaxCat ( int idx );
181
/* Reset the layer - for an OGRLayer, this means clearing the
182
* spatial filter and calling ResetReading
186
/**Returns the minimum value of an attribut
187
@param position the number of the attribute*/
188
QString minValue(int position);
190
/**Returns the maximum value of an attribut
191
@param position the number of the attribute*/
192
QString maxValue(int position);
194
/** Update (reload) non static members (marked !UPDATE!) from the static layer and the map.
195
* This method MUST be called whenever lastUpdate of the map is later then mapLastUpdate
200
/**Returns true if this is a valid layer
204
// ----------------------------------- Edit ----------------------------------
206
/** Is the layer editable? I.e. the layer is valid and current user is owner of the mapset
207
* @return true the layer editable
208
* @return false the is not editable
210
bool isGrassEditable();
212
/** Returns true if the layer is currently edited (opened in update mode)
213
* @return true in update mode
214
* @return false not edited
218
/** Start editing. Reopen the vector for update and set GMAP.update = true
219
* @return true success
220
* @return false failed to reopen success
224
/** Close editing. Rebuild topology, GMAP.update = false
225
* @return true success
226
* @return false failed to close vector or vector was not in update mode
230
/** Get current number of lines.
231
* @return number of lines
233
int numLines ( void );
235
/** Get current number of nodes.
236
* @return number of nodes
238
int numNodes ( void );
241
* @param Points pointer to existing structure or NULL
242
* @param Cats pointer to existing structure or NULL
243
* @param line line number
245
* @return <0 deadline or error
247
int readLine ( struct line_pnts * Points, struct line_cats * Cats, int line );
249
/** Read node coordinates
250
* @param line line number
251
* @return true node is alive
252
* @return false node is dead
254
bool nodeCoor ( int node, double *x, double *y );
257
* @param line line number
258
* @return true line is alive
259
* @return false line is dead
261
bool lineNodes ( int line, int *node1, int *node2 );
263
/** Read boundary areas
264
* @param line line number
265
* @return true line is alive
266
* @return false line is dead
268
bool lineAreas ( int line, int *left, int *right );
270
/** Get centroid area
271
* @param centroid line number
272
* @return area number (negative for island)
274
int centroidArea ( int centroid );
276
/** Get number of lines at node
277
* @param node node number
278
* @return number of lines at node (including dead lines)
280
int nodeNLines ( int node );
282
/** Get line number of line at node for given line index
283
* @param node node number
284
* @param idx line index
285
* @return line number
287
int nodeLine ( int node, int idx );
289
/** True if line is alive
290
* @param line line number
294
int lineAlive ( int line );
296
/** True if node is alive
297
* @param node node number
301
int nodeAlive ( int node );
303
/** Write a new line into vector.
304
* @return line number
307
int writeLine ( int type, struct line_pnts *Points, struct line_cats *Cats );
310
* @return line number
313
int rewriteLine ( int line, int type, struct line_pnts *Points, struct line_cats *Cats );
319
int deleteLine ( int line );
321
/** Number of updated lines
323
int numUpdatedLines ( void );
325
/** Number of updated nodes
327
int numUpdatedNodes ( void );
331
int updatedLine ( int idx );
335
int updatedNode ( int idx );
337
/** Find nearest line
338
* @param threshold maximum distance
339
* @return line number
340
* @return 0 nothing found
342
int findLine ( double x, double y, int type, double threshold );
344
/** Find nearest node
345
* @param threshold maximum distance
346
* @return node number
347
* @return 0 nothing found
349
int findNode ( double x, double y, double threshold );
351
/** Get columns' definitions
354
* @return vector of attributes
356
std::vector<QgsField> *columns ( int field );
358
/** Read attributes from DB
361
* @return vector of attributes
363
std::vector<QgsFeatureAttribute> *attributes ( int field, int cat );
365
/** Key (cat) column name
367
* @return Key column name or empty string
369
QString *key ( int field );
371
/** Get number of db links
372
* @return number of links
374
int numDbLinks ( void );
376
/** Get db link field
378
* @return field number or 0
380
int dbLinkField ( int link );
382
/** Update attributes
385
* @param update comma separated update string, e.g.: col1 = 5, col2 = 'Val d''Aosta'
386
* @return empty string or error message
388
QString *updateAttributes ( int field, int cat, const QString &values );
390
/** Insert new attributes to the table (it does not check if attributes already exists)
393
* @return empty string or error message
395
QString *insertAttributes ( int field, int cat );
397
/** Create table and link vector to this table
399
* @param columns SQL definition for columns, e.g. cat integer, label varchar(10)
400
* @return empty string or error message
402
QString *createTable ( int field, const QString &key, const QString &columns );
404
/** Add column to table
406
* @param column SQL definition for columns, e.g. label varchar(10)
407
* @return empty string or error message
409
QString *addColumn ( int field, const QString &column );
411
/* Following functions work only until first edit operation! (category index used) */
413
/** Get number of fields in category index */
414
int cidxGetNumFields ( void );
416
/** Get field number for index */
417
int cidxGetFieldNumber ( int idx );
419
/** Get maximum category for field index */
420
int cidxGetMaxCat ( int idx );
410
421
/** get data source uri (not implemented) */
411
422
QgsDataSourceURI * getURI(){ return 0;};
424
/** Returns GRASS layer number */
418
// Layer type (layerType)
419
enum TYPE { // layer name:
420
POINT = 1, // <field>_point
421
LINE, // <field>_line
422
POLYGON, // <field>_polygon
423
BOUNDARY, // boundary (currently not used)
424
CENTROID // centroid (currently not used)
427
QString mGisdbase; // map gisdabase
428
QString mLocation; // map location name (not path!)
429
QString mMapset; // map mapset
430
QString mMapName; // map name
431
QString mLayer; // layer name
432
int mLayerField; // field part of layer or -1 if no field specified
433
int mLayerType; // layer type POINT, LINE, ...
434
int mGrassType; // grass feature type: GV_POINT, GV_LINE | GV_BOUNDARY, GV_AREA,
435
// ( GV_BOUNDARY, GV_CENTROID )
436
int mQgisType; // WKBPoint, WKBLineString, ...
437
int mLayerId; // ID used in layers
438
struct Map_info *mMap; // vector header pointer
439
int mMapVersion; // The version of the map for which the instance was last time updated
441
struct line_pnts *mPoints; // points structure
442
struct line_cats *mCats; // cats structure
444
int mCidxFieldIndex; // !UPDATE! Index for layerField in category index or -1 if no such field
445
int mCidxFieldNumCats; // !UPDATE! Number of records in field index
446
int mNextCidx; // !UPDATE! Next index in cidxFieldIndex to be read, used to find nextFeature
448
// selection: array of size nlines or nareas + 1, set to 1 - selected or 0 - not selected, 2 - read
449
// Code 2 means that the line was already read in this cycle, all 2 must be reset to 1
450
// if getFirstFeature() or select() is calles.
451
// Distinction between 1 and 2 is used if attribute table exists, in that case attributes are
452
// read from the table and geometry is append and selection set to 2.
453
// In the end the selection array is scanned for 1 (attributes missing), and the geometry
454
// is returned without attributes
455
char *mSelection; // !UPDATE!
456
int mSelectionSize; // !UPDATE! Size of selection array
458
QString mDataSourceUri;
459
bool mValid; // !UPDATE!
460
long mNumberFeatures; // !UPDATE!
461
int mEndian; // endian
463
void resetSelection(bool sel); // reset selection
464
void checkEndian(); // set endian
466
// -----------------------------------------------------------------------------------------
467
/* Static variables and methods.
468
* These methods opens GRASS vectors and loads some parts of vectors to the memory.
469
* it maintains the list of opened layers so that sources are not duplicated in the memory.
470
* Layers are identified by layer ID.
471
* The layers have unique URI, if next layer of the same URI is requested,
472
* nUsers is increased and ID of the layer which is already opened is returned.
473
* Attributes are loaded from DB and stored in the memory when layer is opened.
476
/*! Open layer. Layer for QgsGrassVector means Map+field
483
* @return -1 cannot open
485
static int openLayer(QString gisdbase, QString location, QString mapset, QString mapName, int field);
487
/*! Load sources from the map.
488
* Must be set: layer.mapId, layer.map, layer.field
489
* Updates: layer.fieldInfo, layer.nColumns, layer.nAttributes, layer.attributes, layer.keyColumn
490
* Unchanged: layer.valid
492
* Old sources are released, namely: layer.fields and layer.attributes
494
* layer.attributes must be pointer to existing array or 0
496
static void loadLayerSourcesFromMap ( GLAYER &layer );
501
static void closeLayer( int layerId );
509
* @return -1 cannot open
511
static int openMap(QString gisdbase, QString location, QString mapset, QString mapName);
516
static void closeMap( int mapId );
518
/*! Update map. Close and reopen vector, all layers in mLayers using this map are also updated.
519
* Instances of QgsGrassProvider are not updated and should call update() method.
522
static void updateMap( int mapId );
524
/*! The map is outdated. The map was for example rewritten by GRASS module outside QGIS.
525
* This function checks internal timestamp stored in QGIS.
528
static bool mapOutdated( int mapId );
530
/*! Allocate sellection array for given map id. The array is large enough for lines or areas
531
* (bigger from num lines and num areas)
532
* Possible old selection array is not released.
533
* @param map pointer to map structure
534
* @param selection pointer to pointer to char array
535
* @return selection size
537
static int allocateSelection( struct Map_info *map, char **selection );
541
* @return pointer to Map_info structure
543
static struct Map_info *layerMap( int layerId );
545
/*! Get attribute by category(key) and attribute number.
547
* @param category (key)
548
* @param column column number ( < nColumns )
549
* @return pointer to string representation of the value or NULL, this value must not be changed
551
static char *attribute( int layerId, int cat, int column );
553
/*! Set feature attributes.
556
* @param cat category number
558
static void setFeatureAttributes ( int layerId, int cat, QgsFeature *feature);
560
/*! Set feature attributes.
563
* @param cat category number
564
* @param attlist a list containing the index number of the fields to set
566
static void setFeatureAttributes ( int layerId, int cat, QgsFeature *feature, std::list<int>& attlist);
568
/* Static arrays of opened layers and vectors */
569
static std::vector<GLAYER> mLayers; // Map + field/attributes
570
static std::vector<GMAP> mMaps; // Map
428
// Layer type (layerType)
429
enum TYPE { // layer name:
430
POINT = 1, // <field>_point
431
LINE, // <field>_line
432
POLYGON, // <field>_polygon
433
BOUNDARY, // boundary (currently not used)
434
CENTROID // centroid (currently not used)
437
QString mGisdbase; // map gisdabase
438
QString mLocation; // map location name (not path!)
439
QString mMapset; // map mapset
440
QString mMapName; // map name
441
QString mLayer; // layer name
442
int mLayerField; // field part of layer or -1 if no field specified
443
int mLayerType; // layer type POINT, LINE, ...
444
int mGrassType; // grass feature type: GV_POINT, GV_LINE | GV_BOUNDARY, GV_AREA,
445
// ( GV_BOUNDARY, GV_CENTROID )
446
int mQgisType; // WKBPoint, WKBLineString, ...
447
int mLayerId; // ID used in layers
448
struct Map_info *mMap; // vector header pointer
449
int mMapVersion; // The version of the map for which the instance was last time updated
451
struct line_pnts *mPoints; // points structure
452
struct line_cats *mCats; // cats structure
454
int mCidxFieldIndex; // !UPDATE! Index for layerField in category index or -1 if no such field
455
int mCidxFieldNumCats; // !UPDATE! Number of records in field index
456
int mNextCidx; // !UPDATE! Next index in cidxFieldIndex to be read, used to find nextFeature
458
// selection: array of size nlines or nareas + 1, set to 1 - selected or 0 - not selected, 2 - read
459
// Code 2 means that the line was already read in this cycle, all 2 must be reset to 1
460
// if getFirstFeature() or select() is calles.
461
// Distinction between 1 and 2 is used if attribute table exists, in that case attributes are
462
// read from the table and geometry is append and selection set to 2.
463
// In the end the selection array is scanned for 1 (attributes missing), and the geometry
464
// is returned without attributes
465
char *mSelection; // !UPDATE!
466
int mSelectionSize; // !UPDATE! Size of selection array
468
QString mDataSourceUri;
469
bool mValid; // !UPDATE!
470
long mNumberFeatures; // !UPDATE!
472
void resetSelection(bool sel); // reset selection
474
// -----------------------------------------------------------------------------------------
475
/* Static variables and methods.
476
* These methods opens GRASS vectors and loads some parts of vectors to the memory.
477
* it maintains the list of opened layers so that sources are not duplicated in the memory.
478
* Layers are identified by layer ID.
479
* The layers have unique URI, if next layer of the same URI is requested,
480
* nUsers is increased and ID of the layer which is already opened is returned.
481
* Attributes are loaded from DB and stored in the memory when layer is opened.
484
/*! Open layer. Layer for QgsGrassVector means Map+field
491
* @return -1 cannot open
493
static int openLayer(QString gisdbase, QString location, QString mapset, QString mapName, int field);
495
/*! Load sources from the map.
496
* Must be set: layer.mapId, layer.map, layer.field
497
* Updates: layer.fieldInfo, layer.nColumns, layer.nAttributes, layer.attributes, layer.keyColumn
498
* Unchanged: layer.valid
500
* Old sources are released, namely: layer.fields and layer.attributes
502
* layer.attributes must be pointer to existing array or 0
504
static void loadLayerSourcesFromMap ( GLAYER &layer );
506
/*! Load attributes from database table.
507
* Must be set: layer.mapId, layer.map, layer.field
508
* Updates: layer.fieldInfo, layer.nColumns, layer.nAttributes, layer.attributes, layer.keyColumn
509
* Unchanged: layer.valid
511
* Old sources are released, namely: layer.attributes
513
* layer.attributes must be pointer to existing array or 0
515
static void loadAttributes ( GLAYER &layer );
520
static void closeLayer( int layerId );
528
* @return -1 cannot open
530
static int openMap(QString gisdbase, QString location, QString mapset, QString mapName);
535
static void closeMap( int mapId );
537
/*! Update map. Close and reopen vector, all layers in mLayers using this map are also updated.
538
* Instances of QgsGrassProvider are not updated and should call update() method.
541
static void updateMap( int mapId );
543
/*! The map is outdated. The map was for example rewritten by GRASS module outside QGIS.
544
* This function checks internal timestamp stored in QGIS.
547
static bool mapOutdated( int mapId );
549
/*! The attributes are outdated. The table was for example updated by GRASS module outside QGIS.
550
* This function checks internal timestamp stored in QGIS.
553
static bool attributesOutdated( int mapId );
555
/*! Allocate sellection array for given map id. The array is large enough for lines or areas
556
* (bigger from num lines and num areas)
557
* Possible old selection array is not released.
558
* @param map pointer to map structure
559
* @param selection pointer to pointer to char array
560
* @return selection size
562
static int allocateSelection( struct Map_info *map, char **selection );
566
* @return pointer to Map_info structure
568
static struct Map_info *layerMap( int layerId );
570
/*! Get attribute by category(key) and attribute number.
572
* @param category (key)
573
* @param column column number ( < nColumns )
574
* @return pointer to string representation of the value or NULL, this value must not be changed
576
static char *attribute( int layerId, int cat, int column );
578
/*! Set feature attributes.
581
* @param cat category number
583
void setFeatureAttributes ( int layerId, int cat, QgsFeature *feature);
585
/*! Set feature attributes.
588
* @param cat category number
589
* @param attlist a list containing the index number of the fields to set
591
void setFeatureAttributes ( int layerId, int cat, QgsFeature *feature, std::list<int> const & attlist);
593
/* Static arrays of opened layers and vectors */
594
static std::vector<GLAYER> mLayers; // Map + field/attributes
595
static std::vector<GMAP> mMaps; // Map
573
598
#endif // QGSGRASSPROVIDER_H