Skip to content

Commit

Permalink
Fix outdated example code, convert to python
Browse files Browse the repository at this point in the history
(because c++ devs are l33t and don't need examples...)
  • Loading branch information
nyalldawson committed May 3, 2018
1 parent fdaa57a commit 1e7d479
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 22 deletions.
28 changes: 17 additions & 11 deletions python/core/qgsfeaturerequest.sip.in
Expand Up @@ -31,19 +31,25 @@ For efficiency, it is also possible to tell provider that some data is not requi
- SimplifyMethod for geometries to fetch

The options may be chained, e.g.:
QgsFeatureRequest().setFilterRect(QgsRectangle(0,0,1,1)).setFlags(QgsFeatureRequest.ExactIntersect)

.. code-block:: python

QgsFeatureRequest().setFilterRect(QgsRectangle(0,0,1,1)).setFlags(QgsFeatureRequest.ExactIntersect)

Examples:
- fetch all features:
QgsFeatureRequest()
- fetch all features, only one attribute
QgsFeatureRequest().setSubsetOfAttributes(QStringList("myfield"), provider->fieldMap())
- fetch all features, without geometries
QgsFeatureRequest().setFlags(QgsFeatureRequest.NoGeometry)
- fetch only features from particular extent
QgsFeatureRequest().setFilterRect(QgsRectangle(0,0,1,1))
- fetch only one feature
QgsFeatureRequest().setFilterFid(45)

.. code-block:: python

# fetch all features:
QgsFeatureRequest()
# fetch all features, only one attribute
QgsFeatureRequest().setSubsetOfAttributes(['myfield'], layer.fields())
# fetch all features, without geometries
QgsFeatureRequest().setFlags(QgsFeatureRequest.NoGeometry)
# fetch only features from particular extent
QgsFeatureRequest().setFilterRect(QgsRectangle(0,0,1,1))
# fetch only one feature
QgsFeatureRequest().setFilterFid(45)
%End

%TypeHeaderCode
Expand Down
27 changes: 16 additions & 11 deletions src/core/qgsfeaturerequest.h
Expand Up @@ -49,20 +49,25 @@
* - SimplifyMethod for geometries to fetch
*
* The options may be chained, e.g.:
* QgsFeatureRequest().setFilterRect(QgsRectangle(0,0,1,1)).setFlags(QgsFeatureRequest::ExactIntersect)
*
* \code{.py}
* QgsFeatureRequest().setFilterRect(QgsRectangle(0,0,1,1)).setFlags(QgsFeatureRequest.ExactIntersect)
* \endcode
*
* Examples:
* - fetch all features:
* QgsFeatureRequest()
* - fetch all features, only one attribute
* QgsFeatureRequest().setSubsetOfAttributes(QStringList("myfield"), provider->fieldMap())
* - fetch all features, without geometries
* QgsFeatureRequest().setFlags(QgsFeatureRequest::NoGeometry)
* - fetch only features from particular extent
* QgsFeatureRequest().setFilterRect(QgsRectangle(0,0,1,1))
* - fetch only one feature
* QgsFeatureRequest().setFilterFid(45)
*
* \code{.py}
* # fetch all features:
* QgsFeatureRequest()
* # fetch all features, only one attribute
* QgsFeatureRequest().setSubsetOfAttributes(['myfield'], layer.fields())
* # fetch all features, without geometries
* QgsFeatureRequest().setFlags(QgsFeatureRequest.NoGeometry)
* # fetch only features from particular extent
* QgsFeatureRequest().setFilterRect(QgsRectangle(0,0,1,1))
* # fetch only one feature
* QgsFeatureRequest().setFilterFid(45)
* \endcode
*/
class CORE_EXPORT QgsFeatureRequest
{
Expand Down

0 comments on commit 1e7d479

Please sign in to comment.