Skip to content
Permalink
Browse files
fix suffix for TIN Mesh creation
  • Loading branch information
vcloarec authored and github-actions committed Nov 14, 2021
1 parent 0fcdb59 commit 8d32b7894ccc3fbd5af2f9d729d733546aff3644
Showing with 14 additions and 3 deletions.
  1. +13 −3 src/analysis/processing/qgsalgorithmtinmeshcreation.cpp
  2. +1 −0 src/analysis/processing/qgsalgorithmtinmeshcreation.h
@@ -71,9 +71,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 +164,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 +176,12 @@ QVariantMap QgsTinMeshCreationAlgorithm::processAlgorithm( const QVariantMap &pa

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

QFileInfo fileInfo( fileName );
QString suffix = fileInfo.suffix();

if ( suffix.isEmpty() )
fileName.append( QStringLiteral( ".%1" ).arg( 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 8d32b78

Please sign in to comment.