33#include <QtConcurrent/QtConcurrentMap>
41 : mIndex( index->clone().release() ), mRequest( request ), mFeedback( feedback ), mProgressValue( progressValue )
46 : mIndex( processor.mIndex->clone().release() ), mRequest( processor.mRequest ), mFeedback( processor.mFeedback ), mProgressValue( processor.mProgressValue )
52 mIndex.reset( rhs.mIndex->clone().release() );
53 mRequest = rhs.mRequest;
54 mFeedback = rhs.mFeedback;
55 mProgressValue = rhs.mProgressValue;
61 if ( mIndex->nodePointCount( node ) < 1 )
64 std::unique_ptr<QgsPointCloudBlock> block =
nullptr;
67 block = mIndex->nodeData( node, mRequest );
93 const QVector<QgsPointCloudAttribute> attributes = attributesCollection.
attributes();
94 const char *ptr = block->data();
95 int count = block->pointCount();
98 QMap<QString, QgsPointCloudAttributeStatistics> statsMap;
102 summary.
minimum = std::numeric_limits<double>::max();
103 summary.
maximum = std::numeric_limits<double>::lowest();
106 summary.
stDev = std::numeric_limits<double>::quiet_NaN();
108 statsMap[ attribute.name() ] = summary;
111 QVector<int> attributeOffsetVector;
112 QSet<int> classifiableAttributesOffsetSet;
115 int attributeOffset = 0;
116 attributesCollection.
find( attribute.name(), attributeOffset );
117 attributeOffsetVector.push_back( attributeOffset );
118 if ( attribute.name() == QLatin1String(
"ScannerChannel" ) ||
119 attribute.name() == QLatin1String(
"ReturnNumber" ) ||
120 attribute.name() == QLatin1String(
"NumberOfReturns" ) ||
121 attribute.name() == QLatin1String(
"ScanDirectionFlag" ) ||
122 attribute.name() == QLatin1String(
"Classification" ) ||
123 attribute.name() == QLatin1String(
"EdgeOfFlightLine" ) ||
124 attribute.name() == QLatin1String(
"PointSourceId" ) ||
125 attribute.name() == QLatin1String(
"Synthetic" ) ||
126 attribute.name() == QLatin1String(
"KeyPoint" ) ||
127 attribute.name() == QLatin1String(
"Withheld" ) ||
128 attribute.name() == QLatin1String(
"Overlap" ) )
130 classifiableAttributesOffsetSet.insert( attributeOffset );
134 for (
int i = 0; i < count; ++i )
136 for (
int j = 0; j < attributes.size(); ++j )
142 QString attributeName = attributes.at( j ).name();
145 double attributeValue = 0;
146 int attributeOffset = attributeOffsetVector[ j ];
152 stats.
mean += attributeValue / count;
155 if ( classifiableAttributesOffsetSet.contains( attributeOffset ) )
165 std::unique_ptr<QgsPointCloudIndex> mIndex =
nullptr;
168 double mProgressValue = 0.0;
170 void updateFeedback()
180 : mIndex( index->clone() )
187 if ( !mIndex->isValid() )
194 qint64 pointCount = 0;
195 QVector<IndexedPointCloudNode> nodes;
196 QQueue<IndexedPointCloudNode> queue;
197 queue.push_back( mIndex->root() );
198 while ( !queue.empty() )
202 if ( !mProcessedNodes.contains( node ) )
203 pointCount += mIndex->nodePointCount( node );
204 if ( pointsLimit != -1 && pointCount > pointsLimit )
206 if ( !mProcessedNodes.contains( node ) )
208 nodes.push_back( node );
209 mProcessedNodes.insert( node );
213 queue.push_back( child );
219 QVector<QgsPointCloudStatistics> list = QtConcurrent::blockingMapped( nodes,
StatsProcessor( mIndex.get(), mRequest, feedback, 100.0 / (
double )nodes.size() ) );
Represents a indexed point cloud node in octree.
QString toString() const
Encode node to string.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
bool isCanceled() const
Tells whether the operation has been canceled already.
void canceled()
Internal routines can connect to this signal if they use event loop.
void setProgress(double progress)
Sets the current progress for the feedback object.
double progress() const
Returns the current progress reported by the feedback object.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
Collection of point cloud attributes.
int pointRecordSize() const
Returns total size of record.
const QgsPointCloudAttribute * find(const QString &attributeName, int &offset) const
Finds the attribute with the name.
QVector< QgsPointCloudAttribute > attributes() const
Returns all attributes.
Attribute for point cloud data pair of name and size in bytes.
DataType
Systems of unit measurement.
Base class for handling loading QgsPointCloudBlock asynchronously.
QString errorStr()
Returns the error message string of the request.
void finished()
Emitted when the request processing has finished.
std::unique_ptr< QgsPointCloudBlock > takeBlock()
Returns the requested block.
Represents a indexed point clouds data in octree.
@ Local
Local means the source is a local file on the machine.
static void getAttribute(const char *data, std::size_t offset, QgsPointCloudAttribute::DataType type, T &value)
Retrieves the attribute value from data at the specified offset, where type indicates the original da...
Point cloud data request.
void setAttributes(const QgsPointCloudAttributeCollection &attributes)
Set attributes filter in the request.
Class used to store statistics of a point cloud dataset.
void combineWith(const QgsPointCloudStatistics &stats)
Merges the current statistics with the statistics from stats.
int sampledPointsCount() const
Returns the number of points used to calculate the statistics.
QgsPointCloudStatsCalculator(QgsPointCloudIndex *index)
Constructor.
bool calculateStats(QgsFeedback *feedback, const QVector< QgsPointCloudAttribute > &attributes, qint64 pointsLimit=-1)
Calculates the statistics of given attributes attributes up to new pointsLimit points Note: the alrea...
Class used to store statistics of one attribute of a point cloud dataset.
QMap< int, int > classCount
StatsProcessor(QgsPointCloudIndex *index, QgsPointCloudRequest request, QgsFeedback *feedback, double progressValue)
static QMutex sStatsProcessorFeedbackMutex
StatsProcessor(const StatsProcessor &processor)
QgsPointCloudStatistics result_type
StatsProcessor & operator=(const StatsProcessor &rhs)
QgsPointCloudStatistics operator()(IndexedPointCloudNode node)