Skip to content
Permalink
Browse files

add pointsLimit and SIP

  • Loading branch information
NEDJIMAbelgacem authored and wonder-sk committed Jan 13, 2021
1 parent c4c7e25 commit 432f29be92393f48637b5f4365f8401afe13dd97
@@ -220,6 +220,9 @@ will be performed on the x/y extent of the box only.
%End

float distanceFromPoint( double x, double y, double z );
%Docstring
Returns shortest distance from the box to a point
%End

QgsRectangle toRectangle() const;
%Docstring
@@ -90,6 +90,41 @@ the number of points returned to ``pointsLimit`` points
%End


SIP_PYLIST getPointsOnRay( const QVector3D &rayOrigin, const QVector3D &rayDirection, double maxScreenError, double cameraFov, int screenSizePx, double pointAngle, int pointsLimit = 1000 );
%Docstring
Returns the Points that are on a ray

:param rayOrigin: : The origin of the ray in layer coordinates
:param rayDirection: : The direction of the ray in layer coordinates
:param maxScreenError: : Maximum screen error (as taken from the 3D point cloud layer renderer)
:param cameraFov: : The field of view of the camera in degrees
:param screenSizePx: : The size of the screen's viewport in pixels
:param pointAngle: : the maximum accepted angle between the point and it's projected point on the ray in degrees
:param pointsLimit: : the maximum number of points returned

:return: a vector of the identified points

.. versionadded:: 3.18
%End
%MethodCode
{
QVector<QMap<QString, QVariant>> res = sipCpp->identify( *a0, *a1, a2, a3, a4, a5, a6 );
sipRes = PyList_New( res.size() );
for ( int i = 0; i < res.size(); ++i )
{
PyObject *dict = PyDict_New();
for ( QString key : res[i].keys() )
{
PyObject *keyObj = sipConvertFromNewType( new QString( key ), sipType_QString, Py_None );
PyObject *valObj = sipConvertFromNewType( new QVariant( res[i][key] ), sipType_QVariant, Py_None );
PyDict_SetItem( dict, keyObj, valObj );
}
PyList_SET_ITEM( sipRes, i, dict );
}
}
%End


virtual QgsPointCloudDataProvider::Capabilities capabilities() const;
%Docstring
Returns flags containing the supported capabilities for the data provider.
@@ -279,5 +279,4 @@ void Qgs3DMapCanvas::identifyPointCloudOnMouseEvent( QVector<QPair<QgsMapLayer *
rayDirWorld = rayDirWorld.normalized();

mScene->identifyPointCloudOnRay( result, QVector3D( rayOriginWorld ), rayDirWorld );
return true;
}
@@ -409,7 +409,7 @@ QVector<IndexedPointCloudNode> QgsPointCloudDataProvider::traverseTree(
return nodes;
}

QVector<QVariantMap> QgsPointCloudDataProvider::getPointsOnRay( const QVector3D &rayOrigin, const QVector3D &rayDirection, double maxScreenError, double cameraFov, int screenSizePx, double pointAngle )
QVector<QVariantMap> QgsPointCloudDataProvider::getPointsOnRay( const QVector3D &rayOrigin, const QVector3D &rayDirection, double maxScreenError, double cameraFov, int screenSizePx, double pointAngle, int pointsLimit )
{
QVector<QVariantMap> points;
QgsPointCloudIndex *index = this->index();
@@ -425,18 +425,21 @@ QVector<QVariantMap> QgsPointCloudDataProvider::getPointsOnRay( const QVector3D

for ( IndexedPointCloudNode n : nodes )
{
std::unique_ptr<QgsPointCloudBlock> block( index->nodeData( n, request ) );
if ( points.size() >= pointsLimit )
break;

std::unique_ptr<QgsPointCloudBlock> block( index->nodeData( n, request ) );
if ( !block )
continue;

const char *ptr = block->data();
QgsPointCloudAttributeCollection blockAttributes = block->attributes();
const std::size_t recordSize = blockAttributes.pointRecordSize();
int xOffset, yOffset, zOffset;
blockAttributes.find( QStringLiteral( "X" ), xOffset );
blockAttributes.find( QStringLiteral( "Y" ), yOffset );
blockAttributes.find( QStringLiteral( "Z" ), zOffset );
for ( int i = 0; i < block->pointCount(); ++i )
for ( int i = 0; i < block->pointCount() && points.size() < pointsLimit; ++i )
{
double x, y, z;
_pointXY( ptr, i, recordSize, xOffset, yOffset, index->scale(), index->offset(), x, y );
@@ -122,6 +122,8 @@ class CORE_EXPORT QgsPointCloudDataProvider: public QgsDataProvider
% End
#endif

#ifndef SIP_RUN

/**
* Returns the Points that are on a ray
*
@@ -131,11 +133,48 @@ class CORE_EXPORT QgsPointCloudDataProvider: public QgsDataProvider
* \param cameraFov : The field of view of the camera in degrees
* \param screenSizePx : The size of the screen's viewport in pixels
* \param pointAngle : the maximum accepted angle between the point and it's projected point on the ray in degrees
* \param pointsLimit : the maximum number of points returned
* \return a list of the identified points
*
* \since QGIS 3.18
*/
QVector<QVariantMap> getPointsOnRay( const QVector3D &rayOrigin, const QVector3D &rayDirection, double maxScreenError, double cameraFov, int screenSizePx, double pointAngle, int pointsLimit = 1000 );
#else

/**
* Returns the Points that are on a ray
*
* \param rayOrigin : The origin of the ray in layer coordinates
* \param rayDirection : The direction of the ray in layer coordinates
* \param maxScreenError : Maximum screen error (as taken from the 3D point cloud layer renderer)
* \param cameraFov : The field of view of the camera in degrees
* \param screenSizePx : The size of the screen's viewport in pixels
* \param pointAngle : the maximum accepted angle between the point and it's projected point on the ray in degrees
* \param pointsLimit : the maximum number of points returned
* \return a vector of the identified points
*
* \since QGIS 3.18
*/
QVector<QVariantMap> getPointsOnRay( const QVector3D &rayOrigin, const QVector3D &rayDirection, double maxScreenError, double cameraFov, int screenSizePx, double pointAngle ) SIP_SKIP;
SIP_PYLIST getPointsOnRay( const QVector3D &rayOrigin, const QVector3D &rayDirection, double maxScreenError, double cameraFov, int screenSizePx, double pointAngle, int pointsLimit = 1000 );
% MethodCode
{
QVector<QMap<QString, QVariant>> res = sipCpp->identify( *a0, *a1, a2, a3, a4, a5, a6 );
sipRes = PyList_New( res.size() );
for ( int i = 0; i < res.size(); ++i )
{
PyObject *dict = PyDict_New();
for ( QString key : res[i].keys() )
{
PyObject *keyObj = sipConvertFromNewType( new QString( key ), sipType_QString, Py_None );
PyObject *valObj = sipConvertFromNewType( new QVariant( res[i][key] ), sipType_QVariant, Py_None );
PyDict_SetItem( dict, keyObj, valObj );
}
PyList_SET_ITEM( sipRes, i, dict );
}
}
% End
#endif


/**
* Returns flags containing the supported capabilities for the data provider.

0 comments on commit 432f29b

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