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