Skip to content
Permalink
Browse files

Use geometry engine

  • Loading branch information
NEDJIMAbelgacem authored and nyalldawson committed Jan 4, 2021
1 parent 6a0e018 commit 16a8ef5be686487e2cfacd2181d94a5b23c067f8
@@ -22,8 +22,7 @@
#include "qgspointcloudlayer.h"
#include "qgspointcloudlayerelevationproperties.h"
#include "qgspointcloudrequest.h"
#include "qgslogger.h"
#include "qgscircle.h"
#include "qgsgeometryengine.h"
#include <mutex>

#include <QtConcurrent/QtConcurrentMap>
@@ -224,14 +223,16 @@ struct MapIndexedPointCloudNode
QgsPointCloudAttributeCollection blockAttributes = block->attributes();
const std::size_t recordSize = blockAttributes.pointRecordSize();
mContext.setAttributes( block->attributes() );
std::unique_ptr< QgsGeometryEngine > extentEngine( QgsGeometry::createGeometryEngine( mExtentGeometry.constGet() ) );
extentEngine->prepareGeometry();
for ( int i = 0; i < block->pointCount(); ++i )
{
double x, y, z;
_pointXY( mContext, ptr, i, x, y );
z = _pointZ( mContext, ptr, i );
QgsPointXY pointXY( x, y );
QgsPoint pointXY( x, y );

if ( pointsCount < mPointsLimit && mExtentGeometry.contains( &pointXY ) && mZRange.contains( z ) )
if ( pointsCount < mPointsLimit && extentEngine->contains( &pointXY ) && mZRange.contains( z ) )
{
QMap<QString, QVariant> pointAttr = mContext.attributeMap( ptr, i * recordSize, blockAttributes );
pointAttr[ QStringLiteral( "X" ) ] = x;
@@ -249,8 +249,7 @@ QVector<QMap<QString, QVariant>> QgsPointCloudRenderer::identify( QgsPointCloudL
QgsPointXY point1MapCoords = renderContext.mapToPixel().toMapCoordinates( point1.x(), point1.y() );
QgsPointXY point2MapCoords = renderContext.mapToPixel().toMapCoordinates( point2.x(), point2.y() );
QgsCircle circle = QgsCircle::from2Points( QgsPoint( point1MapCoords ), QgsPoint( point2MapCoords ) );
// TODO: make this faster?
QgsPolygon *polygon = circle.toPolygon( 5 );
QgsPolygon *polygon = circle.toPolygon( 6 );
QgsGeometry circleGeometry( polygon );
selectionGeometry = circleGeometry;
}

0 comments on commit 16a8ef5

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