Skip to content

Commit

Permalink
Address reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
NEDJIMAbelgacem authored and nyalldawson committed Jan 4, 2021
1 parent 7a4adf6 commit c6ad05d
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 34 deletions.
13 changes: 2 additions & 11 deletions src/core/pointcloud/qgspointclouddataprovider.cpp
Expand Up @@ -286,14 +286,14 @@ struct MapIndexedPointCloudNode
blockAttributes.find( QStringLiteral( "Z" ), zOffset ); blockAttributes.find( QStringLiteral( "Z" ), zOffset );
std::unique_ptr< QgsGeometryEngine > extentEngine( QgsGeometry::createGeometryEngine( mExtentGeometry.constGet() ) ); std::unique_ptr< QgsGeometryEngine > extentEngine( QgsGeometry::createGeometryEngine( mExtentGeometry.constGet() ) );
extentEngine->prepareGeometry(); extentEngine->prepareGeometry();
for ( int i = 0; i < block->pointCount(); ++i ) for ( int i = 0; i < block->pointCount() && pointsCount < mPointsLimit; ++i )
{ {
double x, y, z; double x, y, z;
_pointXY( ptr, i, recordSize, xOffset, yOffset, mIndexScale, mIndexOffset, x, y ); _pointXY( ptr, i, recordSize, xOffset, yOffset, mIndexScale, mIndexOffset, x, y );
z = _pointZ( ptr, i, recordSize, zOffset, mIndexScale, mIndexOffset ); z = _pointZ( ptr, i, recordSize, zOffset, mIndexScale, mIndexOffset );
QgsPoint pointXY( x, y ); QgsPoint pointXY( x, y );


if ( pointsCount < mPointsLimit && extentEngine->contains( &pointXY ) && mZRange.contains( z ) ) if ( mZRange.contains( z ) && extentEngine->contains( &pointXY ) )
{ {
QMap<QString, QVariant> pointAttr = _attributeMap( ptr, i * recordSize, blockAttributes ); QMap<QString, QVariant> pointAttr = _attributeMap( ptr, i * recordSize, blockAttributes );
pointAttr[ QStringLiteral( "X" ) ] = x; pointAttr[ QStringLiteral( "X" ) ] = x;
Expand Down Expand Up @@ -327,15 +327,6 @@ QVector<QMap<QString, QVariant>> QgsPointCloudDataProvider::identify(
const IndexedPointCloudNode root = index->root(); const IndexedPointCloudNode root = index->root();


QgsRectangle rootNodeExtentMapCoords = index->nodeMapExtent( root ); QgsRectangle rootNodeExtentMapCoords = index->nodeMapExtent( root );
// TODO? reproject the root node extent
// try
// {
// rootNodeExtentMapCoords = renderContext.coordinateTransform().transformBoundingBox( index->nodeMapExtent( root ) );
// }
// catch ( QgsCsException & )
// {
// QgsDebugMsg( QStringLiteral( "Could not transform node extent to map CRS" ) );
// }
const float rootErrorInMapCoordinates = rootNodeExtentMapCoords.width() / index->span(); const float rootErrorInMapCoordinates = rootNodeExtentMapCoords.width() / index->span();


QVector<IndexedPointCloudNode> nodes = traverseTree( index, root, maxErrorInMapCoords, rootErrorInMapCoordinates, extentGeometry, extentZRange ); QVector<IndexedPointCloudNode> nodes = traverseTree( index, root, maxErrorInMapCoords, rootErrorInMapCoordinates, extentGeometry, extentZRange );
Expand Down
20 changes: 0 additions & 20 deletions src/core/pointcloud/qgspointcloudlayerrenderer.h
Expand Up @@ -77,26 +77,6 @@ class CORE_EXPORT QgsPointCloudLayerRenderer: public QgsMapLayerRenderer
QgsPointCloudAttributeCollection mLayerAttributes; QgsPointCloudAttributeCollection mLayerAttributes;
QgsPointCloudAttributeCollection mAttributes; QgsPointCloudAttributeCollection mAttributes;
QgsGeometry mCloudExtent; QgsGeometry mCloudExtent;

/**
* Retrieves the x and y coordinate for the point at index \a i.
*/
static void pointXY( QgsPointCloudRenderContext &context, const char *ptr, int i, double &x, double &y )
{
const qint32 ix = *reinterpret_cast< const qint32 * >( ptr + i * context.pointRecordSize() + context.xOffset() );
const qint32 iy = *reinterpret_cast< const qint32 * >( ptr + i * context.pointRecordSize() + context.yOffset() );
x = context.offset().x() + context.scale().x() * ix;
y = context.offset().y() + context.scale().y() * iy;
}

/**
* Retrieves the z value for the point at index \a i.
*/
static double pointZ( QgsPointCloudRenderContext &context, const char *ptr, int i )
{
const qint32 iz = *reinterpret_cast<const qint32 * >( ptr + i * context.pointRecordSize() + context.zOffset() );
return context.offset().z() + context.scale().z() * iz;
}
}; };


#endif // QGSPOINTCLOUDLAYERRENDERER_H #endif // QGSPOINTCLOUDLAYERRENDERER_H
4 changes: 2 additions & 2 deletions src/core/pointcloud/qgspointcloudrenderer.cpp
Expand Up @@ -249,8 +249,8 @@ QVector<QMap<QString, QVariant>> QgsPointCloudRenderer::identify( QgsPointCloudL
QgsPointXY point1MapCoords = renderContext.mapToPixel().toMapCoordinates( point1.x(), point1.y() ); QgsPointXY point1MapCoords = renderContext.mapToPixel().toMapCoordinates( point1.x(), point1.y() );
QgsPointXY point2MapCoords = renderContext.mapToPixel().toMapCoordinates( point2.x(), point2.y() ); QgsPointXY point2MapCoords = renderContext.mapToPixel().toMapCoordinates( point2.x(), point2.y() );
QgsCircle circle = QgsCircle::from2Points( QgsPoint( point1MapCoords ), QgsPoint( point2MapCoords ) ); QgsCircle circle = QgsCircle::from2Points( QgsPoint( point1MapCoords ), QgsPoint( point2MapCoords ) );
QgsPolygon *polygon = circle.toPolygon( 6 ); std::unique_ptr<QgsPolygon> polygon( circle.toPolygon( 6 ) );
QgsGeometry circleGeometry( polygon ); QgsGeometry circleGeometry( std::move( polygon ) );
selectionGeometry = circleGeometry; selectionGeometry = circleGeometry;
} }
} }
Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsmaptoolidentify.cpp
Expand Up @@ -520,7 +520,7 @@ bool QgsMapToolIdentify::identifyPointCloudLayer( QList<QgsMapToolIdentify::Iden
{ {
transformedGeometry.transform( ct ); transformedGeometry.transform( ct );
} }
catch ( QgsCsException& ) catch ( QgsCsException & )
{ {
return false; return false;
} }
Expand Down

0 comments on commit c6ad05d

Please sign in to comment.