QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "qgssingleton.h"
23 #include <QHash>
24 
26 
29 class CORE_EXPORT QgsCoordinateTransformCache : public QgsSingleton<QgsCoordinateTransformCache>
30 {
31  public:
39  const QgsCoordinateTransform* transform( const QString& srcAuthId, const QString& destAuthId, int srcDatumTransform = -1, int destDatumTransform = -1 );
41  void invalidateCrs( const QString& crsAuthId );
42 
43  private:
44  QMultiHash< QPair< QString, QString >, QgsCoordinateTransform* > mTransforms; //same auth_id pairs might have different datum transformations
45 };
46 
47 class CORE_EXPORT QgsCRSCache
48 {
49  public:
50  static QgsCRSCache* instance();
51  ~QgsCRSCache();
53  const QgsCoordinateReferenceSystem& crsByAuthId( const QString& authid );
54  const QgsCoordinateReferenceSystem& crsByEpsgId( long epsg );
55 
56  void updateCRSCache( const QString &authid );
57 
58  protected:
59  QgsCRSCache();
60 
61  private:
62  QHash< QString, QgsCoordinateReferenceSystem > mCRS;
64  QgsCoordinateReferenceSystem mInvalidCRS;
65 };
66 
67 #endif // QGSCRSCACHE_H