37d36 < #include "ogr_spatialref.h" 78,80c77 < VSILFILE *fp; < < char *pszProjection; --- > VSILFILE *fp; 83d79 < SAGADataset(); 96,99c92,93 < < virtual const char *GetProjectionRef(void); < virtual CPLErr SetProjection( const char * ); < virtual char **GetFileList(); --- > > virtual char **GetFileList(); 308,344d301 < /************************************************************************/ < /* OSR_GDS() */ < /************************************************************************/ < < static const char*OSR_GDS( char* pszResult, int nResultLen, < char **papszNV, const char * pszField, < const char *pszDefaultValue ) < < { < int iLine; < < if( papszNV == NULL || papszNV[0] == NULL ) < return pszDefaultValue; < < for( iLine = 0; < papszNV[iLine] != NULL && < !EQUALN(papszNV[iLine],pszField,strlen(pszField)); < iLine++ ) {} < < if( papszNV[iLine] == NULL ) < return pszDefaultValue; < else < { < char **papszTokens; < < papszTokens = CSLTokenizeString(papszNV[iLine]); < < if( CSLCount(papszTokens) > 1 ) < strncpy( pszResult, papszTokens[1], nResultLen); < else < strncpy( pszResult, pszDefaultValue, nResultLen); < pszResult[nResultLen-1] = '\0'; < < CSLDestroy( papszTokens ); < return pszResult; < } < } 352,363d308 < SAGADataset::SAGADataset() < < { < pszProjection = CPLStrdup(""); < } < < /************************************************************************/ < /* ==================================================================== */ < /* ~SAGADataset */ < /* ==================================================================== */ < /************************************************************************/ < 370,371d314 < < CPLFree( pszProjection ); 374,429d316 < /************************************************************************/ < /* GetProjectionRef() */ < /************************************************************************/ < < const char *SAGADataset::GetProjectionRef() < < { < if (pszProjection && strlen(pszProjection) > 0) < return pszProjection; < < return GDALPamDataset::GetProjectionRef(); < } < < /************************************************************************/ < /* SetProjection() */ < /************************************************************************/ < < CPLErr SAGADataset::SetProjection( const char *pszSRS ) < < { < /* -------------------------------------------------------------------- */ < /* Reset coordinate system on the dataset. */ < /* -------------------------------------------------------------------- */ < CPLFree( pszProjection ); < pszProjection = CPLStrdup( pszSRS ); < < if( strlen(pszSRS) == 0 ) < return CE_None; < < /* -------------------------------------------------------------------- */ < /* Convert to ESRI WKT. */ < /* -------------------------------------------------------------------- */ < OGRSpatialReference oSRS( pszSRS ); < char *pszESRI_SRS = NULL; < < oSRS.morphToESRI(); < oSRS.exportToWkt( &pszESRI_SRS ); < < /* -------------------------------------------------------------------- */ < /* Write to .prj file. */ < /* -------------------------------------------------------------------- */ < CPLString osPrjFilename = CPLResetExtension( GetDescription(), "prj" ); < VSILFILE *fp; < < fp = VSIFOpenL( osPrjFilename.c_str(), "wt" ); < if( fp != NULL ) < { < VSIFWriteL( pszESRI_SRS, 1, strlen(pszESRI_SRS), fp ); < VSIFWriteL( (void *) "\n", 1, 1, fp ); < VSIFCloseL( fp ); < } < < CPLFree( pszESRI_SRS ); < < return CE_None; < } 437d323 < VSIStatBufL sStatBuf; 439a326 > CPLString osHDRFilename; 447,454c334,336 < CPLString osFilename = CPLFormCIFilename( osPath, osName, ".sgrd" ); < papszFileList = CSLAddString( papszFileList, osFilename ); < < // projections file. < osFilename = CPLFormCIFilename( osPath, osName, "prj" ); < if( VSIStatExL( osFilename, &sStatBuf, VSI_STAT_EXISTS_FLAG ) == 0 ) < papszFileList = CSLAddString( papszFileList, osFilename ); < --- > osHDRFilename = CPLFormCIFilename( osPath, osName, ".sgrd" ); > papszFileList = CSLAddString( papszFileList, osHDRFilename ); > 686,732d567 < /* Check for a .prj file. */ < /* -------------------------------------------------------------------- */ < const char *pszPrjFilename = CPLFormCIFilename( osPath, osName, "prj" ); < < fp = VSIFOpenL( pszPrjFilename, "r" ); < < if( fp != NULL ) < { < char **papszLines; < OGRSpatialReference oSRS; < < VSIFCloseL( fp ); < < papszLines = CSLLoad( pszPrjFilename ); < < if( oSRS.importFromESRI( papszLines ) == OGRERR_NONE ) < { < // If geographic values are in seconds, we must transform. < // Is there a code for minutes too? < char szResult[80]; < if( oSRS.IsGeographic() < && EQUAL(OSR_GDS( szResult, sizeof(szResult), < papszLines, "Units", ""), "DS") ) < { < < double adfGeoTransform[6]; < < poDS->GetGeoTransform( adfGeoTransform ); < < adfGeoTransform[0] /= 3600.0; < adfGeoTransform[1] /= 3600.0; < adfGeoTransform[2] /= 3600.0; < adfGeoTransform[3] /= 3600.0; < adfGeoTransform[4] /= 3600.0; < adfGeoTransform[5] /= 3600.0; < < poDS->SetGeoTransform( adfGeoTransform ); < } < < CPLFree( poDS->pszProjection ); < oSRS.exportToWkt( &(poDS->pszProjection) ); < } < < CSLDestroy( papszLines ); < } < < /* -------------------------------------------------------------------- */ 1132,1133d966 < < poDstDS->SetProjection( poSrcDS->GetProjectionRef() );