QGIS API Documentation 3.39.0-Master (f6cef42644e)
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
175 static proj_pj_unique_ptr crsToHorizontalCrs( const PJ *crs );
176
187 static proj_pj_unique_ptr crsToVerticalCrs( const PJ *crs );
188
194 static bool hasVerticalAxis( const PJ *crs );
195
202 static proj_pj_unique_ptr unboundCrs( const PJ *crs );
203
215 static proj_pj_unique_ptr crsToDatumEnsemble( const PJ *crs );
216
224 static proj_pj_unique_ptr createCompoundCrs( const PJ *horizontalCrs, const PJ *verticalCrs, QStringList *errors = nullptr );
225
232 static bool identifyCrs( const PJ *crs, QString &authName, QString &authCode, IdentifyFlags flags = IdentifyFlags() );
233
237 static bool coordinateOperationIsAvailable( const QString &projDef );
238
242 static QList< QgsDatumTransform::GridDetails > gridsUsed( const QString &proj );
243
244#if 0 // not possible in current Proj 6 API
245
250 static QStringList nonAvailableGrids( const QString &projDef );
251#endif
252#endif
253};
254
255#ifndef SIP_RUN
256
257#if PROJ_VERSION_MAJOR>=8
258struct pj_ctx;
259typedef struct pj_ctx PJ_CONTEXT;
260#else
261struct projCtx_t;
262typedef struct projCtx_t PJ_CONTEXT;
263#endif
264
272class CORE_EXPORT QgsProjContext
273{
274 public:
275
278
282 static PJ_CONTEXT *get();
283
284 private:
285 PJ_CONTEXT *mContext = nullptr;
286
291#if defined(USE_THREAD_LOCAL) && !defined(Q_OS_WIN)
292 static thread_local QgsProjContext sProjContext;
293#else
294 static QThreadStorage< QgsProjContext * > sProjContext;
295#endif
296};
297
299#endif
300#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.
QFlags< IdentifyFlag > IdentifyFlags
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.