QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
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
175 static proj_pj_unique_ptr crsToHorizontalCrs( const PJ *crs );
176
187 static proj_pj_unique_ptr crsToVerticalCrs( const PJ *crs );
188
195 static proj_pj_unique_ptr unboundCrs( const PJ *crs );
196
208 static proj_pj_unique_ptr crsToDatumEnsemble( const PJ *crs );
209
215 static proj_pj_unique_ptr createCompoundCrs( const PJ *horizontalCrs, const PJ *verticalCrs );
216
223 static bool identifyCrs( const PJ *crs, QString &authName, QString &authCode, IdentifyFlags flags = IdentifyFlags() );
224
228 static bool coordinateOperationIsAvailable( const QString &projDef );
229
233 static QList< QgsDatumTransform::GridDetails > gridsUsed( const QString &proj );
234
235#if 0 // not possible in current Proj 6 API
236
241 static QStringList nonAvailableGrids( const QString &projDef );
242#endif
243#endif
244};
245
246#ifndef SIP_RUN
247
248#if PROJ_VERSION_MAJOR>=8
249struct pj_ctx;
250typedef struct pj_ctx PJ_CONTEXT;
251#else
252struct projCtx_t;
253typedef struct projCtx_t PJ_CONTEXT;
254#endif
255
263class CORE_EXPORT QgsProjContext
264{
265 public:
266
269
273 static PJ_CONTEXT *get();
274
275 private:
276 PJ_CONTEXT *mContext = nullptr;
277
282#if defined(USE_THREAD_LOCAL) && !defined(Q_OS_WIN)
283 static thread_local QgsProjContext sProjContext;
284#else
285 static QThreadStorage< QgsProjContext * > sProjContext;
286#endif
287};
288
290#endif
291#endif // QGSPROJUTILS_H
Used to create and store a proj context object, correctly freeing the context upon destruction.
Definition: qgsprojutils.h:264
Utility functions for working with the proj library.
Definition: qgsprojutils.h:45
IdentifyFlag
Flags controlling CRS identification behavior.
Definition: qgsprojutils.h:120
QFlags< IdentifyFlag > IdentifyFlags
Definition: qgsprojutils.h:123
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(QgsTextRendererUtils::CurvedTextFlags)
const QgsCoordinateReferenceSystem & crs
Destroys Proj PJ objects.
Definition: qgsprojutils.h:129