Skip to content
Permalink
Browse files

remove root error from identify in the provider

  • Loading branch information
NEDJIMAbelgacem authored and nyalldawson committed Jan 4, 2021
1 parent 8ec2600 commit c993eb5dba8b6e1c5fc11bc2872d62f8080c8ff8
@@ -183,8 +183,7 @@ QVariant QgsPointCloudDataProvider::metadataClassStatistic( const QString &, con
}

QVector<QMap<QString, QVariant>> QgsPointCloudDataProvider::identify(
float maxErrorPixels,
float rootErrorPixels,
float maxErrorInMapCoords,
QgsGeometry extentGeometry,
const QgsDoubleRange extentZRange )
{
@@ -195,7 +194,19 @@ QVector<QMap<QString, QVariant>> QgsPointCloudDataProvider::identify(

QgsRenderContext renderContext;

QVector<IndexedPointCloudNode> nodes = traverseTree( index, root, maxErrorPixels, rootErrorPixels, extentGeometry, extentZRange );
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();

QVector<IndexedPointCloudNode> nodes = traverseTree( index, root, maxErrorInMapCoords, rootErrorInMapCoordinates, extentGeometry, extentZRange );

QgsPointCloudAttributeCollection attributeCollection = index->attributes();
QgsPointCloudRequest request;
@@ -240,8 +251,8 @@ QVector<QMap<QString, QVariant>> QgsPointCloudDataProvider::identify(
QVector<IndexedPointCloudNode> QgsPointCloudDataProvider::traverseTree(
const QgsPointCloudIndex *pc,
IndexedPointCloudNode n,
float maxErrorPixels,
float nodeErrorPixels,
float maxError,
float nodeError,
const QgsGeometry &extentGeometry,
const QgsDoubleRange extentZRange )
{
@@ -256,15 +267,15 @@ QVector<IndexedPointCloudNode> QgsPointCloudDataProvider::traverseTree(

nodes.append( n );

float childrenErrorPixels = nodeErrorPixels / 2.0f;
if ( childrenErrorPixels < maxErrorPixels )
float childrenError = nodeError / 2.0f;
if ( childrenError < maxError )
return nodes;

const QList<IndexedPointCloudNode> children = pc->nodeChildren( n );
for ( const IndexedPointCloudNode &nn : children )
{
if ( extentGeometry.intersects( pc->nodeMapExtent( nn ) ) )
nodes += traverseTree( pc, nn, maxErrorPixels, childrenErrorPixels, extentGeometry, extentZRange );
nodes += traverseTree( pc, nn, maxError, childrenError, extentGeometry, extentZRange );
}

return nodes;
@@ -78,17 +78,16 @@ class CORE_EXPORT QgsPointCloudDataProvider: public QgsDataProvider
~QgsPointCloudDataProvider() override;

/**
* Returns the list of points of the point cloud layer \a layer according to a zoom level
* defined by \a maxErrorPixels and \a rootErrorPixels, and an extent defined by a geometry
* in the 2D plane \a geometry and a range for z values \a extentZRange
* Returns the list of points of the point cloud according to a zoom level
* defined by \a maxErrorInMapCoords, an extent \a geometry in the 2D plane
* and a range \a extentZRange for z values
*
* \a maxErrorPixels : maximum accepted error factor in pixels
* \a rootErrorPixels : the root node error factor in pixels
*
* \note this function does not handle elevation properties and you need to change it yourself
* after returning from the function
* \note this function does not handle elevation properties and you need to
* change elevation coordinates yourself after returning from the function
*/
QVector<QMap<QString, QVariant>> identify( float maxErrorPixels, float rootErrorPixels, QgsGeometry extentGeometry, const QgsDoubleRange extentZRange ) SIP_SKIP;
QVector<QMap<QString, QVariant>> identify( float maxErrorInMapCoords, QgsGeometry extentGeometry, const QgsDoubleRange extentZRange ) SIP_SKIP;

/**
* Returns flags containing the supported capabilities for the data provider.
@@ -333,7 +332,7 @@ class CORE_EXPORT QgsPointCloudDataProvider: public QgsDataProvider
return context.offset().z() + context.scale().z() * iz;
}

QVector<IndexedPointCloudNode> traverseTree( const QgsPointCloudIndex *pc, IndexedPointCloudNode n, float maxErrorPixels, float nodeErrorPixels, const QgsGeometry &extentGeometry, const QgsDoubleRange extentZRange );
QVector<IndexedPointCloudNode> traverseTree( const QgsPointCloudIndex *pc, IndexedPointCloudNode n, float maxError, float nodeError, const QgsGeometry &extentGeometry, const QgsDoubleRange extentZRange );
};

#endif // QGSMESHDATAPROVIDER_H
@@ -213,7 +213,6 @@ QVector<QMap<QString, QVariant>> QgsPointCloudRenderer::identify( QgsPointCloudL
{
QgsDebugMsg( QStringLiteral( "Could not transform node extent to map CRS" ) );
}
//

const float rootErrorInMapCoordinates = rootNodeExtentMapCoords.width() / index->span(); // in map coords

@@ -224,7 +223,7 @@ QVector<QMap<QString, QVariant>> QgsPointCloudRenderer::identify( QgsPointCloudL
return selectedPoints;
}

float rootErrorPixels = rootErrorInMapCoordinates / mapUnitsPerPixel; // in pixels
float maxErrorInMapCoordinates = maxErrorPixels * mapUnitsPerPixel;

QgsGeometry selectionGeometry = geometry;
if ( geometry.type() == QgsWkbTypes::PointGeometry )
@@ -257,8 +256,10 @@ QVector<QMap<QString, QVariant>> QgsPointCloudRenderer::identify( QgsPointCloudL
}
}

QVector<QMap<QString, QVariant>> points = layer->dataProvider()->identify( maxErrorPixels, rootErrorPixels, selectionGeometry, QgsDoubleRange() );
QVector<QMap<QString, QVariant>> points = layer->dataProvider()->identify( maxErrorInMapCoordinates, selectionGeometry, QgsDoubleRange() );

points.erase( std::remove_if( points.begin(), points.end(), [this]( const QMap<QString, QVariant> &point ) { return !this->willRenderPoint( point ); } ), points.end() );

return points;
}

0 comments on commit c993eb5

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