allow to drop 2dm files from system file browser (#8987)

* allow to drop 2dm files from system file browser
* support non-ascii files for mesh layer
This commit is contained in:
Peter Petrik 2019-01-30 08:49:37 +01:00 committed by GitHub
parent 1686f0d084
commit 606359117b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 1 deletions

View File

@ -6471,6 +6471,12 @@ bool QgisApp::openLayer( const QString &fileName, bool allowInteractive )
CPLPopErrorHandler();
// Try to load as mesh layer after raster & vector
if ( !ok )
{
ok = addMeshLayer( fileName, fileInfo.completeBaseName(), "mdal" );
}
if ( !ok )
{
// we have no idea what this file is...

View File

@ -54,7 +54,7 @@ QgsCoordinateReferenceSystem QgsMdalProvider::crs() const
QgsMdalProvider::QgsMdalProvider( const QString &uri, const ProviderOptions &options )
: QgsMeshDataProvider( uri, options )
{
QByteArray curi = uri.toAscii();
QByteArray curi = uri.toUtf8();
mMeshH = MDAL_LoadMesh( curi.constData() );
if ( mMeshH )
{

View File

@ -9,6 +9,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/src/core/auth
${CMAKE_SOURCE_DIR}/src/core/expression
${CMAKE_SOURCE_DIR}/src/core/geometry
${CMAKE_SOURCE_DIR}/src/core/mesh
${CMAKE_SOURCE_DIR}/src/core/metadata
${CMAKE_SOURCE_DIR}/src/core/raster
${CMAKE_SOURCE_DIR}/src/core/symbology

View File

@ -27,6 +27,7 @@
#include <qgis.h>
#include <qgsapplication.h>
#include <qgsproviderregistry.h>
#include <qgsmeshdataprovider.h>
/**
* \ingroup UnitTests
@ -42,6 +43,7 @@ class TestQgsMdalProvider : public QObject
void init() {}// will be called before each testfunction is executed.
void cleanup() {}// will be called after every testfunction.
void load();
void filters();
private:
@ -83,5 +85,36 @@ void TestQgsMdalProvider::filters()
QVERIFY( datasetFilters.contains( "*.dat" ) );
}
void TestQgsMdalProvider::load()
{
{
QString file = QStringLiteral( TEST_DATA_DIR ) + "/mesh/quad_flower.2dm";
QgsDataProvider *provider = QgsProviderRegistry::instance()->createProvider(
QStringLiteral( "mdal" ),
file,
QgsDataProvider::ProviderOptions()
);
QgsMeshDataProvider *mp = dynamic_cast< QgsMeshDataProvider * >( provider );
QVERIFY( mp );
QVERIFY( mp->isValid() );
delete provider;
}
{
QString file = QStringLiteral( TEST_DATA_DIR ) + QStringLiteral( "/goodluckwiththisfilename.2dm" );
QgsDataProvider *provider = QgsProviderRegistry::instance()->createProvider(
QStringLiteral( "mdal" ),
file,
QgsDataProvider::ProviderOptions()
);
QgsMeshDataProvider *mp = dynamic_cast< QgsMeshDataProvider * >( provider );
QVERIFY( mp );
QVERIFY( !mp->isValid() );
delete provider;
}
}
QGSTEST_MAIN( TestQgsMdalProvider )
#include "testqgsmdalprovider.moc"