Skip to content

Commit b513d06

Browse files
author
rblazek
committed
changed to pj_set_finder
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5429 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 9b03b9f commit b513d06

File tree

2 files changed

+18
-35
lines changed

2 files changed

+18
-35
lines changed

src/gui/qgscoordinatetransform.cpp

Lines changed: 16 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,17 @@
2525
// Qt4-only includes to go here
2626
#include <QTextOStream>
2727
#include <QApplication>
28-
#include <QFile>
29-
30-
bool QgsCoordinateTransform::environmentSet = false;
3128

3229
QgsCoordinateTransform::QgsCoordinateTransform( ) : QObject(), mSourceSRS(), mDestSRS()
3330

3431
{
35-
setEnvironment();
32+
setFinder();
3633
}
3734

3835
QgsCoordinateTransform::QgsCoordinateTransform(const QgsSpatialRefSys& source,
3936
const QgsSpatialRefSys& dest)
4037
{
41-
setEnvironment();
38+
setFinder();
4239
mSourceSRS = source;
4340
mDestSRS = dest;
4441
initialise();
@@ -48,7 +45,7 @@ QgsCoordinateTransform::QgsCoordinateTransform(const QgsSpatialRefSys& source,
4845
QgsCoordinateTransform::QgsCoordinateTransform( QString theSourceSRS, QString theDestSRS ) : QObject()
4946

5047
{
51-
setEnvironment();
48+
setFinder();
5249
mSourceSRS.createFromWkt(theSourceSRS);
5350
mDestSRS.createFromWkt(theDestSRS);
5451
// initialize the coordinate system data structures
@@ -62,7 +59,7 @@ QgsCoordinateTransform::QgsCoordinateTransform(long theSourceSrid,
6259
QString theDestWKT,
6360
QgsSpatialRefSys::SRS_TYPE theSourceSRSType): QObject()
6461
{
65-
setEnvironment();
62+
setFinder();
6663

6764
mSourceSRS.createFromId(theSourceSrid, theSourceSRSType);
6865
mDestSRS.createFromWkt(theDestWKT);
@@ -536,42 +533,29 @@ bool QgsCoordinateTransform::writeXML( QDomNode & theNode, QDomDocument & theDoc
536533
return true;
537534
}
538535

539-
void QgsCoordinateTransform::setEnvironment()
536+
const char *finder( const char *name )
540537
{
538+
QString proj;
541539
#ifdef WIN32
542-
if ( environmentSet ) return;
543-
544-
bool set = false;
540+
proj = QApplication::applicationDirPath()
541+
+ "/share/proj/" + QString(name);
542+
#endif
543+
return proj.ascii();
544+
}
545545

546-
QString proj = getenv("PROJ_LIB");
547-
546+
void QgsCoordinateTransform::setFinder()
547+
{
548+
#ifdef WIN32
548549
// Attention! It should be possible to set PROJ_LIB
549550
// but it can happen that it was previously set by installer
550551
// (version 0.7) and the old installation was deleted
551-
// => test also if the directory exist
552552

553553
// Another problem: PROJ checks if pj_finder was set before
554554
// PROJ_LIB enviroment variable. pj_finder is probably set in
555555
// GRASS gproj library when plugin is loaded, consequently
556556
// PROJ_LIB is ignored
557-
558-
QString proj_lib = getenv("PROJ_LIB");
559-
if ( proj_lib.length() > 0 )
560-
{
561-
if ( QFile::exists ( proj_lib ) )
562-
{
563-
set = true;
564-
}
565-
}
566-
567-
if ( !set )
568-
{
569-
QString var = "PROJ_LIB=" + QApplication::applicationDirPath() + "/share/proj/";
570-
char *varChar = new char[var.length()+1];
571-
strcpy ( varChar, const_cast<char *>(var.ascii()) );
572-
putenv( varChar );
573-
}
574557

575-
environmentSet = true;
558+
pj_set_finder( finder );
576559
#endif
577560
}
561+

src/gui/qgscoordinatetransform.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,9 @@ class QgsCoordinateTransform: public QObject
252252
projPJ mDestinationProjection;
253253

254254
/*!
255-
* Set enviroment variable PROJ_LIB on Windows if not set.
255+
* Finder for PROJ grid files.
256256
*/
257-
void setEnvironment();
258-
static bool environmentSet;
257+
void setFinder();
259258
};
260259

261260
//! Output stream operator

0 commit comments

Comments
 (0)