Skip to content
Permalink
Browse files
[Backport release-3_22] fix suffix for TIN Mesh creation (#46033)
* fix suffix for TIN Mesh creation

* use QgsFileUtils::ensureFileNameHasExtension

* remove comments

Co-authored-by: vcloarec <vcloarec@gmail.com>
  • Loading branch information
qgis-bot and vcloarec committed Nov 15, 2021
1 parent 914cf37 commit 5540740e5853da663dfa2d58a4778b002624b32a
Showing with 11 additions and 3 deletions.
  1. +10 −3 src/analysis/processing/qgsalgorithmtinmeshcreation.cpp
  2. +1 −0 src/analysis/processing/qgsalgorithmtinmeshcreation.h
@@ -16,6 +16,7 @@
***************************************************************************/

#include "qgsalgorithmtinmeshcreation.h"
#include "qgsfileutils.h"
#include "qgsprovidermetadata.h"
#include "qgsproviderregistry.h"
#include "qgsprocessingparametertininputlayers.h"
@@ -71,9 +72,13 @@ void QgsTinMeshCreationAlgorithm::initAlgorithm( const QVariantMap &configuratio
if ( meta )
driverList = meta->meshDriversMetadata();

for ( const QgsMeshDriverMetadata &driverMeta : driverList )
for ( const QgsMeshDriverMetadata &driverMeta : std::as_const( driverList ) )
if ( driverMeta.capabilities() & QgsMeshDriverMetadata::CanWriteMeshData )
mAvailableFormat.append( driverMeta.name() );
{
const QString name = driverMeta.name();
mDriverSuffix[name] = driverMeta.writeMeshFrameOnFileSuffix();
mAvailableFormat.append( name );
}

addParameter( new QgsProcessingParameterEnum( QStringLiteral( "MESH_FORMAT" ), QObject::tr( "Output format" ), mAvailableFormat, false, 0 ) );
addParameter( new QgsProcessingParameterCrs( QStringLiteral( "CRS_OUTPUT" ), QObject::tr( "Output coordinate system" ), QVariant(), true ) );
@@ -160,7 +165,7 @@ QVariantMap QgsTinMeshCreationAlgorithm::processAlgorithm( const QVariantMap &pa
if ( feedback && feedback->isCanceled() )
return QVariantMap();

const QString fileName = parameterAsFile( parameters, QStringLiteral( "OUTPUT_MESH" ), context );
QString fileName = parameterAsFile( parameters, QStringLiteral( "OUTPUT_MESH" ), context );
const int driverIndex = parameterAsEnum( parameters, QStringLiteral( "MESH_FORMAT" ), context );
const QString driver = mAvailableFormat.at( driverIndex );
if ( feedback )
@@ -172,6 +177,8 @@ QVariantMap QgsTinMeshCreationAlgorithm::processAlgorithm( const QVariantMap &pa

const QgsProviderMetadata *providerMetadata = QgsProviderRegistry::instance()->providerMetadata( QStringLiteral( "mdal" ) );

fileName = QgsFileUtils::ensureFileNameHasExtension( fileName, QStringList() << mDriverSuffix.value( driver ) );

if ( feedback )
feedback->setProgressText( QObject::tr( "Saving mesh to file" ) );
if ( providerMetadata )
@@ -46,6 +46,7 @@ class QgsTinMeshCreationAlgorithm: public QgsProcessingAlgorithm

private:
QStringList mAvailableFormat;
QMap<QString, QString> mDriverSuffix;

struct Layer
{

0 comments on commit 5540740

Please sign in to comment.