QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 
28 class QgsMapLayer;
29 
56 class CORE_EXPORT QgsLayerMetadata : public QgsAbstractMetadataBase
57 {
58  public:
59 
63  struct CORE_EXPORT SpatialExtent
64  {
65 
73 
83 
84  // TODO c++20 - replace with = default
85  bool operator==( const QgsLayerMetadata::SpatialExtent &other ) const;
86  };
87 
91  struct CORE_EXPORT Extent
92  {
93  public:
94 
99  QList< QgsLayerMetadata::SpatialExtent > spatialExtents() const;
100 
105  void setSpatialExtents( const QList< QgsLayerMetadata::SpatialExtent > &extents );
106 
114  QList< QgsDateTimeRange > temporalExtents() const;
115 
120  void setTemporalExtents( const QList< QgsDateTimeRange > &extents );
121 
122  // TODO c++20 - replace with = default
123  bool operator==( const QgsLayerMetadata::Extent &other ) const;
124 
125 #ifndef SIP_RUN
126  private:
127 
128  QList< QgsLayerMetadata::SpatialExtent > mSpatialExtents;
129  QList< QgsDateTimeRange > mTemporalExtents;
130 
131 #endif
132 
133  };
134 
138  struct CORE_EXPORT Constraint
139  {
140 
144  Constraint( const QString &constraint = QString(), const QString &type = QString() )
145  : type( type )
146  , constraint( constraint )
147  {}
148 
153  QString type;
154 
158  QString constraint;
159 
160  // TODO c++20 - replace with = default
161  bool operator==( const QgsLayerMetadata::Constraint &other ) const;
162 
163  };
164 
168  typedef QList< QgsLayerMetadata::Constraint > ConstraintList;
169 
173  QgsLayerMetadata() = default;
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 
325  private:
326 
327  /*
328  * IMPORTANT!!!!!!
329  *
330  * Do NOT add anything to this class without also updating the schema
331  * definition located at resources/qgis-resource-metadata.xsd
332  *
333  */
334 
335  QString mFees;
336  ConstraintList mConstraints;
337  QStringList mRights;
338  QStringList mLicenses;
339 
340  // IMPORTANT - look up before adding anything here!!
341 
342  QString mEncoding;
344 
345  Extent mExtent;
346 
347  /*
348  * IMPORTANT!!!!!!
349  *
350  * Do NOT add anything to this class without also updating the schema
351  * definition located at resources/qgis-resource-metadata.xsd
352  *
353  */
354 
355 };
356 
359 
360 #endif // QGSLAYERMETADATA_H
QgsLayerMetadata::SpatialExtent::extentCrs
QgsCoordinateReferenceSystem extentCrs
Coordinate reference system for spatial extent.
Definition: qgslayermetadata.h:72
operator==
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
Definition: qgsfeatureiterator.h:425
QgsLayerMetadata::SpatialExtent
Metadata spatial extent structure.
Definition: qgslayermetadata.h:63
QgsLayerMetadata::Constraint::Constraint
Constraint(const QString &constraint=QString(), const QString &type=QString())
Constructor for Constraint.
Definition: qgslayermetadata.h:144
crs
const QgsCoordinateReferenceSystem & crs
Definition: qgswfsgetfeature.cpp:105
QgsLayerMetadata
A structured metadata store for a map layer.
Definition: qgslayermetadata.h:56
qgsrange.h
QgsLayerMetadata::SpatialExtent::bounds
QgsBox3d bounds
Geospatial extent of the resource.
Definition: qgslayermetadata.h:82
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsLayerMetadata::ConstraintList
QList< QgsLayerMetadata::Constraint > ConstraintList
A list of constraints.
Definition: qgslayermetadata.h:168
QgsLayerMetadata::Constraint::type
QString type
Constraint type.
Definition: qgslayermetadata.h:153
QgsLayerMetadata::Constraint::constraint
QString constraint
Free-form constraint string.
Definition: qgslayermetadata.h:158
qgis_sip.h
qgsbox3d.h
QgsLayerMetadata::Extent
Metadata extent structure.
Definition: qgslayermetadata.h:91
QgsCoordinateReferenceSystem
This class represents a coordinate reference system (CRS).
Definition: qgscoordinatereferencesystem.h:211
QgsMapLayer
Base class for all map layer types. This is the base class for all map layer types (vector,...
Definition: qgsmaplayer.h:72
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(QgsDatabaseQueryLogEntry)
QgsLayerMetadata::Constraint
Metadata constraint structure.
Definition: qgslayermetadata.h:138
qgsabstractmetadatabase.h
QgsBox3d
A 3-dimensional box composed of x, y, z coordinates.
Definition: qgsbox3d.h:38
QgsAbstractMetadataBase
An abstract base class for metadata stores.
Definition: qgsabstractmetadatabase.h:56
qgscoordinatereferencesystem.h