Skip to content

Commit

Permalink
Add dox
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Mar 18, 2019
1 parent 1ab1ad5 commit 66e9978
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ A feature pool is based on a vector layer and caches features.
QgsFeaturePool( QgsVectorLayer *layer );
virtual ~QgsFeaturePool();

bool getFeature( QgsFeatureId id, QgsFeature &feature, QgsFeedback *feedback = 0 );
bool getFeature( QgsFeatureId id, QgsFeature &feature );
%Docstring
Retrieve the feature with the specified ``id`` into ``feature``.
It will be retrieved from the cache or from the underlying layer if unavailable.
If the feature is neither available from the cache nor from the layer it will return false.
If ``feedback`` is specified, the call may return if the feedback is canceled.
Retrieves the feature with the specified ``id`` into ``feature``.
It will be retrieved from the cache or from the underlying feature source if unavailable.
If the feature is neither available from the cache nor from the source it will return FALSE.
%End


Expand Down Expand Up @@ -76,6 +75,12 @@ The coordinate reference system of this layer.
%End

QString layerName() const;
%Docstring
Returns the name of the layer.

Should be preferred over layer().name() because it can directly be run on
the background thread.
%End

protected:

Expand Down
2 changes: 1 addition & 1 deletion src/analysis/vector/geometry_checker/qgsfeaturepool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ QgsFeaturePool::QgsFeaturePool( QgsVectorLayer *layer )

}

bool QgsFeaturePool::getFeature( QgsFeatureId id, QgsFeature &feature, QgsFeedback *feedback )
bool QgsFeaturePool::getFeature( QgsFeatureId id, QgsFeature &feature )
{
// Why is there a write lock acquired here? Weird, we only want to read a feature from the cache, right?
// A method like `QCache::object(const Key &key) const` certainly would not modify its internals.
Expand Down
19 changes: 13 additions & 6 deletions src/analysis/vector/geometry_checker/qgsfeaturepool.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,20 @@ class ANALYSIS_EXPORT QgsFeaturePool : public QgsFeatureSink SIP_ABSTRACT
virtual ~QgsFeaturePool() = default;

/**
* Retrieve the feature with the specified \a id into \a feature.
* It will be retrieved from the cache or from the underlying layer if unavailable.
* If the feature is neither available from the cache nor from the layer it will return false.
* If \a feedback is specified, the call may return if the feedback is canceled.
* Retrieves the feature with the specified \a id into \a feature.
* It will be retrieved from the cache or from the underlying feature source if unavailable.
* If the feature is neither available from the cache nor from the source it will return FALSE.
*/
bool getFeature( QgsFeatureId id, QgsFeature &feature, QgsFeedback *feedback = nullptr );
bool getFeature( QgsFeatureId id, QgsFeature &feature );

/**
* Get features for the provided \a request. No features will be fetched
* from the cache and the request is sent directly to the underlying feature source.
* Results of the request are cached in the pool and the ids of all the features
* are returned. This can be used to warm the cache for a particular area of interest
* are returned. This is used to warm the cache for a particular area of interest
* (bounding box) or other set of features.
* This will get a new feature source from the source vector layer.
* This needs to be called from the main thread.
* If \a feedback is specified, the call may return if the feedback is canceled.
*/
QgsFeatureIds getFeatures( const QgsFeatureRequest &request, QgsFeedback *feedback = nullptr ) SIP_SKIP;
Expand Down Expand Up @@ -120,6 +121,12 @@ class ANALYSIS_EXPORT QgsFeaturePool : public QgsFeatureSink SIP_ABSTRACT
*/
QgsCoordinateReferenceSystem crs() const;

/**
* Returns the name of the layer.
*
* Should be preferred over layer().name() because it can directly be run on
* the background thread.
*/
QString layerName() const;

protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void QgsGeometryMissingVertexCheck::processPolygon( const QgsCurvePolygon *polyg
if ( fid == currentFeature.id() )
continue;

if ( featurePool->getFeature( fid, compareFeature, feedback ) )
if ( featurePool->getFeature( fid, compareFeature ) )
{
if ( feedback && feedback->isCanceled() )
break;
Expand Down

0 comments on commit 66e9978

Please sign in to comment.