24#include <QJsonDocument>
29#include <qstringliteral.h>
58 QStringList lst = str.split(
'-' );
59 if ( lst.count() != 4 )
61 return QgsPointCloudNodeId( lst[0].toInt(), lst[1].toInt(), lst[2].toInt(), lst[3].toInt() );
66 return QStringLiteral(
"%1-%2-%3-%4" ).arg( mD ).arg( mX ).arg( mY ).arg( mZ );
91 return id.d() +
id.x() +
id.y() +
id.z();
103 , mRequest( request )
104 , mFilterExpression( expression )
110 return mNode == other.mNode &&
111 mUri == other.mUri &&
112 mRequest == other.mRequest &&
113 mFilterExpression == other.mFilterExpression;
133 const double dLevel = d / pow( 2,
id.d() );
135 const double xMin = rootBounds.
xMinimum() + dLevel *
id.x();
136 const double xMax = rootBounds.
xMinimum() + dLevel * (
id.x() + 1 );
137 const double yMin = rootBounds.
yMinimum() + dLevel *
id.y();
138 const double yMax = rootBounds.
yMinimum() + dLevel * (
id.y() + 1 );
139 const double zMin = rootBounds.
zMinimum() + dLevel *
id.z();
140 const double zMax = rootBounds.
zMinimum() + dLevel * (
id.z() + 1 );
142 return QgsBox3D( xMin, yMin, zMin, xMax, yMax, zMax );
179 QList<QgsPointCloudNodeId> children;
181 const int d =
id.d() + 1;
182 const int x =
id.x() * 2;
183 const int y =
id.y() * 2;
184 const int z =
id.z() * 2;
186 for (
int i = 0; i < 8; ++i )
188 int dx = i & 1, dy = !!( i & 2 ), dz = !!( i & 4 );
191 children.append( n2 );
260 QMap<QString, QgsPointCloudAttributeStatistics> statsMap;
265 statsMap[
"Z" ].minimum =
mZMin;
266 statsMap[
"Z" ].maximum =
mZMax;
299 return cached ? cached->
clone() :
nullptr;
333 mIndex.reset( index );
336QgsPointCloudIndex::operator bool()
const
338 return mIndex !=
nullptr;
344 mIndex->load( fileName );
349 return mIndex && mIndex->isValid();
354 return mIndex ? mIndex->error() : QStringLiteral(
"Index is NULL" );
360 return mIndex->accessType();
366 return mIndex->crs();
372 return mIndex->pointCount();
378 return mIndex->originalMetadata();
384 return mIndex->metadataStatistics();
390 return mIndex->writeStatistics( stats );
396 return mIndex->root();
402 return mIndex->hasNode(
id );
408 return mIndex->getNode(
id );
414 return mIndex->attributes();
420 return mIndex->nodeData( n, request );
426 return mIndex->asyncNodeData( n, request );
432 return mIndex->updateNodeData( data );
438 return mIndex->extent();
444 return mIndex->zMin();
449 return mIndex->zMax();
455 return mIndex->rootNodeBounds();
461 return mIndex->scale();
467 return mIndex->offset();
473 return mIndex->span();
480 return mIndex->setSubsetString( subset );
486 return mIndex->subsetString();
492 return mIndex->getNodeDataFromCache( node, request );
498 mIndex->storeNodeDataToCache( data, node, request );
504 return mIndex->extraMetadata();
511 return index->commitChanges( errorMessage );
519 return index->isModified();
PointCloudAccessType
The access type of the data, local is for local files and remote for remote files (over HTTP).
Represents a indexed point clouds data in octree.
void setAttributes(const QgsPointCloudAttributeCollection &attributes)
Sets native attributes of the data.
virtual ~QgsAbstractPointCloudIndex()
virtual qint64 pointCount() const =0
Returns the number of points in the point cloud.
QgsPointCloudAttributeCollection mAttributes
QHash< QgsPointCloudNodeId, int > mHierarchy
Data hierarchy.
void copyCommonProperties(QgsAbstractPointCloudIndex *destination) const
Copies common properties to the destination index.
virtual bool writeStatistics(QgsPointCloudStatistics &stats)
Writes the statistics object stats into the backing file, if possible.
QgsBox3D mRootBounds
Bounds of the root node's cube (in int32 coordinates)
virtual bool hasNode(const QgsPointCloudNodeId &n) const
Returns whether the octree contain given node.
virtual QVariantMap extraMetadata() const
Returns extra metadata that's not accessible through the other methods in an implementation-specific ...
static QMutex sBlockCacheMutex
QgsVector3D mOffset
Offset of our int32 coordinates compared to CRS coords.
QgsPointCloudExpression mFilterExpression
The filter expression to be evaluated when fetching node data.
QgsPointCloudAttributeCollection attributes() const
Returns all attributes that are stored in the file.
virtual bool updateNodeData(const QHash< QgsPointCloudNodeId, QByteArray > &data)
Tries to update the data for the specified nodes.
int span() const
Returns the number of points in one direction in a single node.
static QCache< QgsPointCloudCacheKey, QgsPointCloudBlock > sBlockCache
static void storeNodeDataToCacheStatic(QgsPointCloudBlock *data, const QgsPointCloudNodeId &node, const QgsPointCloudRequest &request, const QgsPointCloudExpression &expression, const QString &uri)
Stores existing data to the cache for the specified node, request, expression and uri.
int mSpan
All native attributes stored in the file.
double mZMax
Vertical extent of data.
void storeNodeDataToCache(QgsPointCloudBlock *data, const QgsPointCloudNodeId &node, const QgsPointCloudRequest &request) const
Stores existing data to the cache for the specified node and request.
QgsPointCloudBlock * getNodeDataFromCache(const QgsPointCloudNodeId &node, const QgsPointCloudRequest &request)
Fetches the requested node data from the cache for the specified node and request.
QgsRectangle mExtent
2D extent of data
QgsVector3D scale() const
Returns scale of data relative to CRS.
virtual QgsPointCloudStatistics metadataStatistics() const
Returns the object containing the statistics metadata extracted from the dataset.
QgsVector3D mScale
Scale of our int32 coordinates compared to CRS coords.
QgsAbstractPointCloudIndex()
Constructs index.
virtual QgsPointCloudNode getNode(const QgsPointCloudNodeId &id) const
Returns object for a given node.
QgsVector3D offset() const
Returns offset of data from CRS.
bool setSubsetString(const QString &subset)
Sets the string used to define a subset of the point cloud.
QString subsetString() const
Returns the string used to define a subset of the point cloud.
A 3-dimensional box composed of x, y, z coordinates.
double xMinimum() const
Returns the minimum x value.
double xMaximum() const
Returns the maximum x value.
double width() const
Returns the width of the box.
double zMinimum() const
Returns the minimum z value.
double yMinimum() const
Returns the minimum y value.
This class represents a coordinate reference system (CRS).
Collection of point cloud attributes.
const QgsPointCloudAttribute * find(const QString &attributeName, int &offset) const
Finds the attribute with the name.
Base class for handling loading QgsPointCloudBlock asynchronously.
Base class for storing raw data from point cloud nodes.
int pointCount() const
Returns number of points that are stored in the block.
int pointRecordSize() const
Returns the total size of each individual point record.
QgsPointCloudBlock * clone() const
Clones the QgsPointCloudBlock returning a new copy.
Container class for QgsPointCloudBlock cache keys.
QgsPointCloudExpression filterExpression() const
Returns the key's QgsPointCloudExpression.
QgsPointCloudCacheKey(const QgsPointCloudNodeId &n, const QgsPointCloudRequest &request, const QgsPointCloudExpression &expression, const QString &uri)
Ctor.
QgsPointCloudRequest request() const
Returns the key's QgsPointCloudRequest.
QgsPointCloudNodeId node() const
Returns the key's QgsPointCloudNodeId.
bool operator==(const QgsPointCloudCacheKey &other) const
QString uri() const
Returns the key's uri.
The QgsPointCloudEditingIndex class is a QgsPointCloudIndex that is used as an editing buffer when ed...
int span() const
Returns the number of points in one direction in a single node.
double zMax() const
Returns z max.
bool isModified() const
Returns true if there are uncommitted changes, false otherwise.
bool writeStatistics(QgsPointCloudStatistics &stats)
Writes the statistics object stats into the backing file, if possible.
QgsBox3D rootNodeBounds() const
Returns bounding box of root node in CRS coords.
void storeNodeDataToCache(QgsPointCloudBlock *data, const QgsPointCloudNodeId &node, const QgsPointCloudRequest &request)
Stores existing data to the cache for the specified node and request.
QString error() const
Returns the error that occurred during the loading of the index.
QString subsetString() const
Returns the string used to define a subset of the point cloud.
double zMin() const
Returns z min.
QgsVector3D offset() const
Returns offset of data from CRS.
QgsVector3D scale() const
Returns scale of data relative to CRS.
QgsPointCloudBlockRequest * asyncNodeData(const QgsPointCloudNodeId &n, const QgsPointCloudRequest &request)
Returns a handle responsible for loading a node data block.
bool setSubsetString(const QString &subset)
Sets the string used to define a subset of the point cloud.
bool isValid() const
Returns whether index is loaded and valid.
QgsRectangle extent() const
Returns extent of the data.
QgsCoordinateReferenceSystem crs() const
Returns the coordinate reference system of the point cloud index.
qint64 pointCount() const
Returns the number of points in the point cloud.
QgsPointCloudStatistics metadataStatistics() const
Returns the object containing the statistics metadata extracted from the dataset.
std::unique_ptr< QgsPointCloudBlock > nodeData(const QgsPointCloudNodeId &n, const QgsPointCloudRequest &request)
Returns node data block.
bool commitChanges(QString *errorMessage=nullptr)
Tries to store pending changes to the data provider.
QVariantMap extraMetadata() const
Returns extra metadata that's not accessible through the other methods in an implementation-specific ...
bool updateNodeData(const QHash< QgsPointCloudNodeId, QByteArray > &data)
Tries to update the data for the specified nodes.
QgsPointCloudNodeId root() const
Returns root node of the index.
QgsPointCloudIndex(QgsAbstractPointCloudIndex *index=nullptr)
Construct wrapper, takes ownership of index.
QgsPointCloudNode getNode(const QgsPointCloudNodeId &id) const
Returns object for a given node.
void load(const QString &fileName)
Loads the index from the file.
bool hasNode(const QgsPointCloudNodeId &id) const
Returns whether the octree contain given node.
QgsPointCloudBlock * getNodeDataFromCache(const QgsPointCloudNodeId &node, const QgsPointCloudRequest &request)
Fetches the requested node data from the cache for the specified node and request.
QVariantMap originalMetadata() const
Returns the original metadata map.
QgsPointCloudAttributeCollection attributes() const
Returns all attributes that are stored in the file.
Qgis::PointCloudAccessType accessType() const
Returns the access type of the data If the access type is Remote, data will be fetched from an HTTP s...
Represents a indexed point cloud node's position in octree.
QgsPointCloudNodeId()
Constructs invalid node.
static QgsPointCloudNodeId fromString(const QString &str)
Creates node from string.
QString toString() const
Encode node to string.
QgsPointCloudNodeId parentNode() const
Returns the parent of the node.
Keeps metadata for indexed point cloud node.
float error() const
Returns node's error in map units (used to determine in whether the node has enough detail for the cu...
QgsBox3D bounds() const
Returns node's bounding cube in CRS coords.
Point cloud data request.
Class used to store statistics of a point cloud dataset.
double minimum(const QString &attribute) const
Returns the minimum value for the attribute attribute If no matching statistic is available then NaN ...
A rectangle specified with double values.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
#define QgsDebugMsgLevel(str, level)
uint qHash(QgsPointCloudNodeId id)
Hash function for indexed nodes.