static void CPLFinderInit() { if( !bFinderInitialized ) { bFinderInitialized = TRUE; CPLPushFileFinder( CPLDefaultFindFile ); CPLPushFinderLocation( "." ); if( CPLGetConfigOption( "GDAL_DATA", NULL ) != NULL ) { CPLPushFinderLocation( CPLGetConfigOption( "GDAL_DATA", NULL ) ); } else { #ifdef GDAL_PREFIX #ifdef MACOSX_FRAMEWORK CPLPushFinderLocation( GDAL_PREFIX "/Resources/gdal" ); #else CPLPushFinderLocation( GDAL_PREFIX "/share/gdal" ); #endif #else CPLPushFinderLocation( "/usr/local/share/gdal" ); #endif } } }
static FindFileTLS* CPLFinderInit() { FindFileTLS* pTLSData = CPLGetFindFileTLS(); if( pTLSData != NULL && !pTLSData->bFinderInitialized ) { pTLSData->bFinderInitialized = TRUE; CPLPushFileFinder( CPLDefaultFindFile ); CPLPushFinderLocation( "." ); if( CPLGetConfigOption( "GDAL_DATA", NULL ) != NULL ) { CPLPushFinderLocation( CPLGetConfigOption( "GDAL_DATA", NULL ) ); } else { #ifdef GDAL_PREFIX #ifdef MACOSX_FRAMEWORK CPLPushFinderLocation( GDAL_PREFIX "/Resources/gdal" ); #else CPLPushFinderLocation( GDAL_PREFIX "/share/gdal" ); #endif #else CPLPushFinderLocation( "/usr/local/share/gdal" ); #endif } } return pTLSData; }
static FindFileTLS* CPLFinderInit() { FindFileTLS* pTLSData = CPLGetFindFileTLS(); if( pTLSData != nullptr && !pTLSData->bFinderInitialized ) { pTLSData->bFinderInitialized = true; CPLPushFileFinder( CPLDefaultFindFile ); CPLPushFinderLocation( "." ); if( CPLGetConfigOption( "GDAL_DATA", nullptr ) != nullptr ) { CPLPushFinderLocation( CPLGetConfigOption( "GDAL_DATA", nullptr ) ); } else { #ifdef INST_DATA CPLPushFinderLocation( INST_DATA ); #endif #ifdef GDAL_PREFIX #ifdef MACOSX_FRAMEWORK CPLPushFinderLocation( GDAL_PREFIX "/Resources/gdal" ); #else CPLPushFinderLocation( GDAL_PREFIX "/share/gdal" ); #endif #endif } } return pTLSData; }
static void CPLFinderInit() { if( !bFinderInitialized ) { bFinderInitialized = TRUE; CPLPushFileFinder( CPLDefaultFindFile ); CPLPushFinderLocation( "/usr/local/share/gdal" ); CPLPushFinderLocation( "." ); } }
const char * GDALDefaultCSVFilename( const char *pszBasename ) { static char szPath[512]; FILE *fp = NULL; const char *pszResult; static int bFinderInitialized = FALSE; pszResult = CPLFindFile( "epsg_csv", pszBasename ); if( pszResult != NULL ) return pszResult; if( !bFinderInitialized ) { bFinderInitialized = TRUE; if( CPLGetConfigOption("GEOTIFF_CSV",NULL) != NULL ) CPLPushFinderLocation( CPLGetConfigOption("GEOTIFF_CSV",NULL)); if( CPLGetConfigOption("GDAL_DATA",NULL) != NULL ) CPLPushFinderLocation( CPLGetConfigOption("GDAL_DATA",NULL) ); pszResult = CPLFindFile( "epsg_csv", pszBasename ); if( pszResult != NULL ) return pszResult; } if( (fp = fopen( "csv/horiz_cs.csv", "rt" )) != NULL ) { sprintf( szPath, "csv/%s", pszBasename ); } else { sprintf( szPath, "/usr/local/share/epsg_csv/%s", pszBasename ); if( (fp = fopen( szPath, "rt" )) == NULL ) strcpy( szPath, pszBasename ); } if( fp != NULL ) fclose( fp ); return( szPath ); }
const char * GDALDefaultCSVFilename( const char *pszBasename ) { /* -------------------------------------------------------------------- */ /* Do we already have this file accessed? If so, just return */ /* the existing path without any further probing. */ /* -------------------------------------------------------------------- */ CSVTable **ppsCSVTableList; ppsCSVTableList = (CSVTable **) CPLGetTLS( CTLS_CSVTABLEPTR ); if( ppsCSVTableList != NULL ) { CSVTable *psTable; int nBasenameLen = strlen(pszBasename); for( psTable = *ppsCSVTableList; psTable != NULL; psTable = psTable->psNext ) { int nFullLen = strlen(psTable->pszFilename); if( nFullLen > nBasenameLen && strcmp(psTable->pszFilename+nFullLen-nBasenameLen, pszBasename) == 0 && strchr("/\\",psTable->pszFilename[+nFullLen-nBasenameLen-1]) != NULL ) { return psTable->pszFilename; } } } /* -------------------------------------------------------------------- */ /* Otherwise we need to look harder for it. */ /* -------------------------------------------------------------------- */ DefaultCSVFileNameTLS* pTLSData = (DefaultCSVFileNameTLS *) CPLGetTLS( CTLS_CSVDEFAULTFILENAME ); if (pTLSData == NULL) { pTLSData = (DefaultCSVFileNameTLS*) CPLCalloc(1, sizeof(DefaultCSVFileNameTLS)); CPLSetTLS( CTLS_CSVDEFAULTFILENAME, pTLSData, TRUE ); } FILE *fp = NULL; const char *pszResult; pszResult = CPLFindFile( "epsg_csv", pszBasename ); if( pszResult != NULL ) return pszResult; if( !pTLSData->bCSVFinderInitialized ) { pTLSData->bCSVFinderInitialized = TRUE; if( CPLGetConfigOption("GEOTIFF_CSV",NULL) != NULL ) CPLPushFinderLocation( CPLGetConfigOption("GEOTIFF_CSV",NULL)); if( CPLGetConfigOption("GDAL_DATA",NULL) != NULL ) CPLPushFinderLocation( CPLGetConfigOption("GDAL_DATA",NULL) ); pszResult = CPLFindFile( "epsg_csv", pszBasename ); if( pszResult != NULL ) return pszResult; } if( (fp = fopen( "csv/horiz_cs.csv", "rt" )) != NULL ) { strcpy( pTLSData->szPath, "csv/" ); CPLStrlcat( pTLSData->szPath, pszBasename, sizeof(pTLSData->szPath) ); } else { #ifdef GDAL_PREFIX #ifdef MACOSX_FRAMEWORK strcpy( pTLSData->szPath, GDAL_PREFIX "/Resources/epsg_csv/" ); CPLStrlcat( pTLSData->szPath, pszBasename, sizeof(pTLSData->szPath) ); #else strcpy( pTLSData->szPath, GDAL_PREFIX "/share/epsg_csv/" ); CPLStrlcat( pTLSData->szPath, pszBasename, sizeof(pTLSData->szPath) ); #endif #else strcpy( pTLSData->szPath, "/usr/local/share/epsg_csv/" ); CPLStrlcat( pTLSData->szPath, pszBasename, sizeof(pTLSData->szPath) ); #endif if( (fp = fopen( pTLSData->szPath, "rt" )) == NULL ) CPLStrlcpy( pTLSData->szPath, pszBasename, sizeof(pTLSData->szPath) ); } if( fp != NULL ) fclose( fp ); return( pTLSData->szPath ); }
int main( int nArgc, char ** papszArgv ) { RegisterOGRGML(); /* -------------------------------------------------------------------- */ /* Process any configuration switches. */ /* -------------------------------------------------------------------- */ int iArg; for( iArg = 1; iArg < nArgc; iArg++ ) { if( EQUAL(papszArgv[iArg],"-log") && iArg < nArgc-1 ) { char *pszLogEnv = (char *) CPLMalloc(strlen(papszArgv[iArg+1])+20); sprintf( pszLogEnv, "CPL_LOG=%s", papszArgv[iArg+1] ); putenv( pszLogEnv ); iArg++; } else if( EQUAL(papszArgv[iArg],"-debug") ) { putenv( "CPL_DEBUG=ON" ); putenv( "PROJ_DEBUG=ON" ); } else if( EQUAL(papszArgv[iArg],"-data") && iArg < nArgc-1 ) { CPLPushFinderLocation( papszArgv[++iArg] ); } else if( EQUAL(papszArgv[iArg],"-put") ) { putenv( "REQUEST_METHOD=PUT" ); } else if( EQUAL(papszArgv[iArg],"-get") && iArg < nArgc-1 ) { char *pszLogEnv = (char *) CPLMalloc(strlen(papszArgv[iArg+1])+20); sprintf( pszLogEnv, "QUERY_STRING=%s", papszArgv[iArg+1] ); putenv( pszLogEnv ); putenv( "REQUEST_METHOD=GET" ); iArg++; } else { WCTSEmitServiceException( "Server misconfigured, unknown commandline options received.\n" "\n" "Usage: ogrwcts [-log logfilename] [-debug] [-data directory]\n" " [-get url] [-put]\n" ); } } /* -------------------------------------------------------------------- */ /* Collect the request as a parsed XML document. */ /* -------------------------------------------------------------------- */ CPLXMLNode *psRequest; psRequest = WCTSCollectRequest(); /* -------------------------------------------------------------------- */ /* Scan for known operation nodes. */ /* -------------------------------------------------------------------- */ CPLXMLNode *psOperation; for( psOperation = psRequest; psOperation != NULL; psOperation = psOperation->psNext ) { if( psOperation->eType == CXT_Element && EQUAL(psOperation->pszValue,"GetCapabilities") ) { WCTSGetCapabilities( psOperation ); assert( FALSE ); } else if( psOperation->eType == CXT_Element && EQUAL(psOperation->pszValue,"IsTransformable") ) { WCTSIsTransformable( psOperation ); assert( FALSE ); } else if( psOperation->eType == CXT_Element && EQUAL(psOperation->pszValue,"Transform") ) { WCTSTransform( psOperation ); assert( FALSE ); } else if( psOperation->eType == CXT_Element && EQUAL(psOperation->pszValue,"DescribeTransformation") ) { WCTSEmitServiceException( "This server does not support the DescribeTransformation operation." ); } } CPLDestroyXMLNode( psRequest ); WCTSEmitServiceException( "No recognisable supported request found." ); exit( 1 ); }