mirror of
https://github.com/qgis/QGIS.git
synced 2025-03-03 00:02:25 -05:00
[MESH] fix mesh calculator saving for windows (#35963)
fix mesh calculator saving for windows (fix #35549)
This commit is contained in:
parent
e7533d0e54
commit
c2bc0f63e3
@ -267,12 +267,12 @@ Returns whether the faces are active for particular dataset
|
||||
.. versionadded:: 3.6
|
||||
%End
|
||||
|
||||
virtual bool persistDatasetGroup( const QString &path,
|
||||
const QgsMeshDatasetGroupMetadata &meta,
|
||||
const QVector<QgsMeshDataBlock> &datasetValues,
|
||||
const QVector<QgsMeshDataBlock> &datasetActive,
|
||||
const QVector<double> ×
|
||||
) = 0;
|
||||
virtual bool persistDatasetGroup( const QString &path,
|
||||
const QgsMeshDatasetGroupMetadata &meta,
|
||||
const QVector<QgsMeshDataBlock> &datasetValues,
|
||||
const QVector<QgsMeshDataBlock> &datasetActive,
|
||||
const QVector<double> ×
|
||||
) /Deprecated/;
|
||||
%Docstring
|
||||
Creates a new dataset group from a data and
|
||||
persists it into a destination path
|
||||
@ -288,7 +288,41 @@ On success, the mesh's dataset group count is changed
|
||||
|
||||
:return: ``True`` on failure, ``False`` on success
|
||||
|
||||
.. note::
|
||||
|
||||
Doesn't work if there is ":" in the path (e.g. Windows system)
|
||||
|
||||
|
||||
.. versionadded:: 3.6
|
||||
|
||||
.. deprecated::
|
||||
QGIS 3.12.3
|
||||
%End
|
||||
|
||||
virtual bool persistDatasetGroup( const QString &outputFilePath,
|
||||
const QString &outputDriver,
|
||||
const QgsMeshDatasetGroupMetadata &meta,
|
||||
const QVector<QgsMeshDataBlock> &datasetValues,
|
||||
const QVector<QgsMeshDataBlock> &datasetActive,
|
||||
const QVector<double> ×
|
||||
) = 0;
|
||||
%Docstring
|
||||
Creates a new dataset group from a data and
|
||||
persists it into a destination path
|
||||
|
||||
On success, the mesh's dataset group count is changed
|
||||
|
||||
:param outputFilePath: destination path of the stored file
|
||||
:param outputDriver: output driver name
|
||||
:param meta: new group's metadata
|
||||
:param datasetValues: scalar/vector values for all datasets and all faces/vertices in the group
|
||||
:param datasetActive: active flag values for all datasets in the group. Empty array represents can be used
|
||||
when all faces are active
|
||||
:param times: times in hours for all datasets in the group
|
||||
|
||||
:return: ``True`` on failure, ``False`` on success
|
||||
|
||||
.. versionadded:: 3.12.3
|
||||
%End
|
||||
};
|
||||
|
||||
|
@ -235,7 +235,8 @@ QgsMeshCalculator::Result QgsMeshCalculator::processCalculation( QgsFeedback *fe
|
||||
|
||||
const QgsMeshDatasetGroupMetadata meta = outputGroup->groupMetadata();
|
||||
bool err = mMeshLayer->dataProvider()->persistDatasetGroup(
|
||||
mOutputDriver + ':' + mOutputFile,
|
||||
mOutputFile,
|
||||
mOutputDriver,
|
||||
meta,
|
||||
datasetValues,
|
||||
datasetActive,
|
||||
|
@ -53,6 +53,27 @@ QgsMeshDatasetGroupMetadata QgsMeshDatasetSourceInterface::datasetGroupMetadata(
|
||||
return datasetGroupMetadata( index.group() );
|
||||
}
|
||||
|
||||
bool QgsMeshDatasetSourceInterface::persistDatasetGroup(
|
||||
const QString &path,
|
||||
const QgsMeshDatasetGroupMetadata &meta,
|
||||
const QVector<QgsMeshDataBlock> &datasetValues,
|
||||
const QVector<QgsMeshDataBlock> &datasetActive,
|
||||
const QVector<double> × )
|
||||
{
|
||||
// Form DRIVER:filename
|
||||
QString filename = path;
|
||||
// ASCII dat supports face, edge and vertex datasets
|
||||
QString driverName = QStringLiteral( "DAT" );
|
||||
QStringList parts = path.split( ':' );
|
||||
if ( parts.size() > 1 )
|
||||
{
|
||||
driverName = parts[0];
|
||||
parts.removeFirst();
|
||||
filename = parts.join( QString() );
|
||||
}
|
||||
return persistDatasetGroup( filename, driverName, meta, datasetValues, datasetActive, times );
|
||||
}
|
||||
|
||||
QgsMeshVertex QgsMesh::vertex( int index ) const
|
||||
{
|
||||
if ( index < vertices.size() && index >= 0 )
|
||||
|
@ -298,9 +298,37 @@ class CORE_EXPORT QgsMeshDatasetSourceInterface SIP_ABSTRACT
|
||||
* \param times times in hours for all datasets in the group
|
||||
* \returns TRUE on failure, FALSE on success
|
||||
*
|
||||
* \note Doesn't work if there is ":" in the path (e.g. Windows system)
|
||||
*
|
||||
* \since QGIS 3.6
|
||||
* \deprecated QGIS 3.12.3
|
||||
*/
|
||||
virtual bool persistDatasetGroup( const QString &path,
|
||||
Q_DECL_DEPRECATED virtual bool persistDatasetGroup( const QString &path,
|
||||
const QgsMeshDatasetGroupMetadata &meta,
|
||||
const QVector<QgsMeshDataBlock> &datasetValues,
|
||||
const QVector<QgsMeshDataBlock> &datasetActive,
|
||||
const QVector<double> ×
|
||||
) SIP_DEPRECATED;
|
||||
|
||||
/**
|
||||
* Creates a new dataset group from a data and
|
||||
* persists it into a destination path
|
||||
*
|
||||
* On success, the mesh's dataset group count is changed
|
||||
*
|
||||
* \param outputFilePath destination path of the stored file
|
||||
* \param outputDriver output driver name
|
||||
* \param meta new group's metadata
|
||||
* \param datasetValues scalar/vector values for all datasets and all faces/vertices in the group
|
||||
* \param datasetActive active flag values for all datasets in the group. Empty array represents can be used
|
||||
* when all faces are active
|
||||
* \param times times in hours for all datasets in the group
|
||||
* \returns TRUE on failure, FALSE on success
|
||||
*
|
||||
* \since QGIS 3.12.3
|
||||
*/
|
||||
virtual bool persistDatasetGroup( const QString &outputFilePath,
|
||||
const QString &outputDriver,
|
||||
const QgsMeshDatasetGroupMetadata &meta,
|
||||
const QVector<QgsMeshDataBlock> &datasetValues,
|
||||
const QVector<QgsMeshDataBlock> &datasetActive,
|
||||
|
@ -611,13 +611,10 @@ QgsMeshDataBlock QgsMeshMemoryDataset::areFacesActive( int faceIndex, int count
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool QgsMeshMemoryDataProvider::persistDatasetGroup( const QString &path,
|
||||
const QgsMeshDatasetGroupMetadata &meta,
|
||||
const QVector<QgsMeshDataBlock> &datasetValues,
|
||||
const QVector<QgsMeshDataBlock> &datasetActive,
|
||||
const QVector<double> × )
|
||||
bool QgsMeshMemoryDataProvider::persistDatasetGroup( const QString &outputFilePath, const QString &outputDriver, const QgsMeshDatasetGroupMetadata &meta, const QVector<QgsMeshDataBlock> &datasetValues, const QVector<QgsMeshDataBlock> &datasetActive, const QVector<double> × )
|
||||
{
|
||||
Q_UNUSED( path )
|
||||
Q_UNUSED( outputFilePath )
|
||||
Q_UNUSED( outputDriver )
|
||||
Q_UNUSED( meta )
|
||||
Q_UNUSED( datasetValues )
|
||||
Q_UNUSED( datasetActive )
|
||||
|
@ -172,7 +172,8 @@ class CORE_EXPORT QgsMeshMemoryDataProvider final: public QgsMeshDataProvider
|
||||
|
||||
bool isFaceActive( QgsMeshDatasetIndex index, int faceIndex ) const override;
|
||||
QgsMeshDataBlock areFacesActive( QgsMeshDatasetIndex index, int faceIndex, int count ) const override;
|
||||
bool persistDatasetGroup( const QString &path,
|
||||
bool persistDatasetGroup( const QString &outputFilePath,
|
||||
const QString &outputDriver,
|
||||
const QgsMeshDatasetGroupMetadata &meta,
|
||||
const QVector<QgsMeshDataBlock> &datasetValues,
|
||||
const QVector<QgsMeshDataBlock> &datasetActive,
|
||||
|
@ -218,12 +218,14 @@ QgsRectangle QgsMdalProvider::extent() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool QgsMdalProvider::persistDatasetGroup( const QString &path,
|
||||
const QgsMeshDatasetGroupMetadata &meta,
|
||||
const QVector<QgsMeshDataBlock> &datasetValues,
|
||||
const QVector<QgsMeshDataBlock> &datasetActive,
|
||||
const QVector<double> ×
|
||||
)
|
||||
bool QgsMdalProvider::persistDatasetGroup(
|
||||
const QString &outputFilePath,
|
||||
const QString &outputDriver,
|
||||
const QgsMeshDatasetGroupMetadata &meta,
|
||||
const QVector<QgsMeshDataBlock> &datasetValues,
|
||||
const QVector<QgsMeshDataBlock> &datasetActive,
|
||||
const QVector<double> ×
|
||||
)
|
||||
{
|
||||
if ( !mMeshH )
|
||||
return true;
|
||||
@ -246,22 +248,10 @@ bool QgsMdalProvider::persistDatasetGroup( const QString &path,
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( path.isEmpty() )
|
||||
if ( outputFilePath.isEmpty() )
|
||||
return true;
|
||||
|
||||
// Form DRIVER:filename
|
||||
QString filename = path;
|
||||
// ASCII dat supports face, edge and vertex datasets
|
||||
QString driverName = QStringLiteral( "DAT" );
|
||||
QStringList parts = path.split( ':' );
|
||||
if ( parts.size() > 1 )
|
||||
{
|
||||
driverName = parts[0];
|
||||
parts.removeFirst();
|
||||
filename = parts.join( QString() );
|
||||
}
|
||||
|
||||
MDAL_DriverH driver = MDAL_driverFromName( driverName.toStdString().c_str() );
|
||||
MDAL_DriverH driver = MDAL_driverFromName( outputDriver.toStdString().c_str() );
|
||||
if ( !driver )
|
||||
return true;
|
||||
|
||||
@ -288,7 +278,7 @@ bool QgsMdalProvider::persistDatasetGroup( const QString &path,
|
||||
location,
|
||||
meta.isScalar(),
|
||||
driver,
|
||||
filename.toStdString().c_str()
|
||||
outputFilePath.toStdString().c_str()
|
||||
);
|
||||
if ( !g )
|
||||
return true;
|
||||
|
@ -78,7 +78,8 @@ class QgsMdalProvider : public QgsMeshDataProvider
|
||||
QgsMeshDataBlock areFacesActive( QgsMeshDatasetIndex index, int faceIndex, int count ) const override;
|
||||
QgsRectangle extent() const override;
|
||||
|
||||
bool persistDatasetGroup( const QString &path,
|
||||
bool persistDatasetGroup( const QString &outputFilePath,
|
||||
const QString &outputDriver,
|
||||
const QgsMeshDatasetGroupMetadata &meta,
|
||||
const QVector<QgsMeshDataBlock> &datasetValues,
|
||||
const QVector<QgsMeshDataBlock> &datasetActive,
|
||||
|
@ -48,6 +48,9 @@ class TestQgsMeshCalculator : public QObject
|
||||
void calcWithVertexLayers();
|
||||
void calcWithFaceLayers();
|
||||
void calcWithMixedLayers();
|
||||
|
||||
void calcAndSave();
|
||||
|
||||
private:
|
||||
|
||||
QgsMeshLayer *mpMeshLayer = nullptr;
|
||||
@ -292,5 +295,26 @@ void TestQgsMeshCalculator::calcWithMixedLayers()
|
||||
QCOMPARE( val.scalar(), 2.0 );
|
||||
}
|
||||
|
||||
void TestQgsMeshCalculator::calcAndSave()
|
||||
{
|
||||
QgsRectangle extent( 1000.000, 1000.000, 3000.000, 3000.000 );
|
||||
|
||||
QString tempFilePath = QDir::tempPath() + '/' + "meshCalculatorResult.out";
|
||||
QgsMeshCalculator rc( QStringLiteral( "\"VertexScalarDataset\" + \"FaceScalarDataset\"" ),
|
||||
QStringLiteral( "BINARY_DAT" ),
|
||||
"NewMixScalarDataset",
|
||||
tempFilePath,
|
||||
extent,
|
||||
0,
|
||||
3600,
|
||||
mpMeshLayer
|
||||
);
|
||||
|
||||
rc.processCalculation();
|
||||
|
||||
QFileInfo fileInfo( tempFilePath );
|
||||
QVERIFY( fileInfo.exists() );
|
||||
}
|
||||
|
||||
QGSTEST_MAIN( TestQgsMeshCalculator )
|
||||
#include "testqgsmeshcalculator.moc"
|
||||
|
Loading…
x
Reference in New Issue
Block a user