OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimFfL5.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: See top level LICENSE.txt file.
4 //
5 // Author: Ken Melero (kmelero@imagelinks.com)
6 // Orginally written by Oscar Kramer (SoBe Software)
7 // Description: Container class for LandSat7 Fast Format header files.
8 //
9 // ********************************************************************
10 // $Id: ossimFfL5.cpp 17501 2010-06-02 11:14:55Z dburken $
11 //
12 
13 #include <cstdio>
14 #include <cstdlib>
15 #include <ctime>
16 #include <fstream>
17 #include <sstream>
18 #include <string>
19 #include <iomanip>
20 using namespace std;
21 
22 #include <ossim/base/ossimString.h>
23 #include <ossim/base/ossimDate.h>
26 
28  : ossimFfL7()
29 {
30 }
31 
32 ossimFfL5::ossimFfL5(const char* headerFile)
33  : ossimFfL7()
34 {
35  // open the header file:
36  readHeaderRevB(headerFile);
37 }
38 
40 {
41 }
42 
43 
44 void ossimFfL5::readHeaderRevB(const ossimString& header_name)
45 {
46  theErrorStatus = ossimErrorCodes::OSSIM_ERROR; // assume error, prove not at end;
47 
48  theRevb = new ossimFfRevb(header_name);
49 
50  if (theRevb->errorStatus() != ossimFfRevb::OSSIM_OK) return;
51 
57  strcpy(theSensorMode, "");
70 
71  //generate band names
72  int i=0;
73  while((theBandsPresentString[i]>='0') && (theBandsPresentString[i]<='9'))
74  {
75  sprintf(theBandFileNames[i],"band%c.dat",theBandsPresentString[i]);
76  ++i;
77  }
78  int nbb=i;
79 
80  std::vector<ossimString> arrayPathRow = ossimString(theLocationCode).split("/");
81  if(arrayPathRow.size() == 2)
82  {
83  thePathNumber = arrayPathRow[0].toInt();
84  theRowNumber = arrayPathRow[1].beforePos(3).toInt();
85  }
86 
87  //extract gains/biases from max/min radiance
88  double min,max;
89  theBias.clear();
90  theGain.clear();
91  for(i=0;i<nbb;++i)
92  {
93  if (sscanf( theRevb->theBandRadiance[i]," %lf/%lf",&max,&min) != 2) return;
94  theBias.push_back(min);
95  theGain.push_back(max/254.0-min/255.0);
96  }
97 
100  strcpy(theDatum, "WGS-84");
101 
102  // added to read in all 15 parameters instead of the first two.
103 
104  for(long parameter=0;parameter < 15; ++parameter)
105  {
106  ossimString temp(theRevb->theUsgsProjParam[parameter]);
107  theProjectionParams[parameter] = temp.gsub('D','E').toDouble();
108  }
109 
111 
112  char temps[256];
113  sprintf(temps,"%s %s",theRevb->theUlLon, theRevb->theUlLat);
115 
116  sprintf(temps,"%s %s",theRevb->theUrLon, theRevb->theUrLat);
118 
119  sprintf(temps,"%s %s",theRevb->theLrLon, theRevb->theLrLat);
121 
122  sprintf(temps,"%s %s",theRevb->theLlLon, theRevb->theLlLat);
124 
125  sprintf(temps,"%s %s",theRevb->theCenterLon, theRevb->theCenterLat);
126  if (convertGeoPoint(temps, theCenterGP) != ossimErrorCodes::OSSIM_OK) return;
127 
130 
135 
136  // The header was successfully extracted:
138  return;
139 }
140 
141 int ossimFfL5::convertGeoPoint(const char* sptr, ossimGpt& geo_point)
142 {
143  int londeg;
144  int lonmin;
145  double lonsec;
146  char lonhem;
147  int latdeg;
148  int latmin;
149  double latsec;
150  char lathem;
151 
152  int converted = sscanf(sptr, "%03d%02d%7lf%c %02d%02d%7lf%c",
153  &londeg, &lonmin, &lonsec, &lonhem,
154  &latdeg, &latmin, &latsec, &lathem);
155 
156  if (converted != 8)
157  {
160  }
161 
162  geo_point.lat = (double)latdeg + (double)latmin/60.0 + latsec/3600.0;
163  if (lathem == 'S')
164  geo_point.lat *= -1.0;
165 
166  geo_point.lon= (double)londeg + (double)lonmin/60.0 + lonsec/3600.0;
167  if (lonhem == 'W')
168  geo_point.lon *= -1.0;
169 
171 }
172 
174 {
175  return theRevb;
176 }
177 
179 {
180  return theRevb;
181 }
char theInstrumentType[INSTRUMENT_TYPE_SIZE+1]
Definition: ossimFfRevb.h:213
char theLocationCode[18]
Definition: ossimFfL7.h:135
char thePathRowNumber[PATH_ROW_NUMBER_SIZE+1]
Definition: ossimFfRevb.h:206
vector< double > theBias
Definition: ossimFfL7.h:157
ossimGpt theUL_Corner
Definition: ossimFfL7.h:167
char theDatum[7]
Definition: ossimFfL7.h:163
char theProductType[PRODUCT_TYPE_SIZE+1]
Definition: ossimFfRevb.h:216
int theRowNumber
Definition: ossimFfL7.h:137
char theUrLat[LAT_SIZE+1]
Definition: ossimFfRevb.h:253
char theProcessingType[12]
Definition: ossimFfL7.h:145
double theSunAzimuth
Definition: ossimFfL7.h:178
char theAcquisitionDate[DATE_SIZE+1]
Definition: ossimFfRevb.h:207
char theResampAlgorithm[3]
Definition: ossimFfL7.h:146
char theUrLon[LON_SIZE+1]
Definition: ossimFfRevb.h:252
virtual ~ossimFfL5()
Definition: ossimFfL5.cpp:39
static const ossimErrorCode OSSIM_OK
char theProductSize[PRODUCT_SIZE_SIZE+1]
Definition: ossimFfRevb.h:217
ossimGpt theUR_Corner
Definition: ossimFfL7.h:168
int theRecordSize
Definition: ossimFfL7.h:149
int theCenterLine
Definition: ossimFfRevb.h:278
int theCenterSample
Definition: ossimFfRevb.h:277
char theProductType[19]
Definition: ossimFfL7.h:143
int theHorizontalOffset
Definition: ossimFfL7.h:175
ossimIpt theCenterImagePoint
Definition: ossimFfL7.h:173
ossimRefPtr< ossimFfRevb > theRevb
Definition: ossimFfL5.h:40
char theBandsPresentString[33]
Definition: ossimFfL7.h:153
int theLinesPerBand
Definition: ossimFfL7.h:148
char theSatName[11]
Definition: ossimFfL7.h:139
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
char theUlLat[LAT_SIZE+1]
Definition: ossimFfRevb.h:248
static const ossimErrorCode OSSIM_ERROR
int theRecordSize
Definition: ossimFfRevb.h:269
char theProductOrderNumber[PRODUCT_ORDER_NUMBER_SIZE+1]
Definition: ossimFfRevb.h:205
char theAcquisitionDate[20]
Definition: ossimFfL7.h:138
char theUlLon[LON_SIZE+1]
Definition: ossimFfRevb.h:247
double theSunElevation
Definition: ossimFfL7.h:177
char theBandRadiance[NUMBER_OF_BANDS][RADIANCE_SIZE+1]
Definition: ossimFfRevb.h:225
char theUsgsProjParam[NUMBER_OF_PROJECTION_PARAMETERS][USGS_PROJ_PARAMS_SIZE+1]
Definition: ossimFfRevb.h:234
double theGsd
Definition: ossimFfRevb.h:243
ossimRefPtr< ossimFfRevb > revb()
Definition: ossimFfL5.cpp:173
char theEllipsoid[19]
Definition: ossimFfL7.h:162
char theBandFileNames[8][30]
Definition: ossimFfL7.h:154
char theSensorMode[7]
Definition: ossimFfL7.h:141
char theMapProjectionName[5]
Definition: ossimFfL7.h:161
char theCenterLat[LAT_SIZE+1]
Definition: ossimFfRevb.h:274
char theProcessingType[PROCESSING_TYPE_SIZE+1]
Definition: ossimFfRevb.h:221
ossimGpt theLR_Corner
Definition: ossimFfL7.h:169
ossim_float64 lon
Definition: ossimGpt.h:266
char theSatNumber[SAT_NUMBER_SIZE+1]
Definition: ossimFfRevb.h:210
char theSensorName[11]
Definition: ossimFfL7.h:140
char theResampAlgorithm[RESAMPLING_ALGO_SIZE+1]
Definition: ossimFfRevb.h:224
char theLlLat[LAT_SIZE+1]
Definition: ossimFfRevb.h:263
double toDouble() const
char theBandsPresentString[BANDS_PRESENT_SIZE+1]
Definition: ossimFfRevb.h:267
int theAcquiredBitsPerPixel
Definition: ossimFfL7.h:152
int convertGeoPoint(const char *sptr, ossimGpt &geo_point)
Definition: ossimFfL5.cpp:141
int theSunAzimuth
Definition: ossimFfRevb.h:271
ossimGpt theCenterGP
Definition: ossimFfL7.h:171
char theLrLon[LON_SIZE+1]
Definition: ossimFfRevb.h:257
void readHeaderRevB(const ossimString &header_name)
Definition: ossimFfL5.cpp:44
ossimGpt theLL_Corner
Definition: ossimFfL7.h:170
int thePixelsPerLine
Definition: ossimFfRevb.h:244
char theLrLat[LAT_SIZE+1]
Definition: ossimFfRevb.h:258
int theUsgsMapZone
Definition: ossimFfL7.h:165
int thePathNumber
Definition: ossimFfL7.h:136
char theMapProjName[MAP_PROJ_NAME_SIZE+1]
Definition: ossimFfRevb.h:230
int theUsgsMapZone
Definition: ossimFfRevb.h:232
char theProductSize[11]
Definition: ossimFfL7.h:144
#define max(a, b)
Definition: auxiliary.h:76
ossim_int32 y
Definition: ossimIpt.h:142
int theSunElevation
Definition: ossimFfRevb.h:270
double theOffNadirAngle
Definition: ossimFfL7.h:142
int theLinesPerImage
Definition: ossimFfRevb.h:245
ossim_int32 x
Definition: ossimIpt.h:141
double theGsd
Definition: ossimFfL7.h:150
ossim_float64 lat
Definition: ossimGpt.h:265
char theLlLon[LON_SIZE+1]
Definition: ossimFfRevb.h:262
ossimString & gsub(const ossimString &searchKey, const ossimString &replacementValue, bool replaceAll=false)
Substitutes searchKey string with replacementValue and returns a reference to *this.
double theProjectionParams[15]
Definition: ossimFfL7.h:164
int thePixelsPerLine
Definition: ossimFfL7.h:147
int errorStatus() const
Definition: ossimFfRevb.h:183
int theOutputBitsPerPixel
Definition: ossimFfL7.h:151
char theEllipsoid[ELLIPSOID_SIZE+1]
Definition: ossimFfRevb.h:240
double theOrientationAngle
Definition: ossimFfRevb.h:229
char theRequestNumber[21]
Definition: ossimFfL7.h:134
char theCenterLon[LON_SIZE+1]
Definition: ossimFfRevb.h:273
vector< double > theGain
Definition: ossimFfL7.h:158
double theOrientationAngle
Definition: ossimFfL7.h:176
#define min(a, b)
Definition: auxiliary.h:75