20#include "moc_qgspointcloudlayer.cpp"
48#include "qgsvirtualpointcloudprovider.h"
54 const QString &baseName,
55 const QString &providerLib,
59 , mLayerOptions( options )
61 if ( !uri.isEmpty() && !providerLib.isEmpty() )
69 setDataSource( uri, baseName, providerLib, providerOptions, providerFlags );
82 mStatsCalculationTask = 0;
84 task->waitForFinished();
96 layer->setRenderer( mRenderer->clone() );
98 layer->mElevationProperties = mElevationProperties->
clone();
99 layer->mElevationProperties->setParent( layer );
101 layer->mLayerOptions = mLayerOptions;
102 layer->mSync3DRendererTo2DRenderer = mSync3DRendererTo2DRenderer;
111 if ( !mDataProvider )
114 return mDataProvider->extent();
121 if ( mRenderer->type() != QLatin1String(
"extent" ) )
122 loadIndexesForRenderContext( rendererContext );
138 return mDataProvider.get();
145 return mDataProvider.get();
153 const QDomNode pkeyNode = layerNode.namedItem( QStringLiteral(
"provider" ) );
163 const QDomNode extentNode = layerNode.namedItem( QStringLiteral(
"extent" ) );
164 if ( !extentNode.isNull() )
175 const QDomNode subset = layerNode.namedItem( QStringLiteral(
"subset" ) );
176 const QString subsetText = subset.toElement().text();
177 if ( !subsetText.isEmpty() )
198 QDomElement mapLayerNode = layerNode.toElement();
203 QDomElement subset = doc.createElement( QStringLiteral(
"subset" ) );
204 const QDomText subsetText = doc.createTextNode(
subsetString() );
205 subset.appendChild( subsetText );
206 layerNode.appendChild( subset );
210 QDomElement provider = doc.createElement( QStringLiteral(
"provider" ) );
211 const QDomText providerText = doc.createTextNode(
providerType() );
212 provider.appendChild( providerText );
213 layerNode.appendChild( provider );
226 const QDomElement elem = node.toElement();
230 readStyle( node, errorMessage, context, categories );
247 bool sync = node.attributes().namedItem( QStringLiteral(
"sync3DRendererTo2DRenderer" ) ).nodeValue().toInt( &ok );
254 QDomElement rendererElement = node.firstChildElement( QStringLiteral(
"renderer" ) );
255 if ( !rendererElement.isNull() )
277 const QDomNode blendModeNode = node.namedItem( QStringLiteral(
"blendMode" ) );
278 if ( !blendModeNode.isNull() )
280 const QDomElement e = blendModeNode.toElement();
288 const QDomNode layerOpacityNode = node.namedItem( QStringLiteral(
"layerOpacity" ) );
289 if ( !layerOpacityNode.isNull() )
291 const QDomElement e = layerOpacityNode.toElement();
295 const bool hasScaleBasedVisibiliy { node.attributes().namedItem( QStringLiteral(
"hasScaleBasedVisibilityFlag" ) ).nodeValue() ==
'1' };
298 const double maxScale { node.attributes().namedItem( QStringLiteral(
"maxScale" ) ).nodeValue().toDouble( &ok ) };
303 const double minScale { node.attributes().namedItem( QStringLiteral(
"minScale" ) ).nodeValue().toDouble( &ok ) };
317 Q_UNUSED( errorMessage )
319 QDomElement elem = node.toElement();
322 ( void )
writeStyle( node, doc, errorMessage, context, categories );
331 QDomElement mapLayerNode = node.toElement();
335 mapLayerNode.setAttribute( QStringLiteral(
"sync3DRendererTo2DRenderer" ), mSync3DRendererTo2DRenderer ? 1 : 0 );
342 const QDomElement rendererElement = mRenderer->save( doc, context );
343 node.appendChild( rendererElement );
356 QDomElement blendModeElem = doc.createElement( QStringLiteral(
"blendMode" ) );
358 blendModeElem.appendChild( blendModeText );
359 node.appendChild( blendModeElem );
365 QDomElement layerOpacityElem = doc.createElement( QStringLiteral(
"layerOpacity" ) );
366 const QDomText layerOpacityText = doc.createTextNode( QString::number(
opacity() ) );
367 layerOpacityElem.appendChild( layerOpacityText );
368 node.appendChild( layerOpacityElem );
370 mapLayerNode.setAttribute( QStringLiteral(
"hasScaleBasedVisibilityFlag" ),
hasScaleBasedVisibility() ? 1 : 0 );
371 mapLayerNode.setAttribute( QStringLiteral(
"maxScale" ),
maximumScale() );
372 mapLayerNode.setAttribute( QStringLiteral(
"minScale" ),
minimumScale() );
386void QgsPointCloudLayer::setDataSourcePrivate(
const QString &dataSource,
const QString &baseName,
const QString &provider,
403 mDataProvider.reset( qobject_cast< QgsPointCloudDataProvider * >(
mPreloadedProvider.release() ) );
407 std::unique_ptr< QgsScopedRuntimeProfile > profile;
409 profile = std::make_unique< QgsScopedRuntimeProfile >( tr(
"Create %1 provider" ).arg( provider ), QStringLiteral(
"projectload" ) );
413 if ( !mDataProvider )
415 QgsDebugError( QStringLiteral(
"Unable to get point cloud data provider" ) );
420 mDataProvider->setParent(
this );
421 QgsDebugMsgLevel( QStringLiteral(
"Instantiated the point cloud data provider plugin" ), 2 );
423 setValid( mDataProvider->isValid() );
435 setCrs( mDataProvider->crs() );
441 bool loadDefaultStyleFlag =
false;
444 loadDefaultStyleFlag =
true;
450 mDataProvider->pointCount() > 0 )
452 mDataProvider->generateIndex();
458 mDataProvider->pointCount() > 0 )
460 calculateStatistics();
463 if ( !mRenderer || loadDefaultStyleFlag )
465 std::unique_ptr< QgsScopedRuntimeProfile > profile;
467 profile = std::make_unique< QgsScopedRuntimeProfile >( tr(
"Load layer style" ), QStringLiteral(
"projectload" ) );
469 bool defaultLoadedFlag =
false;
474 std::unique_ptr< QgsPointCloudRenderer > defaultRenderer( mDataProvider->createRenderer() );
475 if ( defaultRenderer )
477 defaultLoadedFlag =
true;
482 if ( !defaultLoadedFlag && loadDefaultStyleFlag )
487 if ( !defaultLoadedFlag )
522 QgsError providerError = mDataProvider->error();
523 if ( !providerError.
isEmpty() )
543 std::unique_ptr< QgsPointCloudRenderer > defaultRenderer( mDataProvider->createRenderer() );
544 if ( defaultRenderer )
560 QString myMetadata = QStringLiteral(
"<html>\n<body>\n" );
565 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Information from provider" ) + QStringLiteral(
"</h1>\n<hr>\n" );
566 myMetadata += QLatin1String(
"<table class=\"list-view\">\n" );
569 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Extent" ) + QStringLiteral(
"</td><td>" ) +
extent().
toString() + QStringLiteral(
"</td></tr>\n" );
572 QLocale locale = QLocale();
573 locale.setNumberOptions( locale.numberOptions() &= ~QLocale::NumberOption::OmitGroupSeparator );
574 const qint64
pointCount = mDataProvider ? mDataProvider->pointCount() : -1;
575 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" )
576 + tr(
"Point count" ) + QStringLiteral(
"</td><td>" )
577 + (
pointCount < 0 ? tr(
"unknown" ) : locale.toString(
static_cast<qlonglong
>(
pointCount ) ) )
578 + QStringLiteral(
"</td></tr>\n" );
582 myMetadata += provider->htmlMetadata();
585 myMetadata += QLatin1String(
"</table>\n<br><br>" );
591 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Metadata" ) + QStringLiteral(
"</h1>\n<hr>\n" ) + QStringLiteral(
"<table class=\"list-view\">\n" );
592 const QVariantMap originalMetadata = mDataProvider ? mDataProvider->originalMetadata() : QVariantMap();
594 if ( originalMetadata.value( QStringLiteral(
"creation_year" ) ).toInt() > 0 && originalMetadata.contains( QStringLiteral(
"creation_doy" ) ) )
596 QDate creationDate( originalMetadata.value( QStringLiteral(
"creation_year" ) ).toInt(), 1, 1 );
597 creationDate = creationDate.addDays( originalMetadata.value( QStringLiteral(
"creation_doy" ) ).toInt() );
599 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" )
600 + tr(
"Creation date" ) + QStringLiteral(
"</td><td>" )
601 + creationDate.toString( Qt::ISODate )
602 + QStringLiteral(
"</td></tr>\n" );
604 if ( originalMetadata.contains( QStringLiteral(
"major_version" ) ) && originalMetadata.contains( QStringLiteral(
"minor_version" ) ) )
606 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" )
607 + tr(
"Version" ) + QStringLiteral(
"</td><td>" )
608 + QStringLiteral(
"%1.%2" ).arg( originalMetadata.value( QStringLiteral(
"major_version" ) ).toString(),
609 originalMetadata.value( QStringLiteral(
"minor_version" ) ).toString() )
610 + QStringLiteral(
"</td></tr>\n" );
613 if ( !originalMetadata.value( QStringLiteral(
"dataformat_id" ) ).toString().isEmpty() )
615 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" )
616 + tr(
"Data format" ) + QStringLiteral(
"</td><td>" )
618 originalMetadata.value( QStringLiteral(
"dataformat_id" ) ).toString() ).trimmed()
619 + QStringLiteral(
"</td></tr>\n" );
622 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" )
623 + tr(
"Scale X" ) + QStringLiteral(
"</td><td>" )
624 + QString::number( originalMetadata.value( QStringLiteral(
"scale_x" ) ).toDouble() )
625 + QStringLiteral(
"</td></tr>\n" );
626 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" )
627 + tr(
"Scale Y" ) + QStringLiteral(
"</td><td>" )
628 + QString::number( originalMetadata.value( QStringLiteral(
"scale_y" ) ).toDouble() )
629 + QStringLiteral(
"</td></tr>\n" );
630 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" )
631 + tr(
"Scale Z" ) + QStringLiteral(
"</td><td>" )
632 + QString::number( originalMetadata.value( QStringLiteral(
"scale_z" ) ).toDouble() )
633 + QStringLiteral(
"</td></tr>\n" );
635 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" )
636 + tr(
"Offset X" ) + QStringLiteral(
"</td><td>" )
637 + QString::number( originalMetadata.value( QStringLiteral(
"offset_x" ) ).toDouble() )
638 + QStringLiteral(
"</td></tr>\n" );
639 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" )
640 + tr(
"Offset Y" ) + QStringLiteral(
"</td><td>" )
641 + QString::number( originalMetadata.value( QStringLiteral(
"offset_y" ) ).toDouble() )
642 + QStringLiteral(
"</td></tr>\n" );
643 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" )
644 + tr(
"Offset Z" ) + QStringLiteral(
"</td><td>" )
645 + QString::number( originalMetadata.value( QStringLiteral(
"offset_z" ) ).toDouble() )
646 + QStringLiteral(
"</td></tr>\n" );
648 if ( !originalMetadata.value( QStringLiteral(
"project_id" ) ).toString().isEmpty() )
650 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" )
651 + tr(
"Project ID" ) + QStringLiteral(
"</td><td>" )
652 + originalMetadata.value( QStringLiteral(
"project_id" ) ).toString()
653 + QStringLiteral(
"</td></tr>\n" );
656 if ( !originalMetadata.value( QStringLiteral(
"system_id" ) ).toString().isEmpty() )
658 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" )
659 + tr(
"System ID" ) + QStringLiteral(
"</td><td>" )
660 + originalMetadata.value( QStringLiteral(
"system_id" ) ).toString()
661 + QStringLiteral(
"</td></tr>\n" );
664 if ( !originalMetadata.value( QStringLiteral(
"software_id" ) ).toString().isEmpty() )
666 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" )
667 + tr(
"Software ID" ) + QStringLiteral(
"</td><td>" )
668 + originalMetadata.value( QStringLiteral(
"software_id" ) ).toString()
669 + QStringLiteral(
"</td></tr>\n" );
673 myMetadata += QLatin1String(
"</table>\n<br><br>" );
676 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Identification" ) + QStringLiteral(
"</h1>\n<hr>\n" );
677 myMetadata += htmlFormatter.identificationSectionHtml( );
678 myMetadata += QLatin1String(
"<br><br>\n" );
681 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Extent" ) + QStringLiteral(
"</h1>\n<hr>\n" );
682 myMetadata += htmlFormatter.extentSectionHtml(
isSpatial() );
683 myMetadata += QLatin1String(
"<br><br>\n" );
686 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Access" ) + QStringLiteral(
"</h1>\n<hr>\n" );
687 myMetadata += htmlFormatter.accessSectionHtml( );
688 myMetadata += QLatin1String(
"<br><br>\n" );
691 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Attributes" ) + QStringLiteral(
"</h1>\n<hr>\n<table class=\"list-view\">\n" );
696 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Count" ) + QStringLiteral(
"</td><td>" ) + QString::number( attrs.
count() ) + QStringLiteral(
"</td></tr>\n" );
698 myMetadata += QLatin1String(
"</table>\n<br><table width=\"100%\" class=\"tabular-view\">\n" );
699 myMetadata += QLatin1String(
"<tr><th>" ) + tr(
"Attribute" ) + QLatin1String(
"</th><th>" ) + tr(
"Type" ) + QLatin1String(
"</th></tr>\n" );
701 for (
int i = 0; i < attrs.
count(); ++i )
706 rowClass = QStringLiteral(
"class=\"odd-row\"" );
707 myMetadata += QLatin1String(
"<tr " ) + rowClass + QLatin1String(
"><td>" ) + attribute.
name() + QLatin1String(
"</td><td>" ) + attribute.
displayType() + QLatin1String(
"</td></tr>\n" );
711 myMetadata += QLatin1String(
"</table>\n<br><br>" );
715 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Contacts" ) + QStringLiteral(
"</h1>\n<hr>\n" );
716 myMetadata += htmlFormatter.contactsSectionHtml( );
717 myMetadata += QLatin1String(
"<br><br>\n" );
720 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Links" ) + QStringLiteral(
"</h1>\n<hr>\n" );
721 myMetadata += htmlFormatter.linksSectionHtml( );
722 myMetadata += QLatin1String(
"<br><br>\n" );
725 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"History" ) + QStringLiteral(
"</h1>\n<hr>\n" );
726 myMetadata += htmlFormatter.historySectionHtml( );
727 myMetadata += QLatin1String(
"<br><br>\n" );
731 myMetadata += QLatin1String(
"\n</body>\n</html>\n" );
739 return mElevationProperties;
753 return mDataProvider ? mDataProvider->pointCount() : 0;
760 return mRenderer.get();
767 return mRenderer.get();
781 if ( mSync3DRendererTo2DRenderer )
789 if ( !
isValid() || !mDataProvider )
791 QgsDebugMsgLevel( QStringLiteral(
"invoked with invalid layer or null mDataProvider" ), 3 );
795 else if ( subset == mDataProvider->subsetString() )
798 bool res = mDataProvider->setSubsetString( subset );
811 if ( !
isValid() || !mDataProvider )
813 QgsDebugMsgLevel( QStringLiteral(
"invoked with invalid layer or null mDataProvider" ), 3 );
814 return customProperty( QStringLiteral(
"storedSubsetString" ) ).toString();
816 return mDataProvider->subsetString();
838 return mSync3DRendererTo2DRenderer;
845 mSync3DRendererTo2DRenderer = sync;
850void QgsPointCloudLayer::calculateStatistics()
854 if ( !mDataProvider.get() || !mDataProvider->hasValidIndex() )
859 if ( mStatsCalculationTask )
861 QgsMessageLog::logMessage( QObject::tr(
"A statistics calculation task for the point cloud %1 is already in progress" ).arg( this->
name() ) );
866 QList<QString> indexStatsAttributes = indexStats.
statisticsMap().keys();
867 QVector<QgsPointCloudAttribute>
attributes = mDataProvider->attributes().attributes();
871 if ( indexStatsAttributes.contains(
attributes[i].name() ) )
879 mStatistics = indexStats;
889 QgsPointCloudStatsCalculationTask *task =
new QgsPointCloudStatsCalculationTask( mDataProvider->index(),
attributes, 1000000 );
892 mStatistics = task->calculationResults();
895 QMap<QString, QgsPointCloudAttributeStatistics> statsMap = mStatistics.
statisticsMap();
896 for (
const QString &attribute : indexStatsAttributes )
898 statsMap[ attribute ] = indexStats.
statisticsOf( attribute );
905 mStatsCalculationTask = 0;
907 if ( mDataProvider && mDataProvider->index() && mDataProvider->index().isValid() && mDataProvider->name() == QLatin1String(
"pdal" ) && mStatistics.
sampledPointsCount() != 0 )
909 mDataProvider->index().writeStatistics( mStatistics );
917 if ( mStatsCalculationTask )
920 mStatsCalculationTask = 0;
930void QgsPointCloudLayer::resetRenderer()
934 mDataProvider->loadIndex();
937 calculateStatistics();
939 if ( !mRenderer || mRenderer->type() == QLatin1String(
"extent" ) )
948void QgsPointCloudLayer::loadIndexesForRenderContext(
QgsRenderContext &rendererContext )
const
959 QgsDebugError( QStringLiteral(
"Transformation of extent failed!" ) );
962 const QVector<QgsPointCloudSubIndex> subIndex = mDataProvider->subIndexes();
963 if (
const QgsVirtualPointCloudProvider *vpcProvider =
dynamic_cast<QgsVirtualPointCloudProvider *
>( mDataProvider.get() ) )
965 for (
int i = 0; i < subIndex.size(); ++i )
968 if ( subIndex.at( i ).index() )
971 if ( subIndex.at( i ).extent().intersects( renderExtent ) &&
972 ( renderExtent.
width() < vpcProvider->averageSubIndexWidth() ||
973 renderExtent.
height() < vpcProvider->averageSubIndexHeight() ) )
975 mDataProvider->loadSubIndex( i );
1029 return mCommitError;
1038 const QList<QgsPointCloudNodeId> updatedNodes = mEditIndex.
updatedNodes();
1045 if ( !updatedNodes.isEmpty() )
1090 QgsEventTracing::ScopedEvent _trace( QStringLiteral(
"PointCloud" ), QStringLiteral(
"QgsPointCloudLayer::changeAttributeValue" ) );
1096 if ( attribute.
name().compare( QLatin1String(
"X" ), Qt::CaseInsensitive ) == 0 ||
1097 attribute.
name().compare( QLatin1String(
"Y" ), Qt::CaseInsensitive ) == 0 ||
1098 attribute.
name().compare( QLatin1String(
"Z" ), Qt::CaseInsensitive ) == 0 )
1103 int attributeOffset;
1118 for (
auto it = nodesAndPoints.constBegin(); it != nodesAndPoints.constEnd(); it++ )
1121 QVector<int> points = it.value();
1126 if ( points.isEmpty() )
1129 int pointsMin = std::numeric_limits<int>::max();
1130 int pointsMax = std::numeric_limits<int>::min();
1131 for (
int pt : std::as_const( points ) )
1133 if ( pt < pointsMin )
1135 if ( pt > pointsMax )
1155 if ( mDataProvider )
1156 return mDataProvider->index();
Provides global constants and enumerations for use throughout the application.
BlendMode
Blending modes defining the available composition modes that can be used when painting.
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
@ 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.
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.
bool isEmpty() const
Test if no error is set.
QString summary() const
Short error description, usually the first error in chain, the real error.
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.
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
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...
QUndoStack * undoStack()
Returns pointer to layer's undo stack.
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.
@ 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, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE())
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.
A collection of point cloud attributes.
const QgsPointCloudAttribute & at(int index) const
Returns the attribute at the specified index.
const QgsPointCloudAttribute * find(const QString &attributeName, int &offset) const
Finds the attribute with the name.
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.
int size() const
Returns size of the attribute in bytes.
QString name() const
Returns name of the attribute.
DataType type() const
Returns the data type.
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.
A QgsPointCloudIndex that is used as an editing buffer when editing point cloud data.
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.
QgsPointCloudNode getNode(const QgsPointCloudNodeId &id) const
Returns object for a given node.
QList< QgsPointCloudNodeId > updatedNodes() const
Returns a list of node IDs that have been modified.
bool hasNode(const QgsPointCloudNodeId &id) const
Returns whether the octree contain given node.
QgsPointCloudAttributeCollection attributes() const
Returns all attributes that are stored in the file.
static bool isAttributeValueValid(const QgsPointCloudAttribute &attribute, double value)
Check if value is within proper range for the attribute.
Point cloud layer specific subclass of QgsMapLayerElevationProperties.
QgsPointCloudLayerElevationProperties * clone() const override
Creates a clone of the properties.
Implementation of QgsAbstractProfileGenerator for point cloud layers.
Implementation of threaded rendering for point cloud layers.
An undo command subclass for changing point attribute values in a point cloud index.
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.
~QgsPointCloudLayer() override
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.
void chunkAttributeValuesChanged(const QgsPointCloudNodeId &n)
Emitted when a node gets some attribute values of some points changed.
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 an indexed point cloud node's position in octree.
bool isValid() const
Returns whether node is valid.
qint64 pointCount() const
Returns number of points contained in node data.
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.
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.
A container for the context for various read/write operations on 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)
#define QgsDebugError(str)
#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.