LCOV - code coverage report
Current view: top level - core - qgscoordinatereferencesystemregistry.h (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 0 2 0.0 %
Date: 2021-03-26 12:19:53 Functions: 0 0 -
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /***************************************************************************
       2                 :            :                              qgscoordinatereferencesystemregistry.h
       3                 :            :                              -------------------
       4                 :            :     begin                : January 2021
       5                 :            :     copyright            : (C) 2021 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 QGSCOORDINATEREFERENCESYSTEMREGISTRY_H
      19                 :            : #define QGSCOORDINATEREFERENCESYSTEMREGISTRY_H
      20                 :            : 
      21                 :            : #include <QObject>
      22                 :            : #include "qgscoordinatereferencesystem.h"
      23                 :            : 
      24                 :            : /**
      25                 :            :  * \class QgsCoordinateReferenceSystemRegistry
      26                 :            :  * \ingroup core
      27                 :            :  * \brief A registry for known coordinate reference system (CRS) definitions, including
      28                 :            :  * any user-defined CRSes.
      29                 :            :  *
      30                 :            :  * QgsCoordinateReferenceSystemRegistry is not usually directly created, but rather accessed through
      31                 :            :  * QgsApplication::coordinateReferenceSystemRegistry().
      32                 :            :  *
      33                 :            :  * \since QGIS 3.18
      34                 :            :  */
      35                 :            : class CORE_EXPORT QgsCoordinateReferenceSystemRegistry : public QObject
      36                 :            : {
      37                 :            :     Q_OBJECT
      38                 :            :   public:
      39                 :            : 
      40                 :            :     /**
      41                 :            :      * Constructor for QgsCoordinateReferenceSystemRegistry, with the specified \a parent object.
      42                 :            :      */
      43                 :            :     explicit QgsCoordinateReferenceSystemRegistry( QObject *parent = nullptr );
      44                 :            : 
      45                 :            :     /**
      46                 :            :      * \brief Contains details of a custom (user defined) CRS.
      47                 :            :      * \ingroup core
      48                 :            :      * \since QGIS 3.18
      49                 :            :      */
      50                 :          0 :     class UserCrsDetails
      51                 :            :     {
      52                 :            :       public:
      53                 :            : 
      54                 :            :         //! CRS ID
      55                 :          0 :         long id = -1;
      56                 :            : 
      57                 :            :         //! CRS name (or description)
      58                 :            :         QString name;
      59                 :            : 
      60                 :            :         //! PROJ string definition of CRS
      61                 :            :         QString proj;
      62                 :            : 
      63                 :            :         /**
      64                 :            :          * WKT definition of CRS. This will be empty for custom CRSes
      65                 :            :          * which were defined using a PROJ string only.
      66                 :            :          */
      67                 :            :         QString wkt;
      68                 :            : 
      69                 :            :         //! QgsCoordinateReferenceSystem object representing the user-defined CRS.
      70                 :            :         QgsCoordinateReferenceSystem crs;
      71                 :            :     };
      72                 :            : 
      73                 :            :     /**
      74                 :            :      * Returns a list containing the details of all registered
      75                 :            :      * custom (user-defined) CRSes.
      76                 :            :      */
      77                 :            :     QList< QgsCoordinateReferenceSystemRegistry::UserCrsDetails > userCrsList() const;
      78                 :            : 
      79                 :            :     /**
      80                 :            :      * Adds a new \a crs definition as a custom ("USER") CRS.
      81                 :            :      *
      82                 :            :      * Returns the new CRS srsid(), or -1 if the CRS could not be saved.
      83                 :            :      *
      84                 :            :      * The \a nativeFormat argument specifies the format to use when saving the CRS
      85                 :            :      * definition. FormatWkt is recommended as it is a lossless format.
      86                 :            :      *
      87                 :            :      * \warning Not all CRS definitions can be represented as a Proj string, so
      88                 :            :      * take care when using the FormatProj option.
      89                 :            :      *
      90                 :            :      * \see updateUserCrs()
      91                 :            :      * \see userCrsAdded()
      92                 :            :      */
      93                 :            :     long addUserCrs( const QgsCoordinateReferenceSystem &crs, const QString &name, QgsCoordinateReferenceSystem::Format nativeFormat = QgsCoordinateReferenceSystem::FormatWkt );
      94                 :            : 
      95                 :            :     /**
      96                 :            :      * Updates the definition of the existing user CRS with matching \a id.
      97                 :            :      *
      98                 :            :      * The \a crs argument specifies a CRS with the desired new definition.
      99                 :            :      *
     100                 :            :      * Returns FALSE if the new CRS definition could not be saved.
     101                 :            :      *
     102                 :            :      * The \a nativeFormat argument specifies the format to use when saving the CRS
     103                 :            :      * definition. FormatWkt is recommended as it is a lossless format.
     104                 :            :      *
     105                 :            :      * \warning Not all CRS definitions can be represented as a Proj string, so
     106                 :            :      * take care when using the FormatProj option.
     107                 :            :      *
     108                 :            :      * \see addUserCrs()
     109                 :            :      * \see userCrsChanged()
     110                 :            :      */
     111                 :            :     bool updateUserCrs( long id, const QgsCoordinateReferenceSystem &crs, const QString &name, QgsCoordinateReferenceSystem::Format nativeFormat = QgsCoordinateReferenceSystem::FormatWkt );
     112                 :            : 
     113                 :            :     /**
     114                 :            :      * Removes the existing user CRS with matching \a id.
     115                 :            :      *
     116                 :            :      * Returns FALSE if the CRS could not be removed.
     117                 :            :      *
     118                 :            :      * \see userCrsRemoved()
     119                 :            :      */
     120                 :            :     bool removeUserCrs( long id );
     121                 :            : 
     122                 :            :   signals:
     123                 :            : 
     124                 :            :     /**
     125                 :            :      * Emitted whenever an existing user CRS definition is changed.
     126                 :            :      *
     127                 :            :      * The \a id argument specifies the ID of the user CRS which has been changed.
     128                 :            :      *
     129                 :            :      * Objects which store QgsCoordinateReferenceSystem members should connect to this signal
     130                 :            :      * and update any stored CRS definitions to ensure that they always use the current
     131                 :            :      * definition of any user defined CRSes.
     132                 :            :      *
     133                 :            :      * \see crsDefinitionsChanged()
     134                 :            :      * \see userCrsAdded()
     135                 :            :      */
     136                 :            :     void userCrsChanged( const QString &id );
     137                 :            : 
     138                 :            :     /**
     139                 :            :      * Emitted whenever a new user CRS definition is added.
     140                 :            :      *
     141                 :            :      * The \a id argument specifies the ID of the user CRS which has been changed.
     142                 :            :      *
     143                 :            :      * \see userCrsChanged()
     144                 :            :      * \see crsDefinitionsChanged()
     145                 :            :      */
     146                 :            :     void userCrsAdded( const QString &id );
     147                 :            : 
     148                 :            :     /**
     149                 :            :      * Emitted when the user CRS with matching \a id is removed
     150                 :            :      * from the database.
     151                 :            :      *
     152                 :            :      * \see removeUserCrs()
     153                 :            :      */
     154                 :            :     void userCrsRemoved( long id );
     155                 :            : 
     156                 :            :     /**
     157                 :            :      * Emitted whenever an operation has caused any of the known CRS definitions (including
     158                 :            :      * user-defined CRS) to change.
     159                 :            :      */
     160                 :            :     void crsDefinitionsChanged();
     161                 :            : 
     162                 :            :   private:
     163                 :            : 
     164                 :            :     bool insertProjection( const QString &projectionAcronym );
     165                 :            : 
     166                 :            : };
     167                 :            : 
     168                 :            : 
     169                 :            : #endif // QGSCOORDINATEREFERENCESYSTEMREGISTRY_H

Generated by: LCOV version 1.14