20#include "moc_qgspointclouddataprovider.cpp"
32#include <QtConcurrent/QtConcurrentMap>
56 return lIndex && lIndex->isValid();
82 static QMap< int, QString > sCodes
84 {0, QStringLiteral(
"Created, Never Classified" )},
85 {1, QStringLiteral(
"Unclassified" )},
86 {2, QStringLiteral(
"Ground" )},
87 {3, QStringLiteral(
"Low Vegetation" )},
88 {4, QStringLiteral(
"Medium Vegetation" )},
89 {5, QStringLiteral(
"High Vegetation" )},
90 {6, QStringLiteral(
"Building" )},
91 {7, QStringLiteral(
"Low Point (Low Noise)" )},
92 {8, QStringLiteral(
"Reserved" )},
93 {9, QStringLiteral(
"Water" )},
94 {10, QStringLiteral(
"Rail" )},
95 {11, QStringLiteral(
"Road Surface" )},
96 {12, QStringLiteral(
"Reserved" )},
97 {13, QStringLiteral(
"Wire - Guard (Shield)" )},
98 {14, QStringLiteral(
"Wire - Conductor (Phase)" )},
99 {15, QStringLiteral(
"Transmission Tower" )},
100 {16, QStringLiteral(
"Wire-Structure Connector (Insulator)" )},
101 {17, QStringLiteral(
"Bridge Deck" )},
102 {18, QStringLiteral(
"High Noise" )},
105 static std::once_flag initialized;
106 std::call_once( initialized, [ = ]( )
108 for (
int i = 19; i <= 63; ++i )
109 sCodes.insert( i, QStringLiteral(
"Reserved" ) );
110 for (
int i = 64; i <= 255; ++i )
111 sCodes.insert( i, QStringLiteral(
"User Definable" ) );
119 static QMap< int, QString > sCodes
121 {0, QObject::tr(
"Created, Never Classified" )},
122 {1, QObject::tr(
"Unclassified" )},
123 {2, QObject::tr(
"Ground" )},
124 {3, QObject::tr(
"Low Vegetation" )},
125 {4, QObject::tr(
"Medium Vegetation" )},
126 {5, QObject::tr(
"High Vegetation" )},
127 {6, QObject::tr(
"Building" )},
128 {7, QObject::tr(
"Low Point (Noise)" )},
129 {8, QObject::tr(
"Reserved" )},
130 {9, QObject::tr(
"Water" )},
131 {10, QObject::tr(
"Rail" )},
132 {11, QObject::tr(
"Road Surface" )},
133 {12, QObject::tr(
"Reserved" )},
134 {13, QObject::tr(
"Wire - Guard (Shield)" )},
135 {14, QObject::tr(
"Wire - Conductor (Phase)" )},
136 {15, QObject::tr(
"Transmission Tower" )},
137 {16, QObject::tr(
"Wire-Structure Connector (Insulator)" )},
138 {17, QObject::tr(
"Bridge Deck" )},
139 {18, QObject::tr(
"High Noise" )},
142 static std::once_flag initialized;
143 std::call_once( initialized, [ = ]( )
145 for (
int i = 19; i <= 63; ++i )
146 sCodes.insert( i, QObject::tr(
"Reserved" ) );
147 for (
int i = 64; i <= 255; ++i )
148 sCodes.insert( i, QObject::tr(
"User Definable" ) );
156 static const QMap< int, QString > sCodes
158 {0, QStringLiteral(
"No color or time stored" )},
159 {1, QStringLiteral(
"Time is stored" )},
160 {2, QStringLiteral(
"Color is stored" )},
161 {3, QStringLiteral(
"Color and time are stored" )},
162 {6, QStringLiteral(
"Time is stored" )},
163 {7, QStringLiteral(
"Time and color are stored)" )},
164 {8, QStringLiteral(
"Time, color and near infrared are stored" )},
172 static const QMap< int, QString > sCodes
174 {0, QObject::tr(
"No color or time stored" )},
175 {1, QObject::tr(
"Time is stored" )},
176 {2, QObject::tr(
"Color is stored" )},
177 {3, QObject::tr(
"Color and time are stored" )},
178 {6, QObject::tr(
"Time is stored" )},
179 {7, QObject::tr(
"Time and color are stored)" )},
180 {8, QObject::tr(
"Time, color and near infrared are stored" )},
200 return pcIndex->metadataStatistic( attribute, statistic );
212 return pcIndex->metadataClasses( attribute );
214 return QVariantList();
224 return pcIndex->metadataClassStatistic( attribute, value, statistic );
236 return pcIndex->metadataStatistics();
248 return tr(
"QGIS expression" );
268 QVector<QVariantMap> acceptedPoints;
272 return acceptedPoints;
274 const char *ptr = block->data();
277 int xOffset = 0, yOffset = 0, zOffset = 0;
282 extentEngine->prepareGeometry();
286 QgsPointCloudAttribute::getPointXYZ( ptr, i, recordSize, xOffset, xType, yOffset, yType, zOffset, zType, block->scale(), block->offset(), x, y, z );
291 pointAttr[ QStringLiteral(
"X" ) ] = x;
292 pointAttr[ QStringLiteral(
"Y" ) ] = y;
293 pointAttr[ QStringLiteral(
"Z" ) ] = z;
295 acceptedPoints.push_back( pointAttr );
298 return acceptedPoints;
316 QVector<QVariantMap> acceptedPoints;
319 for ( QgsPointCloudSubIndex &subidx :
subIndexes() )
324 || ( !subidx.zRange().overlaps( extentZRange ) )
325 || !subidx.polygonBounds().intersects( extentGeometry ) )
327 acceptedPoints.append(
identify( subidx.index(), maxError, extentGeometry, extentZRange, pointsLimit ) );
331 acceptedPoints.append(
identify(
index(), maxError, extentGeometry, extentZRange, pointsLimit ) );
333 return acceptedPoints;
343 QVector<QVariantMap> acceptedPoints;
346 return acceptedPoints;
353 const QVector<IndexedPointCloudNode> nodes = traverseTree(
index, root, maxError, rootError, extentGeometry, extentZRange );
359 acceptedPoints = QtConcurrent::blockingMappedReduced( nodes,
361 qOverload<
const QVector<QMap<QString, QVariant>>&>( &QVector<QMap<QString, QVariant>>::append ),
362 QtConcurrent::UnorderedReduce );
364 return acceptedPoints;
367QVector<IndexedPointCloudNode> QgsPointCloudDataProvider::traverseTree(
377 QVector<IndexedPointCloudNode> nodes;
380 if ( !extentZRange.
overlaps( nodeZRange ) )
388 const double childrenError = nodeError / 2.0;
389 if ( childrenError < maxError )
392 const QList<IndexedPointCloudNode> children = pc->
nodeChildren( n );
396 nodes += traverseTree( pc, nn, maxError, childrenError, extentGeometry, extentZRange );
406 Q_UNUSED( updateFeatureCount )
407 const auto i =
index();
411 if ( !i->setSubsetString( subset ) )
Represents a indexed point cloud node in octree.
Statistic
Available generic statistics.
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Abstract base class for spatial data provider implementations.
void dataChanged()
Emitted whenever a change is made to the data provider which may have caused changes in the provider'...
virtual QgsRectangle extent() const =0
Returns the extent of the layer.
QgsRange which stores a range of double values.
A geometry is the spatial representation of a feature.
static QgsGeometry fromRect(const QgsRectangle &rect)
Creates a new geometry from a QgsRectangle.
const QgsAbstractGeometry * constGet() const
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
bool intersects(const QgsRectangle &rectangle) const
Returns true if this geometry exactly intersects with a rectangle.
Collection of point cloud attributes.
int pointRecordSize() const
Returns total size of record.
const QgsPointCloudAttribute * find(const QString &attributeName, int &offset) const
Finds the attribute with the name.
QVector< QgsPointCloudAttribute > attributes() const
Returns all attributes.
DataType
Systems of unit measurement.
static void getPointXYZ(const char *ptr, int i, std::size_t pointRecordSize, int xOffset, QgsPointCloudAttribute::DataType xType, int yOffset, QgsPointCloudAttribute::DataType yType, int zOffset, QgsPointCloudAttribute::DataType zType, const QgsVector3D &indexScale, const QgsVector3D &indexOffset, double &x, double &y, double &z)
Retrieves the x, y, z values for the point at index i.
static QVariantMap getAttributeMap(const char *data, std::size_t recordOffset, const QgsPointCloudAttributeCollection &attributeCollection)
Retrieves all the attributes of a point.
DataType type() const
Returns the data type.
QString subsetStringDialect() const override
Returns a user-friendly string describing the dialect which is supported for subset strings by the pr...
@ NoCapabilities
Provider has no capabilities.
bool setSubsetString(const QString &subset, bool updateFeatureCount=false) override
Set the subset string used to create a subset of features in the layer.
~QgsPointCloudDataProvider() override
QgsPointCloudDataProvider(const QString &uri, const QgsDataProvider::ProviderOptions &providerOptions, Qgis::DataProviderReadFlags flags=Qgis::DataProviderReadFlags())
Ctor.
static QMap< int, QString > dataFormatIds()
Returns the map of LAS data format ID to untranslated string value.
bool supportsSubsetString() const override
Returns true if the provider supports setting of subset strings.
virtual QVector< QgsPointCloudSubIndex > subIndexes()
Returns a list of sub indexes available if the provider supports multiple indexes,...
QVector< QVariantMap > identify(double maxError, const QgsGeometry &extentGeometry, const QgsDoubleRange &extentZRange=QgsDoubleRange(), int pointsLimit=1000)
Returns the list of points of the point cloud according to a zoom level defined by maxError (in layer...
QgsPointCloudStatistics metadataStatistics()
Returns the object containing the statistics metadata extracted from the dataset.
QString subsetStringHelpUrl() const override
Returns a URL pointing to documentation describing the dialect which is supported for subset strings ...
QString subsetString() const override
Returns the subset definition string currently in use by the layer and used by the provider to limit ...
static QMap< int, QString > translatedDataFormatIds()
Returns the map of LAS data format ID to translated string value.
virtual QgsPointCloudDataProvider::Capabilities capabilities() const
Returns flags containing the supported capabilities for the data provider.
static QMap< int, QString > translatedLasClassificationCodes()
Returns the map of LAS classification code to translated string value, corresponding to the ASPRS Sta...
QString mSubsetString
String used to define a subset of the layer.
static QMap< int, QString > lasClassificationCodes()
Returns the map of LAS classification code to untranslated string value, corresponding to the ASPRS S...
virtual bool hasStatisticsMetadata() const
Returns whether the dataset contains statistics metadata.
virtual QgsPointCloudIndex * index() const
Returns the point cloud index associated with the provider.
QFlags< Capability > Capabilities
virtual QVariant metadataStatistic(const QString &attribute, Qgis::Statistic statistic) const
Returns a statistic for the specified attribute, taken only from the metadata of the point cloud data...
virtual QgsPointCloudRenderer * createRenderer(const QVariantMap &configuration=QVariantMap()) const
Creates a new 2D point cloud renderer, using provider backend specific information.
bool hasValidIndex() const
Returns whether provider has index which is valid.
virtual QVariantMap originalMetadata() const
Returns a representation of the original metadata included in a point cloud dataset.
virtual QgsGeometry polygonBounds() const
Returns the polygon bounds of the layer.
virtual QVariantList metadataClasses(const QString &attribute) const
Returns a list of existing classes which are present for the specified attribute, taken only from the...
virtual QVariant metadataClassStatistic(const QString &attribute, const QVariant &value, Qgis::Statistic statistic) const
Returns a statistic for one class value from the specified attribute, taken only from the metadata of...
Represents a indexed point clouds data in octree.
int span() const
Returns the number of points in one direction in a single node.
QgsRectangle nodeMapExtent(const IndexedPointCloudNode &node) const
Returns the extent of a node in map coordinates.
virtual QList< IndexedPointCloudNode > nodeChildren(const IndexedPointCloudNode &n) const
Returns all children of node.
QgsVector3D offset() const
Returns offset.
QgsVector3D scale() const
Returns scale.
virtual bool isValid() const =0
Returns whether index is loaded and valid.
IndexedPointCloudNode root()
Returns root node of the index.
virtual bool hasStatisticsMetadata() const =0
Returns whether the dataset contains metadata of statistics.
QgsDoubleRange nodeZRange(const IndexedPointCloudNode &node) const
Returns the z range of a node.
virtual std::unique_ptr< QgsPointCloudBlock > nodeData(const IndexedPointCloudNode &n, const QgsPointCloudRequest &request)=0
Returns node data block.
QgsPointCloudAttributeCollection attributes() const
Returns all attributes that are stored in the file.
Abstract base class for 2d point cloud renderers.
Point cloud data request.
void setAttributes(const QgsPointCloudAttributeCollection &attributes)
Set attributes filter in the request.
Class used to store statistics of a point cloud dataset.
bool overlaps(const QgsRange< T > &other) const
Returns true if this range overlaps another range.
bool contains(const QgsRange< T > &other) const
Returns true if this range contains another range.
A rectangle specified with double values.
double width() const
Returns the width of the rectangle.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS
QVector< QVariantMap > operator()(IndexedPointCloudNode n)
QVector< QMap< QString, QVariant > > result_type
MapIndexedPointCloudNode(QgsPointCloudRequest &request, const QgsVector3D &indexScale, const QgsVector3D &indexOffset, const QgsGeometry &extentGeometry, const QgsDoubleRange &zRange, QgsPointCloudIndex *index, int pointsLimit)
const QgsGeometry & mExtentGeometry
QgsPointCloudIndex * mIndex
const QgsDoubleRange & mZRange
QgsPointCloudRequest & mRequest
Setting options for creating vector data providers.