diff --git a/python/PyQt6/core/auto_generated/pointcloud/qgspointclouddataprovider.sip.in b/python/PyQt6/core/auto_generated/pointcloud/qgspointclouddataprovider.sip.in index c1bd9092a6261..ff63d96ddf56b 100644 --- a/python/PyQt6/core/auto_generated/pointcloud/qgspointclouddataprovider.sip.in +++ b/python/PyQt6/core/auto_generated/pointcloud/qgspointclouddataprovider.sip.in @@ -121,6 +121,12 @@ emits :py:func:`~QgsPointCloudDataProvider.indexGenerationStateChanged` Gets the current index generation state %End + virtual QgsPointCloudIndex index() const; +%Docstring +Returns the point cloud index associated with the provider. + +Can be None (e.g. the index is being created) +%End diff --git a/python/core/auto_generated/pointcloud/qgspointclouddataprovider.sip.in b/python/core/auto_generated/pointcloud/qgspointclouddataprovider.sip.in index 4155ab4d36f6a..41323f305b8ab 100644 --- a/python/core/auto_generated/pointcloud/qgspointclouddataprovider.sip.in +++ b/python/core/auto_generated/pointcloud/qgspointclouddataprovider.sip.in @@ -121,6 +121,12 @@ emits :py:func:`~QgsPointCloudDataProvider.indexGenerationStateChanged` Gets the current index generation state %End + virtual QgsPointCloudIndex index() const; +%Docstring +Returns the point cloud index associated with the provider. + +Can be None (e.g. the index is being created) +%End diff --git a/src/core/pointcloud/qgspointclouddataprovider.h b/src/core/pointcloud/qgspointclouddataprovider.h index 05d7a753571a7..5d65f30e6338e 100644 --- a/src/core/pointcloud/qgspointclouddataprovider.h +++ b/src/core/pointcloud/qgspointclouddataprovider.h @@ -154,10 +154,8 @@ class CORE_EXPORT QgsPointCloudDataProvider: public QgsDataProvider * Returns the point cloud index associated with the provider. * * Can be nullptr (e.g. the index is being created) - * - * \note Not available in Python bindings */ - virtual QgsPointCloudIndex index() const SIP_SKIP {return QgsPointCloudIndex( nullptr );} + virtual QgsPointCloudIndex index() const { return QgsPointCloudIndex( nullptr ); } /** * Returns a list of sub indexes available if the provider supports multiple indexes, empty list otherwise. diff --git a/src/core/pointcloud/qgspointcloudindex.h b/src/core/pointcloud/qgspointcloudindex.h index 3ef3272998523..eade94d9f36c2 100644 --- a/src/core/pointcloud/qgspointcloudindex.h +++ b/src/core/pointcloud/qgspointcloudindex.h @@ -407,7 +407,7 @@ class CORE_EXPORT QgsPointCloudIndex SIP_NODEFAULTCTORS { public: //! Construct wrapper, takes ownership of index - explicit QgsPointCloudIndex( QgsAbstractPointCloudIndex *index ) SIP_SKIP; + explicit QgsPointCloudIndex( QgsAbstractPointCloudIndex *index = nullptr ) SIP_SKIP; //! Checks if index is non-null operator bool() const; diff --git a/tests/src/python/CMakeLists.txt b/tests/src/python/CMakeLists.txt index 4990500675fc0..68b726c124680 100644 --- a/tests/src/python/CMakeLists.txt +++ b/tests/src/python/CMakeLists.txt @@ -226,6 +226,7 @@ ADD_PYTHON_TEST(PyQgsPoint test_qgspoint.py) ADD_PYTHON_TEST(PyQgsPointCloudAttributeByRampRenderer test_qgspointcloudattributebyramprenderer.py) ADD_PYTHON_TEST(PyQgsPointCloudAttributeModel test_qgspointcloudattributemodel.py) ADD_PYTHON_TEST(PyQgsPointCloudClassifiedRenderer test_qgspointcloudclassifiedrenderer.py) +ADD_PYTHON_TEST(PyQgsPointCloudIndex test_qgspointcloudindex.py) ADD_PYTHON_TEST(PyQgsPointCloudDataProvider test_qgspointcloudprovider.py) ADD_PYTHON_TEST(PyQgsPointCloudElevationProperties test_qgspointcloudelevationproperties.py) ADD_PYTHON_TEST(PyQgsPointCloudExtentRenderer test_qgspointcloudextentrenderer.py) diff --git a/tests/src/python/test_qgspointcloudindex.py b/tests/src/python/test_qgspointcloudindex.py new file mode 100644 index 0000000000000..3102a63476d81 --- /dev/null +++ b/tests/src/python/test_qgspointcloudindex.py @@ -0,0 +1,57 @@ +""" +*************************************************************************** + test_qgspointcloudindex.py + --------------------- + Date : November 2024 + Copyright : (C) 2024 by David Koňařík + Email : dvdkon at konarici dot cz +*************************************************************************** +* * +* This program is free software; you can redistribute it and/or modify * +* it under the terms of the GNU General Public License as published by * +* the Free Software Foundation; either version 2 of the License, or * +* (at your option) any later version. * +* * +*************************************************************************** +""" + +from qgis.core import ( + Qgis, + QgsPointCloudLayer, + QgsPointCloudNodeId, + QgsProviderRegistry, +) +import unittest +from qgis.testing import start_app, QgisTestCase + +from utilities import unitTestDataPath + +start_app() + + +class TestQgsPointCloudIndex(QgisTestCase): + + @unittest.skipIf( + "ept" not in QgsProviderRegistry.instance().providerList(), + "EPT provider not available", + ) + def testIndex(self): + layer = QgsPointCloudLayer( + unitTestDataPath() + "/point_clouds/ept/sunshine-coast/ept.json", + "test", + "ept", + ) + self.assertTrue(layer.isValid()) + + index = layer.dataProvider().index() + self.assertTrue(bool(index)) + self.assertTrue(index.isValid()) + + self.assertEqual(index.accessType(), Qgis.PointCloudAccessType.Local) + + root = index.getNode(index.root()) + self.assertEqual(root.id(), QgsPointCloudNodeId(0, 0, 0, 0)) + + +if __name__ == "__main__": + unittest.main()