Skip to content
Permalink
Browse files

Fix sip/doxygen/todo

  • Loading branch information
wonder-sk committed Apr 20, 2018
1 parent bac3080 commit 6c2325c66b3e8dafd2cd091f1416b8deb775e450
Showing with 28 additions and 16 deletions.
  1. +6 −3 python/gui/qgsmaptoolidentify.sip.in
  2. +16 −9 src/gui/qgsmaptoolidentify.cpp
  3. +6 −4 src/gui/qgsmaptoolidentify.h
@@ -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();
@@ -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 );

};

@@ -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 ) )
{
@@ -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;

@@ -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() ) )
@@ -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 );


@@ -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

0 comments on commit 6c2325c

Please sign in to comment.
You can’t perform that action at this time.