|
@@ -23,6 +23,7 @@ |
|
|
#include "qgspointcloudindex.h" |
|
|
#include "qgspointcloudlayerelevationproperties.h" |
|
|
#include "qgslogger.h" |
|
|
#include "qgscircle.h" |
|
|
|
|
|
QgsPointCloudRenderContext::QgsPointCloudRenderContext( QgsRenderContext &context, const QgsVector3D &scale, const QgsVector3D &offset, double zValueScale, double zValueFixedOffset ) |
|
|
: mRenderContext( context ) |
|
@@ -228,7 +229,38 @@ QVector<QMap<QString, QVariant>> QgsPointCloudRenderer::identify( QgsPointCloudL |
|
|
|
|
|
float rootErrorPixels = rootErrorInMapCoordinates / mapUnitsPerPixel; // in pixels |
|
|
|
|
|
QVector<QMap<QString, QVariant>> points = layer->dataProvider()->identify( layer, maximumError, rootErrorPixels, geometry, QgsDoubleRange() ); |
|
|
QgsGeometry selectionGeometry = geometry; |
|
|
if ( geometry.type() == QgsWkbTypes::PointGeometry ) |
|
|
{ |
|
|
double x = geometry.asPoint().x(); |
|
|
double y = geometry.asPoint().y(); |
|
|
if ( pointSymbol() == QgsPointCloudRenderer::PointSymbol::Square ) |
|
|
{ |
|
|
QgsPointXY deviceCoords = context.renderContext().mapToPixel().transform( QgsPointXY( x, y ) ); |
|
|
QgsPointXY point1( deviceCoords.x() - 2 * pointSize(), deviceCoords.y() - 2 * pointSize() ); |
|
|
QgsPointXY point2( deviceCoords.x() + 2 * pointSize(), deviceCoords.y() + 2 * pointSize() ); |
|
|
QgsPointXY point1MapCoords = context.renderContext().mapToPixel().toMapCoordinates( point1.x(), point1.y() ); |
|
|
QgsPointXY point2MapCoords = context.renderContext().mapToPixel().toMapCoordinates( point2.x(), point2.y() ); |
|
|
QgsRectangle pointRect( point1MapCoords, point2MapCoords ); |
|
|
selectionGeometry = QgsGeometry::fromRect( pointRect ); |
|
|
} |
|
|
else if ( pointSymbol() == QgsPointCloudRenderer::PointSymbol::Circle ) |
|
|
{ |
|
|
QgsPoint centerMapCoords( x, y ); |
|
|
QgsPointXY deviceCoords = context.renderContext().mapToPixel().transform( centerMapCoords ); |
|
|
QgsPoint point1( deviceCoords.x(), deviceCoords.y() - 2 * pointSize() ); |
|
|
QgsPoint point2( deviceCoords.x(), deviceCoords.y() + 2 * pointSize() ); |
|
|
QgsPointXY point1MapCoords = context.renderContext().mapToPixel().toMapCoordinates( point1.x(), point1.y() ); |
|
|
QgsPointXY point2MapCoords = context.renderContext().mapToPixel().toMapCoordinates( point2.x(), point2.y() ); |
|
|
QgsCircle circle = QgsCircle::from2Points( QgsPoint( point1MapCoords ), QgsPoint( point2MapCoords ) ); |
|
|
// TODO: make this faster? |
|
|
QgsPolygon *polygon = circle.toPolygon( 5 ); |
|
|
QgsGeometry circleGeometry( polygon ); |
|
|
selectionGeometry = circleGeometry; |
|
|
} |
|
|
} |
|
|
|
|
|
QVector<QMap<QString, QVariant>> points = layer->dataProvider()->identify( layer, maximumError, rootErrorPixels, selectionGeometry, QgsDoubleRange() ); |
|
|
|
|
|
for ( QMap<QString, QVariant> point : points ) |
|
|
{ |
|
|