QGIS API Documentation 3.28.0-Firenze (ed3ad0430f)
qgsprojutils.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsprojutils.h
3 -------------------
4 begin : March 2019
5 copyright : (C) 2019 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#ifndef QGSPROJUTILS_H
18#define QGSPROJUTILS_H
19
20#include <QtGlobal>
21
22#include "qgis_core.h"
23#include "qgis_sip.h"
24#include "qgsconfig.h"
25#include "qgsdatumtransform.h"
26#include <memory>
27#include <QStringList>
28
29#if !defined(USE_THREAD_LOCAL) || defined(Q_OS_WIN)
30#include <QThreadStorage>
31#endif
32
33#ifndef SIP_RUN
34struct PJconsts;
35typedef struct PJconsts PJ;
36#endif
37
44class CORE_EXPORT QgsProjUtils
45{
46 public:
47
51 static int projVersionMajor();
52
58 static int projVersionMinor();
59
66 static QString epsgRegistryVersion();
67
74 static QDate epsgRegistryDate();
75
82 static QString esriDatabaseVersion();
83
90 static QDate esriDatabaseDate();
91
98 static QString ignfDatabaseVersion();
99
106 static QDate ignfDatabaseDate();
107
114 static QStringList searchPaths();
115
116#ifndef SIP_RUN
117
120 {
121 FlagMatchBoundCrsToUnderlyingSourceCrs = 1 << 0,
122 };
123 Q_DECLARE_FLAGS( IdentifyFlags, IdentifyFlag )
124
125
129 {
130
134 void CORE_EXPORT operator()( PJ *object ) const;
135
136 };
137
141 using proj_pj_unique_ptr = std::unique_ptr< PJ, ProjPJDeleter >;
142
147 static bool usesAngularUnit( const QString &projDef );
148
149 //TODO - remove when proj 6.1 is minimum supported version, and replace with proj_normalize_for_visualization
150
155 static bool axisOrderIsSwapped( const PJ *crs );
156
165 static bool isDynamic( const PJ *crs );
166
171 static proj_pj_unique_ptr crsToSingleCrs( const PJ *crs );
172
182 static proj_pj_unique_ptr crsToDatumEnsemble( const PJ *crs );
183
190 static bool identifyCrs( const PJ *crs, QString &authName, QString &authCode, IdentifyFlags flags = IdentifyFlags() );
191
195 static bool coordinateOperationIsAvailable( const QString &projDef );
196
200 static QList< QgsDatumTransform::GridDetails > gridsUsed( const QString &proj );
201
202#if 0 // not possible in current Proj 6 API
203
208 static QStringList nonAvailableGrids( const QString &projDef );
209#endif
210#endif
211};
212
213#ifndef SIP_RUN
214
215#if PROJ_VERSION_MAJOR>=8
216struct pj_ctx;
217typedef struct pj_ctx PJ_CONTEXT;
218#else
219struct projCtx_t;
220typedef struct projCtx_t PJ_CONTEXT;
221#endif
222
230class CORE_EXPORT QgsProjContext
231{
232 public:
233
236
240 static PJ_CONTEXT *get();
241
242 private:
243 PJ_CONTEXT *mContext = nullptr;
244
249#if defined(USE_THREAD_LOCAL) && !defined(Q_OS_WIN)
250 static thread_local QgsProjContext sProjContext;
251#else
252 static QThreadStorage< QgsProjContext * > sProjContext;
253#endif
254};
255
256Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProjUtils::IdentifyFlags )
257#endif
258#endif // QGSPROJUTILS_H
Used to create and store a proj context object, correctly freeing the context upon destruction.
Definition: qgsprojutils.h:231
Utility functions for working with the proj library.
Definition: qgsprojutils.h:45
IdentifyFlag
Flags controlling CRS identification behavior.
Definition: qgsprojutils.h:120
std::unique_ptr< PJ, ProjPJDeleter > proj_pj_unique_ptr
Scoped Proj PJ object.
Definition: qgsprojutils.h:141
struct PJconsts PJ
struct projCtx_t PJ_CONTEXT
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
const QgsCoordinateReferenceSystem & crs
Destroys Proj PJ objects.
Definition: qgsprojutils.h:129