QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
53 QgsDebugMsg( QStringLiteral(
"Unable to use IdentifyKit without mapSettings property set." ) );
60 QgsFeatureList featureList = identifyVectorLayer( layer, mapPoint );
61 for (
const QgsFeature &feature : featureList )
65 QgsDebugMsg( QStringLiteral(
"IdentifyKit identified %1 results for layer %2" ).arg( results.count() ).arg( layer->
name() ) );
79 for (
const QgsFeature &feature : featureList )
84 if ( mIdentifyMode == IdentifyMode::TopDownStopAtFirst && !results.isEmpty() )
86 QgsDebugMsg( QStringLiteral(
"IdentifyKit identified %1 results with TopDownStopAtFirst mode." ).arg( results.count() ) );
91 QgsDebugMsg( QStringLiteral(
"IdentifyKit identified %1 results" ).arg( results.count() ) );
102 double distMinPoint = 1e10, distMinLine = 1e10, distMinPolygon = 1e10;
103 int iMinPoint = -1, iMinLine = -1, iMinPolygon = -1;
104 for (
int i = 0; i < results.count(); ++i )
119 double dist = geom.distance( mapPointGeom );
123 if ( dist < distMinPoint )
131 if ( dist < distMinLine )
139 if ( dist < distMinPolygon )
142 distMinPolygon = dist;
151 if ( iMinPoint != -1 && distMinPoint <= searchRadius )
152 return results.at( iMinPoint );
153 else if ( iMinLine != -1 && distMinLine <= searchRadius )
154 return results.at( iMinLine );
155 else if ( iMinPolygon != -1 )
156 return results.at( iMinPolygon );
164 return _closestFeature( results, mMapSettings->
mapSettings(), point, searchRadiusMU() );
185 double searchRadius = searchRadiusMU();
193 r = toLayerCoordinates( layer, r );
207 QgsDebugMsg( QStringLiteral(
"Invalid point, proceed without a found features." ) );
223 for (
const QgsFeature &feature : featureList )
225 context.expressionContext().setFeature( feature );
230 results.append( feature );
241 double QgsQuickIdentifyKit::searchRadiusMU(
const QgsRenderContext &context )
const
246 double QgsQuickIdentifyKit::searchRadiusMU()
const
249 return searchRadiusMU( context );
259 return mSearchRadiusMm;
273 return mFeaturesLimit;
278 if ( mFeaturesLimit == limit )
281 mFeaturesLimit = limit;
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
@ Filter
Features may be filtered, i.e. some features may not be rendered (categorized, rule based ....
QgsQuickMapSettings * mapSettings
Map settings.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
QgsPointXY mapToLayerCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from output CRS to layer's CRS
double mapUnitsPerPixel() const
Returns current map units per pixel.
@ ExactIntersect
Use exact geometry intersection (slower) instead of bounding boxes.
QgsCoordinateTransform layerTransform(const QgsMapLayer *layer) const
Returns the coordinate transform from layer's CRS to destination CRS.
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
void mapSettingsChanged()
Map settings.
void featuresLimitChanged()
Maximum number of features returned from the QgsQuickIdentifyKit::identify()
Q_INVOKABLE QgsQuickFeatureLayerPairs identify(const QPointF &point, QgsVectorLayer *layer=nullptr)
Gets all features in the search radius.
QgsProject * project
A project property should be used as a primary source of project all other components in the applicat...
virtual QgsFeatureRenderer::Capabilities capabilities()
Returns details about internals of this renderer.
static QgsGeometry fromPointXY(const QgsPointXY &point) SIP_HOLDGIL
Creates a new geometry from a QgsPointXY object.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
Contains information about the context of a rendering operation.
bool isSpatial() const FINAL
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
QgsPointXY toMapCoordinates(int x, int y) const
Transform device coordinates to map (world) coordinates.
QgsMapSettings mapSettings() const
Clone map settings.
A rectangle specified with double values.
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
virtual bool willRenderFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns whether the renderer will render a feature or not.
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
The QgsQuickMapSettings class encapsulates QgsMapSettings class to offer settings of configuration of...
QgsFields fields() const FINAL
Returns the list of fields of this layer.
bool isInScaleRange(double scale) const
Tests whether the layer should be visible at the specified scale.
This class wraps a request for features to a vector layer (or directly its vector data provider).
QgsMapLayer::LayerFlags flags() const
Returns the flags for this layer.
QList< QgsQuickFeatureLayerPair > QgsQuickFeatureLayerPairs
Custom exception class for Coordinate Reference System related exceptions.
double searchRadiusMm
Search radius for the identify functions.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
Q_GADGET QgsVectorLayer * layer
Vector layer to which the feature belongs.
QList< QgsFeature > QgsFeatureList
void setXMinimum(double x) SIP_HOLDGIL
Set the minimum x value.
void searchRadiusMmChanged()
Search radius for the identify functions.
double scale() const
Returns the calculated map scale.
QgsFeature feature
Feature that belongs to layer.
void setXMaximum(double x) SIP_HOLDGIL
Set the maximum x value.
A class to represent a 2D point.
void setYMaximum(double y) SIP_HOLDGIL
Set the maximum y value.
@ Identifiable
If the layer is identifiable using the identify map tool and as a WMS layer.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
bool nextFeature(QgsFeature &f)
void setYMinimum(double y) SIP_HOLDGIL
Set the minimum y value.
A geometry is the spatial representation of a feature.
Represents a vector layer which manages a vector based data sets.
@ ScaleDependent
Depends on scale if feature will be rendered (rule based )
QgsFeatureRequest & setLimit(long limit)
Set the maximum number of features to request.
Base class for all map layer types.
Pair of QgsFeature and QgsVectorLayer.
int featuresLimit
Maximum number of features returned from the QgsQuickIdentifyKit::identify()
void setFeaturesLimit(int limit)
Maximum number of features returned from the QgsQuickIdentifyKit::identify()
static GeometryType geometryType(Type type) SIP_HOLDGIL
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
QList< QgsMapLayer * > layers() const
Gets list of layers for map rendering The layers are stored in the reverse order of how they are rend...
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
void setSearchRadiusMm(double searchRadiusMm)
Search radius for the identify functions.
QgsQuickIdentifyKit(QObject *parent=nullptr)
Constructor of new identify kit.
The QgsMapSettings class contains configuration for rendering of the map.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
Wrapper for iterator of features from vector data provider or vector layer.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
const QgsMapToPixel & mapToPixel() const
QgsFeatureRenderer * renderer()
Returns renderer.
Q_INVOKABLE QgsQuickFeatureLayerPair identifyOne(const QPointF &point, QgsVectorLayer *layer=nullptr)
Gets the closest feature to the point within the search radius.
void setMapSettings(QgsQuickMapSettings *mapSettings)
Map settings.