QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
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;
static QgsGeometry fromPointXY(const QgsPointXY &point)
Creates a new geometry from a QgsPointXY object.
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 setXMinimum(double x)
Set the minimum x value.
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 QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
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.
QgsVectorLayer layer
Vector layer to which the feature belongs.
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.
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.
QgsMapLayer::LayerFlags flags() const
Returns the flags for this layer.
QList< QgsQuickFeatureLayerPair > QgsQuickFeatureLayerPairs
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)
QList< QgsFeature > QgsFeatureList
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
void setXMaximum(double x)
Set the maximum 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.
@ 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)
@ ScaleDependent
Depends on scale if feature will be rendered (rule based )
QgsFeatureRequest & setLimit(long limit)
Set the maximum number of features to request.
int featuresLimit
Maximum number of features returned from the QgsQuickIdentifyKit::identify()
void setFeaturesLimit(int limit)
Maximum number of features returned from the QgsQuickIdentifyKit::identify()
QList< QgsMapLayer * > layers() const
Gets list of layers for map rendering The layers are stored in the reverse order of how they are rend...
void setSearchRadiusMm(double searchRadiusMm)
Search radius for the identify functions.
QgsQuickIdentifyKit(QObject *parent=nullptr)
Constructor of new identify kit.
virtual void startRender(QgsRenderContext &context, const QgsFields &fields)
Must be called when a new render cycle is started.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
const QgsMapToPixel & mapToPixel() const
void setYMinimum(double y)
Set the minimum y value.
void setYMaximum(double y)
Set the maximum y value.
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.