QGIS API Documentation  2.14.11-Essen
qgsvectordataprovider.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectordataprovider.cpp - DataProvider Interface for vector layers
3  --------------------------------------
4  Date : 26-Oct-2004
5  Copyright : (C) 2004 by Marco Hugentobler
6  email : marco.hugentobler@autoform.ch
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include <QSettings>
17 #include <QTextCodec>
18 
19 #include <cfloat> // for DBL_MAX
20 #include <climits>
21 #include <limits>
22 
23 #include "qgsvectordataprovider.h"
24 #include "qgscircularstringv2.h"
25 #include "qgscompoundcurvev2.h"
26 #include "qgsfeature.h"
27 #include "qgsfeatureiterator.h"
28 #include "qgsfeaturerequest.h"
29 #include "qgsfield.h"
30 #include "qgsgeometry.h"
32 #include "qgsgeometryfactory.h"
33 #include "qgslogger.h"
34 #include "qgsmessagelog.h"
35 
37  : QgsDataProvider( uri )
38  , mCacheMinMaxDirty( true )
39  , mAttrPalIndexName( QgsAttrPalIndexNameHash() )
40 {
41  QSettings settings;
42  setEncoding( settings.value( "/UI/encoding", "System" ).toString() );
43 }
44 
45 
47 {
48 }
49 
51 {
52  return "Generic vector file";
53 }
54 
56 {
57  return QString();
58 }
59 
61 {
62  Q_UNUSED( flist );
63  return false;
64 }
65 
67 {
68  Q_UNUSED( ids );
69  return false;
70 }
71 
73 {
74  Q_UNUSED( attributes );
75  return false;
76 }
77 
79 {
80  Q_UNUSED( attributes );
81  return false;
82 }
83 
85 {
86  Q_UNUSED( attr_map );
87  return false;
88 }
89 
91 {
92  Q_UNUSED( fieldId );
93  return QVariant();
94 }
95 
97 {
98  Q_UNUSED( geometry_map );
99  return false;
100 }
101 
103  const QgsGeometryMap &geometry_map )
104 {
105  Q_UNUSED( attr_map );
106  Q_UNUSED( geometry_map );
107  return false;
108 }
109 
111 {
112  return false;
113 }
114 
116 {
117  Q_UNUSED( field );
118  return true;
119 }
120 
122 {
124 }
125 
126 
128 {
130  if ( ncodec )
131  {
132  mEncoding = ncodec;
133  }
134  else
135  {
136  QgsMessageLog::logMessage( tr( "Codec %1 not found. Falling back to system locale" ).arg( e ) );
137  mEncoding = QTextCodec::codecForName( "System" );
138 
139  if ( !mEncoding )
141 
142  Q_ASSERT( mEncoding );
143  }
144 }
145 
147 {
148  if ( mEncoding )
149  {
150  return mEncoding->name();
151  }
152 
153  return "";
154 }
155 
157 {
158  QStringList abilitiesList;
159 
160  int abilities = capabilities();
161 
162  if ( abilities & QgsVectorDataProvider::AddFeatures )
163  {
164  abilitiesList += tr( "Add Features" );
165  QgsDebugMsg( "Capability: Add Features" );
166  }
167 
168  if ( abilities & QgsVectorDataProvider::DeleteFeatures )
169  {
170  abilitiesList += tr( "Delete Features" );
171  QgsDebugMsg( "Capability: Delete Features" );
172  }
173 
175  {
176  abilitiesList += tr( "Change Attribute Values" );
177  QgsDebugMsg( "Capability: Change Attribute Values" );
178  }
179 
180  if ( abilities & QgsVectorDataProvider::AddAttributes )
181  {
182  abilitiesList += tr( "Add Attributes" );
183  QgsDebugMsg( "Capability: Add Attributes" );
184  }
185 
186  if ( abilities & QgsVectorDataProvider::DeleteAttributes )
187  {
188  abilitiesList += tr( "Delete Attributes" );
189  QgsDebugMsg( "Capability: Delete Attributes" );
190  }
191 
193  {
194  // TODO: Tighten up this test. See QgsOgrProvider for details.
195  abilitiesList += tr( "Create Spatial Index" );
196  QgsDebugMsg( "Capability: Create Spatial Index" );
197  }
198 
199  if ( abilities & QgsVectorDataProvider::SelectAtId )
200  {
201  abilitiesList += tr( "Fast Access to Features at ID" );
202  QgsDebugMsg( "Capability: Select at ID" );
203  }
204 
205  if ( abilities & QgsVectorDataProvider::ChangeGeometries )
206  {
207  abilitiesList += tr( "Change Geometries" );
208  QgsDebugMsg( "Capability: Change Geometries" );
209  }
210 
212  {
213  abilitiesList += tr( "Presimplify Geometries" );
214  QgsDebugMsg( "Capability: Simplify Geometries before fetching the feature" );
215  }
216 
218  {
219  abilitiesList += tr( "Presimplify Geometries with Validity Check" );
220  QgsDebugMsg( "Capability: Simplify Geometries before fetch the feature ensuring that the result is a valid geometry" );
221  }
222 
223  if ( abilities & QgsVectorDataProvider::ChangeFeatures )
224  {
225  abilitiesList += tr( "Simultaneous Geometry and Attribute Updates" );
226  QgsDebugMsg( "Capability: change both feature attributes and geometry at once" );
227  }
228 
229  return abilitiesList.join( ", " );
230 }
231 
232 
233 int QgsVectorDataProvider::fieldNameIndex( const QString& fieldName ) const
234 {
235  const QgsFields &theFields = fields();
236 
237  for ( int i = 0; i < theFields.count(); ++i )
238  {
239  if ( QString::compare( theFields[i].name(), fieldName, Qt::CaseInsensitive ) == 0 )
240  {
241  return i;
242  }
243  }
244  return -1;
245 }
246 
248 {
249  QMap<QString, int> resultMap;
250 
251  const QgsFields& theFields = fields();
252  for ( int i = 0; i < theFields.count(); ++i )
253  {
254  resultMap.insert( theFields[i].name(), i );
255  }
256 
257  return resultMap;
258 }
259 
261 {
262  return fields().allAttributesList();
263 }
264 
266 {
267  return mNativeTypes;
268 }
269 
271 {
272  int i;
273  QgsDebugMsgLevel( QString( "field name = %1 type = %2 length = %3 precision = %4" )
274  .arg( field.name(),
275  QVariant::typeToName( field.type() ) )
276  .arg( field.length() )
277  .arg( field.precision() ), 2 );
278  for ( i = 0; i < mNativeTypes.size(); i++ )
279  {
280  QgsDebugMsgLevel( QString( "native field type = %1 min length = %2 max length = %3 min precision = %4 max precision = %5" )
281  .arg( QVariant::typeToName( mNativeTypes[i].mType ) )
282  .arg( mNativeTypes[i].mMinLen )
283  .arg( mNativeTypes[i].mMaxLen )
284  .arg( mNativeTypes[i].mMinPrec )
285  .arg( mNativeTypes[i].mMaxPrec ), 2 );
286 
287  if ( field.type() != mNativeTypes[i].mType )
288  continue;
289 
290  if ( field.length() == -1 )
291  {
292  // source length unlimited
293  if ( mNativeTypes[i].mMinLen > -1 || mNativeTypes[i].mMaxLen > -1 )
294  {
295  // destination limited
296  continue;
297  }
298  }
299  else
300  {
301  // source length limited
302  if ( mNativeTypes[i].mMinLen > -1 && mNativeTypes[i].mMaxLen > -1 &&
303  ( field.length() < mNativeTypes[i].mMinLen || field.length() > mNativeTypes[i].mMaxLen ) )
304  {
305  // source length exceeds destination limits
306  continue;
307  }
308  }
309 
310  if ( field.precision() == -1 )
311  {
312  // source precision unlimited / n/a
313  if ( mNativeTypes[i].mMinPrec > -1 || mNativeTypes[i].mMaxPrec > -1 )
314  {
315  // destination limited
316  continue;
317  }
318  }
319  else
320  {
321  // source precision unlimited / n/a
322  if ( mNativeTypes[i].mMinPrec > -1 && mNativeTypes[i].mMaxPrec > -1 &&
323  ( field.precision() < mNativeTypes[i].mMinPrec || field.precision() > mNativeTypes[i].mMaxPrec ) )
324  {
325  // source precision exceeds destination limits
326  continue;
327  }
328  }
329 
330  QgsDebugMsg( "native type matches" );
331  return true;
332  }
333 
334  QgsDebugMsg( "no sufficient native type found" );
335  return false;
336 }
337 
339 {
340  if ( index < 0 || index >= fields().count() )
341  {
342  QgsDebugMsg( "Warning: access requested to invalid field index: " + QString::number( index ) );
343  return QVariant();
344  }
345 
346  fillMinMaxCache();
347 
348  if ( !mCacheMinValues.contains( index ) )
349  return QVariant();
350 
351  return mCacheMinValues[index];
352 }
353 
355 {
356  if ( index < 0 || index >= fields().count() )
357  {
358  QgsDebugMsg( "Warning: access requested to invalid field index: " + QString::number( index ) );
359  return QVariant();
360  }
361 
362  fillMinMaxCache();
363 
364  if ( !mCacheMaxValues.contains( index ) )
365  return QVariant();
366 
367  return mCacheMaxValues[index];
368 }
369 
371 {
372  QgsFeature f;
373  QgsAttributeList keys;
374  keys.append( index );
375  QgsFeatureIterator fi = getFeatures( QgsFeatureRequest().setSubsetOfAttributes( keys ).setFlags( QgsFeatureRequest::NoGeometry ) );
376 
377  QSet<QString> set;
378  values.clear();
379 
380  while ( fi.nextFeature( f ) )
381  {
382  if ( !set.contains( f.attribute( index ).toString() ) )
383  {
384  values.append( f.attribute( index ) );
385  set.insert( f.attribute( index ).toString() );
386  }
387 
388  if ( limit >= 0 && values.size() >= limit )
389  break;
390  }
391 }
392 
394 {
395  mCacheMinMaxDirty = true;
396 }
397 
399 {
400  if ( !mCacheMinMaxDirty )
401  return;
402 
403  const QgsFields& flds = fields();
404  for ( int i = 0; i < flds.count(); ++i )
405  {
406  if ( flds[i].type() == QVariant::Int )
407  {
408  mCacheMinValues[i] = QVariant( INT_MAX );
409  mCacheMaxValues[i] = QVariant( INT_MIN );
410  }
411  else if ( flds[i].type() == QVariant::LongLong )
412  {
415  }
416  else if ( flds[i].type() == QVariant::Double )
417  {
418  mCacheMinValues[i] = QVariant( DBL_MAX );
419  mCacheMaxValues[i] = QVariant( -DBL_MAX );
420  }
421  else
422  {
423  mCacheMinValues[i] = QVariant();
424  mCacheMaxValues[i] = QVariant();
425  }
426  }
427 
428  QgsFeature f;
430  QgsFeatureIterator fi = getFeatures( QgsFeatureRequest().setSubsetOfAttributes( keys )
431  .setFlags( QgsFeatureRequest::NoGeometry ) );
432 
433  while ( fi.nextFeature( f ) )
434  {
435  QgsAttributes attrs = f.attributes();
436  for ( QgsAttributeList::const_iterator it = keys.begin(); it != keys.end(); ++it )
437  {
438  const QVariant& varValue = attrs.at( *it );
439 
440  if ( varValue.isNull() )
441  continue;
442 
443  if ( flds[*it].type() == QVariant::Int )
444  {
445  int value = varValue.toInt();
446  if ( value < mCacheMinValues[*it].toInt() )
447  mCacheMinValues[*it] = value;
448  if ( value > mCacheMaxValues[*it].toInt() )
449  mCacheMaxValues[*it] = value;
450  }
451  else if ( flds[*it].type() == QVariant::LongLong )
452  {
453  qlonglong value = varValue.toLongLong();
454  if ( value < mCacheMinValues[*it].toLongLong() )
455  mCacheMinValues[*it] = value;
456  if ( value > mCacheMaxValues[*it].toLongLong() )
457  mCacheMaxValues[*it] = value;
458  }
459  else if ( flds[*it].type() == QVariant::Double )
460  {
461  double value = varValue.toDouble();
462  if ( value < mCacheMinValues[*it].toDouble() )
463  mCacheMinValues[*it] = value;
464  if ( value > mCacheMaxValues[*it].toDouble() )
465  mCacheMaxValues[*it] = value;
466  }
467  else
468  {
469  QString value = varValue.toString();
470  if ( mCacheMinValues[*it].isNull() || value < mCacheMinValues[*it].toString() )
471  {
472  mCacheMinValues[*it] = value;
473  }
474  if ( mCacheMaxValues[*it].isNull() || value > mCacheMaxValues[*it].toString() )
475  {
476  mCacheMaxValues[*it] = value;
477  }
478  }
479  }
480  }
481 
482  mCacheMinMaxDirty = false;
483 }
484 
485 QVariant QgsVectorDataProvider::convertValue( QVariant::Type type, const QString& value )
486 {
487  QVariant v( value );
488 
489  if ( !v.convert( type ) || value.isNull() )
490  v = QVariant( type );
491 
492  return v;
493 }
494 
495 static bool _compareEncodings( const QString& s1, const QString& s2 )
496 {
497  return s1.toLower() < s2.toLower();
498 }
499 
501 {
502  if ( smEncodings.isEmpty() )
503  {
504  Q_FOREACH ( const QString& codec, QTextCodec::availableCodecs() )
505  {
506  smEncodings << codec;
507  }
508 #if 0
509  smEncodings << "BIG5";
510  smEncodings << "BIG5-HKSCS";
511  smEncodings << "EUCJP";
512  smEncodings << "EUCKR";
513  smEncodings << "GB2312";
514  smEncodings << "GBK";
515  smEncodings << "GB18030";
516  smEncodings << "JIS7";
517  smEncodings << "SHIFT-JIS";
518  smEncodings << "TSCII";
519  smEncodings << "UTF-8";
520  smEncodings << "UTF-16";
521  smEncodings << "KOI8-R";
522  smEncodings << "KOI8-U";
523  smEncodings << "ISO8859-1";
524  smEncodings << "ISO8859-2";
525  smEncodings << "ISO8859-3";
526  smEncodings << "ISO8859-4";
527  smEncodings << "ISO8859-5";
528  smEncodings << "ISO8859-6";
529  smEncodings << "ISO8859-7";
530  smEncodings << "ISO8859-8";
531  smEncodings << "ISO8859-8-I";
532  smEncodings << "ISO8859-9";
533  smEncodings << "ISO8859-10";
534  smEncodings << "ISO8859-11";
535  smEncodings << "ISO8859-12";
536  smEncodings << "ISO8859-13";
537  smEncodings << "ISO8859-14";
538  smEncodings << "ISO8859-15";
539  smEncodings << "IBM 850";
540  smEncodings << "IBM 866";
541  smEncodings << "CP874";
542  smEncodings << "CP1250";
543  smEncodings << "CP1251";
544  smEncodings << "CP1252";
545  smEncodings << "CP1253";
546  smEncodings << "CP1254";
547  smEncodings << "CP1255";
548  smEncodings << "CP1256";
549  smEncodings << "CP1257";
550  smEncodings << "CP1258";
551  smEncodings << "Apple Roman";
552  smEncodings << "TIS-620";
553  smEncodings << "System";
554 #endif
555  }
556 
557  // Do case-insensitive sorting of encodings
558  qSort( smEncodings.begin(), smEncodings.end(), _compareEncodings );
559 
560  return smEncodings;
561 }
562 
564 {
565  mErrors.clear();
566 }
567 
569 {
570  return !mErrors.isEmpty();
571 }
572 
574 {
575  return mErrors;
576 }
577 
579 {
580  QgsDebugMsg( msg );
581  mErrors << msg;
582  emit raiseError( msg );
583 }
584 
586 {
587  return QSet<QString>();
588 }
589 
591 {
592  if ( geom.isEmpty() )
593  {
594  return nullptr;
595  }
596 
597  QgsAbstractGeometryV2* geometry = geom.geometry();
598  if ( !geometry )
599  {
600  return nullptr;
601  }
602 
603  QgsWKBTypes::Type providerGeomType = QgsWKBTypes::Type( geometryType() );
604 
605  //geom is already in the provider geometry type
606  if ( geometry->wkbType() == providerGeomType )
607  {
608  return nullptr;
609  }
610 
611  QgsAbstractGeometryV2* outputGeom = nullptr;
612 
613  //convert compoundcurve to circularstring (possible if compoundcurve consists of one circular string)
615  {
616  QgsCompoundCurveV2* compoundCurve = static_cast<QgsCompoundCurveV2*>( geometry );
617  if ( compoundCurve )
618  {
619  if ( compoundCurve->nCurves() == 1 )
620  {
621  const QgsCircularStringV2* circularString = dynamic_cast<const QgsCircularStringV2*>( compoundCurve->curveAt( 0 ) );
622  if ( circularString )
623  {
624  outputGeom = circularString->clone();
625  }
626  }
627  }
628  }
629 
630  //convert to multitype if necessary
631  if ( QgsWKBTypes::isMultiType( providerGeomType ) && !QgsWKBTypes::isMultiType( geometry->wkbType() ) )
632  {
633  outputGeom = QgsGeometryFactory::geomFromWkbType( providerGeomType );
634  QgsGeometryCollectionV2* geomCollection = dynamic_cast<QgsGeometryCollectionV2*>( outputGeom );
635  if ( geomCollection )
636  {
637  geomCollection->addGeometry( geometry->clone() );
638  }
639  }
640 
641  //convert to curved type if necessary
642  if ( !QgsWKBTypes::isCurvedType( geometry->wkbType() ) && QgsWKBTypes::isCurvedType( providerGeomType ) )
643  {
644  QgsAbstractGeometryV2* curveGeom = outputGeom ? outputGeom->toCurveType() : geometry->toCurveType();
645  if ( curveGeom )
646  {
647  delete outputGeom;
648  outputGeom = curveGeom;
649  }
650  }
651 
652  //convert to linear type from curved type
653  if ( QgsWKBTypes::isCurvedType( geometry->wkbType() ) && !QgsWKBTypes::isCurvedType( providerGeomType ) )
654  {
655  QgsAbstractGeometryV2* segmentizedGeom = nullptr;
656  segmentizedGeom = outputGeom ? outputGeom->segmentize() : geometry->segmentize();
657  if ( segmentizedGeom )
658  {
659  delete outputGeom;
660  outputGeom = segmentizedGeom;
661  }
662  }
663 
664  //set z/m types
665  if ( QgsWKBTypes::hasZ( providerGeomType ) )
666  {
667  if ( !outputGeom )
668  {
669  outputGeom = geometry->clone();
670  }
671  outputGeom->addZValue();
672  }
673  if ( QgsWKBTypes::hasM( providerGeomType ) )
674  {
675  if ( !outputGeom )
676  {
677  outputGeom = geometry->clone();
678  }
679  outputGeom->addMValue();
680  }
681 
682  if ( outputGeom )
683  {
684  return new QgsGeometry( outputGeom );
685  }
686  return nullptr;
687 }
688 
689 QStringList QgsVectorDataProvider::smEncodings;
qlonglong toLongLong(bool *ok) const
void clear()
QString encoding() const
Get encoding which is used for accessing data.
Wrapper for iterator of features from vector data provider or vector layer.
static unsigned index
static QVariant convertValue(QVariant::Type type, const QString &value)
QgsAttributes attributes() const
Returns the feature&#39;s attributes.
Definition: qgsfeature.cpp:110
QMap< QString, int > fieldNameMap() const
Return a map where the key is the name of the field and the value is its index.
bool contains(const Key &key) const
virtual QByteArray name() const=0
static bool _compareEncodings(const QString &s1, const QString &s2)
virtual bool addAttributes(const QList< QgsField > &attributes)
Adds new attributes.
static bool hasM(Type type)
Tests whether a WKB type contains m values.
Definition: qgswkbtypes.h:703
#define QgsDebugMsg(str)
Definition: qgslogger.h:33
Circular string geometry type.
Supports simplification of geometries on provider side according to a distance tolerance.
virtual QgsAttributeList attributeIndexes()
Return list of indexes to fetch all attributes in nextFeature()
virtual bool deleteFeatures(const QgsFeatureIds &id)
Deletes one or more features.
virtual void setEncoding(const QString &e)
Set encoding used for accessing data from layer.
static bool isMultiType(Type type)
Returns true if the WKB type is a multi type.
Definition: qgswkbtypes.h:476
Abstract base class for all geometries.
virtual void uniqueValues(int index, QList< QVariant > &uniqueValues, int limit=-1)
Return unique values of an attribute.
Container of fields for a vector layer.
Definition: qgsfield.h:187
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:76
QStringList errors()
Get recorded errors.
int precision() const
Gets the precision of the field.
Definition: qgsfield.cpp:104
QMap< int, QVariant > mCacheMaxValues
Abstract base class for spatial data provider implementations.
Allows deletion of attributes (fields)
QString join(const QString &separator) const
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
Definition: qgswkbtypes.h:656
virtual bool addFeatures(QgsFeatureList &flist)
Adds a list of features.
int count() const
Return number of items.
Definition: qgsfield.cpp:365
QString tr(const char *sourceText, const char *disambiguation, int n)
QTextCodec * codecForLocale()
QString name() const
Gets the name of the field.
Definition: qgsfield.cpp:84
virtual QString name() const =0
Return a provider name.
virtual bool createAttributeIndex(int field)
Create an attribute index on the datasource.
int size() const
virtual QgsAbstractGeometryV2 * toCurveType() const
Returns the geometry converted to the more generic curve type.
bool isNull() const
virtual bool addMValue(double mValue=0)=0
Adds a measure to the geometry, initialized to a preset value.
static const QStringList & availableEncodings()
Returns a list of available encodings.
bool supportedType(const QgsField &field) const
check if provider supports type of field
double ANALYSIS_EXPORT max(double x, double y)
Returns the maximum of two doubles or the first argument if both are equal.
QList< Key > keys() const
Allows creation of spatial index.
virtual QVariant maximumValue(int index)
Returns the maximum value of an attribute.
virtual bool createSpatialIndex()
Creates a spatial index on the datasource (if supported by the provider type).
QString number(int n, int base)
void append(const T &value)
QTextCodec * mEncoding
Encoding.
QgsAttributeList allAttributesList() const
Utility function to get list of attribute indexes.
Definition: qgsfield.cpp:520
int toInt(bool *ok) const
bool isNull() const
Allows addition of new attributes (fields)
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:34
static bool isCurvedType(Type type)
Returns true if the WKB type is a curved type or can contain curved geometries.
Definition: qgswkbtypes.h:520
bool hasErrors()
Provider has errors to report.
virtual bool changeAttributeValues(const QgsChangedAttributesMap &attr_map)
Changes attribute values of existing features.
bool isEmpty() const
virtual bool changeFeatures(const QgsChangedAttributesMap &attr_map, const QgsGeometryMap &geometry_map)
Changes attribute values and geometries of existing features.
const char * constData() const
static void logMessage(const QString &message, const QString &tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
virtual QSet< QString > layerDependencies() const
Get the list of layer ids on which this layer depends.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QList< NativeType > mNativeTypes
The names of the providers native types.
int fieldNameIndex(const QString &fieldName) const
Returns the index of a field name or -1 if the field does not exist.
bool isEmpty() const
Returns true if the geometry is empty (ie, contains no underlying geometry accessible via geometry)...
Allows modifications of geometries.
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())=0
Query the provider for features specified in request.
void clearErrors()
Clear recorded errors.
virtual bool addZValue(double zValue=0)=0
Adds a z-dimension to the geometry, initialized to a preset value.
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:44
const QList< NativeType > & nativeTypes() const
Returns the names of the supported types.
virtual QGis::WkbType geometryType() const =0
Get feature type.
Fast access to features using their ID.
virtual bool changeGeometryValues(const QgsGeometryMap &geometry_map)
Changes geometries of existing features.
virtual int capabilities() const
Returns a bitmask containing the supported capabilities Note, some capabilities may change depending ...
static QgsAbstractGeometryV2 * geomFromWkbType(QgsWKBTypes::Type t)
Return empty geometry from wkb type.
Compound curve geometry type.
QgsVectorDataProvider(const QString &uri=QString())
Constructor of the vector provider.
iterator end()
QString toLower() const
QByteArray toLocal8Bit() const
void raiseError(const QString &msg)
Signals an error in this provider.
virtual QgsCircularStringV2 * clone() const override
Clones the geometry by performing a deep copy.
Supports joint updates for attributes and geometry Providers supporting this should still define Chan...
Supports topological simplification of geometries on provider side according to a distance tolerance...
QString capabilitiesString() const
Returns the above in friendly format.
const char * typeToName(Type typ)
const T & at(int i) const
QVariant value(const QString &key, const QVariant &defaultValue) const
QList< QByteArray > availableCodecs()
const QgsCurveV2 * curveAt(int i) const
Returns the curve at the specified index.
virtual const QgsFields & fields() const =0
Return a map of indexes with field names for this layer.
QgsAbstractGeometryV2 * geometry() const
Returns the underlying geometry store.
virtual QVariant defaultValue(int fieldId)
Returns the default value for field specified by fieldId.
QgsWKBTypes::Type wkbType() const
Returns the WKB type of the geometry.
virtual QVariant minimumValue(int index)
Returns the minimum value of an attribute.
QTextCodec * codecForName(const QByteArray &name)
virtual QString dataComment() const
Return a short comment for the data that this provider is providing access to (e.g.
virtual bool addGeometry(QgsAbstractGeometryV2 *g)
Adds a geometry and takes ownership.
virtual ~QgsVectorDataProvider()
Destructor.
int length() const
Gets the length of the field.
Definition: qgsfield.cpp:99
virtual bool deleteAttributes(const QgsAttributeIds &attributes)
Deletes existing attributes.
virtual QgsAbstractGeometryV2 * segmentize() const
Returns a version of the geometry without curves.
int nCurves() const
Returns the number of curves in the geometry.
static Type flatType(Type type)
Returns the flat type for a WKB type.
Definition: qgswkbtypes.h:366
double toDouble(bool *ok) const
iterator insert(const Key &key, const T &value)
void pushError(const QString &msg)
virtual QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
double ANALYSIS_EXPORT min(double x, double y)
Returns the minimum of two doubles or the first argument if both are equal.
bool nextFeature(QgsFeature &f)
Provider has no capabilities.
virtual QgsAbstractGeometryV2 * clone() const =0
Clones the geometry by performing a deep copy.
Geometry is not required. It may still be returned if e.g. required for a filter condition.
A vector of attributes.
Definition: qgsfeature.h:115
QVariant::Type type() const
Gets variant type of the field as it will be retrieved from data source.
Definition: qgsfield.cpp:89
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
Definition: qgsfeature.cpp:271
int compare(const QString &other) const
QgsGeometry * convertToProviderType(const QgsGeometry &geom) const
Converts the geometry to the provider type if possible / necessary.
bool convert(Type t)
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
QString toString() const
iterator begin()
Allows modification of attribute values.
bool isNull(const QVariant &v)
QMap< int, QVariant > mCacheMinValues