QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
qgslayermetadata.h
Go to the documentation of this file.
1/***************************************************************************
2 qgslayermetadata.h
3 -------------------
4 begin : April 2017
5 copyright : (C) 2017 by Nyall Dawson
6 email : nyall dot dawson 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#ifndef QGSLAYERMETADATA_H
19#define QGSLAYERMETADATA_H
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
24#include "qgsbox3d.h"
26#include "qgsrange.h"
27
28class QgsMapLayer;
29
55class CORE_EXPORT QgsLayerMetadata : public QgsAbstractMetadataBase
56{
57 public:
58
62 struct CORE_EXPORT SpatialExtent
63 {
64
72
82
83 // TODO c++20 - replace with = default
84 bool operator==( const QgsLayerMetadata::SpatialExtent &other ) const;
85 };
86
90 struct CORE_EXPORT Extent
91 {
92 public:
93
98 QList< QgsLayerMetadata::SpatialExtent > spatialExtents() const;
99
104 void setSpatialExtents( const QList< QgsLayerMetadata::SpatialExtent > &extents );
105
113 QList< QgsDateTimeRange > temporalExtents() const;
114
119 void setTemporalExtents( const QList< QgsDateTimeRange > &extents );
120
121 // TODO c++20 - replace with = default
122 bool operator==( const QgsLayerMetadata::Extent &other ) const;
123
124#ifndef SIP_RUN
125 private:
126
127 QList< QgsLayerMetadata::SpatialExtent > mSpatialExtents;
128 QList< QgsDateTimeRange > mTemporalExtents;
129
130#endif
131
132 };
133
137 struct CORE_EXPORT Constraint
138 {
139
143 Constraint( const QString &constraint = QString(), const QString &type = QString() )
144 : type( type )
146 {}
147
152 QString type;
153
157 QString constraint;
158
159 // TODO c++20 - replace with = default
160 bool operator==( const QgsLayerMetadata::Constraint &other ) const;
161
162 };
163
167 typedef QList< QgsLayerMetadata::Constraint > ConstraintList;
168
169 QgsLayerMetadata() = default;
170
171
172 QgsLayerMetadata *clone() const override SIP_FACTORY;
173
179 QString fees() const;
180
186 void setFees( const QString &fees );
187
193
199 void addConstraint( const QgsLayerMetadata::Constraint &constraint );
200
206
211 QStringList rights() const;
212
217 void setRights( const QStringList &rights );
218
223 QStringList licenses() const;
224
230 void setLicenses( const QStringList &licenses );
231
236 QString encoding() const;
237
242 void setEncoding( const QString &encoding );
243
248 SIP_SKIP const QgsLayerMetadata::Extent &extent() const;
249
255
260 void setExtent( const QgsLayerMetadata::Extent &extent );
261
280
303
308 void saveToLayer( QgsMapLayer *layer ) const;
309
314 void readFromLayer( const QgsMapLayer *layer );
315
316 bool readMetadataXml( const QDomElement &metadataElement, const QgsReadWriteContext &context = QgsReadWriteContext() ) override;
317 bool writeMetadataXml( QDomElement &metadataElement, QDomDocument &document, const QgsReadWriteContext &context = QgsReadWriteContext() ) const override;
318 void combine( const QgsAbstractMetadataBase *other ) override;
319 void registerTranslations( QgsTranslationContext *translationContext ) const override;
320
321 bool operator==( const QgsLayerMetadata &metadataOther ) const;
322
331 bool contains( const QString &searchString ) const;
332
339 bool matches( const QVector<QRegularExpression> &searchReList ) const;
340
341 private:
342
343 /*
344 * IMPORTANT!!!!!!
345 *
346 * Do NOT add anything to this class without also updating the schema
347 * definition located at resources/qgis-resource-metadata.xsd
348 *
349 */
350
351 QString mFees;
352 ConstraintList mConstraints;
353 QStringList mRights;
354 QStringList mLicenses;
355
356 // IMPORTANT - look up before adding anything here!!
357
358 QString mEncoding;
360
361 Extent mExtent;
362
363 /*
364 * IMPORTANT!!!!!!
365 *
366 * Do NOT add anything to this class without also updating the schema
367 * definition located at resources/qgis-resource-metadata.xsd
368 *
369 */
370
371};
372
376
377#endif // QGSLAYERMETADATA_H
QgsAbstractMetadataBase()=default
Constructor for QgsAbstractMetadataBase.
virtual QgsAbstractMetadataBase * clone() const =0
Clones the metadata object.
A 3-dimensional box composed of x, y, z coordinates.
Definition qgsbox3d.h:42
Represents a coordinate reference system (CRS).
void addConstraint(const QgsLayerMetadata::Constraint &constraint)
Adds an individual constraint to the existing constraints.
const QgsLayerMetadata::Extent & extent() const
Returns the spatial and temporal extents associated with the resource.
void setConstraints(const QgsLayerMetadata::ConstraintList &constraints)
Sets the list of constraints associated with using the resource.
QgsLayerMetadata()=default
void setFees(const QString &fees)
Sets the fees associated with using the resource.
void setLicenses(const QStringList &licenses)
Sets a list of licenses associated with the resource.
QgsLayerMetadata::ConstraintList constraints() const
Returns a list of constraints associated with using the resource.
bool writeMetadataXml(QDomElement &metadataElement, QDomDocument &document, const QgsReadWriteContext &context=QgsReadWriteContext()) const override
Stores state in a DOM node.
void setRights(const QStringList &rights)
Sets a list of rights (attribution or copyright strings) associated with the resource.
QgsCoordinateReferenceSystem crs() const
Returns the coordinate reference system described by the layer's metadata.
void setEncoding(const QString &encoding)
Sets the character encoding of the data in the resource.
QString encoding() const
Returns the character encoding of the data in the resource.
void combine(const QgsAbstractMetadataBase *other) override
Combines the metadata from this object with the metadata from an other object.
QStringList licenses() const
Returns a list of licenses associated with the resource (examples: http://opendefinition....
void registerTranslations(QgsTranslationContext *translationContext) const override
Registers metadata translation strings.
void readFromLayer(const QgsMapLayer *layer)
Reads the metadata state from a layer's custom properties (see QgsMapLayer::customProperty() ).
void saveToLayer(QgsMapLayer *layer) const
Saves the metadata to a layer's custom properties (see QgsMapLayer::setCustomProperty() ).
QStringList rights() const
Returns a list of attribution or copyright strings associated with the resource.
void setExtent(const QgsLayerMetadata::Extent &extent)
Sets the spatial and temporal extents associated with the resource.
bool readMetadataXml(const QDomElement &metadataElement, const QgsReadWriteContext &context=QgsReadWriteContext()) override
Sets state from DOM document.
bool matches(const QVector< QRegularExpression > &searchReList) const
Returns true if the metadata identifier, title, abstract, keywords or categories matches any regular ...
bool contains(const QString &searchString) const
Returns true if the metadata identifier, title, abstract, keywords or categories contain searchString...
QList< QgsLayerMetadata::Constraint > ConstraintList
A list of constraints.
QString fees() const
Returns any fees associated with using the resource.
void setCrs(const QgsCoordinateReferenceSystem &crs)
Sets the coordinate reference system for the layer's metadata.
Base class for all map layer types.
Definition qgsmaplayer.h:80
A container for the context for various read/write operations on objects.
Used for the collecting of strings from projects for translation and creation of ts files.
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_FACTORY
Definition qgis_sip.h:84
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Metadata constraint structure.
Constraint(const QString &constraint=QString(), const QString &type=QString())
Constructor for Constraint.
QString constraint
Free-form constraint string.
QString type
Constraint type.
Metadata extent structure.
QList< QgsLayerMetadata::SpatialExtent > spatialExtents() const
Spatial extents of the resource.
void setSpatialExtents(const QList< QgsLayerMetadata::SpatialExtent > &extents)
Sets the spatial extents of the resource.
void setTemporalExtents(const QList< QgsDateTimeRange > &extents)
Sets the temporal extents of the resource.
QList< QgsDateTimeRange > temporalExtents() const
Temporal extents of the resource.
Metadata spatial extent structure.
QgsCoordinateReferenceSystem extentCrs
Coordinate reference system for spatial extent.
QgsBox3D bounds
Geospatial extent of the resource.