Changeset 13182
- Timestamp:
- 12/01/07 14:47:15 (7 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
sandbox/warmerdam/1.4-esri/gdal/frmts/raw/envidataset.cpp
r12325 r13182 35 35 36 36 CPL_C_START 37 void GDALRegister_ENVI(void);37 void GDALRegister_ENVI(void); 38 38 CPL_C_END 39 39 … … 228 228 int ReadHeader( FILE * ); 229 229 int ProcessMapinfo( const char * ); 230 void ProcessRPCinfo( const char * ); 230 void ProcessRPCinfo( const char * ,int ,int); 231 void ProcessStatsFile(); 232 long byteSwapLong(long); 233 float byteSwapFloat(float); 234 double byteSwapDouble(double); 231 235 void SetENVIDatum( OGRSpatialReference *, const char * ); 232 236 void SetENVIEllipse( OGRSpatialReference *, char ** ); … … 239 243 240 244 public: 241 ENVIDataset();242 ~ENVIDataset();245 ENVIDataset(); 246 ~ENVIDataset(); 243 247 244 248 virtual void FlushCache( void ); … … 306 310 RawDataset::FlushCache(); 307 311 308 if ( !bHeaderDirty )312 if ( !bHeaderDirty) 309 313 return; 310 314 315 /* Retrieve the old system locale so we can restore it later. */ 316 char *strLocale, strLocaleReset[1024]; 317 strLocale = setlocale(LC_NUMERIC, NULL); 318 /* Make a copy as the return value does change. */ 319 strncpy(strLocaleReset, strLocale, 1024); 320 /* Set to a default numeric locale with radix character '.'. */ 321 strLocale = setlocale(LC_NUMERIC, "C"); 311 322 VSIFSeek( fp, 0, SEEK_SET ); 312 313 323 /* -------------------------------------------------------------------- */ 314 324 /* Rewrite out the header. */ … … 318 328 const char *pszInterleaving; 319 329 char** catNames; 320 330 321 331 #ifdef CPL_LSB 322 332 iBigEndian = 0; … … 333 343 GDALRasterBand* band = GetRasterBand(1); 334 344 catNames = band->GetCategoryNames(); 345 335 346 VSIFPrintf( fp, "header offset = 0\n"); 336 347 if (0 == catNames) … … 338 349 else 339 350 VSIFPrintf( fp, "file type = ENVI Classification\n" ); 351 340 352 int iENVIType = GetEnviType(band->GetRasterDataType()); 341 353 VSIFPrintf( fp, "data type = %d\n", iENVIType ); … … 357 369 VSIFPrintf( fp, "interleave = %s\n", pszInterleaving); 358 370 VSIFPrintf( fp, "byte order = %d\n", iBigEndian ); 359 360 371 361 372 /* -------------------------------------------------------------------- */ … … 414 425 /* -------------------------------------------------------------------- */ 415 426 WriteProjectionInfo(); 427 428 416 429 VSIFPrintf( fp, "band names = {\n" ); 417 430 for ( int i = 1; i <= nBands; i++ ) … … 426 439 } 427 440 VSIFPrintf( fp, "}\n" ); 441 442 /* Reset to the system locale. */ 443 setlocale(LC_NUMERIC, strLocaleReset); 444 428 445 } 429 446 … … 725 742 osCommaDatum.c_str(), osOptionalUnits.c_str() ); 726 743 727 VSIFPrintf( fp, "projection info = {9, %.16g, %.16g, %.16g, %.16g, %.16g, %.16g, %.16g, %.16g%s, Albers Conical Equal Area}\n",744 VSIFPrintf( fp, "projection info = {9, %.16g, %.16g, %.16g, %.16g, %.16g, %.16g, %.16g, %.16g%s, Albers Conical Equal Area}\n", 728 745 dfA, dfB, 729 746 oSRS.GetNormProjParm(SRS_PP_LATITUDE_OF_ORIGIN,0.0), … … 932 949 else if( EQUAL(pszENVIDatumName, "Geocentric Datum of Australia 1994") ) 933 950 poSRS->SetWellKnownGeogCS( "EPSG:4283" ); 951 else if( EQUAL(pszENVIDatumName, "Australian Geodetic 1984") ) 952 poSRS->SetWellKnownGeogCS( "EPSG:4203" ); 934 953 else if( EQUAL(pszENVIDatumName, "Nouvelle Triangulation Francaise IGN") ) 935 954 poSRS->SetWellKnownGeogCS( "EPSG:4275" ); … … 1033 1052 SetENVIDatum( &oSRS, papszFields[9] ); 1034 1053 else 1035 oSRS.SetWellKnownGeogCS( " WGS84" );1054 oSRS.SetWellKnownGeogCS( "NAD27" ); 1036 1055 } 1037 1056 else if( EQUALN(papszFields[0],"State Plane (NAD 27)",19) … … 1222 1241 /************************************************************************/ 1223 1242 1224 void ENVIDataset::ProcessRPCinfo( const char *pszRPCinfo ) 1243 void ENVIDataset::ProcessRPCinfo( const char *pszRPCinfo, 1244 int numCols, int numRows) 1225 1245 { 1226 1246 char **papszFields; … … 1237 1257 } 1238 1258 1239 snprintf(sVal, sizeof(sVal), "%.16 f",atof(papszFields[0]));1259 snprintf(sVal, sizeof(sVal), "%.16g",atof(papszFields[0])); 1240 1260 SetMetadataItem("RPC_LINE_OFF",sVal); 1241 snprintf(sVal, sizeof(sVal), "%.16 f",atof(papszFields[5]));1261 snprintf(sVal, sizeof(sVal), "%.16g",atof(papszFields[5])); 1242 1262 SetMetadataItem("RPC_LINE_SCALE",sVal); 1243 snprintf(sVal, sizeof(sVal), "%.16 f",atof(papszFields[1]));1263 snprintf(sVal, sizeof(sVal), "%.16g",atof(papszFields[1])); 1244 1264 SetMetadataItem("RPC_SAMP_OFF",sVal); 1245 snprintf(sVal, sizeof(sVal), "%.16 f",atof(papszFields[6]));1265 snprintf(sVal, sizeof(sVal), "%.16g",atof(papszFields[6])); 1246 1266 SetMetadataItem("RPC_SAMP_SCALE",sVal); 1247 snprintf(sVal, sizeof(sVal), "%.16 f",atof(papszFields[2]));1267 snprintf(sVal, sizeof(sVal), "%.16g",atof(papszFields[2])); 1248 1268 SetMetadataItem("RPC_LAT_OFF",sVal); 1249 snprintf(sVal, sizeof(sVal), "%.16 f",atof(papszFields[7]));1269 snprintf(sVal, sizeof(sVal), "%.16g",atof(papszFields[7])); 1250 1270 SetMetadataItem("RPC_LAT_SCALE",sVal); 1251 snprintf(sVal, sizeof(sVal), "%.16 f",atof(papszFields[3]));1271 snprintf(sVal, sizeof(sVal), "%.16g",atof(papszFields[3])); 1252 1272 SetMetadataItem("RPC_LONG_OFF",sVal); 1253 snprintf(sVal, sizeof(sVal), "%.16 f",atof(papszFields[8]));1273 snprintf(sVal, sizeof(sVal), "%.16g",atof(papszFields[8])); 1254 1274 SetMetadataItem("RPC_LONG_SCALE",sVal); 1255 snprintf(sVal, sizeof(sVal), "%.16 f",atof(papszFields[4]));1275 snprintf(sVal, sizeof(sVal), "%.16g",atof(papszFields[4])); 1256 1276 SetMetadataItem("RPC_HEIGHT_OFF",sVal); 1257 snprintf(sVal, sizeof(sVal), "%.16 f",atof(papszFields[9]));1277 snprintf(sVal, sizeof(sVal), "%.16g",atof(papszFields[9])); 1258 1278 SetMetadataItem("RPC_HEIGHT_SCALE",sVal); 1259 1279 1260 1280 sVal[0] = '\0'; 1261 1281 for(int i = 0; i < 20; i++ ) 1262 snprintf(sVal+strlen(sVal), sizeof(sVal), "%.16 f",1282 snprintf(sVal+strlen(sVal), sizeof(sVal), "%.16g ", 1263 1283 atof(papszFields[10+i])); 1264 1284 SetMetadataItem("RPC_LINE_NUM_COEFF",sVal); … … 1266 1286 sVal[0] = '\0'; 1267 1287 for(int i = 0; i < 20; i++ ) 1268 snprintf(sVal+strlen(sVal), sizeof(sVal), "%.16 f",1288 snprintf(sVal+strlen(sVal), sizeof(sVal), "%.16g ", 1269 1289 atof(papszFields[30+i])); 1270 1290 SetMetadataItem("RPC_LINE_DEN_COEFF",sVal); … … 1272 1292 sVal[0] = '\0'; 1273 1293 for(int i = 0; i < 20; i++ ) 1274 snprintf(sVal+strlen(sVal), sizeof(sVal), "%.16 f",1294 snprintf(sVal+strlen(sVal), sizeof(sVal), "%.16g ", 1275 1295 atof(papszFields[50+i])); 1276 1296 SetMetadataItem("RPC_SAMP_NUM_COEFF",sVal); … … 1278 1298 sVal[0] = '\0'; 1279 1299 for(int i = 0; i < 20; i++ ) 1280 snprintf(sVal+strlen(sVal), sizeof(sVal), "%.16 f",1300 snprintf(sVal+strlen(sVal), sizeof(sVal), "%.16g ", 1281 1301 atof(papszFields[70+i])); 1282 1302 SetMetadataItem("RPC_SAMP_DEN_COEFF",sVal); 1283 1303 1284 snprintf(sVal, sizeof(sVal), "%.16 f",1285 atof(papszFields[3]) - atof(papszFields[8]) / 2.0);1304 snprintf(sVal, sizeof(sVal), "%.16g", 1305 atof(papszFields[3]) - atof(papszFields[8])); 1286 1306 SetMetadataItem("RPC_MIN_LONG",sVal); 1287 1307 1288 snprintf(sVal, sizeof(sVal), "%.16 f",1289 atof(papszFields[3]) + atof(papszFields[8]) / 2.0);1308 snprintf(sVal, sizeof(sVal), "%.16g", 1309 atof(papszFields[3]) + atof(papszFields[8]) ); 1290 1310 SetMetadataItem("RPC_MAX_LONG",sVal); 1291 1311 1292 snprintf(sVal, sizeof(sVal), "%.16 f",1293 atof(papszFields[2]) - atof(papszFields[7]) / 2.0);1312 snprintf(sVal, sizeof(sVal), "%.16g", 1313 atof(papszFields[2]) - atof(papszFields[7])); 1294 1314 SetMetadataItem("RPC_MIN_LAT",sVal); 1295 1315 1296 snprintf(sVal, sizeof(sVal), "%.16 f",1297 atof(papszFields[2]) + atof(papszFields[7]) / 2.0);1316 snprintf(sVal, sizeof(sVal), "%.16g", 1317 atof(papszFields[2]) + atof(papszFields[7])); 1298 1318 SetMetadataItem("RPC_MAX_LAT",sVal); 1299 1319 1300 } 1320 /* Handle the chipping case where the image is a subset. */ 1321 double rowOffset, colOffset; 1322 rowOffset = atof(papszFields[90]); 1323 colOffset = atof(papszFields[91]); 1324 if (rowOffset || colOffset) 1325 { 1326 SetMetadataItem("ICHIP_SCALE_FACTOR", "1"); 1327 SetMetadataItem("ICHIP_ANAMORPH_CORR", "0"); 1328 SetMetadataItem("ICHIP_SCANBLK_NUM", "0"); 1329 1330 SetMetadataItem("ICHIP_OP_ROW_11", "0.5"); 1331 SetMetadataItem("ICHIP_OP_COL_11", "0.5"); 1332 SetMetadataItem("ICHIP_OP_ROW_12", "0.5"); 1333 SetMetadataItem("ICHIP_OP_COL_21", "0.5"); 1334 snprintf(sVal, sizeof(sVal), "%.16g", numCols - 0.5); 1335 SetMetadataItem("ICHIP_OP_COL_12", sVal); 1336 SetMetadataItem("ICHIP_OP_COL_22", sVal); 1337 snprintf(sVal, sizeof(sVal), "%.16g", numRows - 0.5); 1338 SetMetadataItem("ICHIP_OP_ROW_21", sVal); 1339 SetMetadataItem("ICHIP_OP_ROW_22", sVal); 1340 1341 snprintf(sVal, sizeof(sVal), "%.16g", rowOffset + 0.5); 1342 SetMetadataItem("ICHIP_FI_ROW_11", sVal); 1343 SetMetadataItem("ICHIP_FI_ROW_12", sVal); 1344 snprintf(sVal, sizeof(sVal), "%.16g", colOffset + 0.5); 1345 SetMetadataItem("ICHIP_FI_COL_11", sVal); 1346 SetMetadataItem("ICHIP_FI_COL_21", sVal); 1347 snprintf(sVal, sizeof(sVal), "%.16g", colOffset + numCols - 0.5); 1348 SetMetadataItem("ICHIP_FI_COL_12", sVal); 1349 SetMetadataItem("ICHIP_FI_COL_22", sVal); 1350 snprintf(sVal, sizeof(sVal), "%.16g", rowOffset + numRows - 0.5); 1351 SetMetadataItem("ICHIP_FI_ROW_21", sVal); 1352 SetMetadataItem("ICHIP_FI_ROW_22", sVal); 1353 } 1354 CSLDestroy(papszFields); 1355 } 1356 1357 void ENVIDataset::ProcessStatsFile() 1358 { 1359 CPLString osStaFilename; 1360 FILE *fpStaFile; 1361 1362 osStaFilename = CPLResetExtension( pszHDRFilename, "sta" ); 1363 fpStaFile = VSIFOpen( osStaFilename, "rb" ); 1364 1365 if (!fpStaFile) 1366 return; 1367 1368 long lTestHeader[10],lOffset; 1369 1370 if( VSIFRead( lTestHeader, sizeof(long), 10, fpStaFile ) != 10 ) 1371 { 1372 VSIFClose( fpStaFile ); 1373 return; 1374 } 1375 1376 int isFloat; 1377 isFloat = (byteSwapLong(lTestHeader[0]) == 1111838282); 1378 1379 unsigned long nb,i; 1380 float * fStats; 1381 double * dStats, dMin, dMax, dMean, dStd; 1382 1383 nb=byteSwapLong(lTestHeader[3]); 1384 VSIFSeek(fpStaFile,40+(nb+1)*4,SEEK_SET); 1385 1386 if (VSIFRead(&lOffset,sizeof(long),1,fpStaFile) == 1) 1387 { 1388 VSIFSeek(fpStaFile,40+(nb+1)*8+byteSwapLong(lOffset)+nb,SEEK_SET); 1389 // This should be the beginning of the statistics 1390 if (isFloat) 1391 { 1392 fStats = (float*)calloc(nb*4,4); 1393 if (VSIFRead(fStats,4,nb*4,fpStaFile) == nb*4) 1394 { 1395 for (i=0;i<nb;i++) 1396 { 1397 GetRasterBand(i+1)->SetStatistics( 1398 byteSwapFloat(fStats[i]), 1399 byteSwapFloat(fStats[nb+i]), 1400 byteSwapFloat(fStats[2*nb+i]), 1401 byteSwapFloat(fStats[3*nb+i])); 1402 } 1403 } 1404 free(fStats); 1405 } 1406 else 1407 { 1408 dStats = (double*)calloc(nb*4,8); 1409 if (VSIFRead(dStats,8,nb*4,fpStaFile) == nb*4) 1410 { 1411 for (i=0;i<nb;i++) 1412 { 1413 dMin = byteSwapDouble(dStats[i]); 1414 dMax = byteSwapDouble(dStats[nb+i]); 1415 dMean = byteSwapDouble(dStats[2*nb+i]); 1416 dStd = byteSwapDouble(dStats[3*nb+i]); 1417 if (dMin != dMax && dStd != 0) 1418 GetRasterBand(i+1)->SetStatistics(dMin,dMax,dMean,dStd); 1419 } 1420 } 1421 free(dStats); 1422 } 1423 } 1424 VSIFClose( fpStaFile ); 1425 } 1426 long ENVIDataset::byteSwapLong(long swapMe) 1427 { 1428 #ifndef CPL_LSB 1429 return swapMe; 1430 #endif 1431 return ((swapMe&0xFF)<<24)+((swapMe&(0xFF00))<<8)+ 1432 ((swapMe&(0xFF0000))>>8)+((swapMe&(0xFF000000))>>24); 1433 } 1434 1435 float ENVIDataset::byteSwapFloat(float swapMe) 1436 { 1437 #ifndef CPL_LSB 1438 return swapMe; 1439 #endif 1440 long foo,bar; 1441 float retval; 1442 memmove(&foo, &swapMe,4); 1443 bar = byteSwapLong(foo); 1444 memmove(&retval, &bar,4); 1445 1446 return retval; 1447 } 1448 1449 double ENVIDataset::byteSwapDouble(double swapMe) 1450 { 1451 #ifndef CPL_LSB 1452 return swapMe; 1453 #endif 1454 1455 char dblArrSrc[8],dblArrDest[8]; 1456 double retval; 1457 int i; 1458 1459 memmove(dblArrSrc, &swapMe, 8); 1460 1461 for (i=0;i<8;i++) 1462 dblArrDest[i]=dblArrSrc[7-i]; 1463 1464 memmove(&retval,dblArrDest, 8); 1465 return retval; 1466 } 1467 1301 1468 1302 1469 /************************************************************************/ … … 1422 1589 { 1423 1590 osHdrFilename = CPLFormFilename( NULL, poOpenInfo->pszFilename, 1424 "hdr" );1591 "hdr" ); 1425 1592 fpHeader = VSIFOpen( osHdrFilename, pszMode ); 1426 1593 } … … 1429 1596 { 1430 1597 osHdrFilename = CPLFormFilename( NULL, poOpenInfo->pszFilename, 1431 "HDR" );1598 "HDR" ); 1432 1599 fpHeader = VSIFOpen( osHdrFilename, pszMode ); 1433 1600 } … … 1488 1655 1489 1656 /* -------------------------------------------------------------------- */ 1657 /* Has the user selected the .sta (stats) file to open? */ 1658 /* -------------------------------------------------------------------- */ 1659 if( EQUAL(CPLGetExtension(poOpenInfo->pszFilename), "sta") ) 1660 { 1661 delete poDS; 1662 CPLError( CE_Failure, CPLE_AppDefined, 1663 "The selected file is an ENVI statistics file.\n" 1664 "To open ENVI datasets, the data file should be selected\n" 1665 "instead of the .sta file. Please try again selecting\n" 1666 "the data file corresponding to the statistics file:\n" 1667 " %s\n", 1668 poOpenInfo->pszFilename ); 1669 return NULL; 1670 } 1671 1672 /* -------------------------------------------------------------------- */ 1490 1673 /* Extract required values from the .hdr. */ 1491 1674 /* -------------------------------------------------------------------- */ … … 1546 1729 break; 1547 1730 1548 case 6: 1731 /* Removed JBP, ITT-VIS 11/29/2007. Complex data does not display properly 1732 in the ArcGIS application so we are removing it from the supported types list. 1733 This is a bit of a big hammer as it may remove functionality from some 1734 direct GDAL users, but this data is extremely problematic from an ArcGIS 1735 standpoint. */ 1736 /* case 6: 1549 1737 eType = GDT_CFloat32; 1550 1738 break; 1551 1739 1552 case 9:1740 case 9: 1553 1741 eType = GDT_CFloat64; 1554 1742 break; 1555 1743 */ 1556 1744 case 12: 1557 1745 eType = GDT_UInt16; … … 1567 1755 delete poDS; 1568 1756 CPLError( CE_Failure, CPLE_AppDefined, 1569 "The file has a 'data type' value of '%s'. This value\n" 1570 "isn't recognised by the GDAL ENVI driver.", 1571 CSLFetchNameValue(poDS->papszHeader,"data_type" ) ); 1757 "The file does not have a value for the data_type\n" 1758 "that is recognised by the GDAL ENVI driver."); 1572 1759 return NULL; 1573 1760 } … … 1618 1805 { 1619 1806 delete poDS; 1620 CPLError( CE_Failure, CPLE_OpenFailed,1807 CPLError( CE_Failure, CPLE_OpenFailed, 1621 1808 "File %s is marked as compressed in the ENVI .hdr\n" 1622 1809 "GDAL does not support auto-decompression of ENVI data\n" … … 1644 1831 if( poDS->fpImage == NULL ) 1645 1832 { 1646 delete poDS;1833 delete poDS; 1647 1834 CPLError( CE_Failure, CPLE_OpenFailed, 1648 1835 "Failed to re-open %s within ENVI driver.\n", … … 1681 1868 else 1682 1869 { 1683 delete poDS;1870 delete poDS; 1684 1871 CPLError( CE_Failure, CPLE_AppDefined, 1685 1872 "The interleaving type of the file (%s) is not supported.", 1686 1873 pszInterleave ); 1687 return NULL;1874 return NULL; 1688 1875 } 1689 1876 … … 1695 1882 { 1696 1883 poDS->SetBand( i + 1, 1697 new RawRasterBand(poDS, i + 1, poDS->fpImage,1698 nHeaderSize + nBandOffset * i,1699 nPixelOffset, nLineOffset, eType,1700 bNativeOrder, TRUE) );1884 new RawRasterBand(poDS, i + 1, poDS->fpImage, 1885 nHeaderSize + nBandOffset * i, 1886 nPixelOffset, nLineOffset, eType, 1887 bNativeOrder, TRUE) ); 1701 1888 } 1702 1889 1703 1890 /* -------------------------------------------------------------------- */ 1704 1891 /* Apply band names if we have them. */ 1705 /* -------------------------------------------------------------------- */ 1706 if( CSLFetchNameValue( poDS->papszHeader, "band_names" ) != NULL ) 1707 { 1892 /* Use wavelength for more descriptive information if possible */ 1893 /* -------------------------------------------------------------------- */ 1894 if( CSLFetchNameValue( poDS->papszHeader, "band_names" ) != NULL || 1895 CSLFetchNameValue( poDS->papszHeader, "wavelength" ) != NULL) 1896 { 1897 char pszBandId[1024], pszBandName[1024], pszWavelength[1024]; 1708 1898 char **papszBandNames = 1709 1899 poDS->SplitList( CSLFetchNameValue( poDS->papszHeader, 1710 1900 "band_names" ) ); 1711 1712 for( i = 0; i < MIN(CSLCount(papszBandNames),nBands); i++ ) 1713 poDS->GetRasterBand(i + 1)->SetDescription( papszBandNames[i] ); 1714 1901 char **papszWL = 1902 poDS->SplitList( CSLFetchNameValue( poDS->papszHeader, 1903 "wavelength" ) ); 1904 1905 const char *pszWLUnits = NULL; 1906 if (papszWL) 1907 { 1908 /* If WL information is present, process wavelength units */ 1909 pszWLUnits = CSLFetchNameValue( poDS->papszHeader, 1910 "wavelength_units" ); 1911 if (pszWLUnits) 1912 { 1913 /* Don't show unknown or index units */ 1914 if (EQUAL(pszWLUnits,"Unknown") || 1915 EQUAL(pszWLUnits,"Index") ) 1916 pszWLUnits=0; 1917 } 1918 } 1919 1920 for( i = 0; i < nBands; i++ ) 1921 { 1922 /* First set up the wavelength names and units if available */ 1923 if (papszWL && CSLCount(papszWL) > i) 1924 { 1925 snprintf(pszWavelength, sizeof(pszWavelength) ,"%s", papszWL[i]); 1926 if (pszWLUnits) 1927 { 1928 strncat(pszWavelength," ", sizeof(pszWavelength)); 1929 strncat(pszWavelength,pszWLUnits, sizeof(pszWavelength)); 1930 } 1931 } 1932 else pszWavelength[0] = '\0'; 1933 1934 /* Build the final name for this band */ 1935 if (papszBandNames && CSLCount(papszBandNames) > i) 1936 { 1937 snprintf(pszBandName, sizeof(pszBandName), "%s", papszBandNames[i]); 1938 if (strlen(pszWavelength) > 0) 1939 { 1940 strncat(pszBandName," (", sizeof(pszBandName)); 1941 strncat(pszBandName, pszWavelength, sizeof(pszBandName)); 1942 strncat(pszBandName,")", sizeof(pszBandName)); 1943 } 1944 } 1945 else /* WL but no band names */ 1946 strncpy(pszBandName, pszWavelength, sizeof(pszBandName)); 1947 1948 /* Description is for internal GDAL usage */ 1949 poDS->GetRasterBand(i + 1)->SetDescription( pszBandName ); 1950 1951 /* Metadata field named Band_1, etc. needed for ArcGIS integration */ 1952 snprintf(pszBandId, sizeof(pszBandId), "Band_%i", i+1); 1953 poDS->SetMetadataItem(pszBandId, pszBandName); 1954 } 1715 1955 CSLDestroy( papszBandNames ); 1716 1956 } 1717 1718 1957 /* -------------------------------------------------------------------- */ 1719 1958 /* Apply class names if we have them. */ … … 1761 2000 /* -------------------------------------------------------------------- */ 1762 2001 if( CSLFetchNameValue(poDS->papszHeader,"data_ignore_value" ) != NULL ) 1763 {2002 { 1764 2003 for( i = 0; i < poDS->nBands; i++ ) 1765 2004 ((RawRasterBand*)poDS->GetRasterBand(i+1))->StoreNoDataValue(atof( 1766 CSLFetchNameValue(poDS->papszHeader,"data_ignore_value"))); 1767 } 2005 CSLFetchNameValue(poDS->papszHeader,"data_ignore_value"))); 2006 } 2007 2008 /* -------------------------------------------------------------------- */ 2009 /* Read the stats file if it is present */ 2010 /* -------------------------------------------------------------------- */ 2011 poDS->ProcessStatsFile(); 1768 2012 1769 2013 /* -------------------------------------------------------------------- */ … … 1780 2024 /* Look for RPC mapinfo */ 1781 2025 /* -------------------------------------------------------------------- */ 1782 if( CSLFetchNameValue( poDS->papszHeader, "rpc_info" ) != NULL ) 1783 { 1784 poDS->ProcessRPCinfo( 1785 CSLFetchNameValue(poDS->papszHeader,"rpc_info") ); 2026 if( !poDS->bFoundMapinfo && 2027 CSLFetchNameValue( poDS->papszHeader, "rpc_info" ) != NULL ) 2028 { 2029 poDS->ProcessRPCinfo( 2030 CSLFetchNameValue(poDS->papszHeader,"rpc_info"), 2031 poDS->nRasterXSize, poDS->nRasterYSize); 1786 2032 } 1787 2033 … … 1796 2042 poDS->SetDescription( poOpenInfo->pszFilename ); 1797 2043 poDS->TryLoadXML(); 1798 2044 1799 2045 return( poDS ); 1800 2046 } … … 1950 2196 1951 2197 void GDALRegister_ENVI() 1952 1953 2198 { 1954 2199 GDALDriver *poDriver; … … 1985 2230 } 1986 2231 } 1987
