char *OCTProj4Normalize( const char *pszProj4Src ) { char *pszNewProj4Def, *pszCopy; projPJ psPJSource = NULL; CPLMutexHolderD( &hPROJMutex ); if( !LoadProjLibrary() || pfn_pj_dalloc == NULL || pfn_pj_get_def == NULL ) return CPLStrdup( pszProj4Src ); psPJSource = pfn_pj_init_plus( pszProj4Src ); if( psPJSource == NULL ) return CPLStrdup( pszProj4Src ); pszNewProj4Def = pfn_pj_get_def( psPJSource, 0 ); pfn_pj_free( psPJSource ); if( pszNewProj4Def == NULL ) return CPLStrdup( pszProj4Src ); pszCopy = CPLStrdup( pszNewProj4Def ); pfn_pj_dalloc( pszNewProj4Def ); return pszCopy; }
OGRProj4CT::~OGRProj4CT() { if( poSRSSource != NULL ) { if( poSRSSource->Dereference() <= 0 ) delete poSRSSource; } if( poSRSTarget != NULL ) { if( poSRSTarget->Dereference() <= 0 ) delete poSRSTarget; } if (pjctx != NULL) { pfn_pj_ctx_free(pjctx); if( psPJSource != NULL ) pfn_pj_free( psPJSource ); if( psPJTarget != NULL ) pfn_pj_free( psPJTarget ); } else { CPLMutexHolderD( &hPROJMutex ); if( psPJSource != NULL ) pfn_pj_free( psPJSource ); if( psPJTarget != NULL ) pfn_pj_free( psPJTarget ); } CPLFree(padfOriX); CPLFree(padfOriY); CPLFree(padfOriZ); CPLFree(padfTargetX); CPLFree(padfTargetY); CPLFree(padfTargetZ); }
/** This function is really just here since we already have all * the code to load libproj.so. It is intended to "normalize" * a proj.4 definition, expanding +init= definitions and so * forth as possible. */ static char *OCTProj4NormalizeInternal( const char *pszProj4Src ) { char *pszNewProj4Def, *pszCopy; projPJ psPJSource = NULL; psPJSource = pfn_pj_init_plus( pszProj4Src ); if( psPJSource == NULL ) return CPLStrdup( pszProj4Src ); pszNewProj4Def = pfn_pj_get_def( psPJSource, 0 ); pfn_pj_free( psPJSource ); if( pszNewProj4Def == NULL ) return CPLStrdup( pszProj4Src ); pszCopy = CPLStrdup( pszNewProj4Def ); pfn_pj_dalloc( pszNewProj4Def ); return pszCopy; }