Skip to content

Commit

Permalink
Fix sip/doxygen/todo
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Apr 20, 2018
1 parent bac3080 commit 6c2325c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 16 deletions.
9 changes: 6 additions & 3 deletions python/gui/qgsmaptoolidentify.sip.in
Expand Up @@ -109,7 +109,13 @@ this has been made private and two publics methods are offered
%End

QList<QgsMapToolIdentify::IdentifyResult> identify( const QgsGeometry &geometry, IdentifyMode mode, LayerType layerType );
%Docstring
Performs identification based on a geometry (in map coordinates)
%End
QList<QgsMapToolIdentify::IdentifyResult> identify( const QgsGeometry &geometry, IdentifyMode mode, const QList<QgsMapLayer *> &layerList, LayerType layerType );
%Docstring
Performs identification based on a geometry (in map coordinates)
%End


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

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

};

Expand Down
25 changes: 16 additions & 9 deletions src/gui/qgsmaptoolidentify.cpp
Expand Up @@ -190,12 +190,12 @@ void QgsMapToolIdentify::deactivate()
QgsMapTool::deactivate();
}

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

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

QgsGeometry selectionGeom = geometry;
bool isPointOrRectangle = true; // TODO: replace with a proper check
bool isPointOrRectangle;
QgsPointXY point;
bool isSingleClick = selectionGeom.type() == QgsWkbTypes::PointGeometry;
if ( isSingleClick )
{
isPointOrRectangle = true;
point = selectionGeom.asPoint();

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

int featureCount = 0;

Expand All @@ -261,16 +267,17 @@ bool QgsMapToolIdentify::identifyVectorLayer( QList<QgsMapToolIdentify::Identify
else
{
r = toLayerCoordinates( layer, selectionGeom.boundingBox() );

if ( !isPointOrRectangle )
{
QgsCoordinateTransform ct( mCanvas->mapSettings().destinationCrs(), layer->crs(), mCanvas->mapSettings().transformContext() );
if ( ct.isValid() )
selectionGeom.transform( ct );
}
}

QgsFeatureIterator fit = layer->getFeatures( QgsFeatureRequest().setFilterRect( r ).setFlags( QgsFeatureRequest::ExactIntersect ) );
QgsFeature f;


QgsCoordinateTransform ct = QgsCoordinateTransform( mCanvas->mapSettings().destinationCrs(), layer->crs(), mCanvas->mapSettings().transformContext() );
if ( ct.isValid() )
selectionGeom.transform( ct );

while ( fit.nextFeature( f ) )
{
if ( isPointOrRectangle || selectionGeom.intersects( f.geometry() ) )
Expand Down
10 changes: 6 additions & 4 deletions src/gui/qgsmaptoolidentify.h
Expand Up @@ -123,8 +123,9 @@ class GUI_EXPORT QgsMapToolIdentify : public QgsMapTool
\returns a list of IdentifyResult*/
QList<QgsMapToolIdentify::IdentifyResult> identify( int x, int y, IdentifyMode mode, LayerType layerType = AllLayers );

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


Expand Down Expand Up @@ -160,15 +161,16 @@ class GUI_EXPORT QgsMapToolIdentify : public QgsMapTool

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

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

private:

bool identifyLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsMapLayer *layer, const QgsGeometry &geometry, const QgsRectangle &viewExtent, double mapUnitsPerPixel, QgsMapToolIdentify::LayerType layerType = AllLayers );
bool identifyRasterLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsRasterLayer *layer, const QgsGeometry &geometry, const QgsRectangle &viewExtent, double mapUnitsPerPixel );
bool identifyVectorLayer( QList<QgsMapToolIdentify::IdentifyResult> *results, QgsVectorLayer *layer, const QgsGeometry &geometry );

/**
* Desired units for distance display.
* \since QGIS 2.14
Expand Down

0 comments on commit 6c2325c

Please sign in to comment.