Skip to content
Permalink
Browse files

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
  • Loading branch information
PeterPetrik committed Jan 30, 2019
1 parent 1686f0d commit 606359117be338da0cdf5c48df5a470310edd3eb
@@ -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...
@@ -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 )
{
@@ -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
@@ -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"

0 comments on commit 6063591

Please sign in to comment.
You can’t perform that action at this time.