QGIS API Documentation  3.0.2-Girona (307d082)
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.h"
22 #include "qgis_core.h"
24 #include "qgsbox3d.h"
25 #include "qgsrange.h"
26 
27 class QgsMapLayer;
28 
55 class CORE_EXPORT QgsLayerMetadata
56 {
57  public:
58 
62  typedef QMap< QString, QStringList > KeywordMap;
63 
67  struct CORE_EXPORT SpatialExtent
68  {
69 
77 
87 
88  bool operator==( const QgsLayerMetadata::SpatialExtent &other ) const;
89  };
90 
94  struct CORE_EXPORT Extent
95  {
96  public:
97 
102  QList< QgsLayerMetadata::SpatialExtent > spatialExtents() const;
103 
108  void setSpatialExtents( const QList< QgsLayerMetadata::SpatialExtent > &extents );
109 
117  QList< QgsDateTimeRange > temporalExtents() const;
118 
123  void setTemporalExtents( const QList< QgsDateTimeRange > &extents );
124 
125  bool operator==( const QgsLayerMetadata::Extent &other ) const;
126 
127 #ifndef SIP_RUN
128  private:
129 
130  QList< QgsLayerMetadata::SpatialExtent > mSpatialExtents;
131  QList< QgsDateTimeRange > mTemporalExtents;
132 
133 #endif
134 
135  };
136 
140  struct CORE_EXPORT Constraint
141  {
142 
146  Constraint( const QString &constraint = QString(), const QString &type = QString() )
147  : type( type )
148  , constraint( constraint )
149  {}
150 
155  QString type;
156 
160  QString constraint;
161 
162  bool operator==( const QgsLayerMetadata::Constraint &other ) const;
163 
164  };
165 
169  typedef QList< QgsLayerMetadata::Constraint > ConstraintList;
170 
171 
175  struct CORE_EXPORT Address
176  {
177 
181  Address( const QString &type = QString(), const QString &address = QString(), const QString &city = QString(), const QString &administrativeArea = QString(), const QString &postalCode = QString(), const QString &country = QString() )
182  : type( type )
183  , address( address )
184  , city( city )
185  , administrativeArea( administrativeArea )
186  , postalCode( postalCode )
187  , country( country )
188  {}
189 
193  QString type;
194 
198  QString address;
199 
203  QString city;
204 
209 
213  QString postalCode;
214 
218  QString country;
219 
220  bool operator==( const QgsLayerMetadata::Address &other ) const;
221  };
222 
226  struct CORE_EXPORT Contact
227  {
228 
232  Contact( const QString &name = QString() )
233  : name( name )
234  {}
235 
239  QString name;
240 
244  QString organization;
245 
249  QString position;
250 
254  QList< QgsLayerMetadata::Address > addresses;
255 
259  QString voice;
260 
264  QString fax;
265 
270  QString email;
271 
277  QString role;
278 
279  bool operator==( const QgsLayerMetadata::Contact &other ) const;
280  };
281 
285  typedef QList< QgsLayerMetadata::Contact > ContactList;
286 
287 
291  struct CORE_EXPORT Link
292  {
293 
297  Link( const QString &name = QString(), const QString &type = QString(), const QString &url = QString() )
298  : name( name )
299  , type( type )
300  , url( url )
301  {}
302 
306  QString name;
307 
312  QString type;
313 
317  QString description;
318 
322  QString url;
323 
327  QString format;
328 
332  QString mimeType;
333 
337  QString size;
338 
339  bool operator==( const QgsLayerMetadata::Link &other ) const;
340  };
341 
345  typedef QList< QgsLayerMetadata::Link > LinkList;
346 
350  QgsLayerMetadata() = default;
351 
352  virtual ~QgsLayerMetadata() = default;
353 
358  QString identifier() const;
359 
364  void setIdentifier( const QString &identifier );
365 
371  QString parentIdentifier() const;
372 
378  void setParentIdentifier( const QString &parentIdentifier );
379 
387  QString language() const;
388 
395  void setLanguage( const QString &language );
396 
402  QString type() const;
403 
409  void setType( const QString &type );
410 
415  QString title() const;
416 
421  void setTitle( const QString &title );
422 
427  QString abstract() const;
428 
433  void setAbstract( const QString &abstract );
434 
440  QString fees() const;
441 
447  void setFees( const QString &fees );
448 
453  QgsLayerMetadata::ConstraintList constraints() const;
454 
460  void addConstraint( const QgsLayerMetadata::Constraint &constraint );
461 
466  void setConstraints( const QgsLayerMetadata::ConstraintList &constraints );
467 
472  QStringList rights() const;
473 
478  void setRights( const QStringList &rights );
479 
484  QStringList licenses() const;
485 
491  void setLicenses( const QStringList &licenses );
492 
497  QStringList history() const;
498 
505  void setHistory( const QStringList &history );
506 
512  void addHistoryItem( const QString &text );
513 
518  QString encoding() const;
519 
524  void setEncoding( const QString &encoding );
525 
530  SIP_SKIP const QgsLayerMetadata::Extent &extent() const;
531 
536  QgsLayerMetadata::Extent &extent();
537 
542  void setExtent( const QgsLayerMetadata::Extent &extent );
543 
561  QgsCoordinateReferenceSystem crs() const;
562 
584  void setCrs( const QgsCoordinateReferenceSystem &crs );
585 
597  KeywordMap keywords() const;
598 
611  void setKeywords( const KeywordMap &keywords );
612 
623  void addKeywords( const QString &vocabulary, const QStringList &keywords );
624 
631  bool removeKeywords( const QString &vocabulary );
632 
641  QStringList keywordVocabularies() const;
642 
653  QStringList keywords( const QString &vocabulary ) const;
654 
661  QStringList categories() const;
662 
669  void setCategories( const QStringList &categories );
670 
675  QgsLayerMetadata::ContactList contacts() const;
676 
683  void setContacts( const QgsLayerMetadata::ContactList &contacts );
684 
690  void addContact( const QgsLayerMetadata::Contact &contact );
691 
696  QgsLayerMetadata::LinkList links() const;
697 
704  void setLinks( const QgsLayerMetadata::LinkList &links );
705 
711  void addLink( const QgsLayerMetadata::Link &link );
712 
717  void saveToLayer( QgsMapLayer *layer ) const;
718 
723  void readFromLayer( const QgsMapLayer *layer );
724 
731  bool readMetadataXml( const QDomElement &metadataElement );
732 
740  bool writeMetadataXml( QDomElement &metadataElement, QDomDocument &document ) const;
741 
742  bool operator==( const QgsLayerMetadata &metadataOther ) const;
743 
744  private:
745 
746  /*
747  * IMPORTANT!!!!!!
748  *
749  * Do NOT add anything to this class without also updating the schema
750  * definition located at resources/qgis-resource-metadata.xsd
751  *
752  */
753 
754  QString mIdentifier;
755  QString mParentIdentifier;
756  QString mLanguage;
757  QString mType;
758  QString mTitle;
759  QString mAbstract;
760  QString mFees;
761  ConstraintList mConstraints;
762  QStringList mRights;
763  QStringList mLicenses;
764  QStringList mHistory;
765 
766  // IMPORTANT - look up before adding anything here!!
767 
768  QString mEncoding;
770 
771  Extent mExtent;
772 
776  KeywordMap mKeywords;
777 
778  ContactList mContacts;
779 
780  LinkList mLinks;
781 
782  /*
783  * IMPORTANT!!!!!!
784  *
785  * Do NOT add anything to this class without also updating the schema
786  * definition located at resources/qgis-resource-metadata.xsd
787  *
788  */
789 
790 };
791 
797 
798 #endif // QGSLAYERMETADATA_H
Base class for all map layer types.
Definition: qgsmaplayer.h:56
QString name
Name of contact.
bool operator==(const QgsFeatureIterator &fi1, const QgsFeatureIterator &fi2)
QString role
Role of contact.
Constraint(const QString &constraint=QString(), const QString &type=QString())
Constructor for Constraint.
QString position
Position/title of contact.
QString organization
Organization contact belongs to/represents.
QString fax
Facsimile telephone.
A 3-dimensional box composed of x, y, z coordinates.
Definition: qgsbox3d.h:35
Q_DECLARE_METATYPE(QModelIndex)
QList< QgsLayerMetadata::Link > LinkList
A list of links.
QgsCoordinateReferenceSystem extentCrs
Coordinate reference system for spatial extent.
QString type
Constraint type.
QList< QgsLayerMetadata::Contact > ContactList
A list of contacts.
Metadata address structure.
Metadata constraint structure.
Address(const QString &type=QString(), const QString &address=QString(), const QString &city=QString(), const QString &administrativeArea=QString(), const QString &postalCode=QString(), const QString &country=QString())
Constructor for Address.
#define SIP_SKIP
Definition: qgis_sip.h:119
QString postalCode
Postal (or ZIP) code.
Metadata extent structure.
QString email
Electronic mail address.
Contact(const QString &name=QString())
Constructor for Contact.
QMap< QString, QStringList > KeywordMap
Map of vocabulary string to keyword list.
A structured metadata store for a map layer.
QString voice
Voice telephone.
Metadata contact structure.
QgsBox3d bounds
Geospatial extent of the resource.
This class represents a coordinate reference system (CRS).
QString city
City or locality name.
QList< QgsLayerMetadata::Address > addresses
List of addresses associated with this contact.
QString constraint
Free-form constraint string.
QList< QgsLayerMetadata::Constraint > ConstraintList
A list of constraints.
Metadata spatial extent structure.
QString address
Free-form physical address component, e.g.
QString administrativeArea
Administrative area (state, province/territory, etc.).
QString country
Free-form country string.
QString type
Type of address, e.g.