Skip to content

Commit

Permalink
use dummy QgsPointCloudAttributeCollection with attribute names only if
Browse files Browse the repository at this point in the history
there is no index for a point cloud file
  • Loading branch information
alexbruy committed Apr 6, 2023
1 parent 3dfa397 commit dc77709
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 71 deletions.
Expand Up @@ -96,13 +96,6 @@ Returns flags containing the supported capabilities for the data provider.
%Docstring
Returns the attributes available from this data provider.
May return empty collection until :py:func:`~QgsPointCloudDataProvider.pointCloudIndexLoaded` is emitted
%End

virtual QStringList attributeNames() const = 0;
%Docstring
Returns names of the attributes available from this data provider.

.. versionadded:: 3.32
%End

virtual void loadIndex( ) = 0;
Expand Down
Expand Up @@ -122,13 +122,6 @@ QgsPointCloudLayer cannot be copied.
QgsPointCloudAttributeCollection attributes() const;
%Docstring
Returns the attributes available from the layer.
%End

QStringList attributeNames() const;
%Docstring
Returns the names of the attributes available from the layer.

.. versionadded:: 3.32
%End

qint64 pointCount() const;
Expand Down
7 changes: 0 additions & 7 deletions src/core/pointcloud/qgspointclouddataprovider.h
Expand Up @@ -132,13 +132,6 @@ class CORE_EXPORT QgsPointCloudDataProvider: public QgsDataProvider
*/
virtual QgsPointCloudAttributeCollection attributes() const = 0;

/**
* Returns names of the attributes available from this data provider.
*
* \since QGIS 3.32
*/
virtual QStringList attributeNames() const = 0;

/**
* Triggers loading of the point cloud index
*
Expand Down
7 changes: 0 additions & 7 deletions src/core/pointcloud/qgspointcloudlayer.cpp
Expand Up @@ -726,13 +726,6 @@ QgsPointCloudAttributeCollection QgsPointCloudLayer::attributes() const
return mDataProvider ? mDataProvider->attributes() : QgsPointCloudAttributeCollection();
}

QStringList QgsPointCloudLayer::attributeNames() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS

return mDataProvider ? mDataProvider->attributeNames() : QStringList();
}

qint64 QgsPointCloudLayer::pointCount() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
Expand Down
7 changes: 0 additions & 7 deletions src/core/pointcloud/qgspointcloudlayer.h
Expand Up @@ -162,13 +162,6 @@ class CORE_EXPORT QgsPointCloudLayer : public QgsMapLayer, public QgsAbstractPro
*/
QgsPointCloudAttributeCollection attributes() const;

/**
* Returns the names of the attributes available from the layer.
*
* \since QGIS 3.32
*/
QStringList attributeNames() const;

/**
* Returns the total number of points available in the layer.
*/
Expand Down
13 changes: 0 additions & 13 deletions src/core/providers/copc/qgscopcprovider.cpp
Expand Up @@ -78,19 +78,6 @@ QgsPointCloudAttributeCollection QgsCopcProvider::attributes() const
return mIndex->attributes();
}

QStringList QgsCopcProvider::attributeNames() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS

QStringList attributeNames;
const QVector<QgsPointCloudAttribute> attrs = mIndex->attributes().attributes();
for ( const QgsPointCloudAttribute &a : attrs )
{
attributeNames << a.name();
}
return attributeNames;
}

bool QgsCopcProvider::isValid() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
Expand Down
1 change: 0 additions & 1 deletion src/core/providers/copc/qgscopcprovider.h
Expand Up @@ -43,7 +43,6 @@ class QgsCopcProvider: public QgsPointCloudDataProvider

QgsRectangle extent() const override;
QgsPointCloudAttributeCollection attributes() const override;
QStringList attributeNames() const override;
bool isValid() const override;
QString name() const override;
QString description() const override;
Expand Down
13 changes: 0 additions & 13 deletions src/core/providers/ept/qgseptprovider.cpp
Expand Up @@ -74,19 +74,6 @@ QgsPointCloudAttributeCollection QgsEptProvider::attributes() const
return mIndex->attributes();
}

QStringList QgsEptProvider::attributeNames() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS

QStringList attributeNames;
QVector<QgsPointCloudAttribute> attrs = mIndex->attributes().attributes();
for ( const QgsPointCloudAttribute &a : attrs )
{
attributeNames << a.name();
}
return attributeNames;
}

bool QgsEptProvider::isValid() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS
Expand Down
1 change: 0 additions & 1 deletion src/core/providers/ept/qgseptprovider.h
Expand Up @@ -43,7 +43,6 @@ class QgsEptProvider: public QgsPointCloudDataProvider

QgsRectangle extent() const override;
QgsPointCloudAttributeCollection attributes() const override;
QStringList attributeNames() const override;
bool isValid() const override;
QString name() const override;
QString description() const override;
Expand Down
17 changes: 11 additions & 6 deletions src/providers/pdal/qgspdalprovider.cpp
Expand Up @@ -79,12 +79,17 @@ QgsPointCloudAttributeCollection QgsPdalProvider::attributes() const
{
QGIS_PROTECT_QOBJECT_THREAD_ACCESS

return mIndex ? mIndex->attributes() : QgsPointCloudAttributeCollection();
}
if ( mIndex )
{
return mIndex->attributes();
}

QStringList QgsPdalProvider::attributeNames() const
{
return mAttributeNames;
if ( mDummyAttributes.count() > 0 )
{
return mDummyAttributes;
}

return QgsPointCloudAttributeCollection();
}

static QString _outEptDir( const QString &filename )
Expand Down Expand Up @@ -317,7 +322,7 @@ bool QgsPdalProvider::load( const QString &uri )
// attribute names
for ( auto &dim : quickInfo.m_dimNames )
{
mAttributeNames << QString::fromStdString( dim );
mDummyAttributes.push_back( QgsPointCloudAttribute( QString::fromStdString( dim ), QgsPointCloudAttribute::DataType::Float ) );
}

return quickInfo.valid();
Expand Down
4 changes: 2 additions & 2 deletions src/providers/pdal/qgspdalprovider.h
Expand Up @@ -37,7 +37,6 @@ class QgsPdalProvider: public QgsPointCloudDataProvider
QgsCoordinateReferenceSystem crs() const override;
QgsRectangle extent() const override;
QgsPointCloudAttributeCollection attributes() const override;
QStringList attributeNames() const override;
qint64 pointCount() const override;
QVariantMap originalMetadata() const override;
bool isValid() const override;
Expand All @@ -61,7 +60,8 @@ class QgsPdalProvider: public QgsPointCloudDataProvider
qint64 mPointCount = 0;

QVariantMap mOriginalMetadata;
QStringList mAttributeNames;
// will be used when layer was not indexed, e.g. when loaded by Processing algorithm
QgsPointCloudAttributeCollection mDummyAttributes;
std::unique_ptr<QgsPointCloudIndex> mIndex;
QgsPdalIndexingTask *mRunningIndexingTask = nullptr;
bool mGenerateCopc = true;
Expand Down

0 comments on commit dc77709

Please sign in to comment.