|
23 | 23 | #include "qgspointcloudindex.h"
|
24 | 24 | #include "qgspointcloudlayerelevationproperties.h"
|
25 | 25 | #include "qgslogger.h"
|
| 26 | +#include "qgscircle.h" |
26 | 27 |
|
27 | 28 | QgsPointCloudRenderContext::QgsPointCloudRenderContext( QgsRenderContext &context, const QgsVector3D &scale, const QgsVector3D &offset, double zValueScale, double zValueFixedOffset )
|
28 | 29 | : mRenderContext( context )
|
@@ -228,7 +229,38 @@ QVector<QMap<QString, QVariant>> QgsPointCloudRenderer::identify( QgsPointCloudL
|
228 | 229 |
|
229 | 230 | float rootErrorPixels = rootErrorInMapCoordinates / mapUnitsPerPixel; // in pixels
|
230 | 231 |
|
231 |
| - QVector<QMap<QString, QVariant>> points = layer->dataProvider()->identify( layer, maximumError, rootErrorPixels, geometry, QgsDoubleRange() ); |
| 232 | + QgsGeometry selectionGeometry = geometry; |
| 233 | + if ( geometry.type() == QgsWkbTypes::PointGeometry ) |
| 234 | + { |
| 235 | + double x = geometry.asPoint().x(); |
| 236 | + double y = geometry.asPoint().y(); |
| 237 | + if ( pointSymbol() == QgsPointCloudRenderer::PointSymbol::Square ) |
| 238 | + { |
| 239 | + QgsPointXY deviceCoords = context.renderContext().mapToPixel().transform( QgsPointXY( x, y ) ); |
| 240 | + QgsPointXY point1( deviceCoords.x() - 2 * pointSize(), deviceCoords.y() - 2 * pointSize() ); |
| 241 | + QgsPointXY point2( deviceCoords.x() + 2 * pointSize(), deviceCoords.y() + 2 * pointSize() ); |
| 242 | + QgsPointXY point1MapCoords = context.renderContext().mapToPixel().toMapCoordinates( point1.x(), point1.y() ); |
| 243 | + QgsPointXY point2MapCoords = context.renderContext().mapToPixel().toMapCoordinates( point2.x(), point2.y() ); |
| 244 | + QgsRectangle pointRect( point1MapCoords, point2MapCoords ); |
| 245 | + selectionGeometry = QgsGeometry::fromRect( pointRect ); |
| 246 | + } |
| 247 | + else if ( pointSymbol() == QgsPointCloudRenderer::PointSymbol::Circle ) |
| 248 | + { |
| 249 | + QgsPoint centerMapCoords( x, y ); |
| 250 | + QgsPointXY deviceCoords = context.renderContext().mapToPixel().transform( centerMapCoords ); |
| 251 | + QgsPoint point1( deviceCoords.x(), deviceCoords.y() - 2 * pointSize() ); |
| 252 | + QgsPoint point2( deviceCoords.x(), deviceCoords.y() + 2 * pointSize() ); |
| 253 | + QgsPointXY point1MapCoords = context.renderContext().mapToPixel().toMapCoordinates( point1.x(), point1.y() ); |
| 254 | + QgsPointXY point2MapCoords = context.renderContext().mapToPixel().toMapCoordinates( point2.x(), point2.y() ); |
| 255 | + QgsCircle circle = QgsCircle::from2Points( QgsPoint( point1MapCoords ), QgsPoint( point2MapCoords ) ); |
| 256 | + // TODO: make this faster? |
| 257 | + QgsPolygon *polygon = circle.toPolygon( 5 ); |
| 258 | + QgsGeometry circleGeometry( polygon ); |
| 259 | + selectionGeometry = circleGeometry; |
| 260 | + } |
| 261 | + } |
| 262 | + |
| 263 | + QVector<QMap<QString, QVariant>> points = layer->dataProvider()->identify( layer, maximumError, rootErrorPixels, selectionGeometry, QgsDoubleRange() ); |
232 | 264 |
|
233 | 265 | for ( QMap<QString, QVariant> point : points )
|
234 | 266 | {
|
|
0 commit comments