Quantum GIS API Documentation  1.8
src/core/qgscrscache.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                               qgscrscache.cpp
00003                               ---------------
00004   begin                : September 6th, 2011
00005   copyright            : (C) 2011 by Marco Hugentobler
00006   email                : marco dot hugentobler at sourcepole dot ch
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include "qgscrscache.h"
00019 
00020 QgsCRSCache* QgsCRSCache::mInstance = 0;
00021 
00022 QgsCRSCache* QgsCRSCache::instance()
00023 {
00024   if ( !mInstance )
00025   {
00026     mInstance = new QgsCRSCache();
00027   }
00028   return mInstance;
00029 }
00030 
00031 QgsCRSCache::QgsCRSCache()
00032 {
00033 }
00034 
00035 QgsCRSCache::~QgsCRSCache()
00036 {
00037   delete mInstance;
00038 }
00039 
00040 const QgsCoordinateReferenceSystem& QgsCRSCache::crsByAuthId( const QString& authid )
00041 {
00042   QHash< QString, QgsCoordinateReferenceSystem >::const_iterator crsIt = mCRS.find( authid );
00043   if ( crsIt == mCRS.constEnd() )
00044   {
00045     QgsCoordinateReferenceSystem s;
00046     if ( ! s.createFromOgcWmsCrs( authid ) )
00047     {
00048       return mInvalidCRS;
00049     }
00050     return mCRS.insert( authid, s ).value();
00051   }
00052   else
00053   {
00054     return crsIt.value();
00055   }
00056 }
00057 
00058 const QgsCoordinateReferenceSystem& QgsCRSCache::crsByEpsgId( long epsg )
00059 {
00060   return crsByAuthId( "EPSG:" + QString::number( epsg ) );
00061 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines