QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgscrscache.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgscrscache.h
3  --------------
4  begin : September 6th, 2011
5  copyright : (C) 2011 by Marco Hugentobler
6  email : marco dot hugentobler at sourcepole dot ch
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 
18 #ifndef QGSCRSCACHE_H
19 #define QGSCRSCACHE_H
20 
22 #include <QHash>
23 #include <QReadWriteLock>
24 
26 
30 class CORE_EXPORT QgsCoordinateTransformCache
31 {
32  public:
33  static QgsCoordinateTransformCache* instance();
34 
42  const QgsCoordinateTransform* transform( const QString& srcAuthId, const QString& destAuthId, int srcDatumTransform = -1, int destDatumTransform = -1 );
44  void invalidateCrs( const QString& crsAuthId );
45 
46  private:
47  QMultiHash< QPair< QString, QString >, QgsCoordinateTransform* > mTransforms; //same auth_id pairs might have different datum transformations
48 
52 };
53 
54 
55 
67 class CORE_EXPORT QgsCRSCache
68 {
69  public:
70 
72  static QgsCRSCache* instance();
73 
77  Q_DECL_DEPRECATED QgsCoordinateReferenceSystem crsByAuthId( const QString& authid );
78 
85  QgsCoordinateReferenceSystem crsByOgcWmsCrs( const QString& ogcCrs ) const;
86 
91  QgsCoordinateReferenceSystem crsByEpsgId( long epsg ) const;
92 
99  QgsCoordinateReferenceSystem crsByProj4( const QString& proj4 ) const;
100 
107  QgsCoordinateReferenceSystem crsByWkt( const QString& wkt ) const;
108 
115  QgsCoordinateReferenceSystem crsBySrsId( long srsId ) const;
116 
121  void updateCRSCache( const QString& authid );
122 
123  protected:
124  QgsCRSCache();
125 
126  private:
127 
128  mutable QReadWriteLock mCRSLock;
130  mutable QReadWriteLock mCRSProj4Lock;
132  mutable QReadWriteLock mCRSWktLock;
134  mutable QReadWriteLock mCRSSrsIdLock;
136 
138  QgsCoordinateReferenceSystem mInvalidCRS;
139 
140  QgsCRSCache( const QgsCRSCache& other );
141 };
142 
143 #endif // QGSCRSCACHE_H
Caches QgsCoordinateReferenceSystem construction, which may be expensive.
Definition: qgscrscache.h:67
Class for storing a coordinate reference system (CRS)
Class for doing transforms between two map coordinate systems.
Cache coordinate transform by authid of source/dest transformation to avoid the overhead of initializ...
Definition: qgscrscache.h:30