QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsmaptoolidentify.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmaptoolidentify.cpp - map tool for identifying features
3  ---------------------
4  begin : January 2006
5  copyright : (C) 2006 by Martin Dobias
6  email : wonder.sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #include "qgsapplication.h"
17 #include "qgsdistancearea.h"
18 #include "qgsfeature.h"
19 #include "qgsfeatureiterator.h"
20 #include "qgsfeaturestore.h"
21 #include "qgsfields.h"
22 #include "qgsgeometry.h"
23 #include "qgsgeometryengine.h"
24 #include "qgsidentifymenu.h"
25 #include "qgslogger.h"
26 #include "qgsmapcanvas.h"
27 #include "qgsmaptoolidentify.h"
28 #include "qgsmaptopixel.h"
29 #include "qgsmessageviewer.h"
30 #include "qgsmeshlayer.h"
31 #include "qgsmaplayer.h"
32 #include "qgsrasterdataprovider.h"
33 #include "qgsrasterlayer.h"
36 #include "qgsvectordataprovider.h"
37 #include "qgsvectorlayer.h"
38 #include "qgsvectortilelayer.h"
40 #include "qgsvectortileutils.h"
41 #include "qgsproject.h"
42 #include "qgsrenderer.h"
43 #include "qgstiles.h"
44 #include "qgsgeometryutils.h"
45 #include "qgsgeometrycollection.h"
46 #include "qgscurve.h"
47 #include "qgscoordinateutils.h"
48 #include "qgsexception.h"
49 #include "qgssettings.h"
51 
52 #include <QMouseEvent>
53 #include <QCursor>
54 #include <QPixmap>
55 #include <QStatusBar>
56 #include <QVariant>
57 #include <QMenu>
58 
60  : QgsMapTool( canvas )
61  , mIdentifyMenu( new QgsIdentifyMenu( mCanvas ) )
62  , mLastMapUnitsPerPixel( -1.0 )
63  , mCoordinatePrecision( 6 )
64 {
65  setCursor( QgsApplication::getThemeCursor( QgsApplication::Cursor::Identify ) );
66 }
67 
69 {
70  delete mIdentifyMenu;
71 }
72 
74 {
75  Q_UNUSED( e )
76 }
77 
79 {
80  Q_UNUSED( e )
81 }
82 
84 {
85  Q_UNUSED( e )
86 }
87 
88 QList<QgsMapToolIdentify::IdentifyResult> QgsMapToolIdentify::identify( int x, int y, const QList<QgsMapLayer *> &layerList, IdentifyMode mode )
89 {
90  return identify( x, y, mode, layerList, AllLayers );
91 }
92 
93 QList<QgsMapToolIdentify::IdentifyResult> QgsMapToolIdentify::identify( int x, int y, IdentifyMode mode, LayerType layerType )
94 {
95  return identify( x, y, mode, QList<QgsMapLayer *>(), layerType );
96 }
97 
98 QList<QgsMapToolIdentify::IdentifyResult> QgsMapToolIdentify::identify( int x, int y, IdentifyMode mode, const QList<QgsMapLayer *> &layerList, LayerType layerType )
99 {
100  return identify( QgsGeometry::fromPointXY( toMapCoordinates( QPoint( x, y ) ) ), mode, layerList, layerType );
101 }
102 
103 QList<QgsMapToolIdentify::IdentifyResult> QgsMapToolIdentify::identify( const QgsGeometry &geometry, IdentifyMode mode, LayerType layerType )
104 {
105  return identify( geometry, mode, QList<QgsMapLayer *>(), layerType );
106 }
107 
108 QList<QgsMapToolIdentify::IdentifyResult> QgsMapToolIdentify::identify( const QgsGeometry &geometry, IdentifyMode mode, const QList<QgsMapLayer *> &layerList, LayerType layerType )
109 {
110  QList<IdentifyResult> results;
111 
112  mLastGeometry = geometry;
113  mLastExtent = mCanvas->extent();
114  mLastMapUnitsPerPixel = mCanvas->mapUnitsPerPixel();
115 
116  mCoordinatePrecision = QgsCoordinateUtils::calculateCoordinatePrecision( mLastMapUnitsPerPixel, mCanvas->mapSettings().destinationCrs() );
117 
118  if ( mode == DefaultQgsSetting )
119  {
120  QgsSettings settings;
121  mode = settings.enumValue( QStringLiteral( "Map/identifyMode" ), ActiveLayer );
122  }
123 
124  if ( mode == LayerSelection )
125  {
126  QPoint canvasPt = toCanvasCoordinates( geometry.asPoint() );
127  int x = canvasPt.x(), y = canvasPt.y();
128  QList<IdentifyResult> results = identify( x, y, TopDownAll, layerList, layerType );
129  QPoint globalPos = mCanvas->mapToGlobal( QPoint( x + 5, y + 5 ) );
130  return mIdentifyMenu->exec( results, globalPos );
131  }
132  else if ( mode == ActiveLayer && layerList.isEmpty() )
133  {
134  QgsMapLayer *layer = mCanvas->currentLayer();
135 
136  if ( !layer )
137  {
138  emit identifyMessage( tr( "No active layer. To identify features, you must choose an active layer." ) );
139  return results;
140  }
141 
142  QApplication::setOverrideCursor( Qt::WaitCursor );
143 
144  identifyLayer( &results, layer, mLastGeometry, mLastExtent, mLastMapUnitsPerPixel, layerType );
145  }
146  else
147  {
148  QApplication::setOverrideCursor( Qt::WaitCursor );
149 
150  int layerCount;
151  if ( layerList.isEmpty() )
152  layerCount = mCanvas->layerCount();
153  else
154  layerCount = layerList.count();
155 
156 
157  for ( int i = 0; i < layerCount; i++ )
158  {
159 
160  QgsMapLayer *layer = nullptr;
161  if ( layerList.isEmpty() )
162  layer = mCanvas->layer( i );
163  else
164  layer = layerList.value( i );
165 
166  emit identifyProgress( i, mCanvas->layerCount() );
167  emit identifyMessage( tr( "Identifying on %1…" ).arg( layer->name() ) );
168 
169  if ( !layer->flags().testFlag( QgsMapLayer::Identifiable ) )
170  continue;
171 
172  if ( identifyLayer( &results, layer, mLastGeometry, mLastExtent, mLastMapUnitsPerPixel, layerType ) )
173  {
174  if ( mode == TopDownStopAtFirst )
175  break;
176  }
177  }
178 
180  emit identifyMessage( tr( "Identifying done." ) );
181  }
182 
183  QApplication::restoreOverrideCursor();
184 
185  return results;
186 }
187 
188 void QgsMapToolIdentify::setCanvasPropertiesOverrides( double searchRadiusMapUnits )
189 {
190  mOverrideCanvasSearchRadius = searchRadiusMapUnits;
191 }
192 
194 {
195  mOverrideCanvasSearchRadius = -1;
196 }
197 
199 {
201 }
202 
204 {
206 }
207 
208 bool QgsMapToolIdentify::identifyLayer( QList<IdentifyResult> *results, QgsMapLayer *layer, const QgsPointXY &point, const QgsRectangle &viewExtent, double mapUnitsPerPixel, QgsMapToolIdentify::LayerType layerType )
209 {
210  return identifyLayer( results, layer, QgsGeometry::fromPointXY( point ), viewExtent, mapUnitsPerPixel, layerType );
211 }
212 
213 bool QgsMapToolIdentify::identifyLayer( QList<IdentifyResult> *results, QgsMapLayer *layer, const QgsGeometry &geometry, const QgsRectangle &viewExtent, double mapUnitsPerPixel, QgsMapToolIdentify::LayerType layerType )
214 {
215  if ( layer->type() == QgsMapLayerType::RasterLayer && layerType.testFlag( RasterLayer ) )
216  {
217  return identifyRasterLayer( results, qobject_cast<QgsRasterLayer *>( layer ), geometry, viewExtent, mapUnitsPerPixel );
218  }
219  else if ( layer->type() == QgsMapLayerType::VectorLayer && layerType.testFlag( VectorLayer ) )
220  {
221  return identifyVectorLayer( results, qobject_cast<QgsVectorLayer *>( layer ), geometry );
222  }
223  else if ( layer->type() == QgsMapLayerType::MeshLayer && layerType.testFlag( MeshLayer ) )
224  {
225  return identifyMeshLayer( results, qobject_cast<QgsMeshLayer *>( layer ), geometry );
226  }
227  else if ( layer->type() == QgsMapLayerType::VectorTileLayer && layerType.testFlag( VectorTileLayer ) )
228  {
229  return identifyVectorTileLayer( results, qobject_cast<QgsVectorTileLayer *>( layer ), geometry );
230  }
231  else
232  {
233  return false;
234  }
235 }
236 
237 bool QgsMapToolIdentify::identifyVectorLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsVectorLayer *layer, const QgsPointXY &point )
238 {
239  return identifyVectorLayer( results, layer, QgsGeometry::fromPointXY( point ) );
240 }
241 
242 bool QgsMapToolIdentify::identifyMeshLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsMeshLayer *layer, const QgsGeometry &geometry )
243 {
244  const QgsPointXY point = geometry.asPoint(); // mesh layers currently only support identification by point
245  return identifyMeshLayer( results, layer, point );
246 }
247 
248 bool QgsMapToolIdentify::identifyMeshLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsMeshLayer *layer, const QgsPointXY &point )
249 {
250  QgsDebugMsgLevel( "point = " + point.toString(), 4 );
251  if ( !layer || !layer->dataProvider() )
252  return false;
253 
254  const QgsMeshRendererSettings rendererSettings = layer->rendererSettings();
255  const QgsMeshDatasetIndex scalarDatasetIndex = layer->activeScalarDatasetAtTime( mCanvas->temporalRange() );
256  const QgsMeshDatasetIndex vectorDatasetIndex = layer->activeVectorDatasetAtTime( mCanvas->temporalRange() );
257  if ( ! scalarDatasetIndex.isValid() && ! vectorDatasetIndex.isValid() )
258  return false;
259 
260  QMap< QString, QString > scalarAttributes, vectorAttributes, raw3dAttributes;
261 
262  double searchRadius = mOverrideCanvasSearchRadius < 0 ? searchRadiusMU( mCanvas ) : mOverrideCanvasSearchRadius;
263 
264  QString scalarGroup;
265  if ( scalarDatasetIndex.isValid() )
266  {
267  scalarGroup = layer->dataProvider()->datasetGroupMetadata( scalarDatasetIndex.group() ).name();
268 
269  const QgsMeshDatasetValue scalarValue = layer->datasetValue( scalarDatasetIndex, point, searchRadius );
270  const double scalar = scalarValue.scalar();
271  if ( std::isnan( scalar ) )
272  scalarAttributes.insert( tr( "Scalar Value" ), tr( "no data" ) );
273  else
274  scalarAttributes.insert( tr( "Scalar Value" ), QString::number( scalar ) );
275  }
276 
277  QString vectorGroup;
278  if ( vectorDatasetIndex.isValid() )
279  {
280  vectorGroup = layer->dataProvider()->datasetGroupMetadata( vectorDatasetIndex.group() ).name();
281 
282  const QgsMeshDatasetValue vectorValue = layer->datasetValue( vectorDatasetIndex, point, searchRadius );
283  const double vectorX = vectorValue.x();
284  const double vectorY = vectorValue.y();
285 
286  if ( std::isnan( vectorX ) || std::isnan( vectorY ) )
287  vectorAttributes.insert( tr( "Vector Value" ), tr( "no data" ) );
288  else
289  {
290  vectorAttributes.insert( tr( "Vector Magnitude" ), QString::number( vectorValue.scalar() ) );
291  vectorAttributes.insert( tr( "Vector x-component" ), QString::number( vectorY ) );
292  vectorAttributes.insert( tr( "Vector y-component" ), QString::number( vectorX ) );
293  }
294  }
295 
296  const QMap< QString, QString > derivedAttributes = derivedAttributesForPoint( QgsPoint( point ) );
297  if ( scalarGroup == vectorGroup )
298  {
299  const IdentifyResult result( qobject_cast<QgsMapLayer *>( layer ),
300  scalarGroup,
301  vectorAttributes,
302  derivedAttributes );
303  results->append( result );
304  }
305  else
306  {
307  if ( !scalarGroup.isEmpty() )
308  {
309  const IdentifyResult result( qobject_cast<QgsMapLayer *>( layer ),
310  scalarGroup,
311  scalarAttributes,
312  derivedAttributes );
313  results->append( result );
314  }
315  if ( !vectorGroup.isEmpty() )
316  {
317  const IdentifyResult result( qobject_cast<QgsMapLayer *>( layer ),
318  vectorGroup,
319  vectorAttributes,
320  derivedAttributes );
321  results->append( result );
322  }
323  }
324  return true;
325 }
326 
327 bool QgsMapToolIdentify::identifyVectorTileLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsVectorTileLayer *layer, const QgsGeometry &geometry )
328 {
329  if ( !layer || !layer->isSpatial() )
330  return false;
331 
332  if ( !layer->isInScaleRange( mCanvas->mapSettings().scale() ) )
333  {
334  QgsDebugMsgLevel( QStringLiteral( "Out of scale limits" ), 2 );
335  return false;
336  }
337 
338  QgsTemporaryCursorOverride waitCursor( Qt::WaitCursor );
339 
340  QMap< QString, QString > commonDerivedAttributes;
341 
342  QgsGeometry selectionGeom = geometry;
343  bool isPointOrRectangle;
344  QgsPointXY point;
345  bool isSingleClick = selectionGeom.type() == QgsWkbTypes::PointGeometry;
346  if ( isSingleClick )
347  {
348  isPointOrRectangle = true;
349  point = selectionGeom.asPoint();
350 
351  commonDerivedAttributes = derivedAttributesForPoint( QgsPoint( point ) );
352  }
353  else
354  {
355  // we have a polygon - maybe it is a rectangle - in such case we can avoid costly insterestion tests later
356  isPointOrRectangle = QgsGeometry::fromRect( selectionGeom.boundingBox() ).isGeosEqual( selectionGeom );
357  }
358 
359  int featureCount = 0;
360 
361  QgsFeatureList featureList;
362  std::unique_ptr<QgsGeometryEngine> selectionGeomPrepared;
363 
364  // toLayerCoordinates will throw an exception for an 'invalid' point.
365  // For example, if you project a world map onto a globe using EPSG 2163
366  // and then click somewhere off the globe, an exception will be thrown.
367  try
368  {
369  QgsRectangle r;
370  if ( isSingleClick )
371  {
372  double sr = mOverrideCanvasSearchRadius < 0 ? searchRadiusMU( mCanvas ) : mOverrideCanvasSearchRadius;
373  r = toLayerCoordinates( layer, QgsRectangle( point.x() - sr, point.y() - sr, point.x() + sr, point.y() + sr ) );
374  }
375  else
376  {
377  r = toLayerCoordinates( layer, selectionGeom.boundingBox() );
378 
379  if ( !isPointOrRectangle )
380  {
382  if ( ct.isValid() )
383  selectionGeom.transform( ct );
384 
385  // use prepared geometry for faster intersection test
386  selectionGeomPrepared.reset( QgsGeometry::createGeometryEngine( selectionGeom.constGet() ) );
387  }
388  }
389 
390  int tileZoom = QgsVectorTileUtils::scaleToZoomLevel( mCanvas->scale(), layer->sourceMinZoom(), layer->sourceMaxZoom() );
391  QgsTileMatrix tileMatrix = QgsTileMatrix::fromWebMercator( tileZoom );
392  QgsTileRange tileRange = tileMatrix.tileRangeFromExtent( r );
393 
394  for ( int row = tileRange.startRow(); row <= tileRange.endRow(); ++row )
395  {
396  for ( int col = tileRange.startColumn(); col <= tileRange.endColumn(); ++col )
397  {
398  QgsTileXYZ tileID( col, row, tileZoom );
399  QByteArray data = layer->getRawTile( tileID );
400  if ( data.isEmpty() )
401  continue; // failed to get data
402 
403  QgsVectorTileMVTDecoder decoder;
404  if ( !decoder.decode( tileID, data ) )
405  continue; // failed to decode
406 
407  QMap<QString, QgsFields> perLayerFields;
408  const QStringList layerNames = decoder.layers();
409  for ( const QString &layerName : layerNames )
410  {
411  QSet<QString> fieldNames = qgis::listToSet( decoder.layerFieldNames( layerName ) );
412  perLayerFields[layerName] = QgsVectorTileUtils::makeQgisFields( fieldNames );
413  }
414 
415  const QgsVectorTileFeatures features = decoder.layerFeatures( perLayerFields, QgsCoordinateTransform() );
416  const QStringList featuresLayerNames = features.keys();
417  for ( const QString &layerName : featuresLayerNames )
418  {
419  const QgsFields fFields = perLayerFields[layerName];
420  const QVector<QgsFeature> &layerFeatures = features[layerName];
421  for ( const QgsFeature &f : layerFeatures )
422  {
423  if ( f.geometry().intersects( r ) && ( !selectionGeomPrepared || selectionGeomPrepared->intersects( f.geometry().constGet() ) ) )
424  {
425  QMap< QString, QString > derivedAttributes = commonDerivedAttributes;
426  derivedAttributes.insert( tr( "Feature ID" ), FID_TO_STRING( f.id() ) );
427 
428  results->append( IdentifyResult( qobject_cast<QgsMapLayer *>( layer ), layerName, fFields, f, derivedAttributes ) );
429 
430  featureCount++;
431  }
432  }
433  }
434  }
435  }
436 
437  }
438  catch ( QgsCsException &cse )
439  {
440  Q_UNUSED( cse )
441  // catch exception for 'invalid' point and proceed with no features found
442  QgsDebugMsg( QStringLiteral( "Caught CRS exception %1" ).arg( cse.what() ) );
443  }
444 
445  return featureCount > 0;
446 }
447 
448 QMap<QString, QString> QgsMapToolIdentify::derivedAttributesForPoint( const QgsPoint &point )
449 {
450  QMap< QString, QString > derivedAttributes;
451  derivedAttributes.insert( tr( "(clicked coordinate X)" ), formatXCoordinate( point ) );
452  derivedAttributes.insert( tr( "(clicked coordinate Y)" ), formatYCoordinate( point ) );
453  if ( point.is3D() )
454  derivedAttributes.insert( tr( "(clicked coordinate Z)" ), QString::number( point.z(), 'f' ) );
455  return derivedAttributes;
456 }
457 
458 bool QgsMapToolIdentify::identifyVectorLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsVectorLayer *layer, const QgsGeometry &geometry )
459 {
460  if ( !layer || !layer->isSpatial() )
461  return false;
462 
463  if ( !layer->isInScaleRange( mCanvas->mapSettings().scale() ) )
464  {
465  QgsDebugMsg( QStringLiteral( "Out of scale limits" ) );
466  return false;
467  }
468 
469  QApplication::setOverrideCursor( Qt::WaitCursor );
470 
471  QMap< QString, QString > commonDerivedAttributes;
472 
473  QgsGeometry selectionGeom = geometry;
474  bool isPointOrRectangle;
475  QgsPointXY point;
476  bool isSingleClick = selectionGeom.type() == QgsWkbTypes::PointGeometry;
477  if ( isSingleClick )
478  {
479  isPointOrRectangle = true;
480  point = selectionGeom.asPoint();
481 
482  commonDerivedAttributes = derivedAttributesForPoint( QgsPoint( point ) );
483  }
484  else
485  {
486  // we have a polygon - maybe it is a rectangle - in such case we can avoid costly insterestion tests later
487  isPointOrRectangle = QgsGeometry::fromRect( selectionGeom.boundingBox() ).isGeosEqual( selectionGeom );
488  }
489 
490  int featureCount = 0;
491 
492  QgsFeatureList featureList;
493  std::unique_ptr<QgsGeometryEngine> selectionGeomPrepared;
494 
495  // toLayerCoordinates will throw an exception for an 'invalid' point.
496  // For example, if you project a world map onto a globe using EPSG 2163
497  // and then click somewhere off the globe, an exception will be thrown.
498  try
499  {
500  QgsRectangle r;
501  if ( isSingleClick )
502  {
503  double sr = mOverrideCanvasSearchRadius < 0 ? searchRadiusMU( mCanvas ) : mOverrideCanvasSearchRadius;
504  r = toLayerCoordinates( layer, QgsRectangle( point.x() - sr, point.y() - sr, point.x() + sr, point.y() + sr ) );
505  }
506  else
507  {
508  r = toLayerCoordinates( layer, selectionGeom.boundingBox() );
509 
510  if ( !isPointOrRectangle )
511  {
513  if ( ct.isValid() )
514  selectionGeom.transform( ct );
515 
516  // use prepared geometry for faster intersection test
517  selectionGeomPrepared.reset( QgsGeometry::createGeometryEngine( selectionGeom.constGet() ) );
518  }
519  }
520 
521  QgsFeatureIterator fit = layer->getFeatures( QgsFeatureRequest().setFilterRect( r ).setFlags( QgsFeatureRequest::ExactIntersect ) );
522  QgsFeature f;
523  while ( fit.nextFeature( f ) )
524  {
525  if ( !selectionGeomPrepared || selectionGeomPrepared->intersects( f.geometry().constGet() ) )
526  featureList << QgsFeature( f );
527  }
528  }
529  catch ( QgsCsException &cse )
530  {
531  Q_UNUSED( cse )
532  // catch exception for 'invalid' point and proceed with no features found
533  QgsDebugMsg( QStringLiteral( "Caught CRS exception %1" ).arg( cse.what() ) );
534  }
535 
536  bool filter = false;
537 
539  context.expressionContext() << QgsExpressionContextUtils::layerScope( layer );
540  std::unique_ptr< QgsFeatureRenderer > renderer( layer->renderer() ? layer->renderer()->clone() : nullptr );
541  if ( renderer )
542  {
543  // setup scale for scale dependent visibility (rule based)
544  renderer->startRender( context, layer->fields() );
545  filter = renderer->capabilities() & QgsFeatureRenderer::Filter;
546  }
547 
548  for ( const QgsFeature &feature : qgis::as_const( featureList ) )
549  {
550  QMap< QString, QString > derivedAttributes = commonDerivedAttributes;
551 
552  QgsFeatureId fid = feature.id();
553  context.expressionContext().setFeature( feature );
554 
555  if ( filter && !renderer->willRenderFeature( feature, context ) )
556  continue;
557 
558  featureCount++;
559 
560  if ( isSingleClick )
561  derivedAttributes.unite( featureDerivedAttributes( feature, layer, toLayerCoordinates( layer, point ) ) );
562 
563  derivedAttributes.insert( tr( "Feature ID" ), fid < 0 ? tr( "new feature" ) : FID_TO_STRING( fid ) );
564 
565  results->append( IdentifyResult( qobject_cast<QgsMapLayer *>( layer ), feature, derivedAttributes ) );
566  }
567 
568  if ( renderer )
569  {
570  renderer->stopRender( context );
571  }
572 
573  QgsDebugMsgLevel( "Feature count on identify: " + QString::number( featureCount ), 2 );
574 
575  QApplication::restoreOverrideCursor();
576  return featureCount > 0;
577 }
578 
579 void QgsMapToolIdentify::closestVertexAttributes( const QgsAbstractGeometry &geometry, QgsVertexId vId, QgsMapLayer *layer, QMap< QString, QString > &derivedAttributes )
580 {
581  if ( ! vId.isValid( ) )
582  {
583  // We should not get here ...
584  QgsDebugMsg( "Invalid vertex id!" );
585  return;
586  }
587 
588  QString str = QLocale().toString( vId.vertex + 1 );
589  derivedAttributes.insert( tr( "Closest vertex number" ), str );
590 
591  QgsPoint closestPoint = geometry.vertexAt( vId );
592 
593  QgsPointXY closestPointMapCoords = mCanvas->mapSettings().layerToMapCoordinates( layer, QgsPointXY( closestPoint.x(), closestPoint.y() ) );
594  derivedAttributes.insert( tr( "Closest vertex X" ), formatXCoordinate( closestPointMapCoords ) );
595  derivedAttributes.insert( tr( "Closest vertex Y" ), formatYCoordinate( closestPointMapCoords ) );
596 
597  if ( closestPoint.is3D() )
598  {
599  str = QLocale().toString( closestPoint.z(), 'g', 10 );
600  derivedAttributes.insert( tr( "Closest vertex Z" ), str );
601  }
602  if ( closestPoint.isMeasure() )
603  {
604  str = QLocale().toString( closestPoint.m(), 'g', 10 );
605  derivedAttributes.insert( tr( "Closest vertex M" ), str );
606  }
607 
608  if ( vId.type == QgsVertexId::CurveVertex )
609  {
610  double radius, centerX, centerY;
611  QgsVertexId vIdBefore = vId;
612  --vIdBefore.vertex;
613  QgsVertexId vIdAfter = vId;
614  ++vIdAfter.vertex;
615  QgsGeometryUtils::circleCenterRadius( geometry.vertexAt( vIdBefore ), geometry.vertexAt( vId ),
616  geometry.vertexAt( vIdAfter ), radius, centerX, centerY );
617  derivedAttributes.insert( QStringLiteral( "Closest vertex radius" ), QLocale().toString( radius ) );
618  }
619 }
620 
621 void QgsMapToolIdentify::closestPointAttributes( const QgsAbstractGeometry &geometry, const QgsPointXY &layerPoint, QMap<QString, QString> &derivedAttributes )
622 {
623  QgsPoint closestPoint = QgsGeometryUtils::closestPoint( geometry, QgsPoint( layerPoint ) );
624 
625  derivedAttributes.insert( tr( "Closest X" ), formatXCoordinate( closestPoint ) );
626  derivedAttributes.insert( tr( "Closest Y" ), formatYCoordinate( closestPoint ) );
627 
628  if ( closestPoint.is3D() )
629  {
630  const QString str = QLocale().toString( closestPoint.z(), 'g', 10 );
631  derivedAttributes.insert( tr( "Interpolated Z" ), str );
632  }
633  if ( closestPoint.isMeasure() )
634  {
635  const QString str = QLocale().toString( closestPoint.m(), 'g', 10 );
636  derivedAttributes.insert( tr( "Interpolated M" ), str );
637  }
638 }
639 
640 QString QgsMapToolIdentify::formatCoordinate( const QgsPointXY &canvasPoint ) const
641 {
642  return QgsCoordinateUtils::formatCoordinateForProject( QgsProject::instance(), canvasPoint, mCanvas->mapSettings().destinationCrs(),
643  mCoordinatePrecision );
644 }
645 
646 QString QgsMapToolIdentify::formatXCoordinate( const QgsPointXY &canvasPoint ) const
647 {
648  QString coordinate = formatCoordinate( canvasPoint );
649  return coordinate.split( ',' ).at( 0 );
650 }
651 
652 QString QgsMapToolIdentify::formatYCoordinate( const QgsPointXY &canvasPoint ) const
653 {
654  QString coordinate = formatCoordinate( canvasPoint );
655  return coordinate.split( ',' ).at( 1 );
656 }
657 
658 QMap< QString, QString > QgsMapToolIdentify::featureDerivedAttributes( const QgsFeature &feature, QgsMapLayer *layer, const QgsPointXY &layerPoint )
659 {
660  // Calculate derived attributes and insert:
661  // measure distance or area depending on geometry type
662  QMap< QString, QString > derivedAttributes;
663 
664  // init distance/area calculator
665  QString ellipsoid = QgsProject::instance()->ellipsoid();
666  QgsDistanceArea calc;
667  calc.setEllipsoid( ellipsoid );
668  calc.setSourceCrs( layer->crs(), QgsProject::instance()->transformContext() );
669 
672 
673  QgsVertexId vId;
674  QgsPoint closestPoint;
675  if ( feature.hasGeometry() )
676  {
677  geometryType = feature.geometry().type();
678  wkbType = feature.geometry().wkbType();
679  //find closest vertex to clicked point
680  closestPoint = QgsGeometryUtils::closestVertex( *feature.geometry().constGet(), QgsPoint( layerPoint ), vId );
681  }
682 
683 
684 
685  if ( QgsWkbTypes::isMultiType( wkbType ) )
686  {
687  QString str = QLocale().toString( static_cast<const QgsGeometryCollection *>( feature.geometry().constGet() )->numGeometries() );
688  derivedAttributes.insert( tr( "Parts" ), str );
689  str = QLocale().toString( vId.part + 1 );
690  derivedAttributes.insert( tr( "Part number" ), str );
691  }
692 
693  QgsUnitTypes::DistanceUnit cartesianDistanceUnits = QgsUnitTypes::unitType( layer->crs().mapUnits() ) == QgsUnitTypes::unitType( displayDistanceUnits() )
694  ? displayDistanceUnits() : layer->crs().mapUnits();
695  QgsUnitTypes::AreaUnit cartesianAreaUnits = QgsUnitTypes::unitType( QgsUnitTypes::distanceToAreaUnit( layer->crs().mapUnits() ) ) == QgsUnitTypes::unitType( displayAreaUnits() )
696  ? displayAreaUnits() : QgsUnitTypes::distanceToAreaUnit( layer->crs().mapUnits() );
697 
698  if ( geometryType == QgsWkbTypes::LineGeometry )
699  {
700  double dist = calc.measureLength( feature.geometry() );
701  dist = calc.convertLengthMeasurement( dist, displayDistanceUnits() );
702  QString str;
703  if ( ellipsoid != geoNone() )
704  {
705  str = formatDistance( dist );
706  derivedAttributes.insert( tr( "Length (Ellipsoidal — %1)" ).arg( ellipsoid ), str );
707  }
708  str = formatDistance( feature.geometry().constGet()->length()
709  * QgsUnitTypes::fromUnitToUnitFactor( layer->crs().mapUnits(), cartesianDistanceUnits ), cartesianDistanceUnits );
710  if ( !QgsWkbTypes::hasZ( feature.geometry().wkbType() ) )
711  derivedAttributes.insert( tr( "Length (Cartesian)" ), str );
712  else
713  derivedAttributes.insert( tr( "Length (Cartesian — 2D)" ), str );
715  {
716  str = formatDistance( qgsgeometry_cast< const QgsLineString * >( feature.geometry().constGet() )->length3D()
717  * QgsUnitTypes::fromUnitToUnitFactor( layer->crs().mapUnits(), cartesianDistanceUnits ), cartesianDistanceUnits );
718  derivedAttributes.insert( tr( "Length (Cartesian — 3D)" ), str );
719  }
720 
721  const QgsAbstractGeometry *geom = feature.geometry().constGet();
722  if ( geom )
723  {
724  str = QLocale().toString( geom->nCoordinates() );
725  derivedAttributes.insert( tr( "Vertices" ), str );
726  //add details of closest vertex to identify point
727  closestVertexAttributes( *geom, vId, layer, derivedAttributes );
728  closestPointAttributes( *geom, layerPoint, derivedAttributes );
729 
730  if ( const QgsCurve *curve = qgsgeometry_cast< const QgsCurve * >( geom ) )
731  {
732  // Add the start and end points in as derived attributes
733  QgsPointXY pnt = mCanvas->mapSettings().layerToMapCoordinates( layer, QgsPointXY( curve->startPoint().x(), curve->startPoint().y() ) );
734  str = formatXCoordinate( pnt );
735  derivedAttributes.insert( tr( "firstX", "attributes get sorted; translation for lastX should be lexically larger than this one" ), str );
736  str = formatYCoordinate( pnt );
737  derivedAttributes.insert( tr( "firstY" ), str );
738  pnt = mCanvas->mapSettings().layerToMapCoordinates( layer, QgsPointXY( curve->endPoint().x(), curve->endPoint().y() ) );
739  str = formatXCoordinate( pnt );
740  derivedAttributes.insert( tr( "lastX", "attributes get sorted; translation for firstX should be lexically smaller than this one" ), str );
741  str = formatYCoordinate( pnt );
742  derivedAttributes.insert( tr( "lastY" ), str );
743  }
744  }
745  }
746  else if ( geometryType == QgsWkbTypes::PolygonGeometry )
747  {
748  double area = calc.measureArea( feature.geometry() );
749  area = calc.convertAreaMeasurement( area, displayAreaUnits() );
750  QString str;
751  if ( ellipsoid != geoNone() )
752  {
753  str = formatArea( area );
754  derivedAttributes.insert( tr( "Area (Ellipsoidal — %1)" ).arg( ellipsoid ), str );
755  }
756  str = formatArea( feature.geometry().area()
757  * QgsUnitTypes::fromUnitToUnitFactor( QgsUnitTypes::distanceToAreaUnit( layer->crs().mapUnits() ), cartesianAreaUnits ), cartesianAreaUnits );
758  derivedAttributes.insert( tr( "Area (Cartesian)" ), str );
759 
760  if ( ellipsoid != geoNone() )
761  {
762  double perimeter = calc.measurePerimeter( feature.geometry() );
763  perimeter = calc.convertLengthMeasurement( perimeter, displayDistanceUnits() );
764  str = formatDistance( perimeter );
765  derivedAttributes.insert( tr( "Perimeter (Ellipsoidal — %1)" ).arg( ellipsoid ), str );
766  }
767  str = formatDistance( feature.geometry().constGet()->perimeter()
768  * QgsUnitTypes::fromUnitToUnitFactor( layer->crs().mapUnits(), cartesianDistanceUnits ), cartesianDistanceUnits );
769  derivedAttributes.insert( tr( "Perimeter (Cartesian)" ), str );
770 
771  str = QLocale().toString( feature.geometry().constGet()->nCoordinates() );
772  derivedAttributes.insert( tr( "Vertices" ), str );
773 
774  //add details of closest vertex to identify point
775  closestVertexAttributes( *feature.geometry().constGet(), vId, layer, derivedAttributes );
776  closestPointAttributes( *feature.geometry().constGet(), layerPoint, derivedAttributes );
777  }
778  else if ( geometryType == QgsWkbTypes::PointGeometry )
779  {
780  if ( QgsWkbTypes::flatType( wkbType ) == QgsWkbTypes::Point )
781  {
782  // Include the x and y coordinates of the point as a derived attribute
783  QgsPointXY pnt = mCanvas->mapSettings().layerToMapCoordinates( layer, feature.geometry().asPoint() );
784  QString str = formatXCoordinate( pnt );
785  derivedAttributes.insert( tr( "X" ), str );
786  str = formatYCoordinate( pnt );
787  derivedAttributes.insert( tr( "Y" ), str );
788 
789  if ( QgsWkbTypes::hasZ( wkbType ) )
790  {
791  str = QLocale().toString( static_cast<const QgsPoint *>( feature.geometry().constGet() )->z(), 'g', 10 );
792  derivedAttributes.insert( tr( "Z" ), str );
793  }
794  if ( QgsWkbTypes::hasM( wkbType ) )
795  {
796  str = QLocale().toString( static_cast<const QgsPoint *>( feature.geometry().constGet() )->m(), 'g', 10 );
797  derivedAttributes.insert( tr( "M" ), str );
798  }
799  }
800  else
801  {
802  //multipart
803 
804  //add details of closest vertex to identify point
805  const QgsAbstractGeometry *geom = feature.geometry().constGet();
806  {
807  closestVertexAttributes( *geom, vId, layer, derivedAttributes );
808  }
809  }
810  }
811 
812  return derivedAttributes;
813 }
814 
815 bool QgsMapToolIdentify::identifyRasterLayer( QList<IdentifyResult> *results, QgsRasterLayer *layer, const QgsGeometry &geometry, const QgsRectangle &viewExtent, double mapUnitsPerPixel )
816 {
817  QgsPointXY point = geometry.asPoint(); // raster layers currently only support identification by point
818  return identifyRasterLayer( results, layer, point, viewExtent, mapUnitsPerPixel );
819 }
820 
821 bool QgsMapToolIdentify::identifyRasterLayer( QList<IdentifyResult> *results, QgsRasterLayer *layer, QgsPointXY point, const QgsRectangle &viewExtent, double mapUnitsPerPixel )
822 {
823  QgsDebugMsg( "point = " + point.toString() );
824  if ( !layer )
825  return false;
826 
827  QgsRasterDataProvider *dprovider = layer->dataProvider();
828  if ( !dprovider )
829  return false;
830 
831  int capabilities = dprovider->capabilities();
832  if ( !( capabilities & QgsRasterDataProvider::Identify ) )
833  return false;
834 
835  QgsPointXY pointInCanvasCrs = point;
836  try
837  {
838  point = toLayerCoordinates( layer, point );
839  }
840  catch ( QgsCsException &cse )
841  {
842  Q_UNUSED( cse )
843  QgsDebugMsg( QStringLiteral( "coordinate not reprojectable: %1" ).arg( cse.what() ) );
844  return false;
845  }
846  QgsDebugMsg( QStringLiteral( "point = %1 %2" ).arg( point.x() ).arg( point.y() ) );
847 
848  if ( !layer->extent().contains( point ) )
849  return false;
850 
851  QMap< QString, QString > attributes, derivedAttributes;
852 
853  QgsRaster::IdentifyFormat format = QgsRasterDataProvider::identifyFormatFromName( layer->customProperty( QStringLiteral( "identify/format" ) ).toString() );
854 
855  // check if the format is really supported otherwise use first supported format
856  if ( !( QgsRasterDataProvider::identifyFormatToCapability( format ) & capabilities ) )
857  {
859  else if ( capabilities & QgsRasterInterface::IdentifyValue ) format = QgsRaster::IdentifyFormatValue;
860  else if ( capabilities & QgsRasterInterface::IdentifyHtml ) format = QgsRaster::IdentifyFormatHtml;
861  else if ( capabilities & QgsRasterInterface::IdentifyText ) format = QgsRaster::IdentifyFormatText;
862  else return false;
863  }
864 
865  QgsRasterIdentifyResult identifyResult;
866  // We can only use current map canvas context (extent, width, height) if layer is not reprojected,
867  if ( dprovider->crs() != mCanvas->mapSettings().destinationCrs() )
868  {
869  // To get some reasonable response for point/line WMS vector layers we must
870  // use a context with approximately a resolution in layer CRS units
871  // corresponding to current map canvas resolution (for examplei UMN Mapserver
872  // in msWMSFeatureInfo() -> msQueryByRect() is using requested pixel
873  // + TOLERANCE (layer param) for feature selection)
874  //
875  QgsRectangle r;
876  r.setXMinimum( pointInCanvasCrs.x() - mapUnitsPerPixel / 2. );
877  r.setXMaximum( pointInCanvasCrs.x() + mapUnitsPerPixel / 2. );
878  r.setYMinimum( pointInCanvasCrs.y() - mapUnitsPerPixel / 2. );
879  r.setYMaximum( pointInCanvasCrs.y() + mapUnitsPerPixel / 2. );
880  r = toLayerCoordinates( layer, r ); // will be a bit larger
881  // Mapserver (6.0.3, for example) does not work with 1x1 pixel box
882  // but that is fixed (the rect is enlarged) in the WMS provider
883  identifyResult = dprovider->identify( point, format, r, 1, 1 );
884  }
885  else
886  {
887  // It would be nice to use the same extent and size which was used for drawing,
888  // so that WCS can use cache from last draw, unfortunately QgsRasterLayer::draw()
889  // is doing some tricks with extent and size to align raster to output which
890  // would be difficult to replicate here.
891  // Note: cutting the extent may result in slightly different x and y resolutions
892  // and thus shifted point calculated back in QGIS WMS (using average resolution)
893  //viewExtent = dprovider->extent().intersect( &viewExtent );
894 
895  // Width and height are calculated from not projected extent and we hope that
896  // are similar to source width and height used to reproject layer for drawing.
897  // TODO: may be very dangerous, because it may result in different resolutions
898  // in source CRS, and WMS server (QGIS server) calcs wrong coor using average resolution.
899  int width = static_cast< int >( std::round( viewExtent.width() / mapUnitsPerPixel ) );
900  int height = static_cast< int >( std::round( viewExtent.height() / mapUnitsPerPixel ) );
901 
902  QgsDebugMsg( QStringLiteral( "viewExtent.width = %1 viewExtent.height = %2" ).arg( viewExtent.width() ).arg( viewExtent.height() ) );
903  QgsDebugMsg( QStringLiteral( "width = %1 height = %2" ).arg( width ).arg( height ) );
904  QgsDebugMsg( QStringLiteral( "xRes = %1 yRes = %2 mapUnitsPerPixel = %3" ).arg( viewExtent.width() / width ).arg( viewExtent.height() / height ).arg( mapUnitsPerPixel ) );
905 
906  identifyResult = dprovider->identify( point, format, viewExtent, width, height );
907  }
908 
909  derivedAttributes.unite( derivedAttributesForPoint( QgsPoint( pointInCanvasCrs ) ) );
910 
911  if ( identifyResult.isValid() )
912  {
913  QMap<int, QVariant> values = identifyResult.results();
914  QgsGeometry geometry;
915  if ( format == QgsRaster::IdentifyFormatValue )
916  {
917  for ( auto it = values.constBegin(); it != values.constEnd(); ++it )
918  {
919  QString valueString;
920  if ( it.value().isNull() )
921  {
922  valueString = tr( "no data" );
923  }
924  else
925  {
926  QVariant value( it.value() );
927  // The cast is legit. Quoting QT doc :
928  // "Although this function is declared as returning QVariant::Type,
929  // the return value should be interpreted as QMetaType::Type"
930  if ( static_cast<QMetaType::Type>( value.type() ) == QMetaType::Float )
931  {
932  valueString = QgsRasterBlock::printValue( value.toFloat() );
933  }
934  else
935  {
936  valueString = QgsRasterBlock::printValue( value.toDouble() );
937  }
938  }
939  attributes.insert( dprovider->generateBandName( it.key() ), valueString );
940  }
941  QString label = layer->name();
942  results->append( IdentifyResult( qobject_cast<QgsMapLayer *>( layer ), label, attributes, derivedAttributes ) );
943  }
944  else if ( format == QgsRaster::IdentifyFormatFeature )
945  {
946  for ( auto it = values.constBegin(); it != values.constEnd(); ++it )
947  {
948  QVariant value = it.value();
949  if ( value.type() == QVariant::Bool && !value.toBool() )
950  {
951  // sublayer not visible or not queryable
952  continue;
953  }
954 
955  if ( value.type() == QVariant::String )
956  {
957  // error
958  // TODO: better error reporting
959  QString label = layer->subLayers().value( it.key() );
960  attributes.clear();
961  attributes.insert( tr( "Error" ), value.toString() );
962 
963  results->append( IdentifyResult( qobject_cast<QgsMapLayer *>( layer ), label, attributes, derivedAttributes ) );
964  continue;
965  }
966 
967  // list of feature stores for a single sublayer
968  const QgsFeatureStoreList featureStoreList = it.value().value<QgsFeatureStoreList>();
969 
970  for ( const QgsFeatureStore &featureStore : featureStoreList )
971  {
972  const QgsFeatureList storeFeatures = featureStore.features();
973  for ( const QgsFeature &feature : storeFeatures )
974  {
975  attributes.clear();
976  // WMS sublayer and feature type, a sublayer may contain multiple feature types.
977  // Sublayer name may be the same as layer name and feature type name
978  // may be the same as sublayer. We try to avoid duplicities in label.
979  QString sublayer = featureStore.params().value( QStringLiteral( "sublayer" ) ).toString();
980  QString featureType = featureStore.params().value( QStringLiteral( "featureType" ) ).toString();
981  // Strip UMN MapServer '_feature'
982  featureType.remove( QStringLiteral( "_feature" ) );
983  QStringList labels;
984  if ( sublayer.compare( layer->name(), Qt::CaseInsensitive ) != 0 )
985  {
986  labels << sublayer;
987  }
988  if ( featureType.compare( sublayer, Qt::CaseInsensitive ) != 0 || labels.isEmpty() )
989  {
990  labels << featureType;
991  }
992 
993  QMap< QString, QString > derAttributes = derivedAttributes;
994  derAttributes.unite( featureDerivedAttributes( feature, layer, toLayerCoordinates( layer, point ) ) );
995 
996  IdentifyResult identifyResult( qobject_cast<QgsMapLayer *>( layer ), labels.join( QStringLiteral( " / " ) ), featureStore.fields(), feature, derAttributes );
997 
998  identifyResult.mParams.insert( QStringLiteral( "getFeatureInfoUrl" ), featureStore.params().value( QStringLiteral( "getFeatureInfoUrl" ) ) );
999  results->append( identifyResult );
1000  }
1001  }
1002  }
1003  }
1004  else // text or html
1005  {
1006  QgsDebugMsg( QStringLiteral( "%1 HTML or text values" ).arg( values.size() ) );
1007  for ( auto it = values.constBegin(); it != values.constEnd(); ++it )
1008  {
1009  QString value = it.value().toString();
1010  attributes.clear();
1011  attributes.insert( QString(), value );
1012 
1013  QString label = layer->subLayers().value( it.key() );
1014  results->append( IdentifyResult( qobject_cast<QgsMapLayer *>( layer ), label, attributes, derivedAttributes ) );
1015  }
1016  }
1017  }
1018  else
1019  {
1020  attributes.clear();
1021  QString value = identifyResult.error().message( QgsErrorMessage::Text );
1022  attributes.insert( tr( "Error" ), value );
1023  QString label = tr( "Identify error" );
1024  results->append( IdentifyResult( qobject_cast<QgsMapLayer *>( layer ), label, attributes, derivedAttributes ) );
1025  }
1026 
1027  return true;
1028 }
1029 
1030 QgsUnitTypes::DistanceUnit QgsMapToolIdentify::displayDistanceUnits() const
1031 {
1032  return mCanvas->mapUnits();
1033 }
1034 
1035 QgsUnitTypes::AreaUnit QgsMapToolIdentify::displayAreaUnits() const
1036 {
1038 }
1039 
1040 QString QgsMapToolIdentify::formatDistance( double distance ) const
1041 {
1042  return formatDistance( distance, displayDistanceUnits() );
1043 }
1044 
1045 QString QgsMapToolIdentify::formatArea( double area ) const
1046 {
1047  return formatArea( area, displayAreaUnits() );
1048 }
1049 
1050 QString QgsMapToolIdentify::formatDistance( double distance, QgsUnitTypes::DistanceUnit unit ) const
1051 {
1052  QgsSettings settings;
1053  bool baseUnit = settings.value( QStringLiteral( "qgis/measure/keepbaseunit" ), true ).toBool();
1054 
1055  return QgsDistanceArea::formatDistance( distance, 3, unit, baseUnit );
1056 }
1057 
1058 QString QgsMapToolIdentify::formatArea( double area, QgsUnitTypes::AreaUnit unit ) const
1059 {
1060  QgsSettings settings;
1061  bool baseUnit = settings.value( QStringLiteral( "qgis/measure/keepbaseunit" ), true ).toBool();
1062 
1063  return QgsDistanceArea::formatArea( area, 3, unit, baseUnit );
1064 }
1065 
1067 {
1068  QList<IdentifyResult> results;
1069  if ( identifyRasterLayer( &results, layer, mLastGeometry, mLastExtent, mLastMapUnitsPerPixel ) )
1070  {
1071  emit changedRasterResults( results );
1072  }
1073 }
1074 
QgsCurve
Abstract base class for curved geometry type.
Definition: qgscurve.h:35
QgsMapToolIdentify::deactivate
void deactivate() override
called when map tool is being deactivated
Definition: qgsmaptoolidentify.cpp:203
QgsGeometry::fromPointXY
static QgsGeometry fromPointXY(const QgsPointXY &point)
Creates a new geometry from a QgsPointXY object.
Definition: qgsgeometry.cpp:164
QgsMapTool::mCanvas
QgsMapCanvas * mCanvas
pointer to map canvas
Definition: qgsmaptool.h:259
QgsVertexId::part
int part
Definition: qgsabstractgeometry.h:1080
QgsVectorLayer::getFeatures
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
Definition: qgsvectorlayer.cpp:993
QgsMapLayer::crs
QgsCoordinateReferenceSystem crs
Definition: qgsmaplayer.h:88
qgsmaptoolidentify.h
qgsfields.h
qgsexpressioncontextutils.h
QgsFeatureRenderer::Filter
@ Filter
Features may be filtered, i.e. some features may not be rendered (categorized, rule based ....
Definition: qgsrenderer.h:256
QgsRasterBlock::printValue
static QString printValue(double value)
Print double value with all necessary significant digits.
Definition: qgsrasterblock.cpp:626
QgsMapToolIdentify::activate
void activate() override
called when set as currently active map tool
Definition: qgsmaptoolidentify.cpp:198
QgsMapToolIdentify::identify
QList< QgsMapToolIdentify::IdentifyResult > identify(int x, int y, const QList< QgsMapLayer * > &layerList=QList< QgsMapLayer * >(), IdentifyMode mode=DefaultQgsSetting)
Performs the identification.
Definition: qgsmaptoolidentify.cpp:88
QgsVertexId::vertex
int vertex
Definition: qgsabstractgeometry.h:1082
QgsRasterInterface::generateBandName
virtual QString generateBandName(int bandNumber) const
helper function to create zero padded band names
Definition: qgsrasterinterface.h:245
QgsVertexId::isValid
bool isValid() const
Returns true if the vertex id is valid.
Definition: qgsabstractgeometry.h:1051
QgsPointXY::y
double y
Definition: qgspointxy.h:48
QgsDistanceArea::measureLength
double measureLength(const QgsGeometry &geometry) const
Measures the length of a geometry.
Definition: qgsdistancearea.cpp:192
QgsMapToolIdentify::LayerSelection
@ LayerSelection
Definition: qgsmaptoolidentify.h:59
QgsGeometry::transform
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.
Definition: qgsgeometry.cpp:2836
QgsMapCanvas::extent
QgsRectangle extent() const
Returns the current zoom extent of the map canvas.
Definition: qgsmapcanvas.cpp:1049
QgsVectorTileLayer
Definition: qgsvectortilelayer.h:83
qgsrasterlayer.h
QgsMapToolIdentify::AllLayers
@ AllLayers
Definition: qgsmaptoolidentify.h:69
QgsWkbTypes::Point
@ Point
Definition: qgswkbtypes.h:71
QgsRasterInterface::IdentifyHtml
@ IdentifyHtml
Definition: qgsrasterinterface.h:193
QgsMeshRendererSettings
Definition: qgsmeshrenderersettings.h:590
QgsSettings::value
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
Definition: qgssettings.cpp:174
QgsMapLayerType::MeshLayer
@ MeshLayer
Added in 3.2.
QgsTileXYZ
Definition: qgstiles.h:32
QgsFeatureRequest::ExactIntersect
@ ExactIntersect
Use exact geometry intersection (slower) instead of bounding boxes.
Definition: qgsfeaturerequest.h:109
qgsmapcanvas.h
QgsWkbTypes::NullGeometry
@ NullGeometry
Definition: qgswkbtypes.h:145
QgsRenderContext::fromMapSettings
static QgsRenderContext fromMapSettings(const QgsMapSettings &mapSettings)
create initialized QgsRenderContext instance from given QgsMapSettings
Definition: qgsrendercontext.cpp:170
QgsMapLayerType::VectorLayer
@ VectorLayer
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
QgsVectorTileUtils::makeQgisFields
static QgsFields makeQgisFields(QSet< QString > flds)
Returns QgsFields instance based on the set of field names.
Definition: qgsvectortileutils.cpp:51
QgsRectangle::setXMinimum
void setXMinimum(double x)
Set the minimum x value.
Definition: qgsrectangle.h:130
QgsTileRange
Definition: qgstiles.h:65
QgsGeometryCollection::numGeometries
int numGeometries() const
Returns the number of geometries within the collection.
Definition: qgsgeometrycollection.h:51
QgsDebugMsgLevel
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
qgscoordinateutils.h
qgsrasteridentifyresult.h
QgsMapToolIdentify::ActiveLayer
@ ActiveLayer
Definition: qgsmaptoolidentify.h:56
QgsMapToolIdentify::VectorLayer
@ VectorLayer
Definition: qgsmaptoolidentify.h:65
qgsmaptopixel.h
QgsMapCanvas::mapSettings
const QgsMapSettings & mapSettings() const
Gets access to properties used for map rendering.
Definition: qgsmapcanvas.cpp:390
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsMapToolIdentify::MeshLayer
@ MeshLayer
Definition: qgsmaptoolidentify.h:67
QgsApplication::getThemeCursor
static QCursor getThemeCursor(Cursor cursor)
Helper to get a theme cursor.
Definition: qgsapplication.cpp:635
QgsRaster::IdentifyFormatText
@ IdentifyFormatText
Definition: qgsraster.h:74
QgsMeshDatasetValue
Definition: qgsmeshdataset.h:76
QgsUnitTypes::unitType
static Q_INVOKABLE QgsUnitTypes::DistanceUnitType unitType(QgsUnitTypes::DistanceUnit unit)
Returns the type for a distance unit.
Definition: qgsunittypes.cpp:73
QgsMapToolIdentify::QgsMapToolIdentify
QgsMapToolIdentify(QgsMapCanvas *canvas)
constructor
Definition: qgsmaptoolidentify.cpp:59
QgsWkbTypes::isMultiType
static bool isMultiType(Type type)
Returns true if the WKB type is a multi type.
Definition: qgswkbtypes.h:831
QgsWkbTypes::LineString
@ LineString
Definition: qgswkbtypes.h:72
qgsfeatureiterator.h
QgsFields
Definition: qgsfields.h:44
QgsFeatureStore
Definition: qgsfeaturestore.h:32
QgsMapTool::setCursor
virtual void setCursor(const QCursor &cursor)
Sets a user defined cursor.
Definition: qgsmaptool.cpp:149
QgsExpressionContextUtils::layerScope
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
Definition: qgsexpressioncontextutils.cpp:264
QgsMapCanvas
Definition: qgsmapcanvas.h:83
QgsUnitTypes::distanceToAreaUnit
static Q_INVOKABLE QgsUnitTypes::AreaUnit distanceToAreaUnit(QgsUnitTypes::DistanceUnit distanceUnit)
Converts a distance unit to its corresponding area unit, e.g., meters to square meters.
Definition: qgsunittypes.cpp:1176
QgsMapTool::deactivate
virtual void deactivate()
called when map tool is being deactivated
Definition: qgsmaptool.cpp:99
qgsfeature.h
QgsRaster::IdentifyFormatHtml
@ IdentifyFormatHtml
Definition: qgsraster.h:75
QgsFeature::geometry
QgsGeometry geometry
Definition: qgsfeature.h:71
QgsProject::transformContext
QgsCoordinateTransformContext transformContext
Definition: qgsproject.h:99
QgsGeometry::wkbType
QgsWkbTypes::Type wkbType() const
Returns type of the geometry as a WKB type (point / linestring / polygon etc.)
Definition: qgsgeometry.cpp:345
QgsPoint::z
double z
Definition: qgspoint.h:60
QgsRenderContext
Definition: qgsrendercontext.h:57
QgsDistanceArea::measureArea
double measureArea(const QgsGeometry &geometry) const
Measures the area of a geometry.
Definition: qgsdistancearea.cpp:183
QgsProject::instance
static QgsProject * instance()
Returns the QgsProject singleton instance.
Definition: qgsproject.cpp:458
QgsMapToolIdentify::identifyLayer
bool identifyLayer(QList< QgsMapToolIdentify::IdentifyResult > *results, QgsMapLayer *layer, const QgsPointXY &point, const QgsRectangle &viewExtent, double mapUnitsPerPixel, QgsMapToolIdentify::LayerType layerType=AllLayers)
Call the right method depending on layer type.
Definition: qgsmaptoolidentify.cpp:208
QgsAbstractGeometry::length
virtual double length() const
Returns the planar, 2-dimensional length of the geometry.
Definition: qgsabstractgeometry.cpp:132
QgsMapCanvas::scale
double scale() const
Returns the last reported scale of the canvas.
Definition: qgsmapcanvas.cpp:322
QgsVectorLayer::isSpatial
bool isSpatial() const FINAL
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
Definition: qgsvectorlayer.cpp:3591
QgsGeometryUtils::closestPoint
static QgsPoint closestPoint(const QgsAbstractGeometry &geometry, const QgsPoint &point)
Returns the nearest point on a segment of a geometry for the specified point.
Definition: qgsgeometryutils.cpp:101
QgsSettings
Definition: qgssettings.h:61
QgsWkbTypes::Type
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:68
QgsRasterInterface::IdentifyFeature
@ IdentifyFeature
Definition: qgsrasterinterface.h:194
QgsGeometryUtils::circleCenterRadius
static void circleCenterRadius(const QgsPoint &pt1, const QgsPoint &pt2, const QgsPoint &pt3, double &radius, double &centerX, double &centerY)
Returns radius and center of the circle through pt1, pt2, pt3.
Definition: qgsgeometryutils.cpp:673
QgsWkbTypes::hasZ
static bool hasZ(Type type)
Tests whether a WKB type contains the z-dimension.
Definition: qgswkbtypes.h:1042
QgsRasterIdentifyResult::isValid
bool isValid() const
Returns true if valid.
Definition: qgsrasteridentifyresult.h:68
QgsMapCanvas::mapUnits
QgsUnitTypes::DistanceUnit mapUnits() const
Convenience function for returning the current canvas map units.
Definition: qgsmapcanvas.cpp:2129
QgsDebugMsg
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
QgsFields::append
bool append(const QgsField &field, FieldOrigin origin=OriginProvider, int originIndex=-1)
Appends a field. The field must have unique name, otherwise it is rejected (returns false)
Definition: qgsfields.cpp:59
QgsUnitTypes::DistanceUnit
DistanceUnit
Units of distance.
Definition: qgsunittypes.h:67
FID_TO_STRING
#define FID_TO_STRING(fid)
Definition: qgsfeatureid.h:30
QgsRasterInterface::Identify
@ Identify
Definition: qgsrasterinterface.h:190
QgsIdentifyMenu::exec
QList< QgsMapToolIdentify::IdentifyResult > exec(const QList< QgsMapToolIdentify::IdentifyResult > &idResults, QPoint pos)
exec
Definition: qgsidentifymenu.cpp:70
qgsidentifymenu.h
QgsRectangle
Definition: qgsrectangle.h:41
QgsVectorTileMVTDecoder
Definition: qgsvectortilemvtdecoder.h:36
QgsMeshLayer::datasetValue
QgsMeshDatasetValue datasetValue(const QgsMeshDatasetIndex &index, const QgsPointXY &point, double searchRadius=0) const
Interpolates the value on the given point from given dataset.
Definition: qgsmeshlayer.cpp:303
QgsWkbTypes::PolygonGeometry
@ PolygonGeometry
Definition: qgswkbtypes.h:143
QgsMapToolIdentify::TopDownStopAtFirst
@ TopDownStopAtFirst
Definition: qgsmaptoolidentify.h:57
QgsRasterDataProvider::identifyFormatFromName
static QgsRaster::IdentifyFormat identifyFormatFromName(const QString &formatName)
Definition: qgsrasterdataprovider.cpp:481
QgsGeometry::fromRect
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
Definition: qgsgeometry.cpp:229
QgsMapToolIdentify::TopDownAll
@ TopDownAll
Definition: qgsmaptoolidentify.h:58
QgsAbstractGeometry::vertexAt
virtual QgsPoint vertexAt(QgsVertexId id) const =0
Returns the point corresponding to a specified vertex id.
QgsMapTool::toLayerCoordinates
QgsPointXY toLayerCoordinates(const QgsMapLayer *layer, QPoint point)
transformation from screen coordinates to layer's coordinates
Definition: qgsmaptool.cpp:54
QgsDistanceArea::convertAreaMeasurement
double convertAreaMeasurement(double area, QgsUnitTypes::AreaUnit toUnits) const
Takes an area measurement calculated by this QgsDistanceArea object and converts it to a different ar...
Definition: qgsdistancearea.cpp:1156
qgsapplication.h
QgsMapToolIdentify::DefaultQgsSetting
@ DefaultQgsSetting
Definition: qgsmaptoolidentify.h:55
QgsMapTool
Definition: qgsmaptool.h:63
QgsGeometry::isGeosEqual
bool isGeosEqual(const QgsGeometry &) const
Compares the geometry with another geometry using GEOS.
Definition: qgsgeometry.cpp:2754
QgsMeshLayer::rendererSettings
QgsMeshRendererSettings rendererSettings() const
Returns renderer settings.
Definition: qgsmeshlayer.cpp:263
qgsvectortilelayer.h
QgsMapToolIdentify::IdentifyMode
IdentifyMode
Definition: qgsmaptoolidentify.h:53
QgsVectorLayer::fields
QgsFields fields() const FINAL
Returns the list of fields of this layer.
Definition: qgsvectorlayer.cpp:3280
QgsUnitTypes::fromUnitToUnitFactor
static Q_INVOKABLE double fromUnitToUnitFactor(QgsUnitTypes::DistanceUnit fromUnit, QgsUnitTypes::DistanceUnit toUnit)
Returns the conversion factor between the specified distance units.
Definition: qgsunittypes.cpp:352
QgsPoint::y
double y
Definition: qgspoint.h:59
QgsDistanceArea::setEllipsoid
bool setEllipsoid(const QString &ellipsoid)
Sets the ellipsoid by its acronym.
Definition: qgsdistancearea.cpp:66
QgsMapLayer::isInScaleRange
bool isInScaleRange(double scale) const
Tests whether the layer should be visible at the specified scale.
Definition: qgsmaplayer.cpp:669
QgsTileRange::endRow
int endRow() const
Returns index of the last row in the range.
Definition: qgstiles.h:82
QgsMapTool::toCanvasCoordinates
QPoint toCanvasCoordinates(const QgsPointXY &point) const
transformation from map coordinates to screen coordinates
Definition: qgsmaptool.cpp:75
QgsFeatureRequest
Definition: qgsfeaturerequest.h:75
QgsMapLayer::flags
QgsMapLayer::LayerFlags flags() const
Returns the flags for this layer.
Definition: qgsmaplayer.cpp:134
QgsGeometryCollection
Geometry collection.
Definition: qgsgeometrycollection.h:35
QgsMapToolIdentify::derivedAttributesForPoint
QMap< QString, QString > derivedAttributesForPoint(const QgsPoint &point)
Returns derived attributes map for a clicked point in map coordinates. May be 2D or 3D point.
Definition: qgsmaptoolidentify.cpp:448
QgsRasterLayer::subLayers
QStringList subLayers() const override
Returns the sublayers of this layer.
Definition: qgsrasterlayer.cpp:1644
QgsTileMatrix
Definition: qgstiles.h:102
qgsgeometryengine.h
QgsCsException
Definition: qgsexception.h:65
QgsError::message
QString message(QgsErrorMessage::Format format=QgsErrorMessage::Html) const
Full error messages description.
Definition: qgserror.cpp:49
QgsMapToolIdentify::canvasPressEvent
void canvasPressEvent(QgsMapMouseEvent *e) override
Mouse press event for overriding. Default implementation does nothing.
Definition: qgsmaptoolidentify.cpp:78
QgsMapToolIdentify::identifyProgress
void identifyProgress(int, int)
QgsRaster::IdentifyFormatValue
@ IdentifyFormatValue
Definition: qgsraster.h:73
QgsVectorTileMVTDecoder::layerFieldNames
QStringList layerFieldNames(const QString &layerName) const
Returns a list of all field names in a tile. It can only be called after a successful decode()
Definition: qgsvectortilemvtdecoder.cpp:65
QgsMeshDatasetIndex::group
int group() const
Returns a group index.
Definition: qgsmeshdataset.cpp:26
QgsMapSettings::transformContext
QgsCoordinateTransformContext transformContext() const
Returns the coordinate transform context, which stores various information regarding which datum tran...
Definition: qgsmapsettings.cpp:400
QgsMapCanvas::layerCount
int layerCount() const
Returns number of layers on the map.
Definition: qgsmapcanvas.cpp:2097
QgsRasterInterface::IdentifyValue
@ IdentifyValue
Definition: qgsrasterinterface.h:191
QgsMapToolIdentify::changedRasterResults
void changedRasterResults(QList< QgsMapToolIdentify::IdentifyResult > &)
QgsRasterIdentifyResult::results
QMap< int, QVariant > results() const
Returns the identify results.
Definition: qgsrasteridentifyresult.h:79
geoNone
CONSTLATIN1STRING geoNone()
Constant that holds the string representation for "No ellips/No CRS".
Definition: qgis.h:672
QgsMapToolIdentify::setCanvasPropertiesOverrides
void setCanvasPropertiesOverrides(double searchRadiusMapUnits)
Overrides some map canvas properties inside the map tool for the upcoming identify requests.
Definition: qgsmaptoolidentify.cpp:188
QgsRasterIdentifyResult
Definition: qgsrasteridentifyresult.h:30
QgsMapToolIdentify::canvasReleaseEvent
void canvasReleaseEvent(QgsMapMouseEvent *e) override
Mouse release event for overriding. Default implementation does nothing.
Definition: qgsmaptoolidentify.cpp:83
qgsvectortilemvtdecoder.h
QgsRectangle::contains
bool contains(const QgsRectangle &rect) const
Returns true when rectangle contains other rectangle.
Definition: qgsrectangle.h:342
QgsPointXY::toString
QString toString(int precision=-1) const
Returns a string representation of the point (x, y) with a preset precision.
Definition: qgspointxy.cpp:51
QgsMeshDatasetIndex
Definition: qgsmeshdataset.h:45
QgsMapCanvas::layer
QgsMapLayer * layer(int index)
Returns the map layer at position index in the layer stack.
Definition: qgsmapcanvas.cpp:304
QgsFeatureRenderer::clone
virtual QgsFeatureRenderer * clone() const =0
Create a deep copy of this renderer.
QgsRasterIdentifyResult::error
QgsError error() const
Returns the last error.
Definition: qgsrasteridentifyresult.h:88
QgsMapLayer::extent
virtual QgsRectangle extent() const
Returns the extent of the layer.
Definition: qgsmaplayer.cpp:197
QgsMeshLayer
Definition: qgsmeshlayer.h:94
QgsException::what
QString what() const
Definition: qgsexception.h:48
qgsmaplayer.h
QgsMapLayerType::RasterLayer
@ RasterLayer
QgsFeatureStoreList
QList< QgsFeatureStore > QgsFeatureStoreList
Definition: qgsfeaturestore.h:118
qgsmessageviewer.h
QgsMeshDatasetIndex::isValid
bool isValid() const
Returns whether index is valid, ie at least groups is set.
Definition: qgsmeshdataset.cpp:36
QgsMapToolIdentify::identifyRasterLayer
bool identifyRasterLayer(QList< QgsMapToolIdentify::IdentifyResult > *results, QgsRasterLayer *layer, QgsPointXY point, const QgsRectangle &viewExtent, double mapUnitsPerPixel)
Definition: qgsmaptoolidentify.cpp:821
QgsMeshDatasetValue::x
double x() const
Returns x value.
Definition: qgsmeshdataset.cpp:93
qgsvectordataprovider.h
QgsFeatureList
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:572
QgsRasterDataProvider::identify
virtual QgsRasterIdentifyResult identify(const QgsPointXY &point, QgsRaster::IdentifyFormat format, const QgsRectangle &boundingBox=QgsRectangle(), int width=0, int height=0, int dpi=96)
Identify raster value(s) found on the point position.
Definition: qgsrasterdataprovider.cpp:251
QgsUnitTypes
Helper functions for various unit types.
Definition: qgsunittypes.h:38
QgsRectangle::setXMaximum
void setXMaximum(double x)
Set the maximum x value.
Definition: qgsrectangle.h:135
QgsPoint::m
double m
Definition: qgspoint.h:61
QgsDistanceArea::formatDistance
static QString formatDistance(double distance, int decimals, QgsUnitTypes::DistanceUnit unit, bool keepBaseUnit=false)
Returns an distance formatted as a friendly string.
Definition: qgsdistancearea.cpp:1132
QgsUnitTypes::AreaUnit
AreaUnit
Units of area.
Definition: qgsunittypes.h:93
QgsAbstractGeometry::is3D
bool is3D() const
Returns true if the geometry is 3D and contains a z-value.
Definition: qgsabstractgeometry.h:202
QgsAbstractGeometry::nCoordinates
virtual int nCoordinates() const
Returns the number of nodes contained in the geometry.
Definition: qgsabstractgeometry.cpp:116
QgsMapSettings::scale
double scale() const
Returns the calculated map scale.
Definition: qgsmapsettings.cpp:395
QgsGeometry::constGet
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
Definition: qgsgeometry.cpp:128
QgsMeshLayer::activeVectorDatasetAtTime
QgsMeshDatasetIndex activeVectorDatasetAtTime(const QgsDateTimeRange &timeRange) const
Returns dataset index from active vector group depending on the time range If the temporal properties...
Definition: qgsmeshlayer.cpp:554
qgsrenderer.h
QgsTileRange::endColumn
int endColumn() const
Returns index of the last column in the range.
Definition: qgstiles.h:78
QgsDistanceArea::setSourceCrs
void setSourceCrs(const QgsCoordinateReferenceSystem &crs, const QgsCoordinateTransformContext &context)
Sets source spatial reference system crs.
Definition: qgsdistancearea.cpp:60
QgsRasterLayer
Definition: qgsrasterlayer.h:72
QgsMapToolIdentify::RasterLayer
@ RasterLayer
Definition: qgsmaptoolidentify.h:66
QgsMapTool::activate
virtual void activate()
called when set as currently active map tool
Definition: qgsmaptool.cpp:83
QgsMapToolIdentify::identifyMeshLayer
bool identifyMeshLayer(QList< QgsMapToolIdentify::IdentifyResult > *results, QgsMeshLayer *layer, const QgsPointXY &point)
Identifies data from active scalar and vector dataset from the mesh layer.
Definition: qgsmaptoolidentify.cpp:248
QgsMeshDatasetGroupMetadata::name
QString name() const
Returns name of the dataset group.
Definition: qgsmeshdataset.cpp:164
QgsGeometryUtils::closestVertex
static QgsPoint closestVertex(const QgsAbstractGeometry &geom, const QgsPoint &pt, QgsVertexId &id)
Returns the closest vertex to a geometry for a specified point.
Definition: qgsgeometryutils.cpp:67
QgsRaster::IdentifyFormatFeature
@ IdentifyFormatFeature
Definition: qgsraster.h:76
QgsAbstractGeometry
Abstract base class for all geometries.
Definition: qgsabstractgeometry.h:71
QgsVectorTileUtils::scaleToZoomLevel
static int scaleToZoomLevel(double mapScale, int sourceMinZoom, int sourceMaxZoom)
Finds best fitting zoom level (assuming GoogleCRS84Quad tile matrix set) given map scale denominator ...
Definition: qgsvectortileutils.cpp:64
QgsVertexId::type
VertexType type
Definition: qgsabstractgeometry.h:1083
qgsgeometryutils.h
qgsmeshlayer.h
qgsvectorlayer.h
QgsPointXY
Definition: qgspointxy.h:43
QgsMapSettings::destinationCrs
QgsCoordinateReferenceSystem destinationCrs() const
returns CRS of destination coordinate reference system
Definition: qgsmapsettings.cpp:317
QgsMapToolIdentify::formatChanged
void formatChanged(QgsRasterLayer *layer)
Definition: qgsmaptoolidentify.cpp:1066
QgsGeometry::asPoint
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
Definition: qgsgeometry.cpp:1559
QgsVectorTileLayer::sourceMaxZoom
int sourceMaxZoom() const
Returns maximum zoom level at which source has any valid tiles (negative = unconstrained)
Definition: qgsvectortilelayer.h:123
QgsRasterDataProvider::identifyFormatToCapability
static Capability identifyFormatToCapability(QgsRaster::IdentifyFormat format)
Definition: qgsrasterdataprovider.cpp:490
QgsTileRange::startRow
int startRow() const
Returns index of the first row in the range.
Definition: qgstiles.h:80
QgsMapCanvas::temporalRange
const QgsDateTimeRange & temporalRange() const
Returns map canvas datetime range.
Definition: qgsmapcanvas.cpp:930
QgsWkbTypes::hasM
static bool hasM(Type type)
Tests whether a WKB type contains m values.
Definition: qgswkbtypes.h:1092
QgsGeometry::createGeometryEngine
static QgsGeometryEngine * createGeometryEngine(const QgsAbstractGeometry *geometry)
Creates and returns a new geometry engine.
Definition: qgsgeometry.cpp:3659
QgsMapMouseEvent
Definition: qgsmapmouseevent.h:35
QgsMapLayer::Identifiable
@ Identifiable
If the layer is identifiable using the identify map tool and as a WMS layer.
Definition: qgsmaplayer.h:142
QgsWkbTypes::LineGeometry
@ LineGeometry
Definition: qgswkbtypes.h:142
QgsMapToolIdentify::VectorTileLayer
@ VectorTileLayer
Definition: qgsmaptoolidentify.h:68
QgsWkbTypes::PointGeometry
@ PointGeometry
Definition: qgswkbtypes.h:141
QgsCoordinateReferenceSystem::mapUnits
QgsUnitTypes::DistanceUnit mapUnits
Definition: qgscoordinatereferencesystem.h:210
QgsWkbTypes::NoGeometry
@ NoGeometry
Definition: qgswkbtypes.h:84
QgsMapLayer::customProperty
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
Definition: qgsmaplayer.cpp:1718
qgsgeometry.h
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:139
QgsVectorTileMVTDecoder::layerFeatures
QgsVectorTileFeatures layerFeatures(const QMap< QString, QgsFields > &perLayerFields, const QgsCoordinateTransform &ct) const
Returns decoded features grouped by sub-layers. It can only be called after a successful decode()
Definition: qgsvectortilemvtdecoder.cpp:80
qgstiles.h
QgsFeatureIterator::nextFeature
bool nextFeature(QgsFeature &f)
Definition: qgsfeatureiterator.h:373
QgsDistanceArea::measurePerimeter
double measurePerimeter(const QgsGeometry &geometry) const
Measures the perimeter of a polygon geometry.
Definition: qgsdistancearea.cpp:201
qgscurve.h
QgsGeometry
Definition: qgsgeometry.h:122
QgsVectorLayer
Definition: qgsvectorlayer.h:385
QgsFeature::hasGeometry
bool hasGeometry() const
Returns true if the feature has an associated geometry.
Definition: qgsfeature.cpp:197
QgsDistanceArea::convertLengthMeasurement
double convertLengthMeasurement(double length, QgsUnitTypes::DistanceUnit toUnits) const
Takes a length measurement calculated by this QgsDistanceArea object and converts it to a different d...
Definition: qgsdistancearea.cpp:1142
QgsMapLayer
Definition: qgsmaplayer.h:81
QgsRasterInterface::IdentifyText
@ IdentifyText
Definition: qgsrasterinterface.h:192
QgsPointXY::x
double x
Definition: qgspointxy.h:47
QgsVertexId
Utility class for identifying a unique vertex within a geometry.
Definition: qgsabstractgeometry.h:1033
QgsMeshDatasetValue::y
double y() const
Returns y value.
Definition: qgsmeshdataset.cpp:98
qgssettings.h
QgsErrorMessage::Text
@ Text
Definition: qgserror.h:38
QgsRectangle::height
double height() const
Returns the height of the rectangle.
Definition: qgsrectangle.h:209
QgsMapLayerType::VectorTileLayer
@ VectorTileLayer
Added in 3.14.
QgsAbstractGeometry::perimeter
virtual double perimeter() const
Returns the planar, 2-dimensional perimeter of the geometry.
Definition: qgsabstractgeometry.cpp:137
QgsMapLayer::name
QString name
Definition: qgsmaplayer.h:85
QgsMapToolIdentify::identifyMessage
void identifyMessage(const QString &)
QgsVectorTileLayer::getRawTile
QByteArray getRawTile(QgsTileXYZ tileID)
Fetches raw tile data for the give tile coordinates.
Definition: qgsvectortilelayer.cpp:289
QgsAbstractGeometry::isMeasure
bool isMeasure() const
Returns true if the geometry contains m values.
Definition: qgsabstractgeometry.h:211
QgsMapTool::searchRadiusMU
static double searchRadiusMU(const QgsRenderContext &context)
Gets search radius in map units for given context.
Definition: qgsmaptool.cpp:215
QgsGeometry::boundingBox
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
Definition: qgsgeometry.cpp:962
QgsDistanceArea
Definition: qgsdistancearea.h:49
QgsTileMatrix::fromWebMercator
static QgsTileMatrix fromWebMercator(int mZoomLevel)
Returns a tile matrix for the usual web mercator.
Definition: qgstiles.cpp:20
QgsMapToolIdentify::restoreCanvasPropertiesOverrides
void restoreCanvasPropertiesOverrides()
Clears canvas properties overrides previously set with setCanvasPropertiesOverrides()
Definition: qgsmaptoolidentify.cpp:193
qgsgeometrycollection.h
QgsMapToolIdentify::identifyVectorLayer
bool identifyVectorLayer(QList< QgsMapToolIdentify::IdentifyResult > *results, QgsVectorLayer *layer, const QgsPointXY &point)
Definition: qgsmaptoolidentify.cpp:237
qgsexception.h
QgsMapToolIdentify::~QgsMapToolIdentify
~QgsMapToolIdentify() override
Definition: qgsmaptoolidentify.cpp:68
qgsdistancearea.h
QgsFeature
Definition: qgsfeature.h:55
QgsVectorTileLayer::sourceMinZoom
int sourceMinZoom() const
Returns minimum zoom level at which source has any valid tiles (negative = unconstrained)
Definition: qgsvectortilelayer.h:121
QgsMapCanvas::currentLayer
QgsMapLayer * currentLayer()
returns current layer (set by legend widget)
Definition: qgsmapcanvas.cpp:511
QgsMapToolIdentify::mIdentifyMenu
QgsIdentifyMenu * mIdentifyMenu
Definition: qgsmaptoolidentify.h:165
QgsDistanceArea::formatArea
static QString formatArea(double area, int decimals, QgsUnitTypes::AreaUnit unit, bool keepBaseUnit=false)
Returns an area formatted as a friendly string.
Definition: qgsdistancearea.cpp:1137
QgsVectorTileFeatures
QMap< QString, QVector< QgsFeature > > QgsVectorTileFeatures
Features of a vector tile, grouped by sub-layer names (key of the map)
Definition: qgsvectortilerenderer.h:25
QgsSettings::enumValue
T enumValue(const QString &key, const T &defaultValue, const Section section=NoSection)
Returns the setting value for a setting based on an enum.
Definition: qgssettings.h:252
QgsMapLayer::isSpatial
virtual bool isSpatial() const
Returns true if the layer is considered a spatial layer, ie it has some form of geometry associated w...
Definition: qgsmaplayer.cpp:1740
QgsMapToolIdentify::IdentifyResult::mParams
QMap< QString, QVariant > mParams
Definition: qgsmaptoolidentify.h:94
qgslogger.h
qgsvectortileutils.h
qgsfeaturestore.h
QgsIdentifyMenu
The QgsIdentifyMenu class builds a menu to be used with identify results (.
Definition: qgsidentifymenu.h:48
QgsMapCanvas::mapUnitsPerPixel
double mapUnitsPerPixel() const
Returns the mapUnitsPerPixel (map units per pixel) for the canvas.
Definition: qgsmapcanvas.cpp:2124
QgsVertexId::CurveVertex
@ CurveVertex
Definition: qgsabstractgeometry.h:1038
QgsCoordinateTransform
Definition: qgscoordinatetransform.h:52
QgsMeshDatasetValue::scalar
double scalar() const
Returns magnitude of vector for vector data or scalar value for scalar data.
Definition: qgsmeshdataset.cpp:62
QgsGeometry::type
QgsWkbTypes::GeometryType type
Definition: qgsgeometry.h:126
QgsVectorTileMVTDecoder::decode
bool decode(QgsTileXYZ tileID, const QByteArray &rawTileData)
Tries to decode raw tile data, returns true on success.
Definition: qgsvectortilemvtdecoder.cpp:36
QgsFeatureIterator
Definition: qgsfeatureiterator.h:263
QgsMapSettings::layerToMapCoordinates
QgsPointXY layerToMapCoordinates(const QgsMapLayer *layer, QgsPointXY point) const
transform point coordinates from layer's CRS to output CRS
Definition: qgsmapsettings.cpp:482
QgsGeometry::area
double area() const
Returns the planar, 2-dimensional area of the geometry.
Definition: qgsgeometry.cpp:1775
QgsRaster::IdentifyFormat
IdentifyFormat
Definition: qgsraster.h:70
QgsProject::ellipsoid
QString ellipsoid
Definition: qgsproject.h:100
qgscoordinatereferencesystem.h
QgsRasterInterface::capabilities
virtual int capabilities() const
Returns a bitmask containing the supported capabilities.
Definition: qgsrasterinterface.h:206
QgsVectorTileMVTDecoder::layers
QStringList layers() const
Returns a list of sub-layer names in a tile. It can only be called after a successful decode()
Definition: qgsvectortilemvtdecoder.cpp:53
QgsMapLayer::type
QgsMapLayerType type() const
Returns the type of the layer.
Definition: qgsmaplayer.cpp:129
QgsTileMatrix::tileRangeFromExtent
QgsTileRange tileRangeFromExtent(const QgsRectangle &mExtent)
Returns tile range that fully covers the given extent.
Definition: qgstiles.cpp:54
QgsRasterDataProvider
Definition: qgsrasterdataprovider.h:88
QgsMeshDatasetSourceInterface::datasetGroupMetadata
virtual QgsMeshDatasetGroupMetadata datasetGroupMetadata(int groupIndex) const =0
Returns dataset group metadata.
QgsPoint::x
double x
Definition: qgspoint.h:58
QgsMeshLayer::dataProvider
QgsMeshDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
Definition: qgsmeshlayer.cpp:147
qgsproject.h
QgsMapToolIdentify::canvasMoveEvent
void canvasMoveEvent(QgsMapMouseEvent *e) override
Mouse move event for overriding. Default implementation does nothing.
Definition: qgsmaptoolidentify.cpp:73
QgsRectangle::width
double width() const
Returns the width of the rectangle.
Definition: qgsrectangle.h:202
QgsMeshLayer::activeScalarDatasetAtTime
QgsMeshDatasetIndex activeScalarDatasetAtTime(const QgsDateTimeRange &timeRange) const
Returns dataset index from active scalar group depending on the time range.
Definition: qgsmeshlayer.cpp:546
QgsRectangle::setYMinimum
void setYMinimum(double y)
Set the minimum y value.
Definition: qgsrectangle.h:140
QgsRectangle::setYMaximum
void setYMaximum(double y)
Set the maximum y value.
Definition: qgsrectangle.h:145
QgsTemporaryCursorOverride
Temporarily sets a cursor override for the QApplication for the lifetime of the object.
Definition: qgsguiutils.h:203
QgsRasterLayer::dataProvider
QgsRasterDataProvider * dataProvider() override
Returns the source data provider.
Definition: qgsrasterlayer.cpp:233
QgsMapTool::toMapCoordinates
QgsPointXY toMapCoordinates(QPoint point)
transformation from screen coordinates to map coordinates
Definition: qgsmaptool.cpp:42
QgsWkbTypes::flatType
static Type flatType(Type type)
Returns the flat type for a WKB type.
Definition: qgswkbtypes.h:701
QgsTileRange::startColumn
int startColumn() const
Returns index of the first column in the range.
Definition: qgstiles.h:76
qgsrasterdataprovider.h
QgsFeatureId
qint64 QgsFeatureId
Definition: qgsfeatureid.h:25
QgsDataProvider::crs
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.
QgsMapToolIdentify::IdentifyResult
Definition: qgsmaptoolidentify.h:74
QgsVectorLayer::renderer
QgsFeatureRenderer * renderer()
Returns renderer.
Definition: qgsvectorlayer.h:881