Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Older sip versions DO require custom conversion code!
  • Loading branch information
nyalldawson authored and wonder-sk committed Jan 4, 2021
1 parent e3e8af7 commit 923af4e
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
Expand Up @@ -56,7 +56,8 @@ Ctor

~QgsPointCloudDataProvider();

QVector<QVariantMap> identify( double maxError, const QgsGeometry &extentGeometry, const QgsDoubleRange &extentZRange = QgsDoubleRange(), int pointsLimit = 1000 );

SIP_PYLIST identify( float maxErrorInMapCoords, QgsGeometry extentGeometry, const QgsDoubleRange extentZRange = QgsDoubleRange(), int pointsLimit = 1000 );
%Docstring
Returns the list of points of the point cloud according to a zoom level
defined by ``maxError`` (in layer coordinates), an extent ``geometry`` in the 2D plane
Expand All @@ -70,6 +71,23 @@ the number of points returned to ``pointsLimit`` points
this function does not handle elevation properties and you need to
change elevation coordinates yourself after returning from the function
%End
%MethodCode
{
QVector<QMap<QString, QVariant>> res = sipCpp->identify( a0, *a1, *a2, a3 );
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
Expand Down
34 changes: 34 additions & 0 deletions src/core/pointcloud/qgspointclouddataprovider.h
Expand Up @@ -74,6 +74,8 @@ class CORE_EXPORT QgsPointCloudDataProvider: public QgsDataProvider

~QgsPointCloudDataProvider() override;

#ifndef SIP_RUN

/**
* Returns the list of points of the point cloud according to a zoom level
* defined by \a maxError (in layer coordinates), an extent \a geometry in the 2D plane
Expand All @@ -86,6 +88,38 @@ class CORE_EXPORT QgsPointCloudDataProvider: public QgsDataProvider
* change elevation coordinates yourself after returning from the function
*/
QVector<QVariantMap> identify( double maxError, const QgsGeometry &extentGeometry, const QgsDoubleRange &extentZRange = QgsDoubleRange(), int pointsLimit = 1000 );
#else

/**
* Returns the list of points of the point cloud according to a zoom level
* defined by \a maxError (in layer coordinates), an extent \a geometry in the 2D plane
* and a range \a extentZRange for z values. The function will try to limit
* the number of points returned to \a pointsLimit points
*
* \a maxErrorPixels : maximum accepted error factor in pixels
*
* \note this function does not handle elevation properties and you need to
* change elevation coordinates yourself after returning from the function
*/
SIP_PYLIST identify( float maxErrorInMapCoords, QgsGeometry extentGeometry, const QgsDoubleRange extentZRange = QgsDoubleRange(), int pointsLimit = 1000 );
% MethodCode
{
QVector<QMap<QString, QVariant>> res = sipCpp->identify( a0, *a1, *a2, a3 );
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.
Expand Down

0 comments on commit 923af4e

Please sign in to comment.