QGIS API Documentation 3.37.0-Master (fa0c88a90b0)
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_sip.h"
22#include "qgis_core.h"
24#include "qgsbox3d.h"
25#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 )
145 , constraint( constraint )
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
172 QgsLayerMetadata() = default;
173
174
175 QgsLayerMetadata *clone() const override SIP_FACTORY;
176
182 QString fees() const;
183
189 void setFees( const QString &fees );
190
195 QgsLayerMetadata::ConstraintList constraints() const;
196
202 void addConstraint( const QgsLayerMetadata::Constraint &constraint );
203
208 void setConstraints( const QgsLayerMetadata::ConstraintList &constraints );
209
214 QStringList rights() const;
215
220 void setRights( const QStringList &rights );
221
226 QStringList licenses() const;
227
233 void setLicenses( const QStringList &licenses );
234
239 QString encoding() const;
240
245 void setEncoding( const QString &encoding );
246
251 SIP_SKIP const QgsLayerMetadata::Extent &extent() const;
252
257 QgsLayerMetadata::Extent &extent();
258
263 void setExtent( const QgsLayerMetadata::Extent &extent );
264
283
305 void setCrs( const QgsCoordinateReferenceSystem &crs );
306
311 void saveToLayer( QgsMapLayer *layer ) const;
312
317 void readFromLayer( const QgsMapLayer *layer );
318
319 bool readMetadataXml( const QDomElement &metadataElement ) override;
320 bool writeMetadataXml( QDomElement &metadataElement, QDomDocument &document ) const override;
321 void combine( const QgsAbstractMetadataBase *other ) override;
322
323 bool operator==( const QgsLayerMetadata &metadataOther ) const;
324
333 bool contains( const QString &searchString ) const;
334
341 bool matches( const QVector<QRegularExpression> &searchReList ) const;
342
343 private:
344
345 /*
346 * IMPORTANT!!!!!!
347 *
348 * Do NOT add anything to this class without also updating the schema
349 * definition located at resources/qgis-resource-metadata.xsd
350 *
351 */
352
353 QString mFees;
354 ConstraintList mConstraints;
355 QStringList mRights;
356 QStringList mLicenses;
357
358 // IMPORTANT - look up before adding anything here!!
359
360 QString mEncoding;
362
363 Extent mExtent;
364
365 /*
366 * IMPORTANT!!!!!!
367 *
368 * Do NOT add anything to this class without also updating the schema
369 * definition located at resources/qgis-resource-metadata.xsd
370 *
371 */
372
373};
374
378
379#endif // QGSLAYERMETADATA_H
An abstract base class for metadata stores.
virtual QgsAbstractMetadataBase * clone() const =0
Clones the metadata object.
A 3-dimensional box composed of x, y, z coordinates.
Definition: qgsbox3d.h:43
This class represents a coordinate reference system (CRS).
A structured metadata store for a map layer.
QgsLayerMetadata()=default
Constructor for QgsLayerMetadata.
QList< QgsLayerMetadata::Constraint > ConstraintList
A list of constraints.
Base class for all map layer types.
Definition: qgsmaplayer.h:75
#define SIP_SKIP
Definition: qgis_sip.h:126
#define SIP_FACTORY
Definition: qgis_sip.h:76
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
const QgsCoordinateReferenceSystem & crs
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.
Metadata spatial extent structure.
QgsCoordinateReferenceSystem extentCrs
Coordinate reference system for spatial extent.
QgsBox3D bounds
Geospatial extent of the resource.