Skip to content
Permalink
Browse files
make QgsRemoteEptPointCloudIndex derive from QgsEptPointCloudIndex
  • Loading branch information
NEDJIMAbelgacem authored and wonder-sk committed Apr 8, 2021
1 parent 8ea831f commit 9def734ba30783c9de39991d0b1dc7bdbd49310c
@@ -59,17 +59,9 @@ class CORE_EXPORT QgsEptPointCloudIndex: public QgsPointCloudIndex
bool isValid() const override;
QgsPointCloudIndex::AccessType accessType() const override { return QgsPointCloudIndex::Local; };

private:
bool loadSchema( QFile &f );
bool loadHierarchy();

bool mIsValid = false;
QString mDataType;
QString mDirectory;
protected:
QString mWkt;

int mPointCount = 0;

struct AttributeStatistics
{
int count = -1;
@@ -84,6 +76,17 @@ class CORE_EXPORT QgsEptPointCloudIndex: public QgsPointCloudIndex

QMap< QString, QMap< int, int > > mAttributeClasses;
QVariantMap mOriginalMetadata;

private:
bool loadSchema( QFile &f );
bool loadHierarchy();

bool mIsValid = false;
QString mDataType;
QString mDirectory;

int mPointCount = 0;

};

///@endcond
@@ -46,7 +46,7 @@

///@cond PRIVATE

QgsRemoteEptPointCloudIndex::QgsRemoteEptPointCloudIndex() : QgsPointCloudIndex()
QgsRemoteEptPointCloudIndex::QgsRemoteEptPointCloudIndex() : QgsEptPointCloudIndex()
{
mTileDownloadManager = QgsApplication::tileDownloadManager();
}
@@ -97,10 +97,6 @@ void QgsRemoteEptPointCloudIndex::load( const QString &url )

QgsNetworkReplyContent reply = req.reply();
bool success = loadSchema( reply.content() );
// if ( success )
// {
// success = loadHierarchy();
// }

mIsValid = success;
}
@@ -409,82 +405,11 @@ QgsPointCloudBlockHandle *QgsRemoteEptPointCloudIndex::asyncNodeData( const Inde
return handle;
}

QgsCoordinateReferenceSystem QgsRemoteEptPointCloudIndex::crs() const
{
return QgsCoordinateReferenceSystem::fromWkt( mWkt );
}

int QgsRemoteEptPointCloudIndex::pointCount() const
{
return mPointCount;
}

QVariant QgsRemoteEptPointCloudIndex::metadataStatistic( const QString &attribute, QgsStatisticalSummary::Statistic statistic ) const
{
if ( !mMetadataStats.contains( attribute ) )
return QVariant();

const AttributeStatistics &stats = mMetadataStats[ attribute ];
switch ( statistic )
{
case QgsStatisticalSummary::Count:
return stats.count >= 0 ? QVariant( stats.count ) : QVariant();

case QgsStatisticalSummary::Mean:
return std::isnan( stats.mean ) ? QVariant() : QVariant( stats.mean );

case QgsStatisticalSummary::StDev:
return std::isnan( stats.stDev ) ? QVariant() : QVariant( stats.stDev );

case QgsStatisticalSummary::Min:
return stats.minimum;

case QgsStatisticalSummary::Max:
return stats.maximum;

case QgsStatisticalSummary::Range:
return stats.minimum.isValid() && stats.maximum.isValid() ? QVariant( stats.maximum.toDouble() - stats.minimum.toDouble() ) : QVariant();

case QgsStatisticalSummary::CountMissing:
case QgsStatisticalSummary::Sum:
case QgsStatisticalSummary::Median:
case QgsStatisticalSummary::StDevSample:
case QgsStatisticalSummary::Minority:
case QgsStatisticalSummary::Majority:
case QgsStatisticalSummary::Variety:
case QgsStatisticalSummary::FirstQuartile:
case QgsStatisticalSummary::ThirdQuartile:
case QgsStatisticalSummary::InterQuartileRange:
case QgsStatisticalSummary::First:
case QgsStatisticalSummary::Last:
case QgsStatisticalSummary::All:
return QVariant();
}
return QVariant();
}

QVariantList QgsRemoteEptPointCloudIndex::metadataClasses( const QString &attribute ) const
{
QVariantList classes;
const QMap< int, int > values = mAttributeClasses.value( attribute );
for ( auto it = values.constBegin(); it != values.constEnd(); ++it )
{
classes << it.key();
}
return classes;
}

QVariant QgsRemoteEptPointCloudIndex::metadataClassStatistic( const QString &attribute, const QVariant &value, QgsStatisticalSummary::Statistic statistic ) const
{
if ( statistic != QgsStatisticalSummary::Count )
return QVariant();

const QMap< int, int > values = mAttributeClasses.value( attribute );
if ( !values.contains( value.toInt() ) )
return QVariant();
return values.value( value.toInt() );
}

bool QgsRemoteEptPointCloudIndex::loadNodeHierarchy( const IndexedPointCloudNode &nodeId ) const
{
if ( mHierarchy.contains( nodeId ) )
@@ -31,14 +31,15 @@
#include "qgspointcloudattribute.h"
#include "qgsstatisticalsummary.h"
#include "qgis_sip.h"
#include "qgseptpointcloudindex.h"

///@cond PRIVATE
#define SIP_NO_FILE

class QgsCoordinateReferenceSystem;
class QgsTileDownloadManager;

class CORE_EXPORT QgsRemoteEptPointCloudIndex: public QgsPointCloudIndex
class CORE_EXPORT QgsRemoteEptPointCloudIndex: public QgsEptPointCloudIndex
{
Q_OBJECT
public:
@@ -53,12 +54,7 @@ class CORE_EXPORT QgsRemoteEptPointCloudIndex: public QgsPointCloudIndex
QgsPointCloudBlock *nodeData( const IndexedPointCloudNode &n, const QgsPointCloudRequest &request ) override;
QgsPointCloudBlockHandle *asyncNodeData( const IndexedPointCloudNode &n, const QgsPointCloudRequest &request ) override;

QgsCoordinateReferenceSystem crs() const override;
int pointCount() const override;
QVariant metadataStatistic( const QString &attribute, QgsStatisticalSummary::Statistic statistic ) const override;
QVariantList metadataClasses( const QString &attribute ) const override;
QVariant metadataClassStatistic( const QString &attribute, const QVariant &value, QgsStatisticalSummary::Statistic statistic ) const override;
QVariantMap originalMetadata() const override { return mOriginalMetadata; }

bool isValid() const override;

@@ -73,27 +69,11 @@ class CORE_EXPORT QgsRemoteEptPointCloudIndex: public QgsPointCloudIndex
QString mDataType;
QString mUrlDirectoryPart;
QString mUrlFileNamePart;
QString mWkt;

QUrl mUrl;

int mPointCount = 0;

struct AttributeStatistics
{
int count = -1;
QVariant minimum;
QVariant maximum;
double mean = std::numeric_limits< double >::quiet_NaN();
double stDev = std::numeric_limits< double >::quiet_NaN();
double variance = std::numeric_limits< double >::quiet_NaN();
};

QMap< QString, AttributeStatistics > mMetadataStats;

QMap< QString, QMap< int, int > > mAttributeClasses;
QVariantMap mOriginalMetadata;

QgsTileDownloadManager *mTileDownloadManager = nullptr;
};

0 comments on commit 9def734

Please sign in to comment.