Skip to content

Commit e17e69b

Browse files
mkofahltbonfort
authored andcommitted
Evaluate a possibly set environment variable PROJ_LIB (#4930).
1 parent 6c72159 commit e17e69b

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed

mapproject.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,18 @@ static const char *msProjFinder( const char *filename)
12451245
}
12461246
#endif /* def USE_PROJ */
12471247

1248+
/************************************************************************/
1249+
/* msProjLibInitFromEnv() */
1250+
/************************************************************************/
1251+
void msProjLibInitFromEnv()
1252+
{
1253+
const char *val;
1254+
1255+
if( (val=getenv( "PROJ_LIB" )) != NULL ) {
1256+
msSetPROJ_LIB(val, NULL);
1257+
}
1258+
}
1259+
12481260
/************************************************************************/
12491261
/* msSetPROJ_LIB() */
12501262
/************************************************************************/

mapproject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ extern "C" {
9999
double *x, double *y );
100100

101101
MS_DLL_EXPORT void msSetPROJ_LIB( const char *, const char * );
102+
MS_DLL_EXPORT void msProjLibInitFromEnv();
102103

103104
/* Provides compatiblity with PROJ.4 4.4.2 */
104105
#ifndef PJ_VERSION

mapservutil.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,6 +1817,10 @@ int msCGIHandler(const char *query_string, void **out_buffer, size_t *buffer_len
18171817
msIOBuffer *buf;
18181818

18191819
msIO_installStdoutToBuffer();
1820+
1821+
/* Use PROJ_LIB env vars if set */
1822+
msProjLibInitFromEnv();
1823+
18201824
/* Use MS_ERRORFILE and MS_DEBUGLEVEL env vars if set */
18211825
if( msDebugInitFromEnv() != MS_SUCCESS ) {
18221826
msCGIWriteError(mapserv);

maputil.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1893,6 +1893,9 @@ int msSetup()
18931893
msThreadInit();
18941894
#endif
18951895

1896+
/* Use PROJ_LIB env vars if set */
1897+
msProjLibInitFromEnv();
1898+
18961899
/* Use MS_ERRORFILE and MS_DEBUGLEVEL env vars if set */
18971900
if (msDebugInitFromEnv() != MS_SUCCESS)
18981901
return MS_FAILURE;

shp2img.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ int main(int argc, char *argv[])
113113
exit(1);
114114
}
115115

116+
/* Use PROJ_LIB env vars if set */
117+
msProjLibInitFromEnv();
118+
116119
/* Use MS_ERRORFILE and MS_DEBUGLEVEL env vars if set */
117120
if ( msDebugInitFromEnv() != MS_SUCCESS ) {
118121
msWriteError(stderr);

0 commit comments

Comments
 (0)