30using namespace Qt::StringLiterals;
47 mZMin = mIndex.zMin();
48 mZMax = mIndex.zMax();
50 mSpan = mIndex.span();
61 return mIsValid && mIndex.isValid();
66 return mIndex.accessType();
76 return mIndex.pointCount();
81 return mIndex.originalMetadata();
86 return mIndex.hasNode( n );
91 return mIndex.getNode(
id );
96 return mIndex.setSubsetString( subset );
101 return mIndex.subsetString();
106 mEditedNodeDataMutex.lock();
107 if ( mEditedNodeData.contains( n ) )
114 requestAttributes.
extend(
attributes(), filterExpression.referencedAttributes() );
118 QByteArray rawBlockData = mEditedNodeData[n];
119 mEditedNodeDataMutex.unlock();
121 QgsCopcPointCloudIndex *copcIndex =
static_cast<QgsCopcPointCloudIndex *
>( mIndex.get() );
123 int pointCount = copcIndex->mHierarchy.value( n );
125 return QgsLazDecoder::decompressCopc( rawBlockData, *copcIndex->mLazInfo.get(),
pointCount, requestAttributes, filterExpression, filterRect );
129 mEditedNodeDataMutex.unlock();
130 return mIndex.nodeData( n, request );
147 QMutexLocker locker( &mEditedNodeDataMutex );
149 return mEditedNodeData.value( n );
154 QMutexLocker locker( &mEditedNodeDataMutex );
156 mEditedNodeData.remove( n );
161 QMutexLocker locker( &mEditedNodeDataMutex );
163 if ( mEditedNodeData.isEmpty() )
166 QHash<QgsPointCloudNodeId, QgsCopcUpdate::UpdatedChunk> updatedChunks;
167 for (
auto it = mEditedNodeData.constBegin(); it != mEditedNodeData.constEnd(); ++it )
175 QFileInfo fileInfo(
mUri );
176 const QString outputFilename = fileInfo.dir().filePath( fileInfo.baseName() + u
"-update.copc.laz"_s );
184 QgsCopcPointCloudIndex *copcIndex =
static_cast<QgsCopcPointCloudIndex *
>( mIndex.get() );
187 const QString originalFilename = fileInfo.dir().filePath( fileInfo.baseName() + u
"-original.copc.laz"_s );
188 if ( !QFile::rename(
mUri, originalFilename ) )
191 *errorMessage = u
"Rename of the old COPC failed!"_s;
192 QFile::remove( outputFilename );
196 if ( !QFile::rename( outputFilename,
mUri ) )
199 *errorMessage = u
"Rename of the new COPC failed!"_s;
200 QFile::rename( originalFilename,
mUri );
201 QFile::remove( outputFilename );
205 if ( !QFile::remove( originalFilename ) )
208 *errorMessage = u
"Removal of the old COPC failed!"_s;
213 mEditedNodeData.clear();
216 copcIndex->load(
mUri );
223 QMutexLocker locker( &mEditedNodeDataMutex );
225 return !mEditedNodeData.isEmpty();
230 QMutexLocker locker( &mEditedNodeDataMutex );
232 return mEditedNodeData.contains( n );
237 QMutexLocker locker( &mEditedNodeDataMutex );
239 return mEditedNodeData.keys();
244 QMutexLocker locker( &mEditedNodeDataMutex );
246 for (
auto it = data.constBegin(); it != data.constEnd(); ++it )
248 mEditedNodeData[it.key()] = it.value();
254 const QList<QgsPointCloudCacheKey> cacheKeys =
sBlockCache.keys();
PointCloudAccessType
The access type of the data, local is for local files and remote for remote files (over HTTP).
QgsPointCloudAttributeCollection mAttributes
QgsBox3D mRootBounds
Bounds of the root node's cube (in int32 coordinates).
static QMutex sBlockCacheMutex
QgsVector3D mOffset
Offset of our int32 coordinates compared to CRS coords.
QgsPointCloudAttributeCollection attributes() const
Returns all attributes that are stored in the file.
static QCache< QgsPointCloudCacheKey, QgsPointCloudBlock > sBlockCache
int mSpan
All native attributes stored in the file.
double mZMax
Vertical extent of data.
QgsRectangle mExtent
2D extent of data
QgsVector3D mScale
Scale of our int32 coordinates compared to CRS coords.
Represents a coordinate reference system (CRS).
static bool writeUpdatedFile(const QString &inputFilename, const QString &outputFilename, const QHash< QgsPointCloudNodeId, UpdatedChunk > &updatedChunks, QString *errorMessage=nullptr)
Convenience function to do the whole process in one go: load a COPC file, then write a new COPC file ...
QString source() const
Returns the source for the layer.
A collection of point cloud attributes.
void extend(const QgsPointCloudAttributeCollection &otherCollection, const QSet< QString > &matchingNames)
Adds specific missing attributes from another QgsPointCloudAttributeCollection.
Base class for handling loading QgsPointCloudBlock asynchronously.
Container class for QgsPointCloudBlock cache keys.
@ ChangeAttributeValues
Provider can modify the values of point attributes.
virtual QgsPointCloudIndex index() const
Returns the point cloud index associated with the provider.
virtual QgsPointCloudDataProvider::Capabilities capabilities() const
Returns flags containing the supported capabilities for the data provider.
bool hasValidIndex() const
Returns whether provider has index which is valid.
QList< QgsPointCloudNodeId > updatedNodes() const
Returns a list of node IDs that have been modified.
bool hasNode(const QgsPointCloudNodeId &n) const override
Returns whether the octree contain given node.
void load(const QString &fileName, const QString &authcfg=QString()) override
Loads the index from the uri, using an optional authcfg for network requests.
bool isModified() const
Returns true if there are uncommitted changes, false otherwise.
QgsPointCloudIndex backingIndex() const
Returns index for the underlying non-edited data.
QVariantMap originalMetadata() const override
Returns the original metadata map.
qint64 pointCount() const override
Returns the number of points in the point cloud.
bool commitChanges(QString *errorMessage=nullptr)
Tries to store pending changes to the data provider.
bool setSubsetString(const QString &subset) override
Sets the string used to define a subset of the point cloud.
void resetNodeEdits(QgsPointCloudNodeId n)
Removes node edits from index, returning it to its original state.
const QByteArray rawEditedNodeData(QgsPointCloudNodeId n) const
Returns the raw, encoded, compressed data for a node or empty if missing.
QgsPointCloudBlockRequest * asyncNodeData(const QgsPointCloudNodeId &n, const QgsPointCloudRequest &request) override
Returns a handle responsible for loading a node data block.
QgsPointCloudEditingIndex(QgsPointCloudLayer *layer)
Ctor.
bool isNodeModified(QgsPointCloudNodeId n) const
Returns true if this node was modified.
QString subsetString() const override
Returns the string used to define a subset of the point cloud.
bool isValid() const override
Returns whether index is loaded and valid.
std::unique_ptr< QgsPointCloudBlock > nodeData(const QgsPointCloudNodeId &n, const QgsPointCloudRequest &request) override
Returns node data block.
QgsPointCloudNode getNode(const QgsPointCloudNodeId &id) const override
Returns object for a given node.
Qgis::PointCloudAccessType accessType() const override
Returns the access type of the data If the access type is Remote, data will be fetched from an HTTP s...
bool updateNodeData(const QHash< QgsPointCloudNodeId, QByteArray > &data) override
Tries to update the data for the specified nodes.
QgsCoordinateReferenceSystem crs() const override
Returns the coordinate reference system of the point cloud index.
Smart pointer for QgsAbstractPointCloudIndex.
Represents a map layer supporting display of point clouds.
QgsPointCloudDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
Represents an indexed point cloud node's position in octree.
Keeps metadata for an indexed point cloud node.
qint64 pointCount() const
Returns number of points contained in node data.
Point cloud data request.
bool ignoreIndexFilterEnabled() const
Returns whether the request will ignore the point cloud index's filter expression,...
QgsPointCloudAttributeCollection attributes() const
Returns attributes.
QgsRectangle filterRect() const
Returns the rectangle from which points will be taken, in point cloud's crs.
A rectangle specified with double values.
const QString cacheKey(const QString &pathIn)
Keeps information how points of a single chunk has been modified.