OGRErr OGRSpatialReference::importFromDict( const char *pszDictFile, const char *pszCode ) { /* -------------------------------------------------------------------- */ /* Find and open file. */ /* -------------------------------------------------------------------- */ CPLString osDictFile(pszDictFile); const char *pszFilename = CPLFindFile( "gdal", pszDictFile ); if( pszFilename == nullptr ) return OGRERR_UNSUPPORTED_SRS; VSILFILE *fp = VSIFOpenL( pszFilename, "rb" ); if( fp == nullptr ) return OGRERR_UNSUPPORTED_SRS; /* -------------------------------------------------------------------- */ /* Process lines. */ /* -------------------------------------------------------------------- */ OGRErr eErr = OGRERR_UNSUPPORTED_SRS; const char *pszLine = nullptr; while( (pszLine = CPLReadLineL(fp)) != nullptr ) { if( pszLine[0] == '#' ) continue; if( STARTS_WITH_CI(pszLine, "include ") ) { eErr = importFromDict( pszLine + 8, pszCode ); if( eErr != OGRERR_UNSUPPORTED_SRS ) break; continue; } if( strstr(pszLine, ",") == nullptr ) continue; if( EQUALN(pszLine, pszCode, strlen(pszCode)) && pszLine[strlen(pszCode)] == ',' ) { const char *pszWKT = pszLine + strlen(pszCode)+1; eErr = importFromWkt( pszWKT ); if( eErr == OGRERR_NONE && osDictFile.find("esri_") == 0 ) { morphFromESRI(); } break; } } /* -------------------------------------------------------------------- */ /* Cleanup */ /* -------------------------------------------------------------------- */ VSIFCloseL( fp ); return eErr; }
OGRErr OGRSpatialReference::importFromDict( const char *pszDictFile, const char *pszCode ) { const char *pszFilename; FILE *fp; OGRErr eErr = OGRERR_UNSUPPORTED_SRS; /* -------------------------------------------------------------------- */ /* Find and open file. */ /* -------------------------------------------------------------------- */ pszFilename = CPLFindFile( "gdal", pszDictFile ); if( pszFilename == NULL ) return OGRERR_UNSUPPORTED_SRS; fp = VSIFOpen( pszFilename, "rb" ); if( fp == NULL ) return OGRERR_UNSUPPORTED_SRS; /* -------------------------------------------------------------------- */ /* Process lines. */ /* -------------------------------------------------------------------- */ const char *pszLine; while( (pszLine = CPLReadLine(fp)) != NULL ) { if( pszLine[0] == '#' ) /* do nothing */; else if( EQUALN(pszLine,"include ",8) ) { eErr = importFromDict( pszLine + 8, pszCode ); if( eErr != OGRERR_UNSUPPORTED_SRS ) break; } else if( strstr(pszLine,",") == NULL ) /* do nothing */; else if( EQUALN(pszLine,pszCode,strlen(pszCode)) && pszLine[strlen(pszCode)] == ',' ) { char *pszWKT = (char *) pszLine + strlen(pszCode)+1; eErr = importFromWkt( &pszWKT ); break; } } /* -------------------------------------------------------------------- */ /* Cleanup */ /* -------------------------------------------------------------------- */ VSIFClose( fp ); return eErr; }
OGRErr OGR_SRSNode::importFromWkt( char ** ppszInput ) { int nNodes = 0; return importFromWkt( ppszInput, 0, &nNodes ); }