39 if ( mapSettings == mMapSettings )
52 QgsDebugMsg( QStringLiteral(
"Unable to use IdentifyKit without mapSettings property set." ) );
59 QgsFeatureList featureList = identifyVectorLayer( layer, mapPoint );
60 for (
const QgsFeature &feature : featureList )
64 QgsDebugMsg( QStringLiteral(
"IdentifyKit identified %1 results for layer %2" ).arg( results.count() ).arg( layer->
name() ) );
78 for (
const QgsFeature &feature : featureList )
83 if ( mIdentifyMode == IdentifyMode::TopDownStopAtFirst && !results.isEmpty() )
85 QgsDebugMsg( QStringLiteral(
"IdentifyKit identified %1 results with TopDownStopAtFirst mode." ).arg( results.count() ) );
90 QgsDebugMsg( QStringLiteral(
"IdentifyKit identified %1 results" ).arg( results.count() ) );
101 double distMin = 1e10;
103 for (
int i = 0; i < results.count(); ++i )
118 double dist = geom.distance( mapPointGeom );
119 if ( dist < distMin )
126 if ( results.empty() )
132 return results.at( iMin );
139 return _closestFeature( results, mMapSettings->
mapSettings(), point );
160 double searchRadius = searchRadiusMU();
168 r = toLayerCoordinates( layer, r );
182 QgsDebugMsg( QStringLiteral(
"Invalid point, proceed without a found features." ) );
198 for (
const QgsFeature &feature : featureList )
202 if ( filter && !renderer->
willRenderFeature( const_cast<QgsFeature &>( feature ), context ) )
205 results.append( feature );
216 double QgsQuickIdentifyKit::searchRadiusMU(
const QgsRenderContext &context )
const 221 double QgsQuickIdentifyKit::searchRadiusMU()
const 224 return searchRadiusMU( context );
234 return mSearchRadiusMm;
248 return mFeaturesLimit;
253 if ( mFeaturesLimit == limit )
256 mFeaturesLimit = limit;
void featuresLimitChanged()
Maximum number of features returned from the QgsQuickIdentifyKit::identify()
void setSearchRadiusMm(double searchRadiusMm)
Search radius for the identify functions.
Wrapper for iterator of features from vector data provider or vector layer.
QgsProject project
A project property should be used as a primary source of project all other components in the applicat...
A rectangle specified with double values.
Base class for all map layer types.
virtual bool willRenderFeature(const QgsFeature &feature, QgsRenderContext &context) const
Returns whether the renderer will render a feature or not.
Depends on scale if feature will be rendered (rule based )
QgsMapSettings mapSettings() const
Clone map settings.
double scale() const
Returns the calculated map scale.
OperationResult transform(const QgsCoordinateTransform &ct, QgsCoordinateTransform::TransformDirection direction=QgsCoordinateTransform::ForwardTransform, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
void setFeaturesLimit(int limit)
Maximum number of features returned from the QgsQuickIdentifyKit::identify()
void setXMaximum(double x)
Set the maximum x value.
Use exact geometry intersection (slower) instead of bounding boxes.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
Features may be filtered, i.e. some features may not be rendered (categorized, rule based ...
QList< QgsFeature > QgsFeatureList
A class to represent a 2D point.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
A geometry is the spatial representation of a feature.
int featuresLimit() const
Maximum number of features returned from the QgsQuickIdentifyKit::identify()
const QgsMapToPixel & mapToPixel() const
QgsPointXY mapToLayerCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from output CRS to layer's CRS
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsCoordinateTransform layerTransform(const QgsMapLayer *layer) const
Returns the coordinate transform from layer's CRS to destination CRS.
The QgsQuickMapSettings class encapsulates QgsMapSettings class to offer settings of configuration of...
bool isSpatial() const FINAL
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
void setMapSettings(QgsQuickMapSettings *mapSettings)
Map settings.
The QgsMapSettings class contains configuration for rendering of the map.
QList< QgsMapLayer * > layers() const
Gets list of layers for map rendering The layers are stored in the reverse order of how they are rend...
QgsQuickMapSettings * mapSettings() const
Map settings.
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.
void searchRadiusMmChanged()
Search radius for the identify functions.
void setYMinimum(double y)
Set the minimum y value.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsFeatureRequest & setFilterRect(const QgsRectangle &rectangle)
Sets the rectangle from which features will be taken.
double mapUnitsPerPixel() const
Returns current map units per pixel.
QgsFeatureRenderer * renderer()
Returns renderer.
QgsPointXY toMapCoordinates(int x, int y) const
Transform device coordinates to map (world) coordinates.
QgsExpressionContext & expressionContext()
Gets the expression context.
Contains information about the context of a rendering operation.
QgsFeature feature
Feature that belongs to layer.
QgsMapLayer::LayerFlags flags() const
Returns the flags for this layer.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
void setYMaximum(double y)
Set the maximum y value.
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
Q_INVOKABLE QgsQuickFeatureLayerPair identifyOne(const QPointF &point, QgsVectorLayer *layer=nullptr)
Gets the closest feature to the point within the search radius.
virtual void stopRender(QgsRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
QgsVectorLayer layer
Vector layer to which the feature belongs.
QgsFeatureRequest & setLimit(long limit)
Set the maximum number of features to request.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
void mapSettingsChanged()
Map settings.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Query the layer for features specified in request.
Q_INVOKABLE QgsQuickFeatureLayerPairs identify(const QPointF &point, QgsVectorLayer *layer=nullptr)
Gets all features in the search radius.
QList< QgsQuickFeatureLayerPair > QgsQuickFeatureLayerPairs
Custom exception class for Coordinate Reference System related exceptions.
Pair of QgsFeature and QgsVectorLayer.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
bool nextFeature(QgsFeature &f)
Represents a vector layer which manages a vector based data sets.
QgsQuickIdentifyKit(QObject *parent=nullptr)
Constructor of new identify kit.
If the layer is identifiable using the identify map tool and as a WMS layer.
double searchRadiusMm() const
Search radius for the identify functions.
virtual QgsFeatureRenderer::Capabilities capabilities()
Returns details about internals of this renderer.
static QgsGeometry fromPointXY(const QgsPointXY &point)
Creates a new geometry from a QgsPointXY object.
void setXMinimum(double x)
Set the minimum x value.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.