QGIS API Documentation 4.1.0-Master (31622b25bb0)
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 Q_GADGET
58
59 Q_PROPERTY( QStringList rights READ rights )
60 Q_PROPERTY( QStringList licenses READ licenses )
61
62 public:
66 struct CORE_EXPORT SpatialExtent
67 {
75
85
86 // TODO c++20 - replace with = default
87 bool operator==( const QgsLayerMetadata::SpatialExtent &other ) const;
88 };
89
93 struct CORE_EXPORT Extent
94 {
95 public:
100 QList< QgsLayerMetadata::SpatialExtent > spatialExtents() const;
101
106 void setSpatialExtents( const QList< QgsLayerMetadata::SpatialExtent > &extents );
107
115 QList< QgsDateTimeRange > temporalExtents() const;
116
121 void setTemporalExtents( const QList< QgsDateTimeRange > &extents );
122
123 // TODO c++20 - replace with = default
124 bool operator==( const QgsLayerMetadata::Extent &other ) const;
125
126#ifndef SIP_RUN
127 private:
128 QList< QgsLayerMetadata::SpatialExtent > mSpatialExtents;
129 QList< QgsDateTimeRange > mTemporalExtents;
130
131#endif
132 };
133
137 struct CORE_EXPORT Constraint
138 {
142 Constraint( const QString &constraint = QString(), const QString &type = QString() )
143 : type( type )
145 {}
146
151 QString type;
152
156 QString constraint;
157
158 // TODO c++20 - replace with = default
159 bool operator==( const QgsLayerMetadata::Constraint &other ) const;
160 };
161
165 typedef QList< QgsLayerMetadata::Constraint > ConstraintList;
166
167 QgsLayerMetadata() = default;
168
169
170 QgsLayerMetadata *clone() const override SIP_FACTORY;
171
177 QString fees() const;
178
184 void setFees( const QString &fees );
185
191
197 void addConstraint( const QgsLayerMetadata::Constraint &constraint );
198
204
209 QStringList rights() const;
210
215 void setRights( const QStringList &rights );
216
221 QStringList licenses() const;
222
228 void setLicenses( const QStringList &licenses );
229
234 QString encoding() const;
235
240 void setEncoding( const QString &encoding );
241
246 SIP_SKIP const QgsLayerMetadata::Extent &extent() const;
247
253
258 void setExtent( const QgsLayerMetadata::Extent &extent );
259
278
301
306 void saveToLayer( QgsMapLayer *layer ) const;
307
312 void readFromLayer( const QgsMapLayer *layer );
313
314 bool readMetadataXml( const QDomElement &metadataElement, const QgsReadWriteContext &context = QgsReadWriteContext() ) override;
315 bool writeMetadataXml( QDomElement &metadataElement, QDomDocument &document, const QgsReadWriteContext &context = QgsReadWriteContext() ) const override;
316 void combine( const QgsAbstractMetadataBase *other ) override;
317 void registerTranslations( QgsTranslationContext *translationContext ) const override;
318
319 bool operator==( const QgsLayerMetadata &metadataOther ) const;
320
329 bool contains( const QString &searchString ) const;
330
337 bool matches( const QVector<QRegularExpression> &searchReList ) const;
338
339 private:
340 /*
341 * IMPORTANT!!!!!!
342 *
343 * Do NOT add anything to this class without also updating the schema
344 * definition located at resources/qgis-resource-metadata.xsd
345 *
346 */
347
348 QString mFees;
349 ConstraintList mConstraints;
350 QStringList mRights;
351 QStringList mLicenses;
352
353 // IMPORTANT - look up before adding anything here!!
354
355 QString mEncoding;
357
358 Extent mExtent;
359
360 /*
361 * IMPORTANT!!!!!!
362 *
363 * Do NOT add anything to this class without also updating the schema
364 * definition located at resources/qgis-resource-metadata.xsd
365 *
366 */
367};
368
372
373#endif // QGSLAYERMETADATA_H
QgsAbstractMetadataBase()=default
Constructor for QgsAbstractMetadataBase.
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.
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() ).
QgsLayerMetadata * clone() const override
Clones the metadata object.
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.