QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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:
61 struct CORE_EXPORT SpatialExtent
62 {
70
80
81 // TODO c++20 - replace with = default
82 bool operator==( const QgsLayerMetadata::SpatialExtent &other ) const;
83 };
84
88 struct CORE_EXPORT Extent
89 {
90 public:
95 QList< QgsLayerMetadata::SpatialExtent > spatialExtents() const;
96
101 void setSpatialExtents( const QList< QgsLayerMetadata::SpatialExtent > &extents );
102
110 QList< QgsDateTimeRange > temporalExtents() const;
111
116 void setTemporalExtents( const QList< QgsDateTimeRange > &extents );
117
118 // TODO c++20 - replace with = default
119 bool operator==( const QgsLayerMetadata::Extent &other ) const;
120
121#ifndef SIP_RUN
122 private:
123 QList< QgsLayerMetadata::SpatialExtent > mSpatialExtents;
124 QList< QgsDateTimeRange > mTemporalExtents;
125
126#endif
127 };
128
132 struct CORE_EXPORT Constraint
133 {
137 Constraint( const QString &constraint = QString(), const QString &type = QString() )
138 : type( type )
140 {}
141
146 QString type;
147
151 QString constraint;
152
153 // TODO c++20 - replace with = default
154 bool operator==( const QgsLayerMetadata::Constraint &other ) const;
155 };
156
160 typedef QList< QgsLayerMetadata::Constraint > ConstraintList;
161
162 QgsLayerMetadata() = default;
163
164
165 QgsLayerMetadata *clone() const override SIP_FACTORY;
166
172 QString fees() const;
173
179 void setFees( const QString &fees );
180
186
192 void addConstraint( const QgsLayerMetadata::Constraint &constraint );
193
199
204 QStringList rights() const;
205
210 void setRights( const QStringList &rights );
211
216 QStringList licenses() const;
217
223 void setLicenses( const QStringList &licenses );
224
229 QString encoding() const;
230
235 void setEncoding( const QString &encoding );
236
241 SIP_SKIP const QgsLayerMetadata::Extent &extent() const;
242
248
253 void setExtent( const QgsLayerMetadata::Extent &extent );
254
273
296
301 void saveToLayer( QgsMapLayer *layer ) const;
302
307 void readFromLayer( const QgsMapLayer *layer );
308
309 bool readMetadataXml( const QDomElement &metadataElement, const QgsReadWriteContext &context = QgsReadWriteContext() ) override;
310 bool writeMetadataXml( QDomElement &metadataElement, QDomDocument &document, const QgsReadWriteContext &context = QgsReadWriteContext() ) const override;
311 void combine( const QgsAbstractMetadataBase *other ) override;
312 void registerTranslations( QgsTranslationContext *translationContext ) const override;
313
314 bool operator==( const QgsLayerMetadata &metadataOther ) const;
315
324 bool contains( const QString &searchString ) const;
325
332 bool matches( const QVector<QRegularExpression> &searchReList ) const;
333
334 private:
335 /*
336 * IMPORTANT!!!!!!
337 *
338 * Do NOT add anything to this class without also updating the schema
339 * definition located at resources/qgis-resource-metadata.xsd
340 *
341 */
342
343 QString mFees;
344 ConstraintList mConstraints;
345 QStringList mRights;
346 QStringList mLicenses;
347
348 // IMPORTANT - look up before adding anything here!!
349
350 QString mEncoding;
352
353 Extent mExtent;
354
355 /*
356 * IMPORTANT!!!!!!
357 *
358 * Do NOT add anything to this class without also updating the schema
359 * definition located at resources/qgis-resource-metadata.xsd
360 *
361 */
362};
363
367
368#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:45
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:83
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:133
#define SIP_FACTORY
Definition qgis_sip.h:83
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.