Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Point cloud editing: rewrite COPC when committing changes #60133

Merged
merged 5 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ index is memory safe.

operator bool() const;


void load( const QString &fileName );
%Docstring
Loads the index from the file
Expand Down Expand Up @@ -355,9 +356,11 @@ in an implementation-specific dynamic structure.
.. seealso:: :py:func:`QgsAbstractPointCloudIndex.extraMetadata`
%End

bool commitChanges();
bool commitChanges( QString *errorMessage /Out/ = 0 );
%Docstring
Tries to store pending changes to the data provider.
If errorMessage is not a null pointer, it will receive
an error message in case the call failed.

:return: ``True`` on success, otherwise ``False``
%End
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ index is memory safe.

operator bool() const;


void load( const QString &fileName );
%Docstring
Loads the index from the file
Expand Down Expand Up @@ -355,9 +356,11 @@ in an implementation-specific dynamic structure.
.. seealso:: :py:func:`QgsAbstractPointCloudIndex.extraMetadata`
%End

bool commitChanges();
bool commitChanges( QString *errorMessage /Out/ = 0 );
%Docstring
Tries to store pending changes to the data provider.
If errorMessage is not a null pointer, it will receive
an error message in case the call failed.

:return: ``True`` on success, otherwise ``False``
%End
Expand Down
2 changes: 2 additions & 0 deletions src/3d/qgs3dmapscene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,7 @@ void Qgs3DMapScene::addLayerEntity( QgsMapLayer *layer )
QgsPointCloudLayer *pclayer = qobject_cast<QgsPointCloudLayer *>( layer );
connect( pclayer, &QgsPointCloudLayer::renderer3DChanged, this, &Qgs3DMapScene::onLayerRenderer3DChanged );
connect( pclayer, &QgsPointCloudLayer::subsetStringChanged, this, &Qgs3DMapScene::onLayerRenderer3DChanged );
connect( pclayer, &QgsPointCloudLayer::layerModified, this, &Qgs3DMapScene::onLayerRenderer3DChanged );
}
}

Expand Down Expand Up @@ -748,6 +749,7 @@ void Qgs3DMapScene::removeLayerEntity( QgsMapLayer *layer )
QgsPointCloudLayer *pclayer = qobject_cast<QgsPointCloudLayer *>( layer );
disconnect( pclayer, &QgsPointCloudLayer::renderer3DChanged, this, &Qgs3DMapScene::onLayerRenderer3DChanged );
disconnect( pclayer, &QgsPointCloudLayer::subsetStringChanged, this, &Qgs3DMapScene::onLayerRenderer3DChanged );
disconnect( pclayer, &QgsPointCloudLayer::layerModified, this, &Qgs3DMapScene::onLayerRenderer3DChanged );
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2280,6 +2280,7 @@ if (WITH_EPT OR WITH_COPC)
${CMAKE_SOURCE_DIR}/external/lazperf/header.cpp
${CMAKE_SOURCE_DIR}/external/lazperf/lazperf.cpp
${CMAKE_SOURCE_DIR}/external/lazperf/readers.cpp
${CMAKE_SOURCE_DIR}/external/lazperf/writers.cpp
${CMAKE_SOURCE_DIR}/external/lazperf/vlr.cpp
${CMAKE_SOURCE_DIR}/external/lazperf/detail/field_byte10.cpp
${CMAKE_SOURCE_DIR}/external/lazperf/detail/field_byte14.cpp
Expand All @@ -2296,11 +2297,13 @@ if (WITH_EPT OR WITH_COPC)
pointcloud/qgseptdecoder.cpp
pointcloud/qgslazdecoder.cpp
pointcloud/qgslazinfo.cpp
pointcloud/qgscopcupdate.cpp
)
set(QGIS_CORE_HDRS ${QGIS_CORE_HDRS}
pointcloud/qgseptdecoder.h
pointcloud/qgslazdecoder.h
pointcloud/qgslazinfo.h
pointcloud/qgscopcupdate.h
)
endif()

Expand Down
24 changes: 24 additions & 0 deletions src/core/pointcloud/qgscopcpointcloudindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,30 @@ QByteArray QgsCopcPointCloudIndex::fetchCopcStatisticsEvlrData() const
return statisticsEvlrData;
}

void QgsCopcPointCloudIndex::reset()
{
// QgsAbstractPointCloudIndex
mExtent = QgsRectangle();
mZMin = 0;
mZMax = 0;
mHierarchy.clear();
mScale = QgsVector3D();
mOffset = QgsVector3D();
mRootBounds = QgsBox3D();
mAttributes = QgsPointCloudAttributeCollection();
mSpan = 0;
mError.clear();

// QgsCopcPointCloudIndex
mIsValid = false;
mAccessType = Qgis::PointCloudAccessType::Local;
mCopcFile.close();
mOriginalMetadata.clear();
mStatistics.reset();
mLazInfo.reset();
mHierarchyNodePos.clear();
}

QVariantMap QgsCopcPointCloudIndex::extraMetadata() const
{
return
Expand Down
5 changes: 5 additions & 0 deletions src/core/pointcloud/qgscopcpointcloudindex.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ class CORE_EXPORT QgsCopcPointCloudIndex: public QgsAbstractPointCloudIndex

QByteArray fetchCopcStatisticsEvlrData() const;

void reset();

bool mIsValid = false;
Qgis::PointCloudAccessType mAccessType = Qgis::PointCloudAccessType::Local;
mutable std::ifstream mCopcFile;
Expand All @@ -119,6 +121,9 @@ class CORE_EXPORT QgsCopcPointCloudIndex: public QgsAbstractPointCloudIndex
mutable std::optional<QgsPointCloudStatistics> mStatistics;

std::unique_ptr<QgsLazInfo> mLazInfo = nullptr;

friend class QgsPointCloudLayerEditUtils;
friend class QgsPointCloudEditingIndex;
};

///@endcond
Expand Down
Loading
Loading