38 , mCacheMinMaxDirty( true )
52 return "Generic vector file";
74 Q_UNUSED( attributes );
80 Q_UNUSED( attributes );
86 Q_UNUSED( renamedAttributes );
98 Q_UNUSED( forceLazyEval )
105 Q_UNUSED( geometry_map );
112 Q_UNUSED( attr_map );
113 Q_UNUSED( geometry_map );
171 abilitiesList +=
tr(
"Add Features" );
177 abilitiesList +=
tr(
"Delete Features" );
183 abilitiesList +=
tr(
"Change Attribute Values" );
184 QgsDebugMsg(
"Capability: Change Attribute Values" );
189 abilitiesList +=
tr(
"Add Attributes" );
195 abilitiesList +=
tr(
"Delete Attributes" );
201 abilitiesList +=
tr(
"Rename Attributes" );
208 abilitiesList +=
tr(
"Create Spatial Index" );
214 abilitiesList +=
tr(
"Create Attribute Indexes" );
215 QgsDebugMsg(
"Capability: Create Attribute Index" );
220 abilitiesList +=
tr(
"Fast Access to Features at ID" );
226 abilitiesList +=
tr(
"Change Geometries" );
232 abilitiesList +=
tr(
"Presimplify Geometries" );
233 QgsDebugMsg(
"Capability: Simplify Geometries before fetching the feature" );
238 abilitiesList +=
tr(
"Presimplify Geometries with Validity Check" );
239 QgsDebugMsg(
"Capability: Simplify Geometries before fetch the feature ensuring that the result is a valid geometry" );
244 abilitiesList +=
tr(
"Simultaneous Geometry and Attribute Updates" );
245 QgsDebugMsg(
"Capability: change both feature attributes and geometry at once" );
250 abilitiesList +=
tr(
"Transactions" );
256 abilitiesList +=
tr(
"Curved Geometries" );
257 QgsDebugMsg(
"Supports circular geometry types (circularstring, compoundcurve, curvepolygon)" );
260 return abilitiesList.
join(
", " );
274 for (
int i = 0; i < theFields.
count(); ++i )
302 QgsDebugMsgLevel(
QString(
"native field type = %1 min length = %2 max length = %3 min precision = %4 max precision = %5" )
312 if ( field.
length() == -1 )
362 if ( index < 0 || index >=
fields().count() )
378 if ( index < 0 || index >=
fields().count() )
410 if ( limit >= 0 && values.
size() >= limit )
419 Q_UNUSED( aggregate );
421 Q_UNUSED( parameters );
439 for (
int i = 0; i < flds.
count(); ++i )
441 if ( flds[i].type() == QVariant::Int )
446 else if ( flds[i].type() == QVariant::LongLong )
451 else if ( flds[i].type() == QVariant::Double )
478 if ( flds[*it].type() == QVariant::Int )
480 int value = varValue.
toInt();
486 else if ( flds[*it].type() == QVariant::LongLong )
494 else if ( flds[*it].type() == QVariant::Double )
541 smEncodings << codec;
544 smEncodings <<
"BIG5";
545 smEncodings <<
"BIG5-HKSCS";
546 smEncodings <<
"EUCJP";
547 smEncodings <<
"EUCKR";
548 smEncodings <<
"GB2312";
549 smEncodings <<
"GBK";
550 smEncodings <<
"GB18030";
551 smEncodings <<
"JIS7";
552 smEncodings <<
"SHIFT-JIS";
553 smEncodings <<
"TSCII";
554 smEncodings <<
"UTF-8";
555 smEncodings <<
"UTF-16";
556 smEncodings <<
"KOI8-R";
557 smEncodings <<
"KOI8-U";
558 smEncodings <<
"ISO8859-1";
559 smEncodings <<
"ISO8859-2";
560 smEncodings <<
"ISO8859-3";
561 smEncodings <<
"ISO8859-4";
562 smEncodings <<
"ISO8859-5";
563 smEncodings <<
"ISO8859-6";
564 smEncodings <<
"ISO8859-7";
565 smEncodings <<
"ISO8859-8";
566 smEncodings <<
"ISO8859-8-I";
567 smEncodings <<
"ISO8859-9";
568 smEncodings <<
"ISO8859-10";
569 smEncodings <<
"ISO8859-11";
570 smEncodings <<
"ISO8859-12";
571 smEncodings <<
"ISO8859-13";
572 smEncodings <<
"ISO8859-14";
573 smEncodings <<
"ISO8859-15";
574 smEncodings <<
"IBM 850";
575 smEncodings <<
"IBM 866";
576 smEncodings <<
"CP874";
577 smEncodings <<
"CP1250";
578 smEncodings <<
"CP1251";
579 smEncodings <<
"CP1252";
580 smEncodings <<
"CP1253";
581 smEncodings <<
"CP1254";
582 smEncodings <<
"CP1255";
583 smEncodings <<
"CP1256";
584 smEncodings <<
"CP1257";
585 smEncodings <<
"CP1258";
586 smEncodings <<
"Apple Roman";
587 smEncodings <<
"TIS-620";
588 smEncodings <<
"System";
641 if ( geometry->
wkbType() == providerGeomType )
654 if ( compoundCurve->
nCurves() == 1 )
657 if ( circularString )
659 outputGeom = circularString->
clone();
670 if ( geomCollection )
683 outputGeom = curveGeom;
692 if ( segmentizedGeom )
695 outputGeom = segmentizedGeom;
704 outputGeom = geometry->
clone();
712 outputGeom = geometry->
clone();
723 outputGeom = geometry->
clone();
734 outputGeom = geometry->
clone();
744 QString msg =
tr(
"Geometry type %1 not compatible with provider type %2.",
"not compatible geometry" )
qlonglong toLongLong(bool *ok) const
QString encoding() const
Get encoding which is used for accessing data.
Wrapper for iterator of features from vector data provider or vector layer.
static QVariant convertValue(QVariant::Type type, const QString &value)
virtual bool dropMValue()=0
Drops any measure values which exist in the geometry.
QgsAttributes attributes() const
Returns the feature's attributes.
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.
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.
virtual bool renameAttributes(const QgsFieldNameMap &renamedAttributes)
Renames existing attributes.
static bool isMultiType(Type type)
Returns true if the WKB type is a multi type.
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.
A geometry is the spatial representation of a feature.
QStringList errors()
Get recorded errors.
QMap< int, QVariant > mCacheMaxValues
Abstract base class for spatial data provider implementations.
virtual bool dropZValue()=0
Drops any z-dimensions which exist in the geometry.
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...
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
virtual bool addFeatures(QgsFeatureList &flist)
Adds a list of features.
int count() const
Return number of items.
QString tr(const char *sourceText, const char *disambiguation, int n)
QTextCodec * codecForLocale()
virtual QString name() const =0
Return a provider name.
virtual bool createAttributeIndex(int field)
Create an attribute index on the datasource.
virtual QgsAbstractGeometryV2 * toCurveType() const
Returns the geometry converted to the more generic curve type.
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.
static QgsWKBTypes::Type fromOldWkbType(QGis::WkbType type)
Converts from old (pre 2.10) WKB type (OGR) to new WKB type.
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.
int toInt(bool *ok) const
Allows addition of new attributes (fields)
#define QgsDebugMsgLevel(str, level)
static bool isCurvedType(Type type)
Returns true if the WKB type is a curved type or can contain curved geometries.
bool hasErrors()
Provider has errors to report.
virtual bool changeAttributeValues(const QgsChangedAttributesMap &attr_map)
Changes attribute values of existing features.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
virtual bool changeFeatures(const QgsChangedAttributesMap &attr_map, const QgsGeometryMap &geometry_map)
Changes attribute values and geometries of existing features.
const char * constData() const
virtual QgsAbstractGeometryV2 * segmentize(double tolerance=M_PI/180., SegmentationToleranceType toleranceType=MaximumAngle) const
Returns a version of the geometry without curves.
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)...
virtual QVariant aggregate(QgsAggregateCalculator::Aggregate aggregate, int index, const QgsAggregateCalculator::AggregateParameters ¶meters, QgsExpressionContext *context, bool &ok)
Calculates an aggregated value from the layer's features.
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.
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.
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.
virtual QVariant defaultValue(int fieldId, bool forceLazyEval=false)
Returns the default value for field specified by fieldId.
QgsVectorDataProvider(const QString &uri=QString())
Constructor of the vector provider.
QByteArray toLocal8Bit() const
void raiseError(const QString &msg)
Signals an error in this provider.
Supports circular geometry types (circularstring, compoundcurve, curvepolygon)
int fieldNameIndex(const QString &fieldName) const
Look up field's index from name also looks up case-insensitive if there is no match otherwise...
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.
QgsGeometry * convertToProviderType(const QgsGeometry *geom) const
Converts the geometry to the provider type if possible / necessary this is the list of possible modif...
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.
virtual bool deleteAttributes(const QgsAttributeIds &attributes)
Deletes existing attributes.
int nCurves() const
Returns the number of curves in the geometry.
Allows deletion of features.
static Type flatType(Type type)
Returns the flat type for a WKB type.
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.
This is the base class for vector data providers.
virtual QgsAbstractGeometryV2 * clone() const =0
Clones the geometry by performing a deep copy.
static QString displayString(Type type)
Returns a display string type for a WKB type, eg the geometry name used in WKT geometry representatio...
Geometry is not required. It may still be returned if e.g. required for a filter condition.
QVariant::Type type() const
Gets variant type of the field as it will be retrieved from data source.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QString arg(qlonglong a, int fieldWidth, int base, const QChar &fillChar) const
Allows modification of attribute values.
bool isNull(const QVariant &v)
Aggregate
Available aggregates to calculate.
QMap< int, QVariant > mCacheMinValues
Supports renaming attributes (fields).
A bundle of parameters controlling aggregate calculation.