QGIS API Documentation 3.34.0-Prizren (ffbdd678812)
Loading...
Searching...
No Matches
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
173 static proj_pj_unique_ptr crsToHorizontalCrs( const PJ *crs );
174
181 static proj_pj_unique_ptr unboundCrs( const PJ *crs );
182
194 static proj_pj_unique_ptr crsToDatumEnsemble( const PJ *crs );
195
202 static bool identifyCrs( const PJ *crs, QString &authName, QString &authCode, IdentifyFlags flags = IdentifyFlags() );
203
207 static bool coordinateOperationIsAvailable( const QString &projDef );
208
212 static QList< QgsDatumTransform::GridDetails > gridsUsed( const QString &proj );
213
214#if 0 // not possible in current Proj 6 API
215
220 static QStringList nonAvailableGrids( const QString &projDef );
221#endif
222#endif
223};
224
225#ifndef SIP_RUN
226
227#if PROJ_VERSION_MAJOR>=8
228struct pj_ctx;
229typedef struct pj_ctx PJ_CONTEXT;
230#else
231struct projCtx_t;
232typedef struct projCtx_t PJ_CONTEXT;
233#endif
234
242class CORE_EXPORT QgsProjContext
243{
244 public:
245
248
252 static PJ_CONTEXT *get();
253
254 private:
255 PJ_CONTEXT *mContext = nullptr;
256
261#if defined(USE_THREAD_LOCAL) && !defined(Q_OS_WIN)
262 static thread_local QgsProjContext sProjContext;
263#else
264 static QThreadStorage< QgsProjContext * > sProjContext;
265#endif
266};
267
268Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProjUtils::IdentifyFlags )
269#endif
270#endif // QGSPROJUTILS_H
Used to create and store a proj context object, correctly freeing the context upon destruction.
Utility functions for working with the proj library.
IdentifyFlag
Flags controlling CRS identification behavior.
std::unique_ptr< PJ, ProjPJDeleter > proj_pj_unique_ptr
Scoped Proj PJ object.
struct PJconsts PJ
struct projCtx_t PJ_CONTEXT
struct PJconsts PJ
struct projCtx_t PJ_CONTEXT
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsTextRendererUtils::CurvedTextFlags)
const QgsCoordinateReferenceSystem & crs
Destroys Proj PJ objects.