QGIS API Documentation 3.29.0-Master (8c80f25a4f)
qgspointcloudlayer.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgspointcloudlayer.cpp
3 --------------------
4 begin : October 2020
5 copyright : (C) 2020 by Peter Petrik
6 email : zilolv at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "qgspointcloudlayer.h"
20#include "qgspointcloudindex.h"
21#include "qgsrectangle.h"
23#include "qgsproviderregistry.h"
24#include "qgslogger.h"
27#include "qgsruntimeprofiler.h"
28#include "qgsapplication.h"
29#include "qgspainting.h"
32#include "qgsmaplayerlegend.h"
33#include "qgsxmlutils.h"
34#include "qgsmaplayerfactory.h"
35#include "qgsmaplayerutils.h"
39#include "qgsmessagelog.h"
40#include "qgstaskmanager.h"
42#ifdef HAVE_COPC
44#endif
45
46#include <QUrl>
47
49 const QString &baseName,
50 const QString &providerLib,
53 , mElevationProperties( new QgsPointCloudLayerElevationProperties( this ) )
54 , mLayerOptions( options )
55{
56 if ( !uri.isEmpty() && !providerLib.isEmpty() )
57 {
58 const QgsDataProvider::ProviderOptions providerOptions { options.transformContext };
59 QgsDataProvider::ReadFlags providerFlags = QgsDataProvider::ReadFlags();
60 if ( options.loadDefaultStyle )
61 {
63 }
64 setDataSource( uri, baseName, providerLib, providerOptions, providerFlags );
65 }
66
69}
70
72{
73 if ( QgsTask *task = QgsApplication::taskManager()->task( mStatsCalculationTask ) )
74 {
75 task->cancel();
76 }
77}
78
80{
81 QgsPointCloudLayer *layer = new QgsPointCloudLayer( source(), name(), mProviderKey, mLayerOptions );
82 QgsMapLayer::clone( layer );
83
84 if ( mRenderer )
85 layer->setRenderer( mRenderer->clone() );
86
87 layer->mElevationProperties = mElevationProperties->clone();
88 layer->mElevationProperties->setParent( layer );
89
90 layer->mLayerOptions = mLayerOptions;
91 layer->mSync3DRendererTo2DRenderer = mSync3DRendererTo2DRenderer;
92
93 return layer;
94}
95
97{
98 if ( !mDataProvider )
99 return QgsRectangle();
100
101 return mDataProvider->extent();
102}
103
105{
106 return new QgsPointCloudLayerRenderer( this, rendererContext );
107}
108
110{
111 return new QgsPointCloudLayerProfileGenerator( this, request );
112}
113
115{
116 return mDataProvider.get();
117}
118
120{
121 return mDataProvider.get();
122}
123
124bool QgsPointCloudLayer::readXml( const QDomNode &layerNode, QgsReadWriteContext &context )
125{
126 // create provider
127 const QDomNode pkeyNode = layerNode.namedItem( QStringLiteral( "provider" ) );
128 mProviderKey = pkeyNode.toElement().text();
129
131 {
132 const QgsDataProvider::ProviderOptions providerOptions { context.transformContext() };
133 QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags();
134 // read extent
136 {
137 const QDomNode extentNode = layerNode.namedItem( QStringLiteral( "extent" ) );
138 if ( !extentNode.isNull() )
139 {
140 // get the extent
141 const QgsRectangle mbr = QgsXmlUtils::readRectangle( extentNode.toElement() );
142
143 // store the extent
144 setExtent( mbr );
145
146 // skip get extent
148 }
149 }
151 {
153 }
155 {
157 }
159 const QDomNode subset = layerNode.namedItem( QStringLiteral( "subset" ) );
160 const QString subsetText = subset.toElement().text();
161 if ( !subsetText.isEmpty() )
162 setSubsetString( subsetText );
163 }
164
165 if ( !isValid() )
166 {
167 return false;
168 }
169
170 QString errorMsg;
171 if ( !readSymbology( layerNode, errorMsg, context ) )
172 return false;
173
174 readStyleManager( layerNode );
175 return true;
176}
177
178bool QgsPointCloudLayer::writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const
179{
180 QDomElement mapLayerNode = layerNode.toElement();
181 mapLayerNode.setAttribute( QStringLiteral( "type" ), QgsMapLayerFactory::typeToString( QgsMapLayerType::PointCloudLayer ) );
182
183 if ( !subsetString().isEmpty() )
184 {
185 QDomElement subset = doc.createElement( QStringLiteral( "subset" ) );
186 const QDomText subsetText = doc.createTextNode( subsetString() );
187 subset.appendChild( subsetText );
188 layerNode.appendChild( subset );
189 }
190 if ( mDataProvider )
191 {
192 QDomElement provider = doc.createElement( QStringLiteral( "provider" ) );
193 const QDomText providerText = doc.createTextNode( providerType() );
194 provider.appendChild( providerText );
195 layerNode.appendChild( provider );
196 }
197
198 writeStyleManager( layerNode, doc );
199
200 QString errorMsg;
201 return writeSymbology( layerNode, doc, errorMsg, context );
202}
203
204bool QgsPointCloudLayer::readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
205{
206 const QDomElement elem = node.toElement();
207
208 readCommonStyle( elem, context, categories );
209
210 readStyle( node, errorMessage, context, categories );
211
212 if ( categories.testFlag( CustomProperties ) )
213 readCustomProperties( node, QStringLiteral( "variable" ) );
214
215 return true;
216}
217
218bool QgsPointCloudLayer::readStyle( const QDomNode &node, QString &, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
219{
220 bool result = true;
221
222 if ( categories.testFlag( Symbology3D ) )
223 {
224 bool ok;
225 bool sync = node.attributes().namedItem( QStringLiteral( "sync3DRendererTo2DRenderer" ) ).nodeValue().toInt( &ok );
226 if ( ok )
228 }
229
230 if ( categories.testFlag( Symbology ) )
231 {
232 QDomElement rendererElement = node.firstChildElement( QStringLiteral( "renderer" ) );
233 if ( !rendererElement.isNull() )
234 {
235 std::unique_ptr< QgsPointCloudRenderer > r( QgsPointCloudRenderer::load( rendererElement, context ) );
236 if ( r )
237 {
238 setRenderer( r.release() );
239 }
240 else
241 {
242 result = false;
243 }
244 }
245 // make sure layer has a renderer - if none exists, fallback to a default renderer
246 if ( !mRenderer )
247 {
249 }
250 }
251
252 if ( categories.testFlag( Symbology ) )
253 {
254 // get and set the blend mode if it exists
255 const QDomNode blendModeNode = node.namedItem( QStringLiteral( "blendMode" ) );
256 if ( !blendModeNode.isNull() )
257 {
258 const QDomElement e = blendModeNode.toElement();
259 setBlendMode( QgsPainting::getCompositionMode( static_cast< QgsPainting::BlendMode >( e.text().toInt() ) ) );
260 }
261 }
262
263 // get and set the layer transparency and scale visibility if they exists
264 if ( categories.testFlag( Rendering ) )
265 {
266 const QDomNode layerOpacityNode = node.namedItem( QStringLiteral( "layerOpacity" ) );
267 if ( !layerOpacityNode.isNull() )
268 {
269 const QDomElement e = layerOpacityNode.toElement();
270 setOpacity( e.text().toDouble() );
271 }
272
273 const bool hasScaleBasedVisibiliy { node.attributes().namedItem( QStringLiteral( "hasScaleBasedVisibilityFlag" ) ).nodeValue() == '1' };
274 setScaleBasedVisibility( hasScaleBasedVisibiliy );
275 bool ok;
276 const double maxScale { node.attributes().namedItem( QStringLiteral( "maxScale" ) ).nodeValue().toDouble( &ok ) };
277 if ( ok )
278 {
279 setMaximumScale( maxScale );
280 }
281 const double minScale { node.attributes().namedItem( QStringLiteral( "minScale" ) ).nodeValue().toDouble( &ok ) };
282 if ( ok )
283 {
284 setMinimumScale( minScale );
285 }
286 }
287 return result;
288}
289
290bool QgsPointCloudLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
291 const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
292{
293 Q_UNUSED( errorMessage )
294
295 QDomElement elem = node.toElement();
296 writeCommonStyle( elem, doc, context, categories );
297
298 ( void )writeStyle( node, doc, errorMessage, context, categories );
299
300 return true;
301}
302
303bool QgsPointCloudLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &, const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
304{
305 QDomElement mapLayerNode = node.toElement();
306
307 if ( categories.testFlag( Symbology3D ) )
308 {
309 mapLayerNode.setAttribute( QStringLiteral( "sync3DRendererTo2DRenderer" ), mSync3DRendererTo2DRenderer ? 1 : 0 );
310 }
311
312 if ( categories.testFlag( Symbology ) )
313 {
314 if ( mRenderer )
315 {
316 const QDomElement rendererElement = mRenderer->save( doc, context );
317 node.appendChild( rendererElement );
318 }
319 }
320
321 //save customproperties
322 if ( categories.testFlag( CustomProperties ) )
323 {
324 writeCustomProperties( node, doc );
325 }
326
327 if ( categories.testFlag( Symbology ) )
328 {
329 // add the blend mode field
330 QDomElement blendModeElem = doc.createElement( QStringLiteral( "blendMode" ) );
331 const QDomText blendModeText = doc.createTextNode( QString::number( QgsPainting::getBlendModeEnum( blendMode() ) ) );
332 blendModeElem.appendChild( blendModeText );
333 node.appendChild( blendModeElem );
334 }
335
336 // add the layer opacity and scale visibility
337 if ( categories.testFlag( Rendering ) )
338 {
339 QDomElement layerOpacityElem = doc.createElement( QStringLiteral( "layerOpacity" ) );
340 const QDomText layerOpacityText = doc.createTextNode( QString::number( opacity() ) );
341 layerOpacityElem.appendChild( layerOpacityText );
342 node.appendChild( layerOpacityElem );
343
344 mapLayerNode.setAttribute( QStringLiteral( "hasScaleBasedVisibilityFlag" ), hasScaleBasedVisibility() ? 1 : 0 );
345 mapLayerNode.setAttribute( QStringLiteral( "maxScale" ), maximumScale() );
346 mapLayerNode.setAttribute( QStringLiteral( "minScale" ), minimumScale() );
347 }
348 return true;
349}
350
352{
353 if ( mDataProvider )
354 mDataProvider->setTransformContext( transformContext );
356}
357
358void QgsPointCloudLayer::setDataSourcePrivate( const QString &dataSource, const QString &baseName, const QString &provider,
359 const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags )
360{
361 if ( mDataProvider )
362 {
363 disconnect( mDataProvider.get(), &QgsPointCloudDataProvider::dataChanged, this, &QgsPointCloudLayer::dataChanged );
364 disconnect( mDataProvider.get(), &QgsPointCloudDataProvider::indexGenerationStateChanged, this, &QgsPointCloudLayer::onPointCloudIndexGenerationStateChanged );
365 }
366
367 setName( baseName );
368 mProviderKey = provider;
369 mDataSource = dataSource;
370
371 mDataProvider.reset( qobject_cast<QgsPointCloudDataProvider *>( QgsProviderRegistry::instance()->createProvider( provider, dataSource, options, flags ) ) );
372 if ( !mDataProvider )
373 {
374 QgsDebugMsg( QStringLiteral( "Unable to get point cloud data provider" ) );
375 setValid( false );
376 return;
377 }
378
379 mDataProvider->setParent( this );
380 QgsDebugMsgLevel( QStringLiteral( "Instantiated the point cloud data provider plugin" ), 2 );
381
382 setValid( mDataProvider->isValid() );
383 if ( !isValid() )
384 {
385 QgsDebugMsg( QStringLiteral( "Invalid point cloud provider plugin %1" ).arg( QString( mDataSource.toUtf8() ) ) );
386 setError( mDataProvider->error() );
387 return;
388 }
389
390 connect( mDataProvider.get(), &QgsPointCloudDataProvider::indexGenerationStateChanged, this, &QgsPointCloudLayer::onPointCloudIndexGenerationStateChanged );
391 connect( mDataProvider.get(), &QgsPointCloudDataProvider::dataChanged, this, &QgsPointCloudLayer::dataChanged );
392
393 // Load initial extent, crs and renderer
394 setCrs( mDataProvider->crs() );
396 {
397 setExtent( mDataProvider->extent() );
398 }
399
400 bool loadDefaultStyleFlag = false;
402 {
403 loadDefaultStyleFlag = true;
404 }
405
406 if ( !mLayerOptions.skipIndexGeneration && mDataProvider && mDataProvider->indexingState() != QgsPointCloudDataProvider::PointCloudIndexGenerationState::Indexed )
407 {
408 mDataProvider->generateIndex();
409 }
410
411 if ( !mLayerOptions.skipStatisticsCalculation && mDataProvider && !mDataProvider->hasStatisticsMetadata() && mDataProvider->indexingState() == QgsPointCloudDataProvider::PointCloudIndexGenerationState::Indexed )
412 {
413 calculateStatistics();
414 }
415
416 // Note: we load the statistics from the data provider regardless of it being an existing metadata (do not check fot hasStatisticsMetadata)
417 // since the X, Y & Z coordinates will be in the header of the dataset
418 if ( mDataProvider && mDataProvider->isValid() && mStatistics.sampledPointsCount() == 0 && mDataProvider->indexingState() == QgsPointCloudDataProvider::Indexed )
419 {
420 mStatistics = mDataProvider->metadataStatistics();
421 }
422
423 if ( !mRenderer || loadDefaultStyleFlag )
424 {
425 std::unique_ptr< QgsScopedRuntimeProfile > profile;
426 if ( QgsApplication::profiler()->groupIsActive( QStringLiteral( "projectload" ) ) )
427 profile = std::make_unique< QgsScopedRuntimeProfile >( tr( "Load layer style" ), QStringLiteral( "projectload" ) );
428
429 bool defaultLoadedFlag = false;
430
431 if ( loadDefaultStyleFlag && isSpatial() && mDataProvider->capabilities() & QgsPointCloudDataProvider::CreateRenderer )
432 {
433 // first try to create a renderer directly from the data provider
434 std::unique_ptr< QgsPointCloudRenderer > defaultRenderer( mDataProvider->createRenderer() );
435 if ( defaultRenderer )
436 {
437 defaultLoadedFlag = true;
438 setRenderer( defaultRenderer.release() );
439 }
440 }
441
442 if ( !defaultLoadedFlag && loadDefaultStyleFlag )
443 {
444 loadDefaultStyle( defaultLoadedFlag );
445 }
446
447 if ( !defaultLoadedFlag )
448 {
449 // all else failed, create default renderer
451 }
452 }
453}
454
455QString QgsPointCloudLayer::encodedSource( const QString &source, const QgsReadWriteContext &context ) const
456{
457 QVariantMap parts = QgsProviderRegistry::instance()->decodeUri( providerType(), source );
458 if ( parts.contains( QStringLiteral( "path" ) ) )
459 {
460 parts.insert( QStringLiteral( "path" ), context.pathResolver().writePath( parts.value( QStringLiteral( "path" ) ).toString() ) );
462 }
463 else
464 {
465 return source;
466 }
467}
468
469QString QgsPointCloudLayer::decodedSource( const QString &source, const QString &dataProvider, const QgsReadWriteContext &context ) const
470{
472 if ( parts.contains( QStringLiteral( "path" ) ) )
473 {
474 parts.insert( QStringLiteral( "path" ), context.pathResolver().readPath( parts.value( QStringLiteral( "path" ) ).toString() ) );
476 }
477 else
478 {
479 return source;
480 }
481}
482
483void QgsPointCloudLayer::onPointCloudIndexGenerationStateChanged( QgsPointCloudDataProvider::PointCloudIndexGenerationState state )
484{
485 switch ( state )
486 {
488 {
489 resetRenderer();
490 break;
491 }
493 {
494 QgsError providerError = mDataProvider->error();
495 if ( !providerError.isEmpty() )
496 {
497 setError( providerError );
498 emit raiseError( providerError.summary() );
499 }
500 break;
501 }
503 break;
504 }
505}
506
507
508QString QgsPointCloudLayer::loadDefaultStyle( bool &resultFlag )
509{
510 if ( mDataProvider->capabilities() & QgsPointCloudDataProvider::CreateRenderer )
511 {
512 // first try to create a renderer directly from the data provider
513 std::unique_ptr< QgsPointCloudRenderer > defaultRenderer( mDataProvider->createRenderer() );
514 if ( defaultRenderer )
515 {
516 resultFlag = true;
517 setRenderer( defaultRenderer.release() );
518 return QString();
519 }
520 }
521
522 return QgsMapLayer::loadDefaultStyle( resultFlag );
523}
524
526{
527 const QgsLayerMetadataFormatter htmlFormatter( metadata() );
528 QString myMetadata = QStringLiteral( "<html>\n<body>\n" );
529
530 myMetadata += generalHtmlMetadata();
531
532 // Begin Provider section
533 myMetadata += QStringLiteral( "<h1>" ) + tr( "Information from provider" ) + QStringLiteral( "</h1>\n<hr>\n" );
534 myMetadata += QLatin1String( "<table class=\"list-view\">\n" );
535
536 // Extent
537 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Extent" ) + QStringLiteral( "</td><td>" ) + extent().toString() + QStringLiteral( "</td></tr>\n" );
538
539 // feature count
540 QLocale locale = QLocale();
541 locale.setNumberOptions( locale.numberOptions() &= ~QLocale::NumberOption::OmitGroupSeparator );
542 const qint64 pointCount = mDataProvider ? mDataProvider->pointCount() : -1;
543 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
544 + tr( "Point count" ) + QStringLiteral( "</td><td>" )
545 + ( pointCount < 0 ? tr( "unknown" ) : locale.toString( static_cast<qlonglong>( pointCount ) ) )
546 + QStringLiteral( "</td></tr>\n" );
547 myMetadata += QLatin1String( "</table>\n<br><br>" );
548
549 // CRS
550 myMetadata += crsHtmlMetadata();
551
552 // provider metadata section
553 myMetadata += QStringLiteral( "<h1>" ) + tr( "Metadata" ) + QStringLiteral( "</h1>\n<hr>\n" ) + QStringLiteral( "<table class=\"list-view\">\n" );
554 const QVariantMap originalMetadata = mDataProvider ? mDataProvider->originalMetadata() : QVariantMap();
555
556 if ( originalMetadata.value( QStringLiteral( "creation_year" ) ).toInt() > 0 && originalMetadata.contains( QStringLiteral( "creation_doy" ) ) )
557 {
558 QDate creationDate( originalMetadata.value( QStringLiteral( "creation_year" ) ).toInt(), 1, 1 );
559 creationDate = creationDate.addDays( originalMetadata.value( QStringLiteral( "creation_doy" ) ).toInt() );
560
561 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
562 + tr( "Creation date" ) + QStringLiteral( "</td><td>" )
563 + creationDate.toString( Qt::ISODate )
564 + QStringLiteral( "</td></tr>\n" );
565 }
566 if ( originalMetadata.contains( QStringLiteral( "major_version" ) ) && originalMetadata.contains( QStringLiteral( "minor_version" ) ) )
567 {
568 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
569 + tr( "Version" ) + QStringLiteral( "</td><td>" )
570 + QStringLiteral( "%1.%2" ).arg( originalMetadata.value( QStringLiteral( "major_version" ) ).toString(),
571 originalMetadata.value( QStringLiteral( "minor_version" ) ).toString() )
572 + QStringLiteral( "</td></tr>\n" );
573 }
574
575 if ( !originalMetadata.value( QStringLiteral( "dataformat_id" ) ).toString().isEmpty() )
576 {
577 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
578 + tr( "Data format" ) + QStringLiteral( "</td><td>" )
579 + QStringLiteral( "%1 (%2)" ).arg( QgsPointCloudDataProvider::translatedDataFormatIds().value( originalMetadata.value( QStringLiteral( "dataformat_id" ) ).toInt() ),
580 originalMetadata.value( QStringLiteral( "dataformat_id" ) ).toString() ).trimmed()
581 + QStringLiteral( "</td></tr>\n" );
582 }
583
584 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
585 + tr( "Scale X" ) + QStringLiteral( "</td><td>" )
586 + QString::number( originalMetadata.value( QStringLiteral( "scale_x" ) ).toDouble() )
587 + QStringLiteral( "</td></tr>\n" );
588 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
589 + tr( "Scale Y" ) + QStringLiteral( "</td><td>" )
590 + QString::number( originalMetadata.value( QStringLiteral( "scale_y" ) ).toDouble() )
591 + QStringLiteral( "</td></tr>\n" );
592 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
593 + tr( "Scale Z" ) + QStringLiteral( "</td><td>" )
594 + QString::number( originalMetadata.value( QStringLiteral( "scale_z" ) ).toDouble() )
595 + QStringLiteral( "</td></tr>\n" );
596
597 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
598 + tr( "Offset X" ) + QStringLiteral( "</td><td>" )
599 + QString::number( originalMetadata.value( QStringLiteral( "offset_x" ) ).toDouble() )
600 + QStringLiteral( "</td></tr>\n" );
601 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
602 + tr( "Offset Y" ) + QStringLiteral( "</td><td>" )
603 + QString::number( originalMetadata.value( QStringLiteral( "offset_y" ) ).toDouble() )
604 + QStringLiteral( "</td></tr>\n" );
605 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
606 + tr( "Offset Z" ) + QStringLiteral( "</td><td>" )
607 + QString::number( originalMetadata.value( QStringLiteral( "offset_z" ) ).toDouble() )
608 + QStringLiteral( "</td></tr>\n" );
609
610 if ( !originalMetadata.value( QStringLiteral( "project_id" ) ).toString().isEmpty() )
611 {
612 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
613 + tr( "Project ID" ) + QStringLiteral( "</td><td>" )
614 + originalMetadata.value( QStringLiteral( "project_id" ) ).toString()
615 + QStringLiteral( "</td></tr>\n" );
616 }
617
618 if ( !originalMetadata.value( QStringLiteral( "system_id" ) ).toString().isEmpty() )
619 {
620 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
621 + tr( "System ID" ) + QStringLiteral( "</td><td>" )
622 + originalMetadata.value( QStringLiteral( "system_id" ) ).toString()
623 + QStringLiteral( "</td></tr>\n" );
624 }
625
626 if ( !originalMetadata.value( QStringLiteral( "software_id" ) ).toString().isEmpty() )
627 {
628 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
629 + tr( "Software ID" ) + QStringLiteral( "</td><td>" )
630 + originalMetadata.value( QStringLiteral( "software_id" ) ).toString()
631 + QStringLiteral( "</td></tr>\n" );
632 }
633
634 // End Provider section
635 myMetadata += QLatin1String( "</table>\n<br><br>" );
636
637 // identification section
638 myMetadata += QStringLiteral( "<h1>" ) + tr( "Identification" ) + QStringLiteral( "</h1>\n<hr>\n" );
639 myMetadata += htmlFormatter.identificationSectionHtml( );
640 myMetadata += QLatin1String( "<br><br>\n" );
641
642 // extent section
643 myMetadata += QStringLiteral( "<h1>" ) + tr( "Extent" ) + QStringLiteral( "</h1>\n<hr>\n" );
644 myMetadata += htmlFormatter.extentSectionHtml( isSpatial() );
645 myMetadata += QLatin1String( "<br><br>\n" );
646
647 // Start the Access section
648 myMetadata += QStringLiteral( "<h1>" ) + tr( "Access" ) + QStringLiteral( "</h1>\n<hr>\n" );
649 myMetadata += htmlFormatter.accessSectionHtml( );
650 myMetadata += QLatin1String( "<br><br>\n" );
651
652 // Attributes section
653 myMetadata += QStringLiteral( "<h1>" ) + tr( "Attributes" ) + QStringLiteral( "</h1>\n<hr>\n<table class=\"list-view\">\n" );
654
656
657 // count attributes
658 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Count" ) + QStringLiteral( "</td><td>" ) + QString::number( attrs.count() ) + QStringLiteral( "</td></tr>\n" );
659
660 myMetadata += QLatin1String( "</table>\n<br><table width=\"100%\" class=\"tabular-view\">\n" );
661 myMetadata += QLatin1String( "<tr><th>" ) + tr( "Attribute" ) + QLatin1String( "</th><th>" ) + tr( "Type" ) + QLatin1String( "</th></tr>\n" );
662
663 for ( int i = 0; i < attrs.count(); ++i )
664 {
665 const QgsPointCloudAttribute attribute = attrs.at( i );
666 QString rowClass;
667 if ( i % 2 )
668 rowClass = QStringLiteral( "class=\"odd-row\"" );
669 myMetadata += QLatin1String( "<tr " ) + rowClass + QLatin1String( "><td>" ) + attribute.name() + QLatin1String( "</td><td>" ) + attribute.displayType() + QLatin1String( "</td></tr>\n" );
670 }
671
672 //close field list
673 myMetadata += QLatin1String( "</table>\n<br><br>" );
674
675
676 // Start the contacts section
677 myMetadata += QStringLiteral( "<h1>" ) + tr( "Contacts" ) + QStringLiteral( "</h1>\n<hr>\n" );
678 myMetadata += htmlFormatter.contactsSectionHtml( );
679 myMetadata += QLatin1String( "<br><br>\n" );
680
681 // Start the links section
682 myMetadata += QStringLiteral( "<h1>" ) + tr( "Links" ) + QStringLiteral( "</h1>\n<hr>\n" );
683 myMetadata += htmlFormatter.linksSectionHtml( );
684 myMetadata += QLatin1String( "<br><br>\n" );
685
686 // Start the history section
687 myMetadata += QStringLiteral( "<h1>" ) + tr( "History" ) + QStringLiteral( "</h1>\n<hr>\n" );
688 myMetadata += htmlFormatter.historySectionHtml( );
689 myMetadata += QLatin1String( "<br><br>\n" );
690
691 myMetadata += QLatin1String( "\n</body>\n</html>\n" );
692 return myMetadata;
693}
694
696{
697 return mElevationProperties;
698}
699
701{
702 return mDataProvider ? mDataProvider->attributes() : QgsPointCloudAttributeCollection();
703}
704
706{
707 return mDataProvider ? mDataProvider->pointCount() : 0;
708}
709
711{
712 return mRenderer.get();
713}
714
716{
717 return mRenderer.get();
718}
719
721{
722 if ( renderer == mRenderer.get() )
723 return;
724
725 mRenderer.reset( renderer );
726 emit rendererChanged();
728
729 if ( mSync3DRendererTo2DRenderer )
731}
732
733bool QgsPointCloudLayer::setSubsetString( const QString &subset )
734{
735 if ( !isValid() || !mDataProvider )
736 {
737 QgsDebugMsgLevel( QStringLiteral( "invoked with invalid layer or null mDataProvider" ), 3 );
738 setCustomProperty( QStringLiteral( "storedSubsetString" ), subset );
739 return false;
740 }
741 else if ( subset == mDataProvider->subsetString() )
742 return true;
743
744 bool res = mDataProvider->setSubsetString( subset );
745 if ( res )
746 {
747 emit subsetStringChanged();
749 }
750 return res;
751}
752
754{
755 if ( !isValid() || !mDataProvider )
756 {
757 QgsDebugMsgLevel( QStringLiteral( "invoked with invalid layer or null mDataProvider" ), 3 );
758 return customProperty( QStringLiteral( "storedSubsetString" ) ).toString();
759 }
760 return mDataProvider->subsetString();
761}
762
764{
765 bool result = false;
767 if ( r )
768 {
769 result = r->convertFrom2DRenderer( renderer() );
770 setRenderer3D( r );
772 }
773 return result;
774}
775
777{
778 return mSync3DRendererTo2DRenderer;
779}
780
782{
783 mSync3DRendererTo2DRenderer = sync;
784 if ( sync )
786}
787
788void QgsPointCloudLayer::calculateStatistics()
789{
790 if ( !mDataProvider.get() || !mDataProvider->hasValidIndex() )
791 {
792 QgsMessageLog::logMessage( QObject::tr( "Failed to calculate statistics of the point cloud %1" ).arg( this->name() ) );
793 return;
794 }
795 if ( mStatsCalculationTask )
796 {
797 QgsMessageLog::logMessage( QObject::tr( "A statistics calculation task for the point cloud %1 is already in progress" ).arg( this->name() ) );
798 return;
799 }
800#ifdef HAVE_COPC
801 if ( mDataProvider && mDataProvider->index() && mDataProvider->index()->isValid() )
802 {
803 if ( QgsCopcPointCloudIndex *index = qobject_cast<QgsCopcPointCloudIndex *>( mDataProvider->index() ) )
804 {
805 mStatistics = index->readStatistics();
806 }
807 }
808#endif
809 if ( mStatistics.sampledPointsCount() != 0 )
810 {
812 emit statisticsCalculationStateChanged( mStatisticsCalculationState );
813 resetRenderer();
814 return;
815 }
816
817 QVector<QgsPointCloudAttribute> attributes = mDataProvider->attributes().attributes();
818 // Do not calculate stats for X, Y & Z since the point cloud index contains that
819 for ( int i = 0; i < attributes.size(); ++i )
820 {
821 if ( attributes[i].name() == QLatin1String( "X" ) || attributes[i].name() == QLatin1String( "Y" ) || attributes[i].name() == QLatin1String( "Z" ) )
822 {
823 attributes.remove( i );
824 --i;
825 }
826 }
827
828 QgsPointCloudStatsCalculationTask *task = new QgsPointCloudStatsCalculationTask( mDataProvider->index(), attributes, 1000000 );
829 connect( task, &QgsTask::taskCompleted, this, [this, task]()
830 {
831 mStatistics = task->calculationResults();
832
833 // fetch X, Y & Z stats directly from the index
834 QVector<QString> coordinateAttributes;
835 coordinateAttributes.push_back( QStringLiteral( "X" ) );
836 coordinateAttributes.push_back( QStringLiteral( "Y" ) );
837 coordinateAttributes.push_back( QStringLiteral( "Z" ) );
838
839 QMap<QString, QgsPointCloudAttributeStatistics> statsMap = mStatistics.statisticsMap();
840 QgsPointCloudIndex *index = mDataProvider->index();
841 for ( const QString &attribute : coordinateAttributes )
842 {
844 QVariant min = index->metadataStatistic( attribute, QgsStatisticalSummary::Min );
845 QVariant max = index->metadataStatistic( attribute, QgsStatisticalSummary::Max );
846 if ( !min.isValid() )
847 continue;
848 s.minimum = min.toDouble();
849 s.maximum = max.toDouble();
850 s.count = index->metadataStatistic( attribute, QgsStatisticalSummary::Count ).toInt();
851 s.mean = index->metadataStatistic( attribute, QgsStatisticalSummary::Mean ).toInt();
852 s.stDev = index->metadataStatistic( attribute, QgsStatisticalSummary::StDev ).toInt();
853 QVariantList classes = index->metadataClasses( attribute );
854 for ( const QVariant &c : classes )
855 {
856 s.classCount[ c.toInt() ] = index->metadataClassStatistic( attribute, c, QgsStatisticalSummary::Count ).toInt();
857 }
858 statsMap[ attribute ] = s;
859 }
860 mStatistics = QgsPointCloudStatistics( mStatistics.sampledPointsCount(), statsMap );
861 //
862
864 emit statisticsCalculationStateChanged( mStatisticsCalculationState );
865 resetRenderer();
866 mStatsCalculationTask = 0;
867#ifdef HAVE_COPC
868 if ( mDataProvider && mDataProvider->index() && mDataProvider->index()->isValid() && mDataProvider->name() == QLatin1String( "pdal" ) && mStatistics.sampledPointsCount() != 0 )
869 {
870 if ( QgsCopcPointCloudIndex *index = qobject_cast<QgsCopcPointCloudIndex *>( mDataProvider->index() ) )
871 {
872 index->writeStatistics( mStatistics );
873 }
874 }
875#endif
876 } );
877
878 // In case the statistics calculation fails, QgsTask::taskTerminated will be called
879 connect( task, &QgsTask::taskTerminated, this, [this]()
880 {
881 QgsMessageLog::logMessage( QObject::tr( "Failed to calculate statistics of the point cloud %1" ).arg( this->name() ) );
882 mStatsCalculationTask = 0;
883 } );
884
885 mStatsCalculationTask = QgsApplication::taskManager()->addTask( task );
886
888 emit statisticsCalculationStateChanged( mStatisticsCalculationState );
889}
890
891void QgsPointCloudLayer::resetRenderer()
892{
893 mDataProvider->loadIndex();
894 if ( !mLayerOptions.skipStatisticsCalculation && !mDataProvider->hasStatisticsMetadata() && statisticsCalculationState() == QgsPointCloudLayer::PointCloudStatisticsCalculationState::NotStarted )
895 {
896 calculateStatistics();
897 }
898 if ( !mRenderer || mRenderer->type() == QLatin1String( "extent" ) )
899 {
901 }
903
904 emit rendererChanged();
905}
Base class for point cloud 3D renderers.
virtual bool convertFrom2DRenderer(QgsPointCloudRenderer *renderer)=0
Updates the 3D renderer's symbol to match that of a given QgsPointCloudRenderer.
Abstract base class for objects which generate elevation profiles.
static QgsRuntimeProfiler * profiler()
Returns the application runtime profiler.
static QgsTaskManager * taskManager()
Returns the application's task manager, used for managing application wide background task handling.
Contains information about the context in which a coordinate transform is executed.
@ FlagLoadDefaultStyle
Reset the layer's style to the default for the datasource.
@ FlagTrustDataSource
Trust datasource config (primary key unicity, geometry type and srid, etc). Improves provider load ti...
@ ForceReadOnly
Open layer in a read-only mode (since QGIS 3.28)
@ SkipGetExtent
Skip the extent from provider.
void dataChanged()
Emitted whenever a change is made to the data provider which may have caused changes in the provider'...
QgsError is container for error messages (report).
Definition: qgserror.h:81
bool isEmpty() const
Test if any error is set.
Definition: qgserror.h:111
QString summary() const
Short error description, usually the first error in chain, the real error.
Definition: qgserror.cpp:129
Class for metadata formatter.
QString linksSectionHtml() const
Formats the "Links" section according to a metadata object.
QString extentSectionHtml(const bool showSpatialExtent=true) const
Formats the "Extents" section according to a metadata object (extent and temporal).
QString contactsSectionHtml() const
Formats the "Contacts" section according to a metadata object.
QString identificationSectionHtml() const
Formats the "Identification" section according to a metadata object.
QString historySectionHtml() const
Formats the "History" section according to a metadata object.
QString accessSectionHtml() const
Formats the "Access" section according to a metadata object.
Base class for storage of map layer elevation properties.
static QString typeToString(QgsMapLayerType type)
Converts a map layer type to a string value.
static QgsMapLayerLegend * defaultPointCloudLegend(QgsPointCloudLayer *layer)
Create new legend implementation for a point cloud layer.
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Base class for all map layer types.
Definition: qgsmaplayer.h:73
QString name
Definition: qgsmaplayer.h:76
void readStyleManager(const QDomNode &layerNode)
Read style manager's configuration (if any). To be called by subclasses.
virtual bool isSpatial() const
Returns true if the layer is considered a spatial layer, ie it has some form of geometry associated w...
QgsAbstract3DRenderer * renderer3D() const
Returns 3D renderer associated with the layer.
void setError(const QgsError &error)
Sets error message.
Definition: qgsmaplayer.h:1958
void writeStyleManager(QDomNode &layerNode, QDomDocument &doc) const
Write style manager's configuration (if exists). To be called by subclasses.
QString source() const
Returns the source for the layer.
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
QString providerType() const
Returns the provider type (provider key) for this layer.
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
void configChanged()
Emitted whenever the configuration is changed.
void trigger3DUpdate()
Will advise any 3D maps that this layer requires to be updated in the scene.
void setMinimumScale(double scale)
Sets the minimum map scale (i.e.
QgsMapLayer::LayerFlags flags() const
Returns the flags for this layer.
void writeCustomProperties(QDomNode &layerNode, QDomDocument &doc) const
Write custom properties to project file.
virtual QString loadDefaultStyle(bool &resultFlag)
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
QString mLayerName
Name of the layer - used for display.
Definition: qgsmaplayer.h:1975
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
QString crsHtmlMetadata() const
Returns a HTML fragment containing the layer's CRS metadata, for use in the htmlMetadata() method.
void setMaximumScale(double scale)
Sets the maximum map scale (i.e.
QgsLayerMetadata metadata
Definition: qgsmaplayer.h:78
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
virtual void setOpacity(double opacity)
Sets the opacity for the layer, where opacity is a value between 0 (totally transparent) and 1....
void readCustomProperties(const QDomNode &layerNode, const QString &keyStartsWith=QString())
Read custom properties from project file.
Q_INVOKABLE void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
QString mProviderKey
Data provider key (name of the data provider)
Definition: qgsmaplayer.h:2013
QgsCoordinateTransformContext transformContext() const
Returns the layer data provider coordinate transform context or a default transform context if the la...
void rendererChanged()
Signal emitted when renderer is changed.
void setScaleBasedVisibility(bool enabled)
Sets whether scale based visibility is enabled for the layer.
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
void emitStyleChanged()
Triggers an emission of the styleChanged() signal.
void dataChanged()
Data of layer changed.
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
void setName(const QString &name)
Set the display name of the layer.
virtual void setExtent(const QgsRectangle &rect)
Sets the extent.
bool isValid
Definition: qgsmaplayer.h:81
QString mDataSource
Data source description string, varies by layer type.
Definition: qgsmaplayer.h:1972
@ FlagReadExtentFromXml
Read extent from xml and skip get extent from provider.
Definition: qgsmaplayer.h:643
@ FlagTrustLayerMetadata
Trust layer metadata. Improves layer load time by skipping expensive checks like primary key unicity,...
Definition: qgsmaplayer.h:642
@ FlagForceReadOnly
Force open as read only.
Definition: qgsmaplayer.h:644
@ FlagDontResolveLayers
Don't resolve layer paths or create data providers for layers.
Definition: qgsmaplayer.h:641
void setValid(bool valid)
Sets whether layer is valid or not.
void readCommonStyle(const QDomElement &layerElement, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories)
Read style data common to all layer types.
QgsMapLayer::ReadFlags mReadFlags
Read flags. It's up to the subclass to respect these when restoring state from XML.
Definition: qgsmaplayer.h:2018
void setDataSource(const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag=false)
Updates the data source of the layer.
double minimumScale() const
Returns the minimum map scale (i.e.
void setLegend(QgsMapLayerLegend *legend)
Assign a legend controller to the map layer.
double opacity
Definition: qgsmaplayer.h:82
@ Symbology
Symbology.
Definition: qgsmaplayer.h:162
@ Rendering
Rendering: scale visibility, simplify method, opacity.
Definition: qgsmaplayer.h:171
@ Symbology3D
3D symbology
Definition: qgsmaplayer.h:163
@ CustomProperties
Custom properties (by plugins for instance)
Definition: qgsmaplayer.h:172
void setRenderer3D(QgsAbstract3DRenderer *renderer)
Sets 3D renderer for the layer.
QString generalHtmlMetadata() const
Returns an HTML fragment containing general metadata information, for use in the htmlMetadata() metho...
void writeCommonStyle(QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const
Write style data common to all layer types.
double maximumScale() const
Returns the maximum map scale (i.e.
void invalidateWgs84Extent()
Invalidates the WGS84 extent.
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
static QgsPainting::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
Definition: qgspainting.cpp:80
static QPainter::CompositionMode getCompositionMode(QgsPainting::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
Definition: qgspainting.cpp:20
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer.
Definition: qgspainting.h:37
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
Collection of point cloud attributes.
const QgsPointCloudAttribute & at(int index) const
Returns the attribute at the specified index.
int count() const
Returns the number of attributes present in the collection.
Attribute for point cloud data pair of name and size in bytes.
QString displayType() const
Returns the type to use when displaying this field.
QString name() const
Returns name of the attribute.
Base class for providing data for QgsPointCloudLayer.
@ CreateRenderer
Provider can create 2D renderers using backend-specific formatting information. See QgsPointCloudData...
static QMap< int, QString > translatedDataFormatIds()
Returns the map of LAS data format ID to translated string value.
void indexGenerationStateChanged(QgsPointCloudDataProvider::PointCloudIndexGenerationState state)
Emitted when point cloud generation state is changed.
PointCloudIndexGenerationState
Point cloud index state.
@ NotIndexed
Provider has no index available.
@ Indexing
Provider try to index the source data.
@ Indexed
The index is ready to be used.
Represents a indexed point clouds data in octree.
virtual QVariant metadataClassStatistic(const QString &attribute, const QVariant &value, QgsStatisticalSummary::Statistic statistic) const
Returns the statistic statistic of the class value of the attribute attribute.
virtual QVariantList metadataClasses(const QString &attribute) const
Returns the classes of attribute.
virtual QVariant metadataStatistic(const QString &attribute, QgsStatisticalSummary::Statistic statistic) const
Returns the statistic statistic of attribute.
Point cloud layer specific subclass of QgsMapLayerElevationProperties.
QgsPointCloudLayerElevationProperties * clone() const override
Creates a clone of the properties.
Implementation of QgsAbstractProfileGenerator for point cloud layers.
Implementation of threaded rendering for point cloud layers.
Represents a map layer supporting display of point clouds.
QString decodedSource(const QString &source, const QString &dataProvider, const QgsReadWriteContext &context) const override
Called by readLayerXML(), used by derived classes to decode provider's specific data source from proj...
QString htmlMetadata() const override
Obtain a formatted HTML string containing assorted metadata for this layer.
void setSync3DRendererTo2DRenderer(bool sync)
Sets whether this layer's 3D renderer should be automatically updated with changes applied to the lay...
QgsMapLayerElevationProperties * elevationProperties() override
Returns the layer's elevation properties.
@ Calculated
The statistics calculation task is done and statistics are available.
@ NotStarted
The statistics calculation task has not been started.
@ Calculating
The statistics calculation task is running.
bool sync3DRendererTo2DRenderer() const
Returns whether this layer's 3D renderer should be automatically updated with changes applied to the ...
bool writeXml(QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context) const override
Called by writeLayerXML(), used by children to write state specific to them to project files.
QgsRectangle extent() const override
Returns the extent of the layer.
QString encodedSource(const QString &source, const QgsReadWriteContext &context) const override
Called by writeLayerXML(), used by derived classes to encode provider's specific data source to proje...
QgsPointCloudRenderer * renderer()
Returns the 2D renderer for the point cloud.
bool convertRenderer3DFromRenderer2D()
Updates the layer's 3D renderer's symbol to match that of the layer's 2D renderer.
qint64 pointCount() const
Returns the total number of points available in the layer.
bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const override
Write the style for the layer into the document provided.
void raiseError(const QString &msg)
Signals an error related to this point cloud layer.
PointCloudStatisticsCalculationState statisticsCalculationState() const
Returns the status of point cloud statistics calculation.
QgsPointCloudDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
void statisticsCalculationStateChanged(QgsPointCloudLayer::PointCloudStatisticsCalculationState state)
Emitted when statistics calculation state has changed.
bool readSymbology(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) override
Read the symbology for the current layer from the DOM node supplied.
bool readXml(const QDomNode &layerNode, QgsReadWriteContext &context) override
Called by readLayerXML(), used by children to read state specific to them from project files.
QString subsetString() const
Returns the string used to define a subset of the layer.
QgsPointCloudLayer(const QString &uri=QString(), const QString &baseName=QString(), const QString &providerLib=QStringLiteral("pointcloud"), const QgsPointCloudLayer::LayerOptions &options=QgsPointCloudLayer::LayerOptions())
Constructor - creates a point cloud layer.
bool setSubsetString(const QString &subset)
Sets the string used to define a subset of the layer.
QgsPointCloudLayer * clone() const override
Returns a new instance equivalent to this one except for the id which is still unique.
bool readStyle(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) FINAL
Read the style for the current layer from the DOM node supplied.
bool writeStyle(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const FINAL
Write just the symbology information for the layer into the document.
void setRenderer(QgsPointCloudRenderer *renderer)
Sets the 2D renderer for the point cloud.
QString loadDefaultStyle(bool &resultFlag) FINAL
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
QgsPointCloudAttributeCollection attributes() const
Returns the attributes available from the layer.
void subsetStringChanged()
Emitted when the layer's subset string has changed.
void setTransformContext(const QgsCoordinateTransformContext &transformContext) override
Sets the coordinate transform context to transformContext.
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
QgsAbstractProfileGenerator * createProfileGenerator(const QgsProfileRequest &request) override
Given a profile request, returns a new profile generator ready for generating elevation profiles.
static QgsPointCloudRenderer * defaultRenderer(const QgsPointCloudLayer *layer)
Returns a new default point cloud renderer for a specified layer.
Abstract base class for 2d point cloud renderers.
static QgsPointCloudRenderer * load(QDomElement &element, const QgsReadWriteContext &context)
Creates a renderer from an XML element.
Class used to store statistics of a point cloud dataset.
int sampledPointsCount() const
Returns the number of points used to calculate the statistics.
QMap< QString, QgsPointCloudAttributeStatistics > statisticsMap() const
Returns a map object containing all the statistics.
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
QString encodeUri(const QString &providerKey, const QVariantMap &parts)
Reassembles a provider data source URI from its component paths (e.g.
The class is used as a container of context for various read/write operations on other objects.
QgsCoordinateTransformContext transformContext() const
Returns data provider coordinate transform context.
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
Contains information about the context of a rendering operation.
@ StDev
Standard deviation of values.
long addTask(QgsTask *task, int priority=0)
Adds a task to the manager.
Abstract base class for long running background tasks.
void taskCompleted()
Will be emitted by task to indicate its successful completion.
void taskTerminated()
Will be emitted by task if it has terminated for any reason other then completion (e....
static QgsRectangle readRectangle(const QDomElement &element)
Definition: qgsxmlutils.cpp:39
QgsMapLayerType
Types of layers that can be added to a map.
Definition: qgis.h:47
@ PointCloudLayer
Point cloud layer. Added in QGIS 3.18.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
Setting options for creating vector data providers.
Class used to store statistics of one attribute of a point cloud dataset.
Setting options for loading point cloud layers.
bool skipStatisticsCalculation
Set to true if the statistics calculation for this point cloud is disabled.
bool loadDefaultStyle
Set to true if the default layer style should be loaded.
bool skipIndexGeneration
Set to true if point cloud index generation should be skipped.
QgsCoordinateTransformContext transformContext
Coordinate transform context.