Skip to content
Permalink
Browse files

review items

  • Loading branch information
PeterPetrik authored and wonder-sk committed Nov 4, 2020
1 parent 706d579 commit 4dd8f277de92ec3d7e7a523dad22318ab7f72af2
@@ -18,9 +18,11 @@
#include "qgspdaldataitems.h"
#include "qgslogger.h"
#include "qgssettings.h"
#include "qgsfileutils.h"
#include "qgsproviderregistry.h"
#include "qgsprovidermetadata.h"

#include <QFileInfo>
#include <mutex>

QgsPdalLayerItem::QgsPdalLayerItem( QgsDataItem *parent,
const QString &name, const QString &path, const QString &uri )
@@ -40,6 +42,8 @@ QString QgsPdalLayerItem::layerName() const
QgsPdalDataItemProvider::QgsPdalDataItemProvider():
QgsDataItemProvider()
{
QgsProviderMetadata *metadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "pdal" ) );
mFileFilter = metadata->filters( QgsProviderMetadata::FilterType::FilterPointCloud );
}

QString QgsPdalDataItemProvider::name()
@@ -66,8 +70,7 @@ QgsDataItem *QgsPdalDataItemProvider::createDataItem( const QString &path, QgsDa
return nullptr;

// Filter files by extension
// TODO get file filter list from PDAL library
if ( !path.endsWith( QStringLiteral( "laz" ) ) )
if ( !QgsFileUtils::fileMatchesFilter( path, mFileFilter ) )
return nullptr;

const QString name = info.fileName();
@@ -41,6 +41,8 @@ class QgsPdalDataItemProvider : public QgsDataItemProvider
int capabilities() const override;

QgsDataItem *createDataItem( const QString &pathIn, QgsDataItem *parentItem ) override;
private:
QString mFileFilter;
};

#endif // QGSPDALDATAITEMS_H
@@ -79,13 +79,10 @@ bool QgsPdalProvider::load( const QString &uri )
pdal::Option las_opt( "filename", uri.toStdString() );
pdal::Options las_opts;
las_opts.add( las_opt );
pdal::PointTable table;
pdal::LasReader las_reader;
las_reader.setOptions( las_opts );
pdal::PointTable table;
las_reader.prepare( table );
pdal::PointViewSet point_view_set = las_reader.execute( table );
pdal::PointViewPtr point_view = *point_view_set.begin();
pdal::Dimension::IdList dims = point_view->dims();
pdal::LasHeader las_header = las_reader.header();

// extent
@@ -139,6 +136,23 @@ QVariantMap QgsPdalProviderMetadata::decodeUri( const QString &uri )
return uriComponents;
}

QString QgsPdalProviderMetadata::filters( QgsProviderMetadata::FilterType type )
{
switch ( type )
{
case QgsProviderMetadata::FilterType::FilterVector:
case QgsProviderMetadata::FilterType::FilterRaster:
case QgsProviderMetadata::FilterType::FilterMesh:
case QgsProviderMetadata::FilterType::FilterMeshDataset:
return QString();

case QgsProviderMetadata::FilterType::FilterPointCloud:
// TODO get the available/supported filters from PDAL library
return QObject::tr( "PDAL Point Clouds" ) + QStringLiteral( " (*.laz *.las)" );
}
return QString();
}

QString QgsPdalProviderMetadata::encodeUri( const QVariantMap &parts )
{
const QString path = parts.value( QStringLiteral( "path" ) ).toString();
@@ -60,6 +60,7 @@ class QgsPdalProviderMetadata : public QgsProviderMetadata
QList< QgsDataItemProvider * > dataItemProviders() const override;
QString encodeUri( const QVariantMap &parts ) override;
QVariantMap decodeUri( const QString &uri ) override;
QString filters( FilterType type ) override;
};

#endif // QGSPDALPROVIDER_H
@@ -28,7 +28,7 @@ QgsPdalSourceSelect::QgsPdalSourceSelect( QWidget *parent, Qt::WindowFlags fl, Q
setupButtons( buttonBox );

mFileWidget->setDialogTitle( tr( "Open PDAL Supported Point Cloud Dataset(s)" ) );
mFileWidget->setFilter( QgsProviderRegistry::instance()->fileMeshFilters() );
mFileWidget->setFilter( QgsProviderRegistry::instance()->filePointCloudFilters() );
mFileWidget->setStorageMode( QgsFileWidget::GetMultipleFiles );
connect( mFileWidget, &QgsFileWidget::fileChanged, this, [ = ]( const QString & path )
{
@@ -42,13 +42,13 @@ void QgsPdalSourceSelect::addButtonClicked()
if ( mPath.isEmpty() )
{
QMessageBox::information( this,
tr( "Add mesh layer" ),
tr( "Add point cloud layer" ),
tr( "No layers selected." ) );
return;
}

for ( const QString &path : QgsFileWidget::splitFilePaths( mPath ) )
{
emit addMeshLayer( path, QFileInfo( path ).baseName(), QStringLiteral( "mdal" ) );
emit addPointCloudLayer( path, QFileInfo( path ).baseName(), QStringLiteral( "pdal" ) );
}
}

0 comments on commit 4dd8f27

Please sign in to comment.
You can’t perform that action at this time.