Skip to content

Commit

Permalink
Merge pull request #52959 from alexbruy/pdal-provider-ux
Browse files Browse the repository at this point in the history
UX improvements for PDAL provider
  • Loading branch information
alexbruy committed May 2, 2023
2 parents 7fac476 + cbc6922 commit 3ab7530
Show file tree
Hide file tree
Showing 23 changed files with 330 additions and 107 deletions.
13 changes: 13 additions & 0 deletions python/plugins/processing/gui/Postprocessing.py
Expand Up @@ -91,6 +91,19 @@ def handleAlgorithmResults(alg, context, feedback=None, showResults=True, parame
if style:
layer.loadNamedStyle(style)

try:
from qgis._3d import QgsPointCloudLayer3DRenderer
if layer.type() == QgsMapLayerType.PointCloudLayer:
if layer.renderer3D() is None:
# If the layer has no 3D renderer and syncing 3D to 2D renderer is enabled,
# we create a renderer and set it up with the 2D renderer
if layer.sync3DRendererTo2DRenderer():
renderer3D = QgsPointCloudLayer3DRenderer()
renderer3D.convertFrom2DRenderer(layer.renderer())
layer.setRenderer3D(renderer3D)
except ImportError as e:
QgsMessageLog.logMessage(QCoreApplication.translate("Postprocessing", "3D library is not available, can't assign a 3d renderer to a layer."))

# Load layer to layer tree root or to a specific group
mapLayer = context.temporaryLayerStore().takeMapLayer(layer)
group_name = ProcessingConfig.getSetting(ProcessingConfig.RESULTS_GROUP_NAME)
Expand Down
5 changes: 3 additions & 2 deletions src/analysis/CMakeLists.txt
Expand Up @@ -423,6 +423,7 @@ if (WITH_PDAL AND PDAL_2_5_OR_HIGHER)

processing/pdal/qgspdalalgorithmbase.cpp

processing/pdal/qgsalgorithmpdalassignprojection.cpp
processing/pdal/qgsalgorithmpdalboundary.cpp
processing/pdal/qgsalgorithmpdalbuildvpc.cpp
processing/pdal/qgsalgorithmpdalclip.cpp
Expand All @@ -432,12 +433,12 @@ if (WITH_PDAL AND PDAL_2_5_OR_HIGHER)
processing/pdal/qgsalgorithmpdalexportrastertin.cpp
processing/pdal/qgsalgorithmpdalexportvector.cpp
processing/pdal/qgsalgorithmpdalfilter.cpp
processing/pdal/qgsalgorithmpdalfixprojection.cpp
processing/pdal/qgsalgorithmpdalinformation.cpp
processing/pdal/qgsalgorithmpdalmerge.cpp
processing/pdal/qgsalgorithmpdalreproject.cpp
processing/pdal/qgsalgorithmpdalthinbydecimate.cpp
processing/pdal/qgsalgorithmpdalthinbyradius.cpp
processing/pdal/qgsalgorithmpdaltile.cpp
processing/pdal/qgsalgorithmpdalthin.cpp
)

set(QGIS_ANALYSIS_HDRS ${QGIS_ANALYSIS_HDRS}
Expand Down
@@ -1,5 +1,5 @@
/***************************************************************************
qgsalgorithmpdalfixprojection.cpp
qgsalgorithmpdalassignprojection.cpp
---------------------
begin : February 2023
copyright : (C) 2023 by Alexander Bruy
Expand All @@ -15,56 +15,56 @@
* *
***************************************************************************/

#include "qgsalgorithmpdalfixprojection.h"
#include "qgsalgorithmpdalassignprojection.h"

#include "qgsrunprocess.h"
#include "qgspointcloudlayer.h"

///@cond PRIVATE

QString QgsPdalFixProjectionAlgorithm::name() const
QString QgsPdalAssignProjectionAlgorithm::name() const
{
return QStringLiteral( "fixprojection" );
return QStringLiteral( "assignprojection" );
}

QString QgsPdalFixProjectionAlgorithm::displayName() const
QString QgsPdalAssignProjectionAlgorithm::displayName() const
{
return QObject::tr( "Fix projection" );
return QObject::tr( "Assign projection" );
}

QString QgsPdalFixProjectionAlgorithm::group() const
QString QgsPdalAssignProjectionAlgorithm::group() const
{
return QObject::tr( "Point cloud data management" );
}

QString QgsPdalFixProjectionAlgorithm::groupId() const
QString QgsPdalAssignProjectionAlgorithm::groupId() const
{
return QStringLiteral( "pointclouddatamanagement" );
}

QStringList QgsPdalFixProjectionAlgorithm::tags() const
QStringList QgsPdalAssignProjectionAlgorithm::tags() const
{
return QObject::tr( "assign,set,fix,crs,srs" ).split( ',' );
return QObject::tr( "pdal,lidar,assign,set,fix,crs,srs" ).split( ',' );
}

QString QgsPdalFixProjectionAlgorithm::shortHelpString() const
QString QgsPdalAssignProjectionAlgorithm::shortHelpString() const
{
return QObject::tr( "This algorithm fixes (assigns) point cloud CRS if it is not present or wrong." );
return QObject::tr( "This algorithm assigns point cloud CRS if it is not present or wrong." );
}

QgsPdalFixProjectionAlgorithm *QgsPdalFixProjectionAlgorithm::createInstance() const
QgsPdalAssignProjectionAlgorithm *QgsPdalAssignProjectionAlgorithm::createInstance() const
{
return new QgsPdalFixProjectionAlgorithm();
return new QgsPdalAssignProjectionAlgorithm();
}

void QgsPdalFixProjectionAlgorithm::initAlgorithm( const QVariantMap & )
void QgsPdalAssignProjectionAlgorithm::initAlgorithm( const QVariantMap & )
{
addParameter( new QgsProcessingParameterPointCloudLayer( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ) ) );
addParameter( new QgsProcessingParameterCrs( QStringLiteral( "CRS" ), QObject::tr( "Desired CRS" ), QStringLiteral( "EPSG:4326" ) ) );
addParameter( new QgsProcessingParameterPointCloudDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Output layer" ) ) );
}

QStringList QgsPdalFixProjectionAlgorithm::createArgumentLists( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
QStringList QgsPdalAssignProjectionAlgorithm::createArgumentLists( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
{
Q_UNUSED( feedback );

Expand Down
54 changes: 54 additions & 0 deletions src/analysis/processing/pdal/qgsalgorithmpdalassignprojection.h
@@ -0,0 +1,54 @@
/***************************************************************************
qgsalgorithmpdalassignprojection.h
---------------------
begin : February 2023
copyright : (C) 2023 by Alexander Bruy
email : alexander dot bruy at gmail dot com
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

#ifndef QGSALGORITHMPDALASSIGNPROJECTION_H
#define QGSALGORITHMPDALASSIGNPROJECTION_H

#define SIP_NO_FILE

#include "qgis_sip.h"
#include "qgspdalalgorithmbase.h"

///@cond PRIVATE

/**
* Native assign projection algorithm for point clouds.
*/
class QgsPdalAssignProjectionAlgorithm : public QgsPdalAlgorithmBase
{

public:

QgsPdalAssignProjectionAlgorithm() = default;
void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
QString name() const override;
QString displayName() const override;
QString group() const override;
QString groupId() const override;
QStringList tags() const override;
QString shortHelpString() const override;
QgsPdalAssignProjectionAlgorithm *createInstance() const override SIP_FACTORY;

QStringList createArgumentLists( const QVariantMap &parameters,
QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;

friend class TestQgsProcessingPdalAlgs;
};

///@endcond PRIVATE

#endif // QGSALGORITHMPDALASSIGNPROJECTION_H
2 changes: 1 addition & 1 deletion src/analysis/processing/pdal/qgsalgorithmpdalboundary.cpp
Expand Up @@ -44,7 +44,7 @@ QString QgsPdalBoundaryAlgorithm::groupId() const

QStringList QgsPdalBoundaryAlgorithm::tags() const
{
return QObject::tr( "extent,envelope,bounds,bounding,boundary,vector" ).split( ',' );
return QObject::tr( "pdal,lidar,extent,envelope,bounds,bounding,boundary,vector" ).split( ',' );
}

QString QgsPdalBoundaryAlgorithm::shortHelpString() const
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/processing/pdal/qgsalgorithmpdalbuildvpc.cpp
Expand Up @@ -44,7 +44,7 @@ QString QgsPdalBuildVpcAlgorithm::groupId() const

QStringList QgsPdalBuildVpcAlgorithm::tags() const
{
return QObject::tr( "collect,merge,combine,point cloud,virtual,vpc" ).split( ',' );
return QObject::tr( "collect,merge,combine,pdal,lidar,virtual,vpc" ).split( ',' );
}

QString QgsPdalBuildVpcAlgorithm::shortHelpString() const
Expand All @@ -63,7 +63,7 @@ void QgsPdalBuildVpcAlgorithm::initAlgorithm( const QVariantMap & )
addParameter( new QgsProcessingParameterBoolean( QStringLiteral( "BOUNDARY" ), QObject::tr( "Calculate boundary polygons" ), false ) );
addParameter( new QgsProcessingParameterBoolean( QStringLiteral( "STATISTICS" ), QObject::tr( "Calculate statistics" ), false ) );
addParameter( new QgsProcessingParameterBoolean( QStringLiteral( "OVERVIEW" ), QObject::tr( "Build overview point cloud" ), false ) );
addParameter( new QgsProcessingParameterPointCloudDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Virtual point cloud file" ) ) );
addParameter( new QgsProcessingParameterPointCloudDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Virtual point cloud" ) ) );
}

QStringList QgsPdalBuildVpcAlgorithm::createArgumentLists( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/processing/pdal/qgsalgorithmpdalclip.cpp
Expand Up @@ -45,7 +45,7 @@ QString QgsPdalClipAlgorithm::groupId() const

QStringList QgsPdalClipAlgorithm::tags() const
{
return QObject::tr( "clip,intersect,intersection,mask" ).split( ',' );
return QObject::tr( "pdal,lidar,clip,intersect,intersection,mask" ).split( ',' );
}

QString QgsPdalClipAlgorithm::shortHelpString() const
Expand All @@ -63,7 +63,7 @@ void QgsPdalClipAlgorithm::initAlgorithm( const QVariantMap & )
addParameter( new QgsProcessingParameterPointCloudLayer( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ) ) );
addParameter( new QgsProcessingParameterVectorLayer( QStringLiteral( "OVERLAY" ), QObject::tr( "Clipping polygons" ), QList< int >() << QgsProcessing::TypeVectorPolygon ) );
createCommonParameters();
addParameter( new QgsProcessingParameterPointCloudDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Clipped point cloud" ) ) );
addParameter( new QgsProcessingParameterPointCloudDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Clipped" ) ) );
}

QStringList QgsPdalClipAlgorithm::createArgumentLists( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
Expand Down
Expand Up @@ -44,7 +44,7 @@ QString QgsPdalConvertFormatAlgorithm::groupId() const

QStringList QgsPdalConvertFormatAlgorithm::tags() const
{
return QObject::tr( "point cloud,las,laz,format,convert,translate" ).split( ',' );
return QObject::tr( "pdal,lidar,las,laz,format,convert,translate" ).split( ',' );
}

QString QgsPdalConvertFormatAlgorithm::shortHelpString() const
Expand All @@ -60,7 +60,7 @@ QgsPdalConvertFormatAlgorithm *QgsPdalConvertFormatAlgorithm::createInstance() c
void QgsPdalConvertFormatAlgorithm::initAlgorithm( const QVariantMap & )
{
addParameter( new QgsProcessingParameterPointCloudLayer( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ) ) );
addParameter( new QgsProcessingParameterPointCloudDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Output layer" ) ) );
addParameter( new QgsProcessingParameterPointCloudDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Converted" ) ) );
}

QStringList QgsPdalConvertFormatAlgorithm::createArgumentLists( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
Expand Down
8 changes: 4 additions & 4 deletions src/analysis/processing/pdal/qgsalgorithmpdaldensity.cpp
Expand Up @@ -44,7 +44,7 @@ QString QgsPdalDensityAlgorithm::groupId() const

QStringList QgsPdalDensityAlgorithm::tags() const
{
return QObject::tr( "cell,count,density,raster" ).split( ',' );
return QObject::tr( "pdal,lidar,cell,count,density,raster" ).split( ',' );
}

QString QgsPdalDensityAlgorithm::shortHelpString() const
Expand All @@ -63,16 +63,16 @@ void QgsPdalDensityAlgorithm::initAlgorithm( const QVariantMap & )
addParameter( new QgsProcessingParameterNumber( QStringLiteral( "RESOLUTION" ), QObject::tr( "Resolution of the density raster" ), QgsProcessingParameterNumber::Integer, 1, false, 1 ) );
addParameter( new QgsProcessingParameterNumber( QStringLiteral( "TILE_SIZE" ), QObject::tr( "Tile size for parallel runs" ), QgsProcessingParameterNumber::Integer, 1000, false, 1 ) );

createCommonParameters();

std::unique_ptr< QgsProcessingParameterNumber > paramOriginX = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral( "ORIGIN_X" ), QObject::tr( "X origin of a tile for parallel runs" ), QgsProcessingParameterNumber::Double, QVariant(), true, 0 );
paramOriginX->setFlags( paramOriginX->flags() | QgsProcessingParameterDefinition::FlagAdvanced );
addParameter( paramOriginX.release() );
std::unique_ptr< QgsProcessingParameterNumber > paramOriginY = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral( "ORIGIN_Y" ), QObject::tr( "Y origin of a tile for parallel runs" ), QgsProcessingParameterNumber::Integer, QVariant(), true, 0 );
paramOriginY->setFlags( paramOriginY->flags() | QgsProcessingParameterDefinition::FlagAdvanced );
addParameter( paramOriginY.release() );

createCommonParameters();

addParameter( new QgsProcessingParameterRasterDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Density raster" ) ) );
addParameter( new QgsProcessingParameterRasterDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Density" ) ) );
}

QStringList QgsPdalDensityAlgorithm::createArgumentLists( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
Expand Down
8 changes: 4 additions & 4 deletions src/analysis/processing/pdal/qgsalgorithmpdalexportraster.cpp
Expand Up @@ -44,7 +44,7 @@ QString QgsPdalExportRasterAlgorithm::groupId() const

QStringList QgsPdalExportRasterAlgorithm::tags() const
{
return QObject::tr( "export,raster,attribute,create" ).split( ',' );
return QObject::tr( "pdal,lidar,dem,export,raster,attribute,create" ).split( ',' );
}

QString QgsPdalExportRasterAlgorithm::shortHelpString() const
Expand All @@ -64,16 +64,16 @@ void QgsPdalExportRasterAlgorithm::initAlgorithm( const QVariantMap & )
addParameter( new QgsProcessingParameterNumber( QStringLiteral( "RESOLUTION" ), QObject::tr( "Resolution of the density raster" ), QgsProcessingParameterNumber::Integer, 1, false, 1 ) );
addParameter( new QgsProcessingParameterNumber( QStringLiteral( "TILE_SIZE" ), QObject::tr( "Tile size for parallel runs" ), QgsProcessingParameterNumber::Integer, 1000, false, 1 ) );

createCommonParameters();

std::unique_ptr< QgsProcessingParameterNumber > paramOriginX = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral( "ORIGIN_X" ), QObject::tr( "X origin of a tile for parallel runs" ), QgsProcessingParameterNumber::Double, QVariant(), true, 0 );
paramOriginX->setFlags( paramOriginX->flags() | QgsProcessingParameterDefinition::FlagAdvanced );
addParameter( paramOriginX.release() );
std::unique_ptr< QgsProcessingParameterNumber > paramOriginY = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral( "ORIGIN_Y" ), QObject::tr( "Y origin of a tile for parallel runs" ), QgsProcessingParameterNumber::Integer, QVariant(), true, 0 );
paramOriginY->setFlags( paramOriginY->flags() | QgsProcessingParameterDefinition::FlagAdvanced );
addParameter( paramOriginY.release() );

createCommonParameters();

addParameter( new QgsProcessingParameterRasterDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Output raster" ) ) );
addParameter( new QgsProcessingParameterRasterDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Exported" ) ) );
}

QStringList QgsPdalExportRasterAlgorithm::createArgumentLists( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
Expand Down
10 changes: 5 additions & 5 deletions src/analysis/processing/pdal/qgsalgorithmpdalexportrastertin.cpp
Expand Up @@ -29,7 +29,7 @@ QString QgsPdalExportRasterTinAlgorithm::name() const

QString QgsPdalExportRasterTinAlgorithm::displayName() const
{
return QObject::tr( "Export to raster (TIN)" );
return QObject::tr( "Export to raster (using triangulation)" );
}

QString QgsPdalExportRasterTinAlgorithm::group() const
Expand All @@ -44,7 +44,7 @@ QString QgsPdalExportRasterTinAlgorithm::groupId() const

QStringList QgsPdalExportRasterTinAlgorithm::tags() const
{
return QObject::tr( "export,raster,tin,create" ).split( ',' );
return QObject::tr( "pdal,lidar,dem,export,raster,tin,create" ).split( ',' );
}

QString QgsPdalExportRasterTinAlgorithm::shortHelpString() const
Expand All @@ -63,16 +63,16 @@ void QgsPdalExportRasterTinAlgorithm::initAlgorithm( const QVariantMap & )
addParameter( new QgsProcessingParameterNumber( QStringLiteral( "RESOLUTION" ), QObject::tr( "Resolution of the density raster" ), QgsProcessingParameterNumber::Integer, 1, false, 1 ) );
addParameter( new QgsProcessingParameterNumber( QStringLiteral( "TILE_SIZE" ), QObject::tr( "Tile size for parallel runs" ), QgsProcessingParameterNumber::Integer, 1000, false, 1 ) );

createCommonParameters();

std::unique_ptr< QgsProcessingParameterNumber > paramOriginX = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral( "ORIGIN_X" ), QObject::tr( "X origin of a tile for parallel runs" ), QgsProcessingParameterNumber::Double, QVariant(), true, 0 );
paramOriginX->setFlags( paramOriginX->flags() | QgsProcessingParameterDefinition::FlagAdvanced );
addParameter( paramOriginX.release() );
std::unique_ptr< QgsProcessingParameterNumber > paramOriginY = std::make_unique< QgsProcessingParameterNumber >( QStringLiteral( "ORIGIN_Y" ), QObject::tr( "Y origin of a tile for parallel runs" ), QgsProcessingParameterNumber::Integer, QVariant(), true, 0 );
paramOriginY->setFlags( paramOriginY->flags() | QgsProcessingParameterDefinition::FlagAdvanced );
addParameter( paramOriginY.release() );

createCommonParameters();

addParameter( new QgsProcessingParameterRasterDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Output raster" ) ) );
addParameter( new QgsProcessingParameterRasterDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Exported (using triangulation)" ) ) );
}

QStringList QgsPdalExportRasterTinAlgorithm::createArgumentLists( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
Expand Down
4 changes: 2 additions & 2 deletions src/analysis/processing/pdal/qgsalgorithmpdalexportvector.cpp
Expand Up @@ -44,7 +44,7 @@ QString QgsPdalExportVectorAlgorithm::groupId() const

QStringList QgsPdalExportVectorAlgorithm::tags() const
{
return QObject::tr( "export,vector,attribute,create" ).split( ',' );
return QObject::tr( "pdal,lidar,export,vector,attribute,create" ).split( ',' );
}

QString QgsPdalExportVectorAlgorithm::shortHelpString() const
Expand All @@ -62,7 +62,7 @@ void QgsPdalExportVectorAlgorithm::initAlgorithm( const QVariantMap & )
addParameter( new QgsProcessingParameterPointCloudLayer( QStringLiteral( "INPUT" ), QObject::tr( "Input layer" ) ) );
addParameter( new QgsProcessingParameterPointCloudAttribute( QStringLiteral( "ATTRIBUTE" ), QObject::tr( "Attribute" ), QVariant(), QStringLiteral( "INPUT" ), true, true ) );
createCommonParameters();
addParameter( new QgsProcessingParameterVectorDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Output vector" ), QgsProcessing::TypeVectorPoint ) );
addParameter( new QgsProcessingParameterVectorDestination( QStringLiteral( "OUTPUT" ), QObject::tr( "Exported" ), QgsProcessing::TypeVectorPoint ) );
}

QStringList QgsPdalExportVectorAlgorithm::createArgumentLists( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
Expand Down

0 comments on commit 3ab7530

Please sign in to comment.