[QGIS Commit] r13931 - in branches/threading-branch/src: core
providers/delimitedtext providers/gpx providers/grass
providers/memory providers/ogr providers/osm
providers/postgres providers/spatialite providers/wfs
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sun Jul 18 11:07:07 EDT 2010
Author: wonder
Date: 2010-07-18 15:07:07 +0000 (Sun, 18 Jul 2010)
New Revision: 13931
Modified:
branches/threading-branch/src/core/qgsvectordataprovider.cpp
branches/threading-branch/src/core/qgsvectordataprovider.h
branches/threading-branch/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
branches/threading-branch/src/providers/delimitedtext/qgsdelimitedtextprovider.h
branches/threading-branch/src/providers/gpx/qgsgpxprovider.cpp
branches/threading-branch/src/providers/gpx/qgsgpxprovider.h
branches/threading-branch/src/providers/grass/qgsgrassprovider.cpp
branches/threading-branch/src/providers/grass/qgsgrassprovider.h
branches/threading-branch/src/providers/memory/qgsmemoryprovider.cpp
branches/threading-branch/src/providers/memory/qgsmemoryprovider.h
branches/threading-branch/src/providers/ogr/qgsogrprovider.cpp
branches/threading-branch/src/providers/ogr/qgsogrprovider.h
branches/threading-branch/src/providers/osm/osmprovider.cpp
branches/threading-branch/src/providers/osm/osmprovider.h
branches/threading-branch/src/providers/postgres/qgspostgresprovider.cpp
branches/threading-branch/src/providers/postgres/qgspostgresprovider.h
branches/threading-branch/src/providers/spatialite/qgsspatialiteprovider.cpp
branches/threading-branch/src/providers/spatialite/qgsspatialiteprovider.h
branches/threading-branch/src/providers/wfs/qgswfsprovider.cpp
branches/threading-branch/src/providers/wfs/qgswfsprovider.h
Log:
Moved implementation of old provider API to QgsVectorDataProvider. Providers now only implement getFeatures() request.
Modified: branches/threading-branch/src/core/qgsvectordataprovider.cpp
===================================================================
--- branches/threading-branch/src/core/qgsvectordataprovider.cpp 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/core/qgsvectordataprovider.cpp 2010-07-18 15:07:07 UTC (rev 13931)
@@ -20,6 +20,10 @@
#include <cfloat> // for DBL_MAX
#include <climits>
+#include <QApplication>
+#include <QThread>
+
+
#include "qgsvectordataprovider.h"
#include "qgsfeature.h"
#include "qgsfield.h"
@@ -162,6 +166,55 @@
return QgsFeatureIterator();
}
+void QgsVectorDataProvider::select( QgsAttributeList fetchAttributes,
+ QgsRectangle rect,
+ bool fetchGeometry,
+ bool useIntersect )
+{
+ if ( !isValid() )
+ {
+ QgsDebugMsg( "Read attempt on an invalid data source" );
+ return;
+ }
+
+ if (qApp->thread() != QThread::currentThread())
+ {
+ QgsDebugMsg("accessing old provider API from non-gui thread! (IGNORING)");
+ return;
+ }
+
+ mOldApiIter = getFeatures( fetchAttributes, rect, fetchGeometry, useIntersect );
+}
+
+bool QgsVectorDataProvider::nextFeature( QgsFeature& feature )
+{
+ if ( !isValid() )
+ {
+ QgsDebugMsg( "Read attempt on an invalid data source" );
+ return false;
+ }
+
+ if ( mOldApiIter.isClosed() )
+ {
+ QgsDebugMsg( "nextFeature() without select()" );
+ return false;
+ }
+
+ if (mOldApiIter.nextFeature(feature))
+ return true;
+ else
+ {
+ mOldApiIter.close(); // make sure to unlock the layer
+ return false;
+ }
+}
+
+void QgsVectorDataProvider::rewind()
+{
+ mOldApiIter.rewind();
+}
+
+
bool QgsVectorDataProvider::featureAtId( int featureId,
QgsFeature& feature,
bool fetchGeometry,
@@ -453,12 +506,12 @@
QgsFeature f;
QgsAttributeList keys;
keys.append( index );
- select( keys, QgsRectangle(), false );
+ QgsFeatureIterator fi = getFeatures( keys, QgsRectangle(), false );
QSet<QString> set;
values.clear();
- while ( nextFeature( f ) )
+ while ( fi.nextFeature( f ) )
{
if ( !set.contains( f.attributeMap()[index].toString() ) )
{
@@ -490,9 +543,9 @@
QgsFeature f;
QgsAttributeList keys = mCacheMinValues.keys();
- select( keys, QgsRectangle(), false );
+ QgsFeatureIterator fi = getFeatures( keys, QgsRectangle(), false );
- while ( nextFeature( f ) )
+ while ( fi.nextFeature( f ) )
{
QgsAttributeMap attrMap = f.attributeMap();
for ( QgsAttributeList::const_iterator it = keys.begin(); it != keys.end(); ++it )
Modified: branches/threading-branch/src/core/qgsvectordataprovider.h
===================================================================
--- branches/threading-branch/src/core/qgsvectordataprovider.h 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/core/qgsvectordataprovider.h 2010-07-18 15:07:07 UTC (rev 13931)
@@ -178,11 +178,12 @@
* @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
+ * @deprecated do not use nor implement in providers, use getFeatures() instead
*/
virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(),
QgsRectangle rect = QgsRectangle(),
bool fetchGeometry = true,
- bool useIntersect = false ) = 0;
+ bool useIntersect = false );
/**
* This function does nothing useful, it's kept only for compatibility.
@@ -193,6 +194,12 @@
/**
* Start iterating over features of the vector data provider.
* For new code, consider using this method instead of select/nextFeature combo.
+ * @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
+ * @return iterator instance for retrieval of features
* @note Added in v1.6
*/
virtual QgsFeatureIterator getFeatures( QgsAttributeList fetchAttributes = QgsAttributeList(),
@@ -220,8 +227,9 @@
* 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
+ * @deprecated do not use nor implement in providers, use getFeatures() instead
*/
- virtual bool nextFeature( QgsFeature& feature ) = 0;
+ virtual bool nextFeature( QgsFeature& feature );
/**
* Get feature type.
@@ -255,8 +263,9 @@
*/
virtual QString dataComment() const;
- /** Restart reading features from previous select operation */
- virtual void rewind() = 0;
+ /** Restart reading features from previous select operation
+ @deprecated do not use nor implement in providers, use getFeatures() instead */
+ virtual void rewind();
/**
* Returns the minimum value of an attribute
@@ -462,6 +471,8 @@
/**The names of the providers native types*/
QList< NativeType > mNativeTypes;
+ QgsFeatureIterator mOldApiIter;
+
private:
/** old notation **/
QMap<QString, QVariant::Type> mOldTypeList;
Modified: branches/threading-branch/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
===================================================================
--- branches/threading-branch/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/providers/delimitedtext/qgsdelimitedtextprovider.cpp 2010-07-18 15:07:07 UTC (rev 13931)
@@ -315,6 +315,8 @@
QgsDelimitedTextProvider::~QgsDelimitedTextProvider()
{
+ mOldApiIter.close();
+
mFile->close();
delete mFile;
delete mStream;
@@ -335,34 +337,6 @@
}
-bool QgsDelimitedTextProvider::nextFeature( QgsFeature& feature )
-{
- if (mOldApiIter.nextFeature(feature))
- return true;
- else
- {
- mOldApiIter.close(); // make sure to unlock the layer
- return false;
- }
-}
-
-
-void QgsDelimitedTextProvider::select( QgsAttributeList fetchAttributes,
- QgsRectangle rect,
- bool fetchGeometry,
- bool useIntersect )
-{
- mOldApiIter.close();
- mOldApiIter = getFeatures(fetchAttributes, rect, fetchGeometry, useIntersect);
-}
-
-void QgsDelimitedTextProvider::rewind()
-{
- mOldApiIter.rewind();
-}
-
-
-
void QgsDelimitedTextProvider::showInvalidLinesErrors()
{
// TODO: this should be modified to only set an error string that can be read from provider
Modified: branches/threading-branch/src/providers/delimitedtext/qgsdelimitedtextprovider.h
===================================================================
--- branches/threading-branch/src/providers/delimitedtext/qgsdelimitedtextprovider.h 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/providers/delimitedtext/qgsdelimitedtextprovider.h 2010-07-18 15:07:07 UTC (rev 13931)
@@ -58,28 +58,17 @@
*/
virtual QString storageType() const;
- /** Select features based on a bounding rectangle. Features can be retrieved with calls to nextFeature.
- * @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,
+ /**
+ * Start iterating over features of the vector data provider.
+ * For new code, consider using this method instead of select/nextFeature combo.
+ * @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
+ * @return iterator instance for retrieval of features
+ * @note Added in v1.6
*/
- virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(),
- QgsRectangle rect = QgsRectangle(),
- 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
- *
- * mFile should be open with the file pointer at the record of the next
- * feature, or EOF. The feature found on the current line is parsed.
- */
- virtual bool nextFeature( QgsFeature& feature );
-
virtual QgsFeatureIterator getFeatures( QgsAttributeList fetchAttributes = QgsAttributeList(),
QgsRectangle rect = QgsRectangle(),
bool fetchGeometry = true,
@@ -108,9 +97,6 @@
*/
virtual const QgsFieldMap & fields() const;
- /** Restart reading features from previous select operation */
- virtual void rewind();
-
/** Returns a bitmask containing the supported capabilities
Note, some capabilities may change depending on whether
a spatial filter is active on this provider, so it may
@@ -200,7 +186,6 @@
void showInvalidLinesErrors();
friend class QgsDelimitedTextFeatureIterator;
- QgsFeatureIterator mOldApiIter;
QMutex mStreamMutex;
};
Modified: branches/threading-branch/src/providers/gpx/qgsgpxprovider.cpp
===================================================================
--- branches/threading-branch/src/providers/gpx/qgsgpxprovider.cpp 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/providers/gpx/qgsgpxprovider.cpp 2010-07-18 15:07:07 UTC (rev 13931)
@@ -108,6 +108,8 @@
QgsGPXProvider::~QgsGPXProvider()
{
+ mOldApiIter.close();
+
QgsGPSData::releaseData( mFileName );
}
@@ -132,33 +134,7 @@
return QgsFeatureIterator( new QgsGPXFeatureIterator(this, fetchAttributes, rect, fetchGeometry, useIntersect) );
}
-bool QgsGPXProvider::nextFeature( QgsFeature& feature )
-{
- if (mOldApiIter.nextFeature(feature))
- return true;
- else
- {
- mOldApiIter.close(); // make sure to unlock the layer
- return false;
- }
-}
-void QgsGPXProvider::select( QgsAttributeList fetchAttributes,
- QgsRectangle rect,
- bool fetchGeometry,
- bool useIntersect )
-{
- mOldApiIter = getFeatures( fetchAttributes, rect, fetchGeometry, useIntersect );
-}
-
-
-void QgsGPXProvider::rewind()
-{
- mOldApiIter.rewind();
-}
-
-
-
// Return the extent of the layer
QgsRectangle QgsGPXProvider::extent()
{
Modified: branches/threading-branch/src/providers/gpx/qgsgpxprovider.h
===================================================================
--- branches/threading-branch/src/providers/gpx/qgsgpxprovider.h 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/providers/gpx/qgsgpxprovider.h 2010-07-18 15:07:07 UTC (rev 13931)
@@ -52,25 +52,17 @@
*/
virtual QString storageType() const;
- /** Select features based on a bounding rectangle. Features can be retrieved with calls to nextFeature.
+ /**
+ * Start iterating over features of the vector data provider.
+ * For new code, consider using this method instead of select/nextFeature combo.
* @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
+ * @return iterator instance for retrieval of features
+ * @note Added in v1.6
*/
- virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(),
- QgsRectangle rect = QgsRectangle(),
- 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 nextFeature( QgsFeature& feature );
-
virtual QgsFeatureIterator getFeatures( QgsAttributeList fetchAttributes = QgsAttributeList(),
QgsRectangle rect = QgsRectangle(),
bool fetchGeometry = true,
@@ -98,9 +90,6 @@
*/
virtual const QgsFieldMap & fields() const;
- /** Restart reading features from previous select operation */
- virtual void rewind();
-
/**
* Adds a list of features
* @return true in case of success and false in case of failure
@@ -176,7 +165,6 @@
long mNumberFeatures;
friend class QgsGPXFeatureIterator;
- QgsFeatureIterator mOldApiIter;
QMutex mDataMutex;
};
Modified: branches/threading-branch/src/providers/grass/qgsgrassprovider.cpp
===================================================================
--- branches/threading-branch/src/providers/grass/qgsgrassprovider.cpp 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/providers/grass/qgsgrassprovider.cpp 2010-07-18 15:07:07 UTC (rev 13931)
@@ -241,6 +241,9 @@
QgsGrassProvider::~QgsGrassProvider()
{
QgsDebugMsg( "entered." );
+
+ mOldApiIter.close();
+
closeLayer( mLayerId );
}
@@ -258,32 +261,7 @@
return QgsFeatureIterator( new QgsGrassFeatureIterator(this, fetchAttributes, rect, fetchGeometry, useIntersect) );
}
-void QgsGrassProvider::select( QgsAttributeList fetchAttributes,
- QgsRectangle rect,
- bool fetchGeometry,
- bool useIntersect )
-{
- mOldApiIter = getFeatures( fetchAttributes, rect, fetchGeometry, useIntersect );
-}
-bool QgsGrassProvider::nextFeature( QgsFeature& feature )
-{
- if (mOldApiIter.nextFeature(feature))
- return true;
- else
- {
- mOldApiIter.close(); // make sure to unlock the layer
- return false;
- }
-}
-
-
-void QgsGrassProvider::rewind()
-{
- mOldApiIter.rewind();
-}
-
-
QgsRectangle QgsGrassProvider::extent()
{
BOUND_BOX box;
Modified: branches/threading-branch/src/providers/grass/qgsgrassprovider.h
===================================================================
--- branches/threading-branch/src/providers/grass/qgsgrassprovider.h 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/providers/grass/qgsgrassprovider.h 2010-07-18 15:07:07 UTC (rev 13931)
@@ -126,28 +126,17 @@
*/
virtual QString storageType() const;
-
- /** Select features based on a bounding rectangle. Features can be retrieved with calls to nextFeature.
- * @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,
+ /**
+ * Start iterating over features of the vector data provider.
+ * For new code, consider using this method instead of select/nextFeature combo.
+ * @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)
+ * @return iterator instance for retrieval of features
+ * @note Added in v1.6
*/
- virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(),
- QgsRectangle rect = QgsRectangle(),
- 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 nextFeature( QgsFeature& feature );
-
virtual QgsFeatureIterator getFeatures( QgsAttributeList fetchAttributes = QgsAttributeList(),
QgsRectangle rect = QgsRectangle(),
bool fetchGeometry = true,
@@ -184,9 +173,6 @@
// ! Key (category) field index
int keyField();
- /** Restart reading features from previous select operation */
- void rewind();
-
/** Returns the minimum value of an attributs
* @param index the index of the attribute */
QVariant minimumValue( int index );
@@ -549,7 +535,6 @@
bool mValid; // !UPDATE!
long mNumberFeatures; // !UPDATE!
- QgsFeatureIterator mOldApiIter;
friend class QgsGrassFeatureIterator;
QMutex mMapMutex;
Modified: branches/threading-branch/src/providers/memory/qgsmemoryprovider.cpp
===================================================================
--- branches/threading-branch/src/providers/memory/qgsmemoryprovider.cpp 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/providers/memory/qgsmemoryprovider.cpp 2010-07-18 15:07:07 UTC (rev 13931)
@@ -57,6 +57,8 @@
QgsMemoryProvider::~QgsMemoryProvider()
{
+ mOldApiIter.close();
+
delete mSpatialIndex;
}
@@ -73,18 +75,7 @@
return QgsFeatureIterator( new QgsMemoryFeatureIterator(this, fetchAttributes, rect, fetchGeometry, useIntersect) );
}
-bool QgsMemoryProvider::nextFeature( QgsFeature& feature )
-{
- if (mOldApiIter.nextFeature(feature))
- return true;
- else
- {
- mOldApiIter.close(); // make sure to unlock the layer
- return false;
- }
-}
-
bool QgsMemoryProvider::featureAtId( int featureId,
QgsFeature& feature,
bool fetchGeometry,
@@ -104,20 +95,6 @@
}
-void QgsMemoryProvider::select( QgsAttributeList fetchAttributes,
- QgsRectangle rect,
- bool fetchGeometry,
- bool useIntersect )
-{
- mOldApiIter = getFeatures( fetchAttributes, rect, fetchGeometry, useIntersect );
-}
-
-void QgsMemoryProvider::rewind()
-{
- mOldApiIter.rewind();
-}
-
-
QgsRectangle QgsMemoryProvider::extent()
{
return mExtent;
Modified: branches/threading-branch/src/providers/memory/qgsmemoryprovider.h
===================================================================
--- branches/threading-branch/src/providers/memory/qgsmemoryprovider.h 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/providers/memory/qgsmemoryprovider.h 2010-07-18 15:07:07 UTC (rev 13931)
@@ -37,28 +37,18 @@
*/
virtual QString storageType() const;
- /** Select features based on a bounding rectangle. Features can be retrieved with calls to nextFeature.
- * @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
- */
- virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(),
- QgsRectangle rect = QgsRectangle(),
- 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
- *
- * mFile should be open with the file pointer at the record of the next
- * feature, or EOF. The feature found on the current line is parsed.
+ * Start iterating over features of the vector data provider.
+ * For new code, consider using this method instead of select/nextFeature combo.
+ * @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
+ * @return iterator instance for retrieval of features
+ * @note Added in v1.6
*/
- virtual bool nextFeature( QgsFeature& feature );
-
virtual QgsFeatureIterator getFeatures( QgsAttributeList fetchAttributes = QgsAttributeList(),
QgsRectangle rect = QgsRectangle(),
bool fetchGeometry = true,
@@ -100,10 +90,7 @@
*/
virtual const QgsFieldMap & fields() const;
- /** Restart reading features from previous select operation */
- virtual void rewind();
-
/**
* Adds a list of features
* @return true in case of success and false in case of failure
@@ -204,7 +191,6 @@
QgsSpatialIndex* mSpatialIndex;
friend class QgsMemoryFeatureIterator;
- QgsFeatureIterator mOldApiIter;
QMutex mDataMutex;
};
Modified: branches/threading-branch/src/providers/ogr/qgsogrprovider.cpp
===================================================================
--- branches/threading-branch/src/providers/ogr/qgsogrprovider.cpp 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/providers/ogr/qgsogrprovider.cpp 2010-07-18 15:07:07 UTC (rev 13931)
@@ -197,6 +197,8 @@
QgsOgrProvider::~QgsOgrProvider()
{
+ mOldApiIter.close();
+
if ( ogrLayer != ogrOrigLayer )
{
OGR_DS_ReleaseResultSet( ogrDataSource, ogrLayer );
@@ -466,32 +468,7 @@
return true;
}
-bool QgsOgrProvider::nextFeature( QgsFeature& feature )
-{
- if (mOldApiIter.nextFeature(feature))
- return true;
- else
- {
- mOldApiIter.close(); // make sure to unlock the layer
- return false;
- }
-}
-#include <QThread>
-void QgsOgrProvider::select( QgsAttributeList fetchAttributes, QgsRectangle rect, bool fetchGeometry, bool useIntersect )
-{
- if (qApp->thread() != QThread::currentThread())
- {
- QgsDebugMsg("accessing old provider API from non-gui thread! (IGNORING)");
- return;
- }
-
- //if (mOldApiIter != QgsFeatureIterator())
- mOldApiIter.close();
- mOldApiIter = getFeatures( fetchAttributes, rect, fetchGeometry, useIntersect );
-}
-
-
unsigned char * QgsOgrProvider::getGeometryPointer( OGRFeatureH fet )
{
OGRGeometryH geom = OGR_F_GetGeometryRef( fet );
@@ -632,14 +609,7 @@
return mAttributeFields;
}
-void QgsOgrProvider::rewind()
-{
- // the iterator is closed everyt
- //mOldApiIter = getFeatures( fetchAttributes, rect, fetchGeometry, useIntersect );
- mOldApiIter.rewind();
-}
-
//TODO - add sanity check for shape file layers, to include cheking to
// see if the .shp, .dbf, .shx files are all present and the layer
// actually has features
Modified: branches/threading-branch/src/providers/ogr/qgsogrprovider.h
===================================================================
--- branches/threading-branch/src/providers/ogr/qgsogrprovider.h 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/providers/ogr/qgsogrprovider.h 2010-07-18 15:07:07 UTC (rev 13931)
@@ -62,26 +62,17 @@
*/
virtual QString storageType() const;
- /** Select features based on a bounding rectangle. Features can be retrieved with calls to nextFeature.
- * @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,
+ /**
+ * Start iterating over features of the vector data provider.
+ * For new code, consider using this method instead of select/nextFeature combo.
+ * @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
+ * @return iterator instance for retrieval of features
+ * @note Added in v1.6
*/
- virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(),
- QgsRectangle rect = QgsRectangle(),
- 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 nextFeature( QgsFeature& feature );
-
-
virtual QgsFeatureIterator getFeatures( QgsAttributeList fetchAttributes = QgsAttributeList(),
QgsRectangle rect = QgsRectangle(),
bool fetchGeometry = true,
@@ -141,9 +132,6 @@
*/
virtual QgsRectangle extent();
- /** Restart reading features from previous select operation */
- virtual void rewind();
-
/**Writes a list of features to the file*/
virtual bool addFeatures( QgsFeatureList & flist );
@@ -290,7 +278,6 @@
int geomType;
long featuresCounted;
- QgsFeatureIterator mOldApiIter;
friend class QgsOgrFeatureIterator;
/**Adds one feature*/
Modified: branches/threading-branch/src/providers/osm/osmprovider.cpp
===================================================================
--- branches/threading-branch/src/providers/osm/osmprovider.cpp 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/providers/osm/osmprovider.cpp 2010-07-18 15:07:07 UTC (rev 13931)
@@ -327,6 +327,8 @@
QgsOSMDataProvider::~QgsOSMDataProvider()
{
+ mOldApiIter.close();
+
// finalize all created sqlite3 statements
sqlite3_finalize( mTagsStmt );
sqlite3_finalize( mCustomTagsStmt );
@@ -454,32 +456,6 @@
}
-void QgsOSMDataProvider::select( QgsAttributeList fetchAttributes,
- QgsRectangle rect,
- bool fetchGeometry,
- bool useIntersect )
-{
- mOldApiIter = getFeatures( fetchAttributes, rect, fetchGeometry, useIntersect );
-}
-
-
-bool QgsOSMDataProvider::nextFeature( QgsFeature& feature )
-{
- if (mOldApiIter.nextFeature(feature))
- return true;
- else
- {
- mOldApiIter.close(); // make sure to unlock the layer
- return false;
- }
-}
-
-void QgsOSMDataProvider::rewind()
-{
- mOldApiIter.rewind();
-}
-
-
bool QgsOSMDataProvider::featureAtId( int featureId,
QgsFeature& feature,
bool fetchGeometry,
Modified: branches/threading-branch/src/providers/osm/osmprovider.h
===================================================================
--- branches/threading-branch/src/providers/osm/osmprovider.h 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/providers/osm/osmprovider.h 2010-07-18 15:07:07 UTC (rev 13931)
@@ -94,7 +94,6 @@
QgsFieldMap mAttributeFields;
friend class QgsOSMFeatureIterator;
- QgsFeatureIterator mOldApiIter;
mutable QMutex mDatabaseMutex;
@@ -119,25 +118,18 @@
*/
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
- */
- virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(),
- QgsRectangle rect = QgsRectangle(),
- 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
+ * Start iterating over features of the vector data provider.
+ * For new code, consider using this method instead of select/nextFeature combo.
+ * @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
+ * @return iterator instance for retrieval of features
+ * @note Added in v1.6
*/
- virtual bool nextFeature( QgsFeature& feature );
-
virtual QgsFeatureIterator getFeatures( QgsAttributeList fetchAttributes = QgsAttributeList(),
QgsRectangle rect = QgsRectangle(),
bool fetchGeometry = true,
@@ -180,11 +172,6 @@
virtual const QgsFieldMap & fields() const;
/**
- * Restart reading features from previous select operation.
- */
- virtual void rewind();
-
- /**
* Changes attribute values of existing features.
* @param attr_map a map containing changed attributes
* @return true in case of success and false in case of failure
Modified: branches/threading-branch/src/providers/postgres/qgspostgresprovider.cpp
===================================================================
--- branches/threading-branch/src/providers/postgres/qgspostgresprovider.cpp 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/providers/postgres/qgspostgresprovider.cpp 2010-07-18 15:07:07 UTC (rev 13931)
@@ -524,30 +524,6 @@
}
-void QgsPostgresProvider::select( QgsAttributeList fetchAttributes, QgsRectangle rect, bool fetchGeometry, bool useIntersect )
-{
- if (!mOldApiIter.isClosed())
- mOldApiIter.close();
- mOldApiIter = getFeatures(fetchAttributes, rect, fetchGeometry, useIntersect);
-}
-
-bool QgsPostgresProvider::nextFeature( QgsFeature& feature )
-{
- if ( !valid )
- {
- QgsDebugMsg( "Read attempt on an invalid postgresql data source" );
- return false;
- }
-
- if ( mOldApiIter.isClosed() )
- {
- QgsDebugMsg( "nextFeature() without select()" );
- return false;
- }
-
- return mOldApiIter.nextFeature( feature );
-}
-
QString QgsPostgresProvider::whereClause( int featureId ) const
{
QString whereClause;
@@ -659,11 +635,6 @@
return mDataComment;
}
-void QgsPostgresProvider::rewind()
-{
- mOldApiIter.rewind();
-}
-
/** @todo XXX Perhaps this should be promoted to QgsDataProvider? */
QString QgsPostgresProvider::endianString()
{
Modified: branches/threading-branch/src/providers/postgres/qgspostgresprovider.h
===================================================================
--- branches/threading-branch/src/providers/postgres/qgspostgresprovider.h 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/providers/postgres/qgspostgresprovider.h 2010-07-18 15:07:07 UTC (rev 13931)
@@ -73,25 +73,17 @@
*/
virtual QgsCoordinateReferenceSystem crs();
- /** Select features based on a bounding rectangle. Features can be retrieved with calls to nextFeature.
- * @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,
+ /**
+ * Start iterating over features of the vector data provider.
+ * For new code, consider using this method instead of select/nextFeature combo.
+ * @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
+ * @return iterator instance for retrieval of features
+ * @note Added in v1.6
*/
- virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(),
- QgsRectangle rect = QgsRectangle(),
- 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 nextFeature( QgsFeature& feature );
-
virtual QgsFeatureIterator getFeatures( QgsAttributeList fetchAttributes = QgsAttributeList(),
QgsRectangle rect = QgsRectangle(),
bool fetchGeometry = true,
@@ -176,11 +168,6 @@
*/
QString dataComment() const;
- /** Reset the layer - for a PostgreSQL layer, this means clearing the PQresult
- * pointer, setting it to 0 and reloading the field list
- */
- void rewind();
-
/** Returns the minimum value of an attribute
* @param index the index of the attribute */
QVariant minimumValue( int index );
@@ -373,7 +360,6 @@
QgsFieldMap attributeFields;
QString mDataComment;
- QgsFeatureIterator mOldApiIter;
friend class QgsPostgresFeatureIterator;
//! Data source URI struct for this layer
Modified: branches/threading-branch/src/providers/spatialite/qgsspatialiteprovider.cpp
===================================================================
--- branches/threading-branch/src/providers/spatialite/qgsspatialiteprovider.cpp 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/providers/spatialite/qgsspatialiteprovider.cpp 2010-07-18 15:07:07 UTC (rev 13931)
@@ -391,44 +391,10 @@
bool fetchGeometry,
bool useIntersect )
{
- if ( !valid )
- {
- QgsDebugMsg( "Read attempt on an invalid SpatiaLite data source" );
- return QgsFeatureIterator();
- }
-
return QgsFeatureIterator( new QgsSpatiaLiteFeatureIterator(this, fetchAttributes, rect, fetchGeometry, useIntersect) );
}
-void QgsSpatiaLiteProvider::select( QgsAttributeList fetchAttributes, QgsRectangle rect, bool fetchGeometry, bool useIntersect )
-{
- mOldApiIter = getFeatures( fetchAttributes, rect, fetchGeometry, useIntersect );
-}
-
-bool QgsSpatiaLiteProvider::nextFeature( QgsFeature & feature )
-{
- if ( !valid )
- {
- QgsDebugMsg( "Read attempt on an invalid SpatiaLite data source" );
- return false;
- }
-
- if (mOldApiIter.nextFeature(feature))
- return true;
- else
- {
- mOldApiIter.close(); // make sure to unlock the layer
- return false;
- }
-}
-
-void QgsSpatiaLiteProvider::rewind()
-{
- mOldApiIter.rewind();
-}
-
-
QgsRectangle QgsSpatiaLiteProvider::extent()
{
return layerExtent;
Modified: branches/threading-branch/src/providers/spatialite/qgsspatialiteprovider.h
===================================================================
--- branches/threading-branch/src/providers/spatialite/qgsspatialiteprovider.h 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/providers/spatialite/qgsspatialiteprovider.h 2010-07-18 15:07:07 UTC (rev 13931)
@@ -85,23 +85,17 @@
virtual bool supportsSubsetString() { return true; }
- /** Select features based on a bounding rectangle. Features can be retrieved with calls to nextFeature.
- * @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,
+ /**
+ * Start iterating over features of the vector data provider.
+ * For new code, consider using this method instead of select/nextFeature combo.
+ * @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
+ * @return iterator instance for retrieval of features
+ * @note Added in v1.6
*/
- virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(),
- QgsRectangle rect = QgsRectangle(), 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 nextFeature( QgsFeature & feature );
-
virtual QgsFeatureIterator getFeatures( QgsAttributeList fetchAttributes = QgsAttributeList(),
QgsRectangle rect = QgsRectangle(),
bool fetchGeometry = true,
@@ -150,9 +144,6 @@
*/
const QgsFieldMap & fields() const;
- /** Reset the layer */
- void rewind();
-
/** Returns the minimum value of an attribute
* @param index the index of the attribute */
QVariant minimumValue( int index );
@@ -411,7 +402,6 @@
SqliteHandles *handle;
friend class QgsSpatiaLiteFeatureIterator;
- QgsFeatureIterator mOldApiIter;
QMutex mHandleMutex;
};
Modified: branches/threading-branch/src/providers/wfs/qgswfsprovider.cpp
===================================================================
--- branches/threading-branch/src/providers/wfs/qgswfsprovider.cpp 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/providers/wfs/qgswfsprovider.cpp 2010-07-18 15:07:07 UTC (rev 13931)
@@ -103,42 +103,11 @@
bool fetchGeometry,
bool useIntersect )
{
- if ( !mValid )
- {
- QgsDebugMsg( "Read attempt on an invalid WFS layer" );
- return QgsFeatureIterator();
- }
-
return QgsFeatureIterator( new QgsWFSFeatureIterator(this, fetchAttributes, rect, fetchGeometry, useIntersect) );
}
-void QgsWFSProvider::select( QgsAttributeList fetchAttributes,
- QgsRectangle rect,
- bool fetchGeometry,
- bool useIntersect )
-{
- mOldApiIter = getFeatures( fetchAttributes, rect, fetchGeometry, useIntersect );
-}
-bool QgsWFSProvider::nextFeature( QgsFeature& feature )
-{
- if (mOldApiIter.nextFeature(feature))
- return true;
- else
- {
- mOldApiIter.close(); // make sure to unlock the layer
- return false;
- }
-}
-
-void QgsWFSProvider::rewind()
-{
- mOldApiIter.rewind();
-}
-
-
-
int QgsWFSProvider::getFeature( const QString& uri )
{
QString geometryAttribute;
Modified: branches/threading-branch/src/providers/wfs/qgswfsprovider.h
===================================================================
--- branches/threading-branch/src/providers/wfs/qgswfsprovider.h 2010-07-18 12:06:52 UTC (rev 13930)
+++ branches/threading-branch/src/providers/wfs/qgswfsprovider.h 2010-07-18 15:07:07 UTC (rev 13931)
@@ -48,25 +48,17 @@
/* Inherited from QgsVectorDataProvider */
- /** Select features based on a bounding rectangle. Features can be retrieved with calls to nextFeature.
- * @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,
+ /**
+ * Start iterating over features of the vector data provider.
+ * For new code, consider using this method instead of select/nextFeature combo.
+ * @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
+ * @return iterator instance for retrieval of features
+ * @note Added in v1.6
*/
- virtual void select( QgsAttributeList fetchAttributes = QgsAttributeList(),
- QgsRectangle rect = QgsRectangle(),
- 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 nextFeature( QgsFeature& feature );
-
virtual QgsFeatureIterator getFeatures( QgsAttributeList fetchAttributes = QgsAttributeList(),
QgsRectangle rect = QgsRectangle(),
bool fetchGeometry = true,
@@ -76,7 +68,6 @@
long featureCount() const;
uint fieldCount() const;
const QgsFieldMap & fields() const;
- void rewind();
virtual QgsCoordinateReferenceSystem crs();
@@ -126,7 +117,6 @@
bool mValid;
friend class QgsWFSFeatureIterator;
- QgsFeatureIterator mOldApiIter;
QMutex mDataMutex;
More information about the QGIS-commit
mailing list