Skip to content
Permalink
Browse files

Ensure that ept provider is the preferred provider for ept.json files

  • Loading branch information
nyalldawson committed Nov 4, 2020
1 parent 0ebe788 commit eb6e53d612b744a9bb0feb1d10137d9276c01bd8
@@ -90,6 +90,16 @@ QList<QgsDataItemProvider *> QgsEptProviderMetadata::dataItemProviders() const
return providers;
}

int QgsEptProviderMetadata::priorityForUri( const QString &uri )
{
const QVariantMap parts = decodeUri( uri );
QFileInfo fi( parts.value( QStringLiteral( "path" ) ).toString() );
if ( fi.fileName().compare( QLatin1String( "ept.json" ), Qt::CaseInsensitive ) == 0 )
return 100;

return 0;
}

QVariantMap QgsEptProviderMetadata::decodeUri( const QString &uri )
{
const QString path = uri;
@@ -63,6 +63,7 @@ class QgsEptProviderMetadata : public QgsProviderMetadata
QgsEptProviderMetadata();
QgsEptProvider *createProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() ) override;
QList< QgsDataItemProvider * > dataItemProviders() const override;
int priorityForUri( const QString &uri ) override;
QString encodeUri( const QVariantMap &parts ) override;
QVariantMap decodeUri( const QString &uri ) override;
QString filters( FilterType type ) override;
@@ -46,6 +46,7 @@ class TestQgsEptProvider : public QObject
void filters();
void encodeUri();
void decodeUri();
void preferredUri();

private:
QString mTestDataDir;
@@ -108,6 +109,13 @@ void TestQgsEptProvider::decodeUri()
QCOMPARE( parts.value( QStringLiteral( "path" ) ).toString(), QStringLiteral( "/home/point_clouds/ept.json" ) );
}

void TestQgsEptProvider::preferredUri()
{
// test that EPT is the preferred provider for ept.json uris
QCOMPARE( QgsProviderRegistry::instance()->preferredProviderForUri( QStringLiteral( "/home/test/ept.json" ) )->key(), QStringLiteral( "ept" ) );
QCOMPARE( QgsProviderRegistry::instance()->preferredProviderForUri( QStringLiteral( "/home/test/EPT.JSON" ) )->key(), QStringLiteral( "ept" ) );
}


QGSTEST_MAIN( TestQgsEptProvider )
#include "testqgseptprovider.moc"

0 comments on commit eb6e53d

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