QGIS API Documentation 3.41.0-Master (d2aaa9c6e02)
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"
19#include "moc_qgspointcloudlayer.cpp"
23#include "qgspointcloudindex.h"
26#include "qgsrectangle.h"
28#include "qgsproviderregistry.h"
29#include "qgslogger.h"
32#include "qgsruntimeprofiler.h"
33#include "qgsapplication.h"
34#include "qgspainting.h"
37#include "qgsmaplayerlegend.h"
38#include "qgsxmlutils.h"
39#include "qgsmaplayerfactory.h"
42#include "qgsmessagelog.h"
43#include "qgstaskmanager.h"
44#include "qgsthreadingutils.h"
46#ifdef HAVE_COPC
48#endif
49
50#include "qgsvirtualpointcloudprovider.h"
51
52
53#include <QUrl>
54
56 const QString &baseName,
57 const QString &providerLib,
59 : QgsMapLayer( Qgis::LayerType::PointCloud, baseName, uri )
60 , mElevationProperties( new QgsPointCloudLayerElevationProperties( this ) )
61 , mLayerOptions( options )
62{
63 if ( !uri.isEmpty() && !providerLib.isEmpty() )
64 {
65 const QgsDataProvider::ProviderOptions providerOptions { options.transformContext };
66 Qgis::DataProviderReadFlags providerFlags;
67 if ( options.loadDefaultStyle )
68 {
70 }
71 setDataSource( uri, baseName, providerLib, providerOptions, providerFlags );
72 }
73
76}
77
79{
80 if ( QgsTask *task = QgsApplication::taskManager()->task( mStatsCalculationTask ) )
81 {
82 mStatsCalculationTask = 0;
83 task->cancel();
84 task->waitForFinished();
85 }
86}
87
89{
91
92 QgsPointCloudLayer *layer = new QgsPointCloudLayer( source(), name(), mProviderKey, mLayerOptions );
93 QgsMapLayer::clone( layer );
94
95 if ( mRenderer )
96 layer->setRenderer( mRenderer->clone() );
97
98 layer->mElevationProperties = mElevationProperties->clone();
99 layer->mElevationProperties->setParent( layer );
100
101 layer->mLayerOptions = mLayerOptions;
102 layer->mSync3DRendererTo2DRenderer = mSync3DRendererTo2DRenderer;
103
104 return layer;
105}
106
108{
110
111 if ( !mDataProvider )
112 return QgsRectangle();
113
114 return mDataProvider->extent();
115}
116
118{
120
121 if ( mRenderer->type() != QLatin1String( "extent" ) )
122 loadIndexesForRenderContext( rendererContext );
123
124 return new QgsPointCloudLayerRenderer( this, rendererContext );
125}
126
133
135{
136 // BAD! 2D rendering of point clouds is NOT thread safe
138
139 return mDataProvider.get();
140}
141
143{
145
146 return mDataProvider.get();
147}
148
149bool QgsPointCloudLayer::readXml( const QDomNode &layerNode, QgsReadWriteContext &context )
150{
152
153 // create provider
154 const QDomNode pkeyNode = layerNode.namedItem( QStringLiteral( "provider" ) );
155 mProviderKey = pkeyNode.toElement().text();
156
158 {
159 const QgsDataProvider::ProviderOptions providerOptions { context.transformContext() };
161 // read extent
163 {
164 const QDomNode extentNode = layerNode.namedItem( QStringLiteral( "extent" ) );
165 if ( !extentNode.isNull() )
166 {
167 // get the extent
168 const QgsRectangle mbr = QgsXmlUtils::readRectangle( extentNode.toElement() );
169
170 // store the extent
171 setExtent( mbr );
172 }
173 }
174
176 const QDomNode subset = layerNode.namedItem( QStringLiteral( "subset" ) );
177 const QString subsetText = subset.toElement().text();
178 if ( !subsetText.isEmpty() )
179 setSubsetString( subsetText );
180 }
181
182 if ( !isValid() )
183 {
184 return false;
185 }
186
187 QString errorMsg;
188 if ( !readSymbology( layerNode, errorMsg, context ) )
189 return false;
190
191 readStyleManager( layerNode );
192 return true;
193}
194
195bool QgsPointCloudLayer::writeXml( QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context ) const
196{
198
199 QDomElement mapLayerNode = layerNode.toElement();
200 mapLayerNode.setAttribute( QStringLiteral( "type" ), QgsMapLayerFactory::typeToString( Qgis::LayerType::PointCloud ) );
201
202 if ( !subsetString().isEmpty() )
203 {
204 QDomElement subset = doc.createElement( QStringLiteral( "subset" ) );
205 const QDomText subsetText = doc.createTextNode( subsetString() );
206 subset.appendChild( subsetText );
207 layerNode.appendChild( subset );
208 }
209 if ( mDataProvider )
210 {
211 QDomElement provider = doc.createElement( QStringLiteral( "provider" ) );
212 const QDomText providerText = doc.createTextNode( providerType() );
213 provider.appendChild( providerText );
214 layerNode.appendChild( provider );
215 }
216
217 writeStyleManager( layerNode, doc );
218
219 QString errorMsg;
220 return writeSymbology( layerNode, doc, errorMsg, context );
221}
222
223bool QgsPointCloudLayer::readSymbology( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
224{
226
227 const QDomElement elem = node.toElement();
228
229 readCommonStyle( elem, context, categories );
230
231 readStyle( node, errorMessage, context, categories );
232
233 if ( categories.testFlag( CustomProperties ) )
234 readCustomProperties( node, QStringLiteral( "variable" ) );
235
236 return true;
237}
238
239bool QgsPointCloudLayer::readStyle( const QDomNode &node, QString &, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
240{
242
243 bool result = true;
244
245 if ( categories.testFlag( Symbology3D ) )
246 {
247 bool ok;
248 bool sync = node.attributes().namedItem( QStringLiteral( "sync3DRendererTo2DRenderer" ) ).nodeValue().toInt( &ok );
249 if ( ok )
251 }
252
253 if ( categories.testFlag( Symbology ) )
254 {
255 QDomElement rendererElement = node.firstChildElement( QStringLiteral( "renderer" ) );
256 if ( !rendererElement.isNull() )
257 {
258 std::unique_ptr< QgsPointCloudRenderer > r( QgsPointCloudRenderer::load( rendererElement, context ) );
259 if ( r )
260 {
261 setRenderer( r.release() );
262 }
263 else
264 {
265 result = false;
266 }
267 }
268 // make sure layer has a renderer - if none exists, fallback to a default renderer
269 if ( !mRenderer )
270 {
272 }
273 }
274
275 if ( categories.testFlag( Symbology ) )
276 {
277 // get and set the blend mode if it exists
278 const QDomNode blendModeNode = node.namedItem( QStringLiteral( "blendMode" ) );
279 if ( !blendModeNode.isNull() )
280 {
281 const QDomElement e = blendModeNode.toElement();
282 setBlendMode( QgsPainting::getCompositionMode( static_cast< Qgis::BlendMode >( e.text().toInt() ) ) );
283 }
284 }
285
286 // get and set the layer transparency and scale visibility if they exists
287 if ( categories.testFlag( Rendering ) )
288 {
289 const QDomNode layerOpacityNode = node.namedItem( QStringLiteral( "layerOpacity" ) );
290 if ( !layerOpacityNode.isNull() )
291 {
292 const QDomElement e = layerOpacityNode.toElement();
293 setOpacity( e.text().toDouble() );
294 }
295
296 const bool hasScaleBasedVisibiliy { node.attributes().namedItem( QStringLiteral( "hasScaleBasedVisibilityFlag" ) ).nodeValue() == '1' };
297 setScaleBasedVisibility( hasScaleBasedVisibiliy );
298 bool ok;
299 const double maxScale { node.attributes().namedItem( QStringLiteral( "maxScale" ) ).nodeValue().toDouble( &ok ) };
300 if ( ok )
301 {
302 setMaximumScale( maxScale );
303 }
304 const double minScale { node.attributes().namedItem( QStringLiteral( "minScale" ) ).nodeValue().toDouble( &ok ) };
305 if ( ok )
306 {
307 setMinimumScale( minScale );
308 }
309 }
310 return result;
311}
312
313bool QgsPointCloudLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
314 const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
315{
317
318 Q_UNUSED( errorMessage )
319
320 QDomElement elem = node.toElement();
321 writeCommonStyle( elem, doc, context, categories );
322
323 ( void )writeStyle( node, doc, errorMessage, context, categories );
324
325 return true;
326}
327
328bool QgsPointCloudLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &, const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
329{
331
332 QDomElement mapLayerNode = node.toElement();
333
334 if ( categories.testFlag( Symbology3D ) )
335 {
336 mapLayerNode.setAttribute( QStringLiteral( "sync3DRendererTo2DRenderer" ), mSync3DRendererTo2DRenderer ? 1 : 0 );
337 }
338
339 if ( categories.testFlag( Symbology ) )
340 {
341 if ( mRenderer )
342 {
343 const QDomElement rendererElement = mRenderer->save( doc, context );
344 node.appendChild( rendererElement );
345 }
346 }
347
348 //save customproperties
349 if ( categories.testFlag( CustomProperties ) )
350 {
351 writeCustomProperties( node, doc );
352 }
353
354 if ( categories.testFlag( Symbology ) )
355 {
356 // add the blend mode field
357 QDomElement blendModeElem = doc.createElement( QStringLiteral( "blendMode" ) );
358 const QDomText blendModeText = doc.createTextNode( QString::number( static_cast< int >( QgsPainting::getBlendModeEnum( blendMode() ) ) ) );
359 blendModeElem.appendChild( blendModeText );
360 node.appendChild( blendModeElem );
361 }
362
363 // add the layer opacity and scale visibility
364 if ( categories.testFlag( Rendering ) )
365 {
366 QDomElement layerOpacityElem = doc.createElement( QStringLiteral( "layerOpacity" ) );
367 const QDomText layerOpacityText = doc.createTextNode( QString::number( opacity() ) );
368 layerOpacityElem.appendChild( layerOpacityText );
369 node.appendChild( layerOpacityElem );
370
371 mapLayerNode.setAttribute( QStringLiteral( "hasScaleBasedVisibilityFlag" ), hasScaleBasedVisibility() ? 1 : 0 );
372 mapLayerNode.setAttribute( QStringLiteral( "maxScale" ), maximumScale() );
373 mapLayerNode.setAttribute( QStringLiteral( "minScale" ), minimumScale() );
374 }
375 return true;
376}
377
379{
381
382 if ( mDataProvider )
383 mDataProvider->setTransformContext( transformContext );
385}
386
387void QgsPointCloudLayer::setDataSourcePrivate( const QString &dataSource, const QString &baseName, const QString &provider,
389{
391
392 if ( mDataProvider )
393 {
394 disconnect( mDataProvider.get(), &QgsPointCloudDataProvider::dataChanged, this, &QgsPointCloudLayer::dataChanged );
395 disconnect( mDataProvider.get(), &QgsPointCloudDataProvider::indexGenerationStateChanged, this, &QgsPointCloudLayer::onPointCloudIndexGenerationStateChanged );
396 }
397
398 setName( baseName );
399 mProviderKey = provider;
400 mDataSource = dataSource;
401
402 if ( mPreloadedProvider )
403 {
404 mDataProvider.reset( qobject_cast< QgsPointCloudDataProvider * >( mPreloadedProvider.release() ) );
405 }
406 else
407 {
408 std::unique_ptr< QgsScopedRuntimeProfile > profile;
409 if ( QgsApplication::profiler()->groupIsActive( QStringLiteral( "projectload" ) ) )
410 profile = std::make_unique< QgsScopedRuntimeProfile >( tr( "Create %1 provider" ).arg( provider ), QStringLiteral( "projectload" ) );
411 mDataProvider.reset( qobject_cast<QgsPointCloudDataProvider *>( QgsProviderRegistry::instance()->createProvider( provider, dataSource, options, flags ) ) );
412 }
413
414 if ( !mDataProvider )
415 {
416 QgsDebugError( QStringLiteral( "Unable to get point cloud data provider" ) );
417 setValid( false );
418 return;
419 }
420
421 mDataProvider->setParent( this );
422 QgsDebugMsgLevel( QStringLiteral( "Instantiated the point cloud data provider plugin" ), 2 );
423
424 setValid( mDataProvider->isValid() );
425 if ( !isValid() )
426 {
427 QgsDebugError( QStringLiteral( "Invalid point cloud provider plugin %1" ).arg( QString( mDataSource.toUtf8() ) ) );
428 setError( mDataProvider->error() );
429 return;
430 }
431
432 connect( mDataProvider.get(), &QgsPointCloudDataProvider::indexGenerationStateChanged, this, &QgsPointCloudLayer::onPointCloudIndexGenerationStateChanged );
433 connect( mDataProvider.get(), &QgsPointCloudDataProvider::dataChanged, this, &QgsPointCloudLayer::dataChanged );
434
435 // Load initial extent, crs and renderer
436 setCrs( mDataProvider->crs() );
438 {
439 setExtent3D( mDataProvider->extent3D() );
440 }
441
442 bool loadDefaultStyleFlag = false;
444 {
445 loadDefaultStyleFlag = true;
446 }
447
448 if ( !mLayerOptions.skipIndexGeneration &&
449 mDataProvider &&
451 mDataProvider->pointCount() > 0 )
452 {
453 mDataProvider->generateIndex();
454 }
455
456 if ( !mLayerOptions.skipStatisticsCalculation &&
457 mDataProvider &&
459 mDataProvider->pointCount() > 0 )
460 {
461 calculateStatistics();
462 }
463
464 if ( !mRenderer || loadDefaultStyleFlag )
465 {
466 std::unique_ptr< QgsScopedRuntimeProfile > profile;
467 if ( QgsApplication::profiler()->groupIsActive( QStringLiteral( "projectload" ) ) )
468 profile = std::make_unique< QgsScopedRuntimeProfile >( tr( "Load layer style" ), QStringLiteral( "projectload" ) );
469
470 bool defaultLoadedFlag = false;
471
472 if ( loadDefaultStyleFlag && isSpatial() && mDataProvider->capabilities() & QgsPointCloudDataProvider::CreateRenderer )
473 {
474 // first try to create a renderer directly from the data provider
475 std::unique_ptr< QgsPointCloudRenderer > defaultRenderer( mDataProvider->createRenderer() );
476 if ( defaultRenderer )
477 {
478 defaultLoadedFlag = true;
479 setRenderer( defaultRenderer.release() );
480 }
481 }
482
483 if ( !defaultLoadedFlag && loadDefaultStyleFlag )
484 {
485 loadDefaultStyle( defaultLoadedFlag );
486 }
487
488 if ( !defaultLoadedFlag )
489 {
490 // all else failed, create default renderer
492 }
493 }
494}
495
496QString QgsPointCloudLayer::encodedSource( const QString &source, const QgsReadWriteContext &context ) const
497{
499
501}
502
503QString QgsPointCloudLayer::decodedSource( const QString &source, const QString &dataProvider, const QgsReadWriteContext &context ) const
504{
506
508}
509
510void QgsPointCloudLayer::onPointCloudIndexGenerationStateChanged( QgsPointCloudDataProvider::PointCloudIndexGenerationState state )
511{
513
514 switch ( state )
515 {
517 {
518 resetRenderer();
519 break;
520 }
522 {
523 QgsError providerError = mDataProvider->error();
524 if ( !providerError.isEmpty() )
525 {
526 setError( providerError );
527 emit raiseError( providerError.summary() );
528 }
529 break;
530 }
532 break;
533 }
534}
535
536
537QString QgsPointCloudLayer::loadDefaultStyle( bool &resultFlag )
538{
540
541 if ( mDataProvider->capabilities() & QgsPointCloudDataProvider::CreateRenderer )
542 {
543 // first try to create a renderer directly from the data provider
544 std::unique_ptr< QgsPointCloudRenderer > defaultRenderer( mDataProvider->createRenderer() );
545 if ( defaultRenderer )
546 {
547 resultFlag = true;
548 setRenderer( defaultRenderer.release() );
549 return QString();
550 }
551 }
552
553 return QgsMapLayer::loadDefaultStyle( resultFlag );
554}
555
557{
559
560 const QgsLayerMetadataFormatter htmlFormatter( metadata() );
561 QString myMetadata = QStringLiteral( "<html>\n<body>\n" );
562
563 myMetadata += generalHtmlMetadata();
564
565 // Begin Provider section
566 myMetadata += QStringLiteral( "<h1>" ) + tr( "Information from provider" ) + QStringLiteral( "</h1>\n<hr>\n" );
567 myMetadata += QLatin1String( "<table class=\"list-view\">\n" );
568
569 // Extent
570 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Extent" ) + QStringLiteral( "</td><td>" ) + extent().toString() + QStringLiteral( "</td></tr>\n" );
571
572 // feature count
573 QLocale locale = QLocale();
574 locale.setNumberOptions( locale.numberOptions() &= ~QLocale::NumberOption::OmitGroupSeparator );
575 const qint64 pointCount = mDataProvider ? mDataProvider->pointCount() : -1;
576 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
577 + tr( "Point count" ) + QStringLiteral( "</td><td>" )
578 + ( pointCount < 0 ? tr( "unknown" ) : locale.toString( static_cast<qlonglong>( pointCount ) ) )
579 + QStringLiteral( "</td></tr>\n" );
580
581 if ( const QgsPointCloudDataProvider *provider = dataProvider() )
582 {
583 myMetadata += provider->htmlMetadata();
584 }
585
586 myMetadata += QLatin1String( "</table>\n<br><br>" );
587
588 // CRS
589 myMetadata += crsHtmlMetadata();
590
591 // provider metadata section
592 myMetadata += QStringLiteral( "<h1>" ) + tr( "Metadata" ) + QStringLiteral( "</h1>\n<hr>\n" ) + QStringLiteral( "<table class=\"list-view\">\n" );
593 const QVariantMap originalMetadata = mDataProvider ? mDataProvider->originalMetadata() : QVariantMap();
594
595 if ( originalMetadata.value( QStringLiteral( "creation_year" ) ).toInt() > 0 && originalMetadata.contains( QStringLiteral( "creation_doy" ) ) )
596 {
597 QDate creationDate( originalMetadata.value( QStringLiteral( "creation_year" ) ).toInt(), 1, 1 );
598 creationDate = creationDate.addDays( originalMetadata.value( QStringLiteral( "creation_doy" ) ).toInt() );
599
600 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
601 + tr( "Creation date" ) + QStringLiteral( "</td><td>" )
602 + creationDate.toString( Qt::ISODate )
603 + QStringLiteral( "</td></tr>\n" );
604 }
605 if ( originalMetadata.contains( QStringLiteral( "major_version" ) ) && originalMetadata.contains( QStringLiteral( "minor_version" ) ) )
606 {
607 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
608 + tr( "Version" ) + QStringLiteral( "</td><td>" )
609 + QStringLiteral( "%1.%2" ).arg( originalMetadata.value( QStringLiteral( "major_version" ) ).toString(),
610 originalMetadata.value( QStringLiteral( "minor_version" ) ).toString() )
611 + QStringLiteral( "</td></tr>\n" );
612 }
613
614 if ( !originalMetadata.value( QStringLiteral( "dataformat_id" ) ).toString().isEmpty() )
615 {
616 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
617 + tr( "Data format" ) + QStringLiteral( "</td><td>" )
618 + QStringLiteral( "%1 (%2)" ).arg( QgsPointCloudDataProvider::translatedDataFormatIds().value( originalMetadata.value( QStringLiteral( "dataformat_id" ) ).toInt() ),
619 originalMetadata.value( QStringLiteral( "dataformat_id" ) ).toString() ).trimmed()
620 + QStringLiteral( "</td></tr>\n" );
621 }
622
623 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
624 + tr( "Scale X" ) + QStringLiteral( "</td><td>" )
625 + QString::number( originalMetadata.value( QStringLiteral( "scale_x" ) ).toDouble() )
626 + QStringLiteral( "</td></tr>\n" );
627 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
628 + tr( "Scale Y" ) + QStringLiteral( "</td><td>" )
629 + QString::number( originalMetadata.value( QStringLiteral( "scale_y" ) ).toDouble() )
630 + QStringLiteral( "</td></tr>\n" );
631 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
632 + tr( "Scale Z" ) + QStringLiteral( "</td><td>" )
633 + QString::number( originalMetadata.value( QStringLiteral( "scale_z" ) ).toDouble() )
634 + QStringLiteral( "</td></tr>\n" );
635
636 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
637 + tr( "Offset X" ) + QStringLiteral( "</td><td>" )
638 + QString::number( originalMetadata.value( QStringLiteral( "offset_x" ) ).toDouble() )
639 + QStringLiteral( "</td></tr>\n" );
640 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
641 + tr( "Offset Y" ) + QStringLiteral( "</td><td>" )
642 + QString::number( originalMetadata.value( QStringLiteral( "offset_y" ) ).toDouble() )
643 + QStringLiteral( "</td></tr>\n" );
644 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
645 + tr( "Offset Z" ) + QStringLiteral( "</td><td>" )
646 + QString::number( originalMetadata.value( QStringLiteral( "offset_z" ) ).toDouble() )
647 + QStringLiteral( "</td></tr>\n" );
648
649 if ( !originalMetadata.value( QStringLiteral( "project_id" ) ).toString().isEmpty() )
650 {
651 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
652 + tr( "Project ID" ) + QStringLiteral( "</td><td>" )
653 + originalMetadata.value( QStringLiteral( "project_id" ) ).toString()
654 + QStringLiteral( "</td></tr>\n" );
655 }
656
657 if ( !originalMetadata.value( QStringLiteral( "system_id" ) ).toString().isEmpty() )
658 {
659 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
660 + tr( "System ID" ) + QStringLiteral( "</td><td>" )
661 + originalMetadata.value( QStringLiteral( "system_id" ) ).toString()
662 + QStringLiteral( "</td></tr>\n" );
663 }
664
665 if ( !originalMetadata.value( QStringLiteral( "software_id" ) ).toString().isEmpty() )
666 {
667 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
668 + tr( "Software ID" ) + QStringLiteral( "</td><td>" )
669 + originalMetadata.value( QStringLiteral( "software_id" ) ).toString()
670 + QStringLiteral( "</td></tr>\n" );
671 }
672
673 // End Provider section
674 myMetadata += QLatin1String( "</table>\n<br><br>" );
675
676 // identification section
677 myMetadata += QStringLiteral( "<h1>" ) + tr( "Identification" ) + QStringLiteral( "</h1>\n<hr>\n" );
678 myMetadata += htmlFormatter.identificationSectionHtml( );
679 myMetadata += QLatin1String( "<br><br>\n" );
680
681 // extent section
682 myMetadata += QStringLiteral( "<h1>" ) + tr( "Extent" ) + QStringLiteral( "</h1>\n<hr>\n" );
683 myMetadata += htmlFormatter.extentSectionHtml( isSpatial() );
684 myMetadata += QLatin1String( "<br><br>\n" );
685
686 // Start the Access section
687 myMetadata += QStringLiteral( "<h1>" ) + tr( "Access" ) + QStringLiteral( "</h1>\n<hr>\n" );
688 myMetadata += htmlFormatter.accessSectionHtml( );
689 myMetadata += QLatin1String( "<br><br>\n" );
690
691 // Attributes section
692 myMetadata += QStringLiteral( "<h1>" ) + tr( "Attributes" ) + QStringLiteral( "</h1>\n<hr>\n<table class=\"list-view\">\n" );
693
695
696 // count attributes
697 myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Count" ) + QStringLiteral( "</td><td>" ) + QString::number( attrs.count() ) + QStringLiteral( "</td></tr>\n" );
698
699 myMetadata += QLatin1String( "</table>\n<br><table width=\"100%\" class=\"tabular-view\">\n" );
700 myMetadata += QLatin1String( "<tr><th>" ) + tr( "Attribute" ) + QLatin1String( "</th><th>" ) + tr( "Type" ) + QLatin1String( "</th></tr>\n" );
701
702 for ( int i = 0; i < attrs.count(); ++i )
703 {
704 const QgsPointCloudAttribute attribute = attrs.at( i );
705 QString rowClass;
706 if ( i % 2 )
707 rowClass = QStringLiteral( "class=\"odd-row\"" );
708 myMetadata += QLatin1String( "<tr " ) + rowClass + QLatin1String( "><td>" ) + attribute.name() + QLatin1String( "</td><td>" ) + attribute.displayType() + QLatin1String( "</td></tr>\n" );
709 }
710
711 //close field list
712 myMetadata += QLatin1String( "</table>\n<br><br>" );
713
714
715 // Start the contacts section
716 myMetadata += QStringLiteral( "<h1>" ) + tr( "Contacts" ) + QStringLiteral( "</h1>\n<hr>\n" );
717 myMetadata += htmlFormatter.contactsSectionHtml( );
718 myMetadata += QLatin1String( "<br><br>\n" );
719
720 // Start the links section
721 myMetadata += QStringLiteral( "<h1>" ) + tr( "Links" ) + QStringLiteral( "</h1>\n<hr>\n" );
722 myMetadata += htmlFormatter.linksSectionHtml( );
723 myMetadata += QLatin1String( "<br><br>\n" );
724
725 // Start the history section
726 myMetadata += QStringLiteral( "<h1>" ) + tr( "History" ) + QStringLiteral( "</h1>\n<hr>\n" );
727 myMetadata += htmlFormatter.historySectionHtml( );
728 myMetadata += QLatin1String( "<br><br>\n" );
729
730 myMetadata += customPropertyHtmlMetadata();
731
732 myMetadata += QLatin1String( "\n</body>\n</html>\n" );
733 return myMetadata;
734}
735
742
744{
746
747 return mDataProvider ? mDataProvider->attributes() : QgsPointCloudAttributeCollection();
748}
749
751{
753
754 return mDataProvider ? mDataProvider->pointCount() : 0;
755}
756
763
765{
767
768 return mRenderer.get();
769}
770
772{
774
775 if ( renderer == mRenderer.get() )
776 return;
777
778 mRenderer.reset( renderer );
779 emit rendererChanged();
781
782 if ( mSync3DRendererTo2DRenderer )
784}
785
786bool QgsPointCloudLayer::setSubsetString( const QString &subset )
787{
789
790 if ( !isValid() || !mDataProvider )
791 {
792 QgsDebugMsgLevel( QStringLiteral( "invoked with invalid layer or null mDataProvider" ), 3 );
793 setCustomProperty( QStringLiteral( "storedSubsetString" ), subset );
794 return false;
795 }
796 else if ( subset == mDataProvider->subsetString() )
797 return true;
798
799 bool res = mDataProvider->setSubsetString( subset );
800 if ( res )
801 {
802 emit subsetStringChanged();
804 }
805 return res;
806}
807
809{
811
812 if ( !isValid() || !mDataProvider )
813 {
814 QgsDebugMsgLevel( QStringLiteral( "invoked with invalid layer or null mDataProvider" ), 3 );
815 return customProperty( QStringLiteral( "storedSubsetString" ) ).toString();
816 }
817 return mDataProvider->subsetString();
818}
819
821{
823
824 bool result = false;
826 if ( r )
827 {
828 result = r->convertFrom2DRenderer( renderer() );
829 setRenderer3D( r );
831 }
832 return result;
833}
834
836{
838
839 return mSync3DRendererTo2DRenderer;
840}
841
843{
845
846 mSync3DRendererTo2DRenderer = sync;
847 if ( sync )
849}
850
851void QgsPointCloudLayer::calculateStatistics()
852{
854
855 if ( !mDataProvider.get() || !mDataProvider->hasValidIndex() )
856 {
857 QgsMessageLog::logMessage( QObject::tr( "Failed to calculate statistics of the point cloud %1" ).arg( this->name() ) );
858 return;
859 }
860 if ( mStatsCalculationTask )
861 {
862 QgsMessageLog::logMessage( QObject::tr( "A statistics calculation task for the point cloud %1 is already in progress" ).arg( this->name() ) );
863 return;
864 }
865
866 QgsPointCloudStatistics indexStats = mDataProvider->metadataStatistics();
867 QList<QString> indexStatsAttributes = indexStats.statisticsMap().keys();
868 QVector<QgsPointCloudAttribute> attributes = mDataProvider->attributes().attributes();
869 // Do not calculate stats for attributes that the index gives us stats for
870 for ( int i = 0; i < attributes.size(); ++i )
871 {
872 if ( indexStatsAttributes.contains( attributes[i].name() ) )
873 {
874 attributes.remove( i );
875 --i;
876 }
877 }
878
879 // Use the layer statistics for now, until we can calculate complete ones
880 mStatistics = indexStats;
881 if ( attributes.empty() && indexStats.sampledPointsCount() > 0 )
882 {
883 // All attributes are covered by the saved stats, skip calculating anything
885 emit statisticsCalculationStateChanged( mStatisticsCalculationState );
886 resetRenderer();
887 return;
888 }
889
890 QgsPointCloudStatsCalculationTask *task = new QgsPointCloudStatsCalculationTask( mDataProvider->index(), attributes, 1000000 );
891 connect( task, &QgsTask::taskCompleted, this, [this, task, indexStats, indexStatsAttributes]()
892 {
893 mStatistics = task->calculationResults();
894
895 // Fetch what we can directly from the index
896 QMap<QString, QgsPointCloudAttributeStatistics> statsMap = mStatistics.statisticsMap();
897 for ( const QString &attribute : indexStatsAttributes )
898 {
899 statsMap[ attribute ] = indexStats.statisticsOf( attribute );
900 }
901 mStatistics = QgsPointCloudStatistics( mStatistics.sampledPointsCount(), statsMap );
902
904 emit statisticsCalculationStateChanged( mStatisticsCalculationState );
905 resetRenderer();
906 mStatsCalculationTask = 0;
907#ifdef HAVE_COPC
908 if ( mDataProvider && mDataProvider->index() && mDataProvider->index().isValid() && mDataProvider->name() == QLatin1String( "pdal" ) && mStatistics.sampledPointsCount() != 0 )
909 {
910 mDataProvider->index().writeStatistics( mStatistics );
911 }
912#endif
913 } );
914
915 // In case the statistics calculation fails, QgsTask::taskTerminated will be called
916 connect( task, &QgsTask::taskTerminated, this, [this]()
917 {
918 if ( mStatsCalculationTask )
919 {
920 QgsMessageLog::logMessage( QObject::tr( "Failed to calculate statistics of the point cloud %1" ).arg( this->name() ) );
921 mStatsCalculationTask = 0;
922 }
923 } );
924
925 mStatsCalculationTask = QgsApplication::taskManager()->addTask( task );
926
928 emit statisticsCalculationStateChanged( mStatisticsCalculationState );
929}
930
931void QgsPointCloudLayer::resetRenderer()
932{
934
935 mDataProvider->loadIndex();
937 {
938 calculateStatistics();
939 }
940 if ( !mRenderer || mRenderer->type() == QLatin1String( "extent" ) )
941 {
943 }
945
946 emit rendererChanged();
947}
948
949void QgsPointCloudLayer::loadIndexesForRenderContext( QgsRenderContext &rendererContext ) const
950{
951 if ( mDataProvider->capabilities() & QgsPointCloudDataProvider::ContainSubIndexes )
952 {
953 QgsRectangle renderExtent;
954 try
955 {
956 renderExtent = rendererContext.coordinateTransform().transformBoundingBox( rendererContext.mapExtent(), Qgis::TransformDirection::Reverse );
957 }
958 catch ( QgsCsException & )
959 {
960 QgsDebugError( QStringLiteral( "Transformation of extent failed!" ) );
961 }
962
963 const QVector<QgsPointCloudSubIndex> subIndex = mDataProvider->subIndexes();
964 if ( const QgsVirtualPointCloudProvider *vpcProvider = dynamic_cast<QgsVirtualPointCloudProvider *>( mDataProvider.get() ) )
965 {
966 for ( int i = 0; i < subIndex.size(); ++i )
967 {
968 // no need to load as it's there
969 if ( subIndex.at( i ).index() )
970 continue;
971
972 if ( subIndex.at( i ).extent().intersects( renderExtent ) &&
973 ( renderExtent.width() < vpcProvider->averageSubIndexWidth() ||
974 renderExtent.height() < vpcProvider->averageSubIndexHeight() ) )
975 {
976 mDataProvider->loadSubIndex( i );
977 }
978 }
979 }
980 }
981}
982
984{
986 if ( mEditIndex )
987 return false;
988
989 mEditIndex = QgsPointCloudIndex( new QgsPointCloudEditingIndex( this ) );
990
991 if ( !mEditIndex.isValid() )
992 {
993 mEditIndex = QgsPointCloudIndex();
994 return false;
995 }
996
997 emit editingStarted();
998 return true;
999}
1000
1002{
1004 if ( !mEditIndex )
1005 return false;
1006
1007 if ( mEditIndex.isModified() )
1008 {
1009 if ( !mEditIndex.commitChanges( &mCommitError ) )
1010 return false;
1011
1012 emit layerModified();
1014 }
1015
1016 if ( stopEditing )
1017 {
1018 mEditIndex = QgsPointCloudIndex();
1019 emit editingStopped();
1020 }
1021
1022 return true;
1023}
1024
1026{
1028 return mCommitError;
1029}
1030
1032{
1034 if ( !mEditIndex )
1035 return false;
1036
1037 if ( isModified() )
1038 {
1039 emit layerModified();
1041 }
1042
1043 mEditIndex = QgsPointCloudIndex();
1044 emit editingStopped();
1045
1046 return true;
1047}
1048
1050{
1052 return mDataProvider && mDataProvider->capabilities() & QgsPointCloudDataProvider::Capability::ChangeAttributeValues;
1053}
1054
1056{
1058 if ( mEditIndex )
1059 return true;
1060
1061 return false;
1062}
1063
1065{
1067 if ( !mEditIndex )
1068 return false;
1069
1070 return mEditIndex.isModified();
1071}
1072
1073bool QgsPointCloudLayer::changeAttributeValue( const QgsPointCloudNodeId &n, const QVector<int> &pts, const QgsPointCloudAttribute &attribute, double value )
1074{
1076 if ( !mEditIndex )
1077 return false;
1078
1079 QgsPointCloudLayerEditUtils utils( this );
1080
1081 const bool success = utils.changeAttributeValue( n, pts, attribute, value );
1082 if ( success )
1083 {
1084 emit layerModified();
1085 }
1086
1087 return success;
1088}
1089
1091{
1093 if ( mEditIndex )
1094 return mEditIndex;
1095
1096 if ( mDataProvider )
1097 return mDataProvider->index();
1098
1099 return QgsPointCloudIndex();
1100}
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:4657
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
Definition qgis.h:450
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
@ LoadDefaultStyle
Reset the layer's style to the default for the datasource.
@ SkipGetExtent
Skip the extent from provider.
@ 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.
void dataChanged()
Emitted whenever a change is made to the data provider which may have caused changes in the provider'...
A container for error messages.
Definition qgserror.h:81
bool isEmpty() const
Test if any error is set.
Definition qgserror.h:110
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:76
QString name
Definition qgsmaplayer.h:80
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.
void editingStopped()
Emitted when edited changes have been successfully written to the data provider.
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.
static Qgis::DataProviderReadFlags providerReadFlags(const QDomNode &layerNode, QgsMapLayer::ReadFlags layerReadFlags)
Returns provider read flag deduced from layer read flags layerReadFlags and a dom node layerNode that...
QgsMapLayer::LayerFlags flags() const
Returns the flags for this layer.
void editingStarted()
Emitted when editing on this layer has started.
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...
void setDataSource(const QString &dataSource, const QString &baseName=QString(), const QString &provider=QString(), bool loadDefaultStyleFlag=false)
Updates the data source of the layer.
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:82
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
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.
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:88
@ Symbology
Symbology.
@ Rendering
Rendering: scale visibility, simplify method, opacity.
@ Symbology3D
3D symbology
@ CustomProperties
Custom properties (by plugins for instance)
void layerModified()
Emitted when modifications has been done on layer.
void setRenderer3D(QgsAbstract3DRenderer *renderer)
Sets 3D renderer for the layer.
QString customPropertyHtmlMetadata() const
Returns an HTML fragment containing custom property information, for use in the htmlMetadata() method...
QString generalHtmlMetadata() const
Returns an HTML fragment containing general metadata information, for use in the htmlMetadata() metho...
void writeCommonStyle(QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const
Write style data common to all layer types.
double maximumScale() const
Returns the maximum map scale (i.e.
void invalidateWgs84Extent()
Invalidates the WGS84 extent.
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
static 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...
@ ChangeAttributeValues
Provider can modify the values of point attributes.
@ ContainSubIndexes
Provider can contain multiple indexes. Virtual point cloud files for example.
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.
The QgsPointCloudEditingIndex class is a QgsPointCloudIndex that is used as an editing buffer when ed...
Smart pointer for QgsAbstractPointCloudIndex.
bool isModified() const
Returns true if there are uncommitted changes, false otherwise.
bool isValid() const
Returns whether index is loaded and valid.
bool commitChanges(QString *errorMessage=nullptr)
Tries to store pending changes to the data provider.
Contains utility functions for editing point cloud layers.
bool changeAttributeValue(const QgsPointCloudNodeId &n, const QVector< int > &points, const QgsPointCloudAttribute &attribute, double value)
Attempts to modify attribute values for specific points in the editing buffer.
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.
bool isModified() const override
Returns true if the layer has been modified since last commit/save.
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...
bool changeAttributeValue(const QgsPointCloudNodeId &n, const QVector< int > &points, const QgsPointCloudAttribute &attribute, double value)
Attempts to modify attribute values for specific points in the editing buffer.
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.
QgsPointCloudIndex index() const
Returns the point cloud index associated with the layer.
bool commitChanges(bool stopEditing=true)
Attempts to commit to the underlying data provider any buffered changes made since the last to call t...
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.
bool isEditable() const override
Returns true if the layer can be edited.
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 rollBack()
Stops a current editing operation and discards any uncommitted edits.
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.
QString commitError() const
Returns the last error message generated when attempting to commit changes to 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.
bool startEditing()
Makes the layer editable.
bool supportsEditing() const override
Returns whether the layer supports editing or not.
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.
Represents a indexed point cloud node's position in octree.
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.
QgsPointCloudAttributeStatistics statisticsOf(const QString &attribute) const
Returns the calculated statistics of attribute attribute.
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.
Q_INVOKABLE QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
Contains information about the context of a rendering operation.
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)
#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.
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.