QGIS API Documentation 3.41.0-Master (d5b93354e9c)
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
249 static void proj_logger( void *user_data, int level, const char *message );
250
258 static void proj_collecting_logger( void *user_data, int level, const char *message );
259
260#if 0 // not possible in current Proj 6 API
261
266 static QStringList nonAvailableGrids( const QString &projDef );
267#endif
268#endif
269};
270
271#ifndef SIP_RUN
272
273#if PROJ_VERSION_MAJOR>=8
274struct pj_ctx;
275typedef struct pj_ctx PJ_CONTEXT;
276#else
277struct projCtx_t;
278typedef struct projCtx_t PJ_CONTEXT;
279#endif
280
288class CORE_EXPORT QgsProjContext
289{
290 public:
291
294
298 static PJ_CONTEXT *get();
299
300 private:
301 PJ_CONTEXT *mContext = nullptr;
302
307#if defined(USE_THREAD_LOCAL) && !defined(Q_OS_WIN)
308 static thread_local QgsProjContext sProjContext;
309#else
310 static QThreadStorage< QgsProjContext * > sProjContext;
311#endif
312};
313
314
329{
330 public:
331
338
343
347 QStringList errors() const { return mProjErrors; }
348
349 private:
350
351 QStringList mProjErrors;
352};
353
355#endif
356#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.
Scoped object for temporary swapping to an error-collecting PROJ log function.
QStringList errors() const
Returns the (possibly empty) list of collected errors.
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.