QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgscoordinatetransform_p.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscoordinatetransform_p.h
3  --------------------------
4  begin : July 2016
5  copyright : (C) 2016 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 QGSCOORDINATETRANSFORMPRIVATE_H
18 #define QGSCOORDINATETRANSFORMPRIVATE_H
19 
20 #define SIP_NO_FILE
21 #include "qgsconfig.h"
22 
24 
25 //
26 // W A R N I N G
27 // -------------
28 //
29 // This file is not part of the QGIS API. It exists purely as an
30 // implementation detail. This header file may change from version to
31 // version without notice, or even be removed.
32 //
33 
34 #include <QSharedData>
35 
36 #ifndef USE_THREAD_LOCAL
37 #include <QThreadStorage>
38 #endif
39 
42 
43 typedef void *projPJ;
44 typedef void *projCtx;
45 
51 class QgsProjContextStore
52 {
53  public:
54 
55  QgsProjContextStore();
56  ~QgsProjContextStore();
57 
58  projCtx get() { return context; }
59 
60  private:
61  projCtx context;
62 };
63 
64 class QgsCoordinateTransformPrivate : public QSharedData
65 {
66 
67  public:
68 
69  explicit QgsCoordinateTransformPrivate();
70 
71  QgsCoordinateTransformPrivate( const QgsCoordinateReferenceSystem &source,
72  const QgsCoordinateReferenceSystem &destination,
73  const QgsCoordinateTransformContext &context );
74 
75  QgsCoordinateTransformPrivate( const QgsCoordinateReferenceSystem &source,
76  const QgsCoordinateReferenceSystem &destination,
77  int sourceDatumTransform,
78  int destDatumTransform );
79 
80  QgsCoordinateTransformPrivate( const QgsCoordinateTransformPrivate &other );
81 
82  ~QgsCoordinateTransformPrivate();
83 
84  bool checkValidity();
85 
86  void invalidate();
87 
88  bool initialize();
89 
90  void calculateTransforms( const QgsCoordinateTransformContext &context );
91 
92  QPair< projPJ, projPJ > threadLocalProjData();
93 
98  bool mIsValid = false;
99 
104  bool mShortCircuit = false;
105 
107  QgsCoordinateReferenceSystem mSourceCRS;
108 
111 
112  QString mSourceProjString;
113  QString mDestProjString;
114 
115  int mSourceDatumTransform = -1;
116  int mDestinationDatumTransform = -1;
117 
122 #ifdef USE_THREAD_LOCAL
123  static thread_local QgsProjContextStore mProjContext;
124 #else
125  static QThreadStorage< QgsProjContextStore * > mProjContext;
126 #endif
127 
128  QReadWriteLock mProjLock;
129  QMap < uintptr_t, QPair< projPJ, projPJ > > mProjProjections;
130 
131  private:
132 
134  QString stripDatumTransform( const QString &proj4 ) const;
135 
137  void addNullGridShifts( QString &srcProjString, QString &destProjString, int sourceDatumTransform, int destinationDatumTransform ) const;
138 
139  void setFinder();
140 
141  void freeProj();
142 };
143 
145 
146 #endif // QGSCOORDINATETRANSFORMPRIVATE_H
Contains information about the context in which a coordinate transform is executed.
This class represents a coordinate reference system (CRS).