QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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  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  bool operator==( const QgsLayerMetadata::Extent &other ) const;
122 
123 #ifndef SIP_RUN
124  private:
125 
126  QList< QgsLayerMetadata::SpatialExtent > mSpatialExtents;
127  QList< QgsDateTimeRange > mTemporalExtents;
128 
129 #endif
130 
131  };
132 
136  struct CORE_EXPORT Constraint
137  {
138 
142  Constraint( const QString &constraint = QString(), const QString &type = QString() )
143  : type( type )
144  , constraint( constraint )
145  {}
146 
151  QString type;
152 
156  QString constraint;
157 
158  bool operator==( const QgsLayerMetadata::Constraint &other ) const;
159 
160  };
161 
165  typedef QList< QgsLayerMetadata::Constraint > ConstraintList;
166 
170  QgsLayerMetadata() = default;
171 
172  QgsLayerMetadata *clone() const override SIP_FACTORY;
173 
179  QString fees() const;
180 
186  void setFees( const QString &fees );
187 
192  QgsLayerMetadata::ConstraintList constraints() const;
193 
199  void addConstraint( const QgsLayerMetadata::Constraint &constraint );
200 
205  void setConstraints( const QgsLayerMetadata::ConstraintList &constraints );
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 
254  QgsLayerMetadata::Extent &extent();
255 
260  void setExtent( const QgsLayerMetadata::Extent &extent );
261 
280 
302  void setCrs( const QgsCoordinateReferenceSystem &crs );
303 
308  void saveToLayer( QgsMapLayer *layer ) const;
309 
314  void readFromLayer( const QgsMapLayer *layer );
315 
316  bool readMetadataXml( const QDomElement &metadataElement ) override;
317  bool writeMetadataXml( QDomElement &metadataElement, QDomDocument &document ) const override;
318 
319  bool operator==( const QgsLayerMetadata &metadataOther ) const;
320 
321  private:
322 
323  /*
324  * IMPORTANT!!!!!!
325  *
326  * Do NOT add anything to this class without also updating the schema
327  * definition located at resources/qgis-resource-metadata.xsd
328  *
329  */
330 
331  QString mFees;
332  ConstraintList mConstraints;
333  QStringList mRights;
334  QStringList mLicenses;
335 
336  // IMPORTANT - look up before adding anything here!!
337 
338  QString mEncoding;
340 
341  Extent mExtent;
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 };
352 
355 
356 #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:399
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:142
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
Q_DECLARE_METATYPE
Q_DECLARE_METATYPE(QgsMeshTimeSettings)
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsLayerMetadata::ConstraintList
QList< QgsLayerMetadata::Constraint > ConstraintList
A list of constraints.
Definition: qgslayermetadata.h:165
QgsLayerMetadata::Constraint::type
QString type
Constraint type.
Definition: qgslayermetadata.h:151
QgsLayerMetadata::Constraint::constraint
QString constraint
Free-form constraint string.
Definition: qgslayermetadata.h:156
qgis_sip.h
qgsbox3d.h
QgsLayerMetadata::Extent
Metadata extent structure.
Definition: qgslayermetadata.h:90
QgsCoordinateReferenceSystem
Definition: qgscoordinatereferencesystem.h:206
QgsMapLayer
Definition: qgsmaplayer.h:81
QgsLayerMetadata::Constraint
Metadata constraint structure.
Definition: qgslayermetadata.h:136
qgsabstractmetadatabase.h
QgsBox3d
Definition: qgsbox3d.h:36
QgsAbstractMetadataBase
An abstract base class for metadata stores.
Definition: qgsabstractmetadatabase.h:56
qgscoordinatereferencesystem.h