diff --git a/src/core/pointcloud/qgspointcloudlayerprofilegenerator.cpp b/src/core/pointcloud/qgspointcloudlayerprofilegenerator.cpp index 50b894579f96..b5f561253ce4 100644 --- a/src/core/pointcloud/qgspointcloudlayerprofilegenerator.cpp +++ b/src/core/pointcloud/qgspointcloudlayerprofilegenerator.cpp @@ -470,6 +470,10 @@ bool QgsPointCloudLayerProfileGenerator::generateProfile( const QgsProfileGenera } double rootErrorPixels = rootErrorInMapCoordinates / mapUnitsPerPixel; // in pixels const QVector nodes = traverseTree( pc, pc->root(), maximumErrorPixels, rootErrorPixels, context.elevationRange() ); + if ( nodes.empty() ) + { + return false; + } const double rootErrorInLayerCoordinates = rootNodeExtentLayerCoords.width() / pc->span(); const double maxErrorInMapCoordinates = maximumErrorPixels * mapUnitsPerPixel; diff --git a/tests/src/python/test_qgspointcloudlayerprofilegenerator.py b/tests/src/python/test_qgspointcloudlayerprofilegenerator.py index bad06e4ded0b..7dc6b4a7a989 100644 --- a/tests/src/python/test_qgspointcloudlayerprofilegenerator.py +++ b/tests/src/python/test_qgspointcloudlayerprofilegenerator.py @@ -66,9 +66,9 @@ def testProfileGeneration(self): req.setCrs(pcl.crs()) # zero tolerance => no points generator = pcl.createProfileGenerator(req) - self.assertTrue(generator.generateProfile()) + self.assertFalse(generator.generateProfile()) results = generator.takeResults() - self.assertFalse(results.distanceToHeightMap()) + self.assertTrue(results is None) req.setTolerance(0.05) generator = pcl.createProfileGenerator(req)