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