QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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"
22#include "qgsrectangle.h"
24#include "qgsproviderregistry.h"
25#include "qgslogger.h"
28#include "qgsruntimeprofiler.h"
29#include "qgsapplication.h"
30#include "qgspainting.h"
33#include "qgsmaplayerlegend.h"
34#include "qgsxmlutils.h"
35#include "qgsmaplayerfactory.h"
38#include "qgsmessagelog.h"
39#include "qgstaskmanager.h"
40#include "qgsthreadingutils.h"
42#ifdef HAVE_COPC
44#endif
45
46#include <QUrl>
47
49 const QString &baseName,
50 const QString &providerLib,
52 : QgsMapLayer( Qgis::LayerType::PointCloud, baseName, uri )
53 , mElevationProperties( new QgsPointCloudLayerElevationProperties( this ) )
54 , mLayerOptions( options )
55{
56 if ( !uri.isEmpty() && !providerLib.isEmpty() )
57 {
58 const QgsDataProvider::ProviderOptions providerOptions { options.transformContext };
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 mStatsCalculationTask = 0;
76 task->cancel();
77 task->waitForFinished();
78 }
79}
80
82{
84
85 QgsPointCloudLayer *layer = new QgsPointCloudLayer( source(), name(), mProviderKey, mLayerOptions );
86 QgsMapLayer::clone( layer );
87
88 if ( mRenderer )
89 layer->setRenderer( mRenderer->clone() );
90
91 layer->mElevationProperties = mElevationProperties->clone();
92 layer->mElevationProperties->setParent( layer );
93
94 layer->mLayerOptions = mLayerOptions;
95 layer->mSync3DRendererTo2DRenderer = mSync3DRendererTo2DRenderer;
96
97 return layer;
98}
99
101{
103
104 if ( !mDataProvider )
105 return QgsRectangle();
106
107 return mDataProvider->extent();
108}
109
111{
113
114 if ( mRenderer->type() != QLatin1String( "extent" ) )
115 loadIndexesForRenderContext( rendererContext );
116
117 return new QgsPointCloudLayerRenderer( this, rendererContext );
118}
119
121{
123
124 return new QgsPointCloudLayerProfileGenerator( this, request );
125}
126
128{
129 // BAD! 2D rendering of point clouds is NOT thread safe
131
132 return mDataProvider.get();
133}
134
136{
138
139 return mDataProvider.get();
140}
141
142bool QgsPointCloudLayer::readXml( const QDomNode &layerNode, QgsReadWriteContext &context )
143{
145
146 // create provider
147 const QDomNode pkeyNode = layerNode.namedItem( QStringLiteral( "provider" ) );
148 mProviderKey = pkeyNode.toElement().text();
149
151 {
152 const QgsDataProvider::ProviderOptions providerOptions { context.transformContext() };
154 // read extent
156 {
157 const QDomNode extentNode = layerNode.namedItem( QStringLiteral( "extent" ) );
158 if ( !extentNode.isNull() )
159 {
160 // get the extent
161 const QgsRectangle mbr = QgsXmlUtils::readRectangle( extentNode.toElement() );
162
163 // store the extent
164 setExtent( mbr );
165 }
166 }
167
169 const QDomNode subset = layerNode.namedItem( QStringLiteral( "subset" ) );
170 const QString subsetText = subset.toElement().text();
171 if ( !subsetText.isEmpty() )
172 setSubsetString( subsetText );
173 }
174
175 if ( !isValid() )
176 {
177 return false;
178 }
179
180 QString errorMsg;
181 if ( !readSymbology( layerNode, errorMsg, context ) )
182 return false;
183
184 readStyleManager( layerNode );
185 return true;
186}
187
188bool QgsPointCloudLayer::writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const
189{
191
192 QDomElement mapLayerNode = layerNode.toElement();
193 mapLayerNode.setAttribute( QStringLiteral( "type" ), QgsMapLayerFactory::typeToString( Qgis::LayerType::PointCloud ) );
194
195 if ( !subsetString().isEmpty() )
196 {
197 QDomElement subset = doc.createElement( QStringLiteral( "subset" ) );
198 const QDomText subsetText = doc.createTextNode( subsetString() );
199 subset.appendChild( subsetText );
200 layerNode.appendChild( subset );
201 }
202 if ( mDataProvider )
203 {
204 QDomElement provider = doc.createElement( QStringLiteral( "provider" ) );
205 const QDomText providerText = doc.createTextNode( providerType() );
206 provider.appendChild( providerText );
207 layerNode.appendChild( provider );
208 }
209
210 writeStyleManager( layerNode, doc );
211
212 QString errorMsg;
213 return writeSymbology( layerNode, doc, errorMsg, context );
214}
215
216bool QgsPointCloudLayer::readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
217{
219
220 const QDomElement elem = node.toElement();
221
222 readCommonStyle( elem, context, categories );
223
224 readStyle( node, errorMessage, context, categories );
225
226 if ( categories.testFlag( CustomProperties ) )
227 readCustomProperties( node, QStringLiteral( "variable" ) );
228
229 return true;
230}
231
232bool QgsPointCloudLayer::readStyle( const QDomNode &node, QString &, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
233{
235
236 bool result = true;
237
238 if ( categories.testFlag( Symbology3D ) )
239 {
240 bool ok;
241 bool sync = node.attributes().namedItem( QStringLiteral( "sync3DRendererTo2DRenderer" ) ).nodeValue().toInt( &ok );
242 if ( ok )
244 }
245
246 if ( categories.testFlag( Symbology ) )
247 {
248 QDomElement rendererElement = node.firstChildElement( QStringLiteral( "renderer" ) );
249 if ( !rendererElement.isNull() )
250 {
251 std::unique_ptr< QgsPointCloudRenderer > r( QgsPointCloudRenderer::load( rendererElement, context ) );
252 if ( r )
253 {
254 setRenderer( r.release() );
255 }
256 else
257 {
258 result = false;
259 }
260 }
261 // make sure layer has a renderer - if none exists, fallback to a default renderer
262 if ( !mRenderer )
263 {
265 }
266 }
267
268 if ( categories.testFlag( Symbology ) )
269 {
270 // get and set the blend mode if it exists
271 const QDomNode blendModeNode = node.namedItem( QStringLiteral( "blendMode" ) );
272 if ( !blendModeNode.isNull() )
273 {
274 const QDomElement e = blendModeNode.toElement();
275 setBlendMode( QgsPainting::getCompositionMode( static_cast< Qgis::BlendMode >( e.text().toInt() ) ) );
276 }
277 }
278
279 // get and set the layer transparency and scale visibility if they exists
280 if ( categories.testFlag( Rendering ) )
281 {
282 const QDomNode layerOpacityNode = node.namedItem( QStringLiteral( "layerOpacity" ) );
283 if ( !layerOpacityNode.isNull() )
284 {
285 const QDomElement e = layerOpacityNode.toElement();
286 setOpacity( e.text().toDouble() );
287 }
288
289 const bool hasScaleBasedVisibiliy { node.attributes().namedItem( QStringLiteral( "hasScaleBasedVisibilityFlag" ) ).nodeValue() == '1' };
290 setScaleBasedVisibility( hasScaleBasedVisibiliy );
291 bool ok;
292 const double maxScale { node.attributes().namedItem( QStringLiteral( "maxScale" ) ).nodeValue().toDouble( &ok ) };
293 if ( ok )
294 {
295 setMaximumScale( maxScale );
296 }
297 const double minScale { node.attributes().namedItem( QStringLiteral( "minScale" ) ).nodeValue().toDouble( &ok ) };
298 if ( ok )
299 {
300 setMinimumScale( minScale );
301 }
302 }
303 return result;
304}
305
306bool QgsPointCloudLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
307 const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
308{
310
311 Q_UNUSED( errorMessage )
312
313 QDomElement elem = node.toElement();
314 writeCommonStyle( elem, doc, context, categories );
315
316 ( void )writeStyle( node, doc, errorMessage, context, categories );
317
318 return true;
319}
320
321bool QgsPointCloudLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &, const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
322{
324
325 QDomElement mapLayerNode = node.toElement();
326
327 if ( categories.testFlag( Symbology3D ) )
328 {
329 mapLayerNode.setAttribute( QStringLiteral( "sync3DRendererTo2DRenderer" ), mSync3DRendererTo2DRenderer ? 1 : 0 );
330 }
331
332 if ( categories.testFlag( Symbology ) )
333 {
334 if ( mRenderer )
335 {
336 const QDomElement rendererElement = mRenderer->save( doc, context );
337 node.appendChild( rendererElement );
338 }
339 }
340
341 //save customproperties
342 if ( categories.testFlag( CustomProperties ) )
343 {
344 writeCustomProperties( node, doc );
345 }
346
347 if ( categories.testFlag( Symbology ) )
348 {
349 // add the blend mode field
350 QDomElement blendModeElem = doc.createElement( QStringLiteral( "blendMode" ) );
351 const QDomText blendModeText = doc.createTextNode( QString::number( static_cast< int >( QgsPainting::getBlendModeEnum( blendMode() ) ) ) );
352 blendModeElem.appendChild( blendModeText );
353 node.appendChild( blendModeElem );
354 }
355
356 // add the layer opacity and scale visibility
357 if ( categories.testFlag( Rendering ) )
358 {
359 QDomElement layerOpacityElem = doc.createElement( QStringLiteral( "layerOpacity" ) );
360 const QDomText layerOpacityText = doc.createTextNode( QString::number( opacity() ) );
361 layerOpacityElem.appendChild( layerOpacityText );
362 node.appendChild( layerOpacityElem );
363
364 mapLayerNode.setAttribute( QStringLiteral( "hasScaleBasedVisibilityFlag" ), hasScaleBasedVisibility() ? 1 : 0 );
365 mapLayerNode.setAttribute( QStringLiteral( "maxScale" ), maximumScale() );
366 mapLayerNode.setAttribute( QStringLiteral( "minScale" ), minimumScale() );
367 }
368 return true;
369}
370
372{
374
375 if ( mDataProvider )
376 mDataProvider->setTransformContext( transformContext );
378}
379
380void QgsPointCloudLayer::setDataSourcePrivate( const QString &dataSource, const QString &baseName, const QString &provider,
382{
384
385 if ( mDataProvider )
386 {
387 disconnect( mDataProvider.get(), &QgsPointCloudDataProvider::dataChanged, this, &QgsPointCloudLayer::dataChanged );
388 disconnect( mDataProvider.get(), &QgsPointCloudDataProvider::indexGenerationStateChanged, this, &QgsPointCloudLayer::onPointCloudIndexGenerationStateChanged );
389 }
390
391 setName( baseName );
392 mProviderKey = provider;
393 mDataSource = dataSource;
394
395 if ( mPreloadedProvider )
396 {
397 mDataProvider.reset( qobject_cast< QgsPointCloudDataProvider * >( mPreloadedProvider.release() ) );
398 }
399 else
400 {
401 std::unique_ptr< QgsScopedRuntimeProfile > profile;
402 if ( QgsApplication::profiler()->groupIsActive( QStringLiteral( "projectload" ) ) )
403 profile = std::make_unique< QgsScopedRuntimeProfile >( tr( "Create %1 provider" ).arg( provider ), QStringLiteral( "projectload" ) );
404 mDataProvider.reset( qobject_cast<QgsPointCloudDataProvider *>( QgsProviderRegistry::instance()->createProvider( provider, dataSource, options, flags ) ) );
405 }
406
407 if ( !mDataProvider )
408 {
409 QgsDebugError( QStringLiteral( "Unable to get point cloud data provider" ) );
410 setValid( false );
411 return;
412 }
413
414 mDataProvider->setParent( this );
415 QgsDebugMsgLevel( QStringLiteral( "Instantiated the point cloud data provider plugin" ), 2 );
416
417 setValid( mDataProvider->isValid() );
418 if ( !isValid() )
419 {
420 QgsDebugError( QStringLiteral( "Invalid point cloud provider plugin %1" ).arg( QString( mDataSource.toUtf8() ) ) );
421 setError( mDataProvider->error() );
422 return;
423 }
424
425 connect( mDataProvider.get(), &QgsPointCloudDataProvider::indexGenerationStateChanged, this, &QgsPointCloudLayer::onPointCloudIndexGenerationStateChanged );
426 connect( mDataProvider.get(), &QgsPointCloudDataProvider::dataChanged, this, &QgsPointCloudLayer::dataChanged );
427
428 // Load initial extent, crs and renderer
429 setCrs( mDataProvider->crs() );
431 {
432 setExtent3D( mDataProvider->extent3D() );
433 }
434
435 bool loadDefaultStyleFlag = false;
437 {
438 loadDefaultStyleFlag = true;
439 }
440
441 if ( !mLayerOptions.skipIndexGeneration &&
442 mDataProvider &&
443 mDataProvider->indexingState() != QgsPointCloudDataProvider::PointCloudIndexGenerationState::Indexed &&
444 mDataProvider->pointCount() > 0 )
445 {
446 mDataProvider->generateIndex();
447 }
448
449 if ( !mLayerOptions.skipStatisticsCalculation &&
450 mDataProvider &&
451 !mDataProvider->hasStatisticsMetadata() &&
452 mDataProvider->indexingState() == QgsPointCloudDataProvider::PointCloudIndexGenerationState::Indexed &&
453 mDataProvider->pointCount() > 0 )
454 {
455 calculateStatistics();
456 }
457
458 // Note: we load the statistics from the data provider regardless of it being an existing metadata (do not check for hasStatisticsMetadata)
459 // since the X, Y & Z coordinates will be in the header of the dataset
460 if ( mDataProvider && mDataProvider->isValid() && mStatistics.sampledPointsCount() == 0 && mDataProvider->indexingState() == QgsPointCloudDataProvider::Indexed )
461 {
462 mStatistics = mDataProvider->metadataStatistics();
463 }
464
465 if ( !mRenderer || loadDefaultStyleFlag )
466 {
467 std::unique_ptr< QgsScopedRuntimeProfile > profile;
468 if ( QgsApplication::profiler()->groupIsActive( QStringLiteral( "projectload" ) ) )
469 profile = std::make_unique< QgsScopedRuntimeProfile >( tr( "Load layer style" ), QStringLiteral( "projectload" ) );
470
471 bool defaultLoadedFlag = false;
472
473 if ( loadDefaultStyleFlag && isSpatial() && mDataProvider->capabilities() & QgsPointCloudDataProvider::CreateRenderer )
474 {
475 // first try to create a renderer directly from the data provider
476 std::unique_ptr< QgsPointCloudRenderer > defaultRenderer( mDataProvider->createRenderer() );
477 if ( defaultRenderer )
478 {
479 defaultLoadedFlag = true;
480 setRenderer( defaultRenderer.release() );
481 }
482 }
483
484 if ( !defaultLoadedFlag && loadDefaultStyleFlag )
485 {
486 loadDefaultStyle( defaultLoadedFlag );
487 }
488
489 if ( !defaultLoadedFlag )
490 {
491 // all else failed, create default renderer
493 }
494 }
495}
496
497QString QgsPointCloudLayer::encodedSource( const QString &source, const QgsReadWriteContext &context ) const
498{
500
502}
503
504QString QgsPointCloudLayer::decodedSource( const QString &source, const QString &dataProvider, const QgsReadWriteContext &context ) const
505{
507
509}
510
511void QgsPointCloudLayer::onPointCloudIndexGenerationStateChanged( QgsPointCloudDataProvider::PointCloudIndexGenerationState state )
512{
514
515 switch ( state )
516 {
518 {
519 resetRenderer();
520 break;
521 }
523 {
524 QgsError providerError = mDataProvider->error();
525 if ( !providerError.isEmpty() )
526 {
527 setError( providerError );
528 emit raiseError( providerError.summary() );
529 }
530 break;
531 }
533 break;
534 }
535}
536
537
538QString QgsPointCloudLayer::loadDefaultStyle( bool &resultFlag )
539{
541
542 if ( mDataProvider->capabilities() & QgsPointCloudDataProvider::CreateRenderer )
543 {
544 // first try to create a renderer directly from the data provider
545 std::unique_ptr< QgsPointCloudRenderer > defaultRenderer( mDataProvider->createRenderer() );
546 if ( defaultRenderer )
547 {
548 resultFlag = true;
549 setRenderer( defaultRenderer.release() );
550 return QString();
551 }
552 }
553
554 return QgsMapLayer::loadDefaultStyle( resultFlag );
555}
556
558{
560
561 const QgsLayerMetadataFormatter htmlFormatter( metadata() );
562 QString myMetadata = QStringLiteral( "<html>\n<body>\n" );
563
564 myMetadata += generalHtmlMetadata();
565
566 // Begin Provider section
567 myMetadata += QStringLiteral( "<h1>" ) + tr( "Information from provider" ) + QStringLiteral( "</h1>\n<hr>\n" );
568 myMetadata += QLatin1String( "<table class=\"list-view\">\n" );
569
570 // Extent
571 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Extent" ) + QStringLiteral( "</td><td>" ) + extent().toString() + QStringLiteral( "</td></tr>\n" );
572
573 // feature count
574 QLocale locale = QLocale();
575 locale.setNumberOptions( locale.numberOptions() &= ~QLocale::NumberOption::OmitGroupSeparator );
576 const qint64 pointCount = mDataProvider ? mDataProvider->pointCount() : -1;
577 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
578 + tr( "Point count" ) + QStringLiteral( "</td><td>" )
579 + ( pointCount < 0 ? tr( "unknown" ) : locale.toString( static_cast<qlonglong>( pointCount ) ) )
580 + QStringLiteral( "</td></tr>\n" );
581
582 if ( const QgsPointCloudDataProvider *provider = dataProvider() )
583 {
584 myMetadata += provider->htmlMetadata();
585 }
586
587 myMetadata += QLatin1String( "</table>\n<br><br>" );
588
589 // CRS
590 myMetadata += crsHtmlMetadata();
591
592 // provider metadata section
593 myMetadata += QStringLiteral( "<h1>" ) + tr( "Metadata" ) + QStringLiteral( "</h1>\n<hr>\n" ) + QStringLiteral( "<table class=\"list-view\">\n" );
594 const QVariantMap originalMetadata = mDataProvider ? mDataProvider->originalMetadata() : QVariantMap();
595
596 if ( originalMetadata.value( QStringLiteral( "creation_year" ) ).toInt() > 0 && originalMetadata.contains( QStringLiteral( "creation_doy" ) ) )
597 {
598 QDate creationDate( originalMetadata.value( QStringLiteral( "creation_year" ) ).toInt(), 1, 1 );
599 creationDate = creationDate.addDays( originalMetadata.value( QStringLiteral( "creation_doy" ) ).toInt() );
600
601 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
602 + tr( "Creation date" ) + QStringLiteral( "</td><td>" )
603 + creationDate.toString( Qt::ISODate )
604 + QStringLiteral( "</td></tr>\n" );
605 }
606 if ( originalMetadata.contains( QStringLiteral( "major_version" ) ) && originalMetadata.contains( QStringLiteral( "minor_version" ) ) )
607 {
608 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
609 + tr( "Version" ) + QStringLiteral( "</td><td>" )
610 + QStringLiteral( "%1.%2" ).arg( originalMetadata.value( QStringLiteral( "major_version" ) ).toString(),
611 originalMetadata.value( QStringLiteral( "minor_version" ) ).toString() )
612 + QStringLiteral( "</td></tr>\n" );
613 }
614
615 if ( !originalMetadata.value( QStringLiteral( "dataformat_id" ) ).toString().isEmpty() )
616 {
617 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
618 + tr( "Data format" ) + QStringLiteral( "</td><td>" )
619 + QStringLiteral( "%1 (%2)" ).arg( QgsPointCloudDataProvider::translatedDataFormatIds().value( originalMetadata.value( QStringLiteral( "dataformat_id" ) ).toInt() ),
620 originalMetadata.value( QStringLiteral( "dataformat_id" ) ).toString() ).trimmed()
621 + QStringLiteral( "</td></tr>\n" );
622 }
623
624 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
625 + tr( "Scale X" ) + QStringLiteral( "</td><td>" )
626 + QString::number( originalMetadata.value( QStringLiteral( "scale_x" ) ).toDouble() )
627 + QStringLiteral( "</td></tr>\n" );
628 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
629 + tr( "Scale Y" ) + QStringLiteral( "</td><td>" )
630 + QString::number( originalMetadata.value( QStringLiteral( "scale_y" ) ).toDouble() )
631 + QStringLiteral( "</td></tr>\n" );
632 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
633 + tr( "Scale Z" ) + QStringLiteral( "</td><td>" )
634 + QString::number( originalMetadata.value( QStringLiteral( "scale_z" ) ).toDouble() )
635 + QStringLiteral( "</td></tr>\n" );
636
637 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
638 + tr( "Offset X" ) + QStringLiteral( "</td><td>" )
639 + QString::number( originalMetadata.value( QStringLiteral( "offset_x" ) ).toDouble() )
640 + QStringLiteral( "</td></tr>\n" );
641 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
642 + tr( "Offset Y" ) + QStringLiteral( "</td><td>" )
643 + QString::number( originalMetadata.value( QStringLiteral( "offset_y" ) ).toDouble() )
644 + QStringLiteral( "</td></tr>\n" );
645 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
646 + tr( "Offset Z" ) + QStringLiteral( "</td><td>" )
647 + QString::number( originalMetadata.value( QStringLiteral( "offset_z" ) ).toDouble() )
648 + QStringLiteral( "</td></tr>\n" );
649
650 if ( !originalMetadata.value( QStringLiteral( "project_id" ) ).toString().isEmpty() )
651 {
652 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
653 + tr( "Project ID" ) + QStringLiteral( "</td><td>" )
654 + originalMetadata.value( QStringLiteral( "project_id" ) ).toString()
655 + QStringLiteral( "</td></tr>\n" );
656 }
657
658 if ( !originalMetadata.value( QStringLiteral( "system_id" ) ).toString().isEmpty() )
659 {
660 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
661 + tr( "System ID" ) + QStringLiteral( "</td><td>" )
662 + originalMetadata.value( QStringLiteral( "system_id" ) ).toString()
663 + QStringLiteral( "</td></tr>\n" );
664 }
665
666 if ( !originalMetadata.value( QStringLiteral( "software_id" ) ).toString().isEmpty() )
667 {
668 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
669 + tr( "Software ID" ) + QStringLiteral( "</td><td>" )
670 + originalMetadata.value( QStringLiteral( "software_id" ) ).toString()
671 + QStringLiteral( "</td></tr>\n" );
672 }
673
674 // End Provider section
675 myMetadata += QLatin1String( "</table>\n<br><br>" );
676
677 // identification section
678 myMetadata += QStringLiteral( "<h1>" ) + tr( "Identification" ) + QStringLiteral( "</h1>\n<hr>\n" );
679 myMetadata += htmlFormatter.identificationSectionHtml( );
680 myMetadata += QLatin1String( "<br><br>\n" );
681
682 // extent section
683 myMetadata += QStringLiteral( "<h1>" ) + tr( "Extent" ) + QStringLiteral( "</h1>\n<hr>\n" );
684 myMetadata += htmlFormatter.extentSectionHtml( isSpatial() );
685 myMetadata += QLatin1String( "<br><br>\n" );
686
687 // Start the Access section
688 myMetadata += QStringLiteral( "<h1>" ) + tr( "Access" ) + QStringLiteral( "</h1>\n<hr>\n" );
689 myMetadata += htmlFormatter.accessSectionHtml( );
690 myMetadata += QLatin1String( "<br><br>\n" );
691
692 // Attributes section
693 myMetadata += QStringLiteral( "<h1>" ) + tr( "Attributes" ) + QStringLiteral( "</h1>\n<hr>\n<table class=\"list-view\">\n" );
694
696
697 // count attributes
698 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Count" ) + QStringLiteral( "</td><td>" ) + QString::number( attrs.count() ) + QStringLiteral( "</td></tr>\n" );
699
700 myMetadata += QLatin1String( "</table>\n<br><table width=\"100%\" class=\"tabular-view\">\n" );
701 myMetadata += QLatin1String( "<tr><th>" ) + tr( "Attribute" ) + QLatin1String( "</th><th>" ) + tr( "Type" ) + QLatin1String( "</th></tr>\n" );
702
703 for ( int i = 0; i < attrs.count(); ++i )
704 {
705 const QgsPointCloudAttribute attribute = attrs.at( i );
706 QString rowClass;
707 if ( i % 2 )
708 rowClass = QStringLiteral( "class=\"odd-row\"" );
709 myMetadata += QLatin1String( "<tr " ) + rowClass + QLatin1String( "><td>" ) + attribute.name() + QLatin1String( "</td><td>" ) + attribute.displayType() + QLatin1String( "</td></tr>\n" );
710 }
711
712 //close field list
713 myMetadata += QLatin1String( "</table>\n<br><br>" );
714
715
716 // Start the contacts section
717 myMetadata += QStringLiteral( "<h1>" ) + tr( "Contacts" ) + QStringLiteral( "</h1>\n<hr>\n" );
718 myMetadata += htmlFormatter.contactsSectionHtml( );
719 myMetadata += QLatin1String( "<br><br>\n" );
720
721 // Start the links section
722 myMetadata += QStringLiteral( "<h1>" ) + tr( "Links" ) + QStringLiteral( "</h1>\n<hr>\n" );
723 myMetadata += htmlFormatter.linksSectionHtml( );
724 myMetadata += QLatin1String( "<br><br>\n" );
725
726 // Start the history section
727 myMetadata += QStringLiteral( "<h1>" ) + tr( "History" ) + QStringLiteral( "</h1>\n<hr>\n" );
728 myMetadata += htmlFormatter.historySectionHtml( );
729 myMetadata += QLatin1String( "<br><br>\n" );
730
731 myMetadata += QLatin1String( "\n</body>\n</html>\n" );
732 return myMetadata;
733}
734
736{
738
739 return mElevationProperties;
740}
741
743{
745
746 return mDataProvider ? mDataProvider->attributes() : QgsPointCloudAttributeCollection();
747}
748
750{
752
753 return mDataProvider ? mDataProvider->pointCount() : 0;
754}
755
757{
759
760 return mRenderer.get();
761}
762
764{
766
767 return mRenderer.get();
768}
769
771{
773
774 if ( renderer == mRenderer.get() )
775 return;
776
777 mRenderer.reset( renderer );
778 emit rendererChanged();
780
781 if ( mSync3DRendererTo2DRenderer )
783}
784
785bool QgsPointCloudLayer::setSubsetString( const QString &subset )
786{
788
789 if ( !isValid() || !mDataProvider )
790 {
791 QgsDebugMsgLevel( QStringLiteral( "invoked with invalid layer or null mDataProvider" ), 3 );
792 setCustomProperty( QStringLiteral( "storedSubsetString" ), subset );
793 return false;
794 }
795 else if ( subset == mDataProvider->subsetString() )
796 return true;
797
798 bool res = mDataProvider->setSubsetString( subset );
799 if ( res )
800 {
801 emit subsetStringChanged();
803 }
804 return res;
805}
806
808{
810
811 if ( !isValid() || !mDataProvider )
812 {
813 QgsDebugMsgLevel( QStringLiteral( "invoked with invalid layer or null mDataProvider" ), 3 );
814 return customProperty( QStringLiteral( "storedSubsetString" ) ).toString();
815 }
816 return mDataProvider->subsetString();
817}
818
820{
822
823 bool result = false;
825 if ( r )
826 {
827 result = r->convertFrom2DRenderer( renderer() );
828 setRenderer3D( r );
830 }
831 return result;
832}
833
835{
837
838 return mSync3DRendererTo2DRenderer;
839}
840
842{
844
845 mSync3DRendererTo2DRenderer = sync;
846 if ( sync )
848}
849
850void QgsPointCloudLayer::calculateStatistics()
851{
853
854 if ( !mDataProvider.get() || !mDataProvider->hasValidIndex() )
855 {
856 QgsMessageLog::logMessage( QObject::tr( "Failed to calculate statistics of the point cloud %1" ).arg( this->name() ) );
857 return;
858 }
859 if ( mStatsCalculationTask )
860 {
861 QgsMessageLog::logMessage( QObject::tr( "A statistics calculation task for the point cloud %1 is already in progress" ).arg( this->name() ) );
862 return;
863 }
864#ifdef HAVE_COPC
865 if ( mDataProvider && mDataProvider->index() && mDataProvider->index()->isValid() )
866 {
867 if ( QgsCopcPointCloudIndex *index = qobject_cast<QgsCopcPointCloudIndex *>( mDataProvider->index() ) )
868 {
869 mStatistics = index->readStatistics();
870 }
871 }
872#endif
873 if ( mStatistics.sampledPointsCount() != 0 )
874 {
876 emit statisticsCalculationStateChanged( mStatisticsCalculationState );
877 resetRenderer();
878 return;
879 }
880
881 QVector<QgsPointCloudAttribute> attributes = mDataProvider->attributes().attributes();
882 // Do not calculate stats for X, Y & Z since the point cloud index contains that
883 for ( int i = 0; i < attributes.size(); ++i )
884 {
885 if ( attributes[i].name() == QLatin1String( "X" ) || attributes[i].name() == QLatin1String( "Y" ) || attributes[i].name() == QLatin1String( "Z" ) )
886 {
887 attributes.remove( i );
888 --i;
889 }
890 }
891
892 QgsPointCloudStatsCalculationTask *task = new QgsPointCloudStatsCalculationTask( mDataProvider->index(), attributes, 1000000 );
893 connect( task, &QgsTask::taskCompleted, this, [this, task]()
894 {
895 mStatistics = task->calculationResults();
896
897 // fetch X, Y & Z stats directly from the index
898 QVector<QString> coordinateAttributes;
899 coordinateAttributes.push_back( QStringLiteral( "X" ) );
900 coordinateAttributes.push_back( QStringLiteral( "Y" ) );
901 coordinateAttributes.push_back( QStringLiteral( "Z" ) );
902
903 QMap<QString, QgsPointCloudAttributeStatistics> statsMap = mStatistics.statisticsMap();
904 QgsPointCloudIndex *index = mDataProvider->index();
905 for ( const QString &attribute : coordinateAttributes )
906 {
908 QVariant min = index->metadataStatistic( attribute, Qgis::Statistic::Min );
909 QVariant max = index->metadataStatistic( attribute, Qgis::Statistic::Max );
910 if ( !min.isValid() )
911 continue;
912 s.minimum = min.toDouble();
913 s.maximum = max.toDouble();
914 s.count = index->metadataStatistic( attribute, Qgis::Statistic::Count ).toInt();
915 s.mean = index->metadataStatistic( attribute, Qgis::Statistic::Mean ).toInt();
916 s.stDev = index->metadataStatistic( attribute, Qgis::Statistic::StDev ).toInt();
917 QVariantList classes = index->metadataClasses( attribute );
918 for ( const QVariant &c : classes )
919 {
920 s.classCount[ c.toInt() ] = index->metadataClassStatistic( attribute, c, Qgis::Statistic::Count ).toInt();
921 }
922 statsMap[ attribute ] = s;
923 }
924 mStatistics = QgsPointCloudStatistics( mStatistics.sampledPointsCount(), statsMap );
925 //
926
928 emit statisticsCalculationStateChanged( mStatisticsCalculationState );
929 resetRenderer();
930 mStatsCalculationTask = 0;
931#ifdef HAVE_COPC
932 if ( mDataProvider && mDataProvider->index() && mDataProvider->index()->isValid() && mDataProvider->name() == QLatin1String( "pdal" ) && mStatistics.sampledPointsCount() != 0 )
933 {
934 if ( QgsCopcPointCloudIndex *index = qobject_cast<QgsCopcPointCloudIndex *>( mDataProvider->index() ) )
935 {
936 index->writeStatistics( mStatistics );
937 }
938 }
939#endif
940 } );
941
942 // In case the statistics calculation fails, QgsTask::taskTerminated will be called
943 connect( task, &QgsTask::taskTerminated, this, [this]()
944 {
945 if ( mStatsCalculationTask )
946 {
947 QgsMessageLog::logMessage( QObject::tr( "Failed to calculate statistics of the point cloud %1" ).arg( this->name() ) );
948 mStatsCalculationTask = 0;
949 }
950 } );
951
952 mStatsCalculationTask = QgsApplication::taskManager()->addTask( task );
953
955 emit statisticsCalculationStateChanged( mStatisticsCalculationState );
956}
957
958void QgsPointCloudLayer::resetRenderer()
959{
961
962 mDataProvider->loadIndex();
963 if ( !mLayerOptions.skipStatisticsCalculation && !mDataProvider->hasStatisticsMetadata() && statisticsCalculationState() == QgsPointCloudLayer::PointCloudStatisticsCalculationState::NotStarted )
964 {
965 calculateStatistics();
966 }
967 if ( !mRenderer || mRenderer->type() == QLatin1String( "extent" ) )
968 {
970 }
972
973 emit rendererChanged();
974}
975
976void QgsPointCloudLayer::loadIndexesForRenderContext( QgsRenderContext &rendererContext ) const
977{
978 if ( mDataProvider->capabilities() & QgsPointCloudDataProvider::ContainSubIndexes )
979 {
980 QgsRectangle renderExtent;
981 try
982 {
983 renderExtent = rendererContext.coordinateTransform().transformBoundingBox( rendererContext.mapExtent(), Qgis::TransformDirection::Reverse );
984 }
985 catch ( QgsCsException & )
986 {
987 QgsDebugError( QStringLiteral( "Transformation of extent failed!" ) );
988 }
989
990 const QVector<QgsPointCloudSubIndex> subIndex = mDataProvider->subIndexes();
991 for ( int i = 0; i < subIndex.size(); ++i )
992 {
993 // no need to load as it's there
994 if ( subIndex.at( i ).index() )
995 continue;
996
997 if ( subIndex.at( i ).extent().intersects( renderExtent ) &&
998 renderExtent.width() < subIndex.at( i ).extent().width() )
999 {
1000 mDataProvider->loadSubIndex( i );
1001 }
1002 }
1003 }
1004}
The Qgis class provides global constants for use throughout the application.
Definition: qgis.h:54
@ StDev
Standard deviation of values.
@ Mean
Mean of values.
@ Max
Max of values.
@ Min
Min of values.
BlendMode
Blending modes defining the available composition modes that can be used when painting.
Definition: qgis.h:4041
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
@ Reverse
Reverse/inverse transform (from destination to source)
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.
QgsRectangle transformBoundingBox(const QgsRectangle &rectangle, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool handle180Crossover=false) const
Transforms a rectangle from the source CRS to the destination CRS.
Custom exception class for Coordinate Reference System related exceptions.
Definition: qgsexception.h:67
@ FlagLoadDefaultStyle
Reset the layer's style to the default for the datasource.
@ 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'...
QFlags< ReadFlag > ReadFlags
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.
Base class for storage of map layer elevation properties.
static QString typeToString(Qgis::LayerType 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:75
QString name
Definition: qgsmaplayer.h:78
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:2107
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.
virtual void setExtent3D(const QgsBox3D &box)
Sets the extent.
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:2124
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:80
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.
QFlags< StyleCategory > StyleCategories
Definition: qgsmaplayer.h:188
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:2162
QgsCoordinateTransformContext transformContext() const
Returns the layer data provider coordinate transform context or a default transform context if the la...
std::unique_ptr< QgsDataProvider > mPreloadedProvider
Optionally used when loading a project, it is released when the layer is effectively created.
Definition: qgsmaplayer.h:2225
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:83
QString mDataSource
Data source description string, varies by layer type.
Definition: qgsmaplayer.h:2121
@ FlagReadExtentFromXml
Read extent from xml and skip get extent from provider.
Definition: qgsmaplayer.h:642
@ FlagDontResolveLayers
Don't resolve layer paths or create data providers for layers.
Definition: qgsmaplayer.h:640
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:2167
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:84
@ Symbology
Symbology.
Definition: qgsmaplayer.h:167
@ Rendering
Rendering: scale visibility, simplify method, opacity.
Definition: qgsmaplayer.h:176
@ Symbology3D
3D symbology
Definition: qgsmaplayer.h:168
@ CustomProperties
Custom properties (by plugins for instance)
Definition: qgsmaplayer.h:177
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 QgsDataProvider::ReadFlags providerReadFlags(const QDomNode &layerNode, QgsMapLayer::ReadFlags layerReadFlags)
Returns provider read flag deduced from layer read flags layerReadFlags and a dom node layerNode that...
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 Qgis::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a Qgis::BlendMode corresponding to a QPainter::CompositionMode.
Definition: qgspainting.cpp:81
static QPainter::CompositionMode getCompositionMode(Qgis::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a Qgis::BlendMode.
Definition: qgspainting.cpp:21
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...
@ ContainSubIndexes
Provider can contain multiple indexes. Virtual point cloud files for example (since QGIS 3....
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 QVariantList metadataClasses(const QString &attribute) const
Returns the classes of attribute.
virtual QVariant metadataStatistic(const QString &attribute, Qgis::Statistic statistic) const
Returns the statistic statistic of attribute.
virtual QVariant metadataClassStatistic(const QString &attribute, const QVariant &value, Qgis::Statistic statistic) const
Returns the statistic statistic of the class value of the attribute 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...
QString absoluteToRelativeUri(const QString &providerKey, const QString &uri, const QgsReadWriteContext &context) const
Converts absolute path(s) to relative path(s) in the given provider-specific URI.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
QString relativeToAbsoluteUri(const QString &providerKey, const QString &uri, const QgsReadWriteContext &context) const
Converts relative path(s) to absolute path(s) in the given provider-specific URI.
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.
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...
double width() const
Returns the width of the rectangle.
Definition: qgsrectangle.h:236
Contains information about the context of a rendering operation.
QgsRectangle mapExtent() const
Returns the original extent of the map being rendered.
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
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:64
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 QgsDebugError(str)
Definition: qgslogger.h:38
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS_NON_FATAL
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS
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.