Skip to content

Commit 6c2325c

Browse files
committed
Fix sip/doxygen/todo
1 parent bac3080 commit 6c2325c

File tree

3 files changed

+28
-16
lines changed

3 files changed

+28
-16
lines changed

python/gui/qgsmaptoolidentify.sip.in

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,13 @@ this has been made private and two publics methods are offered
109109
%End
110110

111111
QList<QgsMapToolIdentify::IdentifyResult> identify( const QgsGeometry &geometry, IdentifyMode mode, LayerType layerType );
112+
%Docstring
113+
Performs identification based on a geometry (in map coordinates)
114+
%End
112115
QList<QgsMapToolIdentify::IdentifyResult> identify( const QgsGeometry &geometry, IdentifyMode mode, const QList<QgsMapLayer *> &layerList, LayerType layerType );
116+
%Docstring
117+
Performs identification based on a geometry (in map coordinates)
118+
%End
113119

114120

115121
QgsIdentifyMenu *identifyMenu();
@@ -148,12 +154,9 @@ this has been made private and two publics methods are offered
148154
%Docstring
149155
Call the right method depending on layer type
150156
%End
151-
bool identifyLayer( QList<IdentifyResult> *results, QgsMapLayer *layer, const QgsGeometry &geometry, const QgsRectangle &viewExtent, double mapUnitsPerPixel, LayerType layerType );
152157

153158
bool identifyRasterLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsRasterLayer *layer, QgsPointXY point, const QgsRectangle &viewExtent, double mapUnitsPerPixel );
154-
bool identifyRasterLayer( QList<IdentifyResult> *results, QgsRasterLayer *layer, const QgsGeometry &geometry, const QgsRectangle &viewExtent, double mapUnitsPerPixel );
155159
bool identifyVectorLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsVectorLayer *layer, const QgsPointXY &point );
156-
bool identifyVectorLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsVectorLayer *layer, const QgsGeometry &geometry );
157160

158161
};
159162

src/gui/qgsmaptoolidentify.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ void QgsMapToolIdentify::deactivate()
190190
QgsMapTool::deactivate();
191191
}
192192

193-
bool QgsMapToolIdentify::identifyLayer( QList<IdentifyResult> *results, QgsMapLayer *layer, const QgsPointXY &point, const QgsRectangle &viewExtent, double mapUnitsPerPixel, LayerType layerType )
193+
bool QgsMapToolIdentify::identifyLayer( QList<IdentifyResult> *results, QgsMapLayer *layer, const QgsPointXY &point, const QgsRectangle &viewExtent, double mapUnitsPerPixel, QgsMapToolIdentify::LayerType layerType )
194194
{
195195
return identifyLayer( results, layer, QgsGeometry::fromPointXY( point ), viewExtent, mapUnitsPerPixel, layerType );
196196
}
197197

198-
bool QgsMapToolIdentify::identifyLayer( QList<IdentifyResult> *results, QgsMapLayer *layer, const QgsGeometry &geometry, const QgsRectangle &viewExtent, double mapUnitsPerPixel, LayerType layerType )
198+
bool QgsMapToolIdentify::identifyLayer( QList<IdentifyResult> *results, QgsMapLayer *layer, const QgsGeometry &geometry, const QgsRectangle &viewExtent, double mapUnitsPerPixel, QgsMapToolIdentify::LayerType layerType )
199199
{
200200
if ( layer->type() == QgsMapLayer::RasterLayer && layerType.testFlag( RasterLayer ) )
201201
{
@@ -232,16 +232,22 @@ bool QgsMapToolIdentify::identifyVectorLayer( QList<QgsMapToolIdentify::Identify
232232
QMap< QString, QString > commonDerivedAttributes;
233233

234234
QgsGeometry selectionGeom = geometry;
235-
bool isPointOrRectangle = true; // TODO: replace with a proper check
235+
bool isPointOrRectangle;
236236
QgsPointXY point;
237237
bool isSingleClick = selectionGeom.type() == QgsWkbTypes::PointGeometry;
238238
if ( isSingleClick )
239239
{
240+
isPointOrRectangle = true;
240241
point = selectionGeom.asPoint();
241242

242243
commonDerivedAttributes.insert( tr( "(clicked coordinate X)" ), formatXCoordinate( point ) );
243244
commonDerivedAttributes.insert( tr( "(clicked coordinate Y)" ), formatYCoordinate( point ) );
244245
}
246+
else
247+
{
248+
// we have a polygon - maybe it is a rectangle - in such case we can avoid costly insterestion tests later
249+
isPointOrRectangle = QgsGeometry::fromRect( selectionGeom.boundingBox() ).isGeosEqual( selectionGeom );
250+
}
245251

246252
int featureCount = 0;
247253

@@ -261,16 +267,17 @@ bool QgsMapToolIdentify::identifyVectorLayer( QList<QgsMapToolIdentify::Identify
261267
else
262268
{
263269
r = toLayerCoordinates( layer, selectionGeom.boundingBox() );
270+
271+
if ( !isPointOrRectangle )
272+
{
273+
QgsCoordinateTransform ct( mCanvas->mapSettings().destinationCrs(), layer->crs(), mCanvas->mapSettings().transformContext() );
274+
if ( ct.isValid() )
275+
selectionGeom.transform( ct );
276+
}
264277
}
265278

266279
QgsFeatureIterator fit = layer->getFeatures( QgsFeatureRequest().setFilterRect( r ).setFlags( QgsFeatureRequest::ExactIntersect ) );
267280
QgsFeature f;
268-
269-
270-
QgsCoordinateTransform ct = QgsCoordinateTransform( mCanvas->mapSettings().destinationCrs(), layer->crs(), mCanvas->mapSettings().transformContext() );
271-
if ( ct.isValid() )
272-
selectionGeom.transform( ct );
273-
274281
while ( fit.nextFeature( f ) )
275282
{
276283
if ( isPointOrRectangle || selectionGeom.intersects( f.geometry() ) )

src/gui/qgsmaptoolidentify.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,9 @@ class GUI_EXPORT QgsMapToolIdentify : public QgsMapTool
123123
\returns a list of IdentifyResult*/
124124
QList<QgsMapToolIdentify::IdentifyResult> identify( int x, int y, IdentifyMode mode, LayerType layerType = AllLayers );
125125

126-
// geometry is in map coordinates
126+
//! Performs identification based on a geometry (in map coordinates)
127127
QList<QgsMapToolIdentify::IdentifyResult> identify( const QgsGeometry &geometry, IdentifyMode mode, LayerType layerType );
128+
//! Performs identification based on a geometry (in map coordinates)
128129
QList<QgsMapToolIdentify::IdentifyResult> identify( const QgsGeometry &geometry, IdentifyMode mode, const QList<QgsMapLayer *> &layerList, LayerType layerType );
129130

130131

@@ -160,15 +161,16 @@ class GUI_EXPORT QgsMapToolIdentify : public QgsMapTool
160161

161162
//! Call the right method depending on layer type
162163
bool identifyLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsMapLayer *layer, const QgsPointXY &point, const QgsRectangle &viewExtent, double mapUnitsPerPixel, QgsMapToolIdentify::LayerType layerType = AllLayers );
163-
bool identifyLayer( QList<IdentifyResult> *results, QgsMapLayer *layer, const QgsGeometry &geometry, const QgsRectangle &viewExtent, double mapUnitsPerPixel, LayerType layerType );
164164

165165
bool identifyRasterLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsRasterLayer *layer, QgsPointXY point, const QgsRectangle &viewExtent, double mapUnitsPerPixel );
166-
bool identifyRasterLayer( QList<IdentifyResult> *results, QgsRasterLayer *layer, const QgsGeometry &geometry, const QgsRectangle &viewExtent, double mapUnitsPerPixel );
167166
bool identifyVectorLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsVectorLayer *layer, const QgsPointXY &point );
168-
bool identifyVectorLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsVectorLayer *layer, const QgsGeometry &geometry );
169167

170168
private:
171169

170+
bool identifyLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsMapLayer *layer, const QgsGeometry &geometry, const QgsRectangle &viewExtent, double mapUnitsPerPixel, QgsMapToolIdentify::LayerType layerType = AllLayers );
171+
bool identifyRasterLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsRasterLayer *layer, const QgsGeometry &geometry, const QgsRectangle &viewExtent, double mapUnitsPerPixel );
172+
bool identifyVectorLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsVectorLayer *layer, const QgsGeometry &geometry );
173+
172174
/**
173175
* Desired units for distance display.
174176
* \since QGIS 2.14

0 commit comments

Comments
 (0)