Skip to content

Commit

Permalink
[api] Add option to QgsFeatureRequest to request features
Browse files Browse the repository at this point in the history
within a certain distance of a reference geometry

E.g. this request will retrieve all features within 50 map units of the
provided linestring:

    QgsFeatureRequest().setDistanceWithin(QgsGeometry.fromWkt('LineString(0 0, 10 0, 12 1)'), 50)

A new enum Qgis::SpatialFilterType has been added to reflect whether
a request uses no spatial filter, a BoundingBox filter (via
setFilterRect), or the new DistanceWithin filter.

Distance within filters are treated like bounding box filters, in
that they are independant of any attribute/id filters (such as
feature ids or expressions).
  • Loading branch information
nyalldawson committed Aug 5, 2021
1 parent d01aa28 commit 686a6e5
Show file tree
Hide file tree
Showing 14 changed files with 766 additions and 89 deletions.
7 changes: 7 additions & 0 deletions python/core/auto_additions/qgis.py
Expand Up @@ -627,3 +627,10 @@
Qgis.JoinStyle.__doc__ = 'Join styles for buffers.\n\n.. versionadded:: 3.22\n\n' + '* ``JoinStyleRound``: ' + Qgis.JoinStyle.Round.__doc__ + '\n' + '* ``JoinStyleMiter``: ' + Qgis.JoinStyle.Miter.__doc__ + '\n' + '* ``JoinStyleBevel``: ' + Qgis.JoinStyle.Bevel.__doc__
# --
Qgis.JoinStyle.baseClass = Qgis
# monkey patching scoped based enum
Qgis.SpatialFilterType.NoFilter.__doc__ = "No spatial filtering of features"
Qgis.SpatialFilterType.BoundingBox.__doc__ = "Filter using a bounding box"
Qgis.SpatialFilterType.DistanceWithin.__doc__ = "Filter by distance to reference geometry"
Qgis.SpatialFilterType.__doc__ = 'Feature request spatial filter types.\n\n.. versionadded:: 3.22\n\n' + '* ``NoFilter``: ' + Qgis.SpatialFilterType.NoFilter.__doc__ + '\n' + '* ``BoundingBox``: ' + Qgis.SpatialFilterType.BoundingBox.__doc__ + '\n' + '* ``DistanceWithin``: ' + Qgis.SpatialFilterType.DistanceWithin.__doc__
# --
Qgis.SpatialFilterType.baseClass = Qgis
7 changes: 7 additions & 0 deletions python/core/auto_generated/qgis.sip.in
Expand Up @@ -437,6 +437,13 @@ The development version
Bevel,
};

enum class SpatialFilterType
{
NoFilter,
BoundingBox,
DistanceWithin,
};

static const double DEFAULT_SEARCH_RADIUS_MM;

static const float DEFAULT_MAPTOPIXEL_THRESHOLD;
Expand Down

0 comments on commit 686a6e5

Please sign in to comment.