OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimFfRevb.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 //
3 // License: MIT
4 //
5 // Author: Ken Melero (kmelero@imagelinks.com)
6 // Orginally written by Dave Burken (dburken@imagelinks.com)
7 // Description: This class parses an EOSAT Fast Format rev b header.
8 //
9 //********************************************************************
10 // $Id$
11 
12 
15 #include <ossim/base/ossimNotify.h>
16 #include <ossim/base/ossimString.h>
18 #include <sstream>
19 #include <iomanip>
20 
21 
22 // File scope constants for seek positions.
23 const int RADIANCE_OFFSET [7] = { 300,
24  317,
25  334,
26  351,
27  368,
28  385,
29  402 };
30 
31 static const int PROJ_PARAM_OFFSET [15] = { 594,
32  618,
33  642,
34  666,
35  690,
36  714,
37  738,
38  762,
39  786,
40  810,
41  834,
42  858,
43  882,
44  906,
45  930 };
46 
47 
48 //***************************************************************************
49 // CONSTRUCTOR
50 //***************************************************************************
52  :
53  the1stLineInVolume(1),
54  theLinesPerVolume(0),
55  theOrientationAngle(0.0),
56  theUsgsProjNumber(0),
57  theUsgsMapZone(0),
58  theSemiMajorAxis(0.0),
59  theSemiMinorAxis(0.0),
60  theGsd(0.0),
61  thePixelsPerLine(0),
62  theLinesPerImage(0),
63  theUlEasting(0.0),
64  theUlNorthing(0.0),
65  theUrEasting(0.0),
66  theUrNorthing(0.0),
67  theLrEasting(0.0),
68  theLrNorthing(0.0),
69  theLlEasting(0.0),
70  theLlNorthing(0.0),
71  theBlockingFactor(0),
72  theRecordSize(0),
73  theSunElevation(0),
74  theSunAzimuth(0),
75  theCenterEasting(0.0),
76  theCenterNorthing(0.0),
77  theCenterSample(0),
78  theCenterLine(0),
79  theOffset(0),
80  theErrorStatus(OSSIM_OK)
81 {
82  const char tmpBuff[] = "";
83 
84  strcpy(theProductOrderNumber, tmpBuff);
85  strcpy(thePathRowNumber, tmpBuff);
86  strcpy(theAcquisitionDate, tmpBuff);
87  strcpy(theSatNumber, tmpBuff);
88  strcpy(theInstrumentType, tmpBuff);
89  strcpy(theProductType, "MAP ORIENTED");
90  strcpy(theProductSize, tmpBuff);
91  strcpy(theMapSheetName, tmpBuff);
92  strcpy(theProcessingType, "TERRAIN");
93  strcpy(theResampAlgorithm, "NN");
94 
95  int i;
96  for (i=0; i<NUMBER_OF_BANDS; i++)
97  {
98  strcpy(theBandRadiance[i], tmpBuff);
99  }
100 
101  strcpy(theVolumeNumber, tmpBuff);
102  strcpy(theMapProjName, tmpBuff);
103 
104  for (i=0; i<NUMBER_OF_PROJECTION_PARAMETERS; i++)
105  {
106  strcpy(theUsgsProjParam[i], tmpBuff);
107  }
108 
109  strcpy(theEllipsoid, tmpBuff);
110  strcpy(theUlLon, tmpBuff);
111  strcpy(theUlLat, tmpBuff);
112  strcpy(theUrLon, tmpBuff);
113  strcpy(theUrLat, tmpBuff);
114  strcpy(theLrLon, tmpBuff);
115  strcpy(theLrLat, tmpBuff);
116  strcpy(theLlLon, tmpBuff);
117  strcpy(theLlLat, tmpBuff);
118  strcpy(theBandsPresentString, "P");
119  strcpy(theCenterLon, tmpBuff);
120  strcpy(theCenterLat, tmpBuff);
121  strcpy(theFormatVersion, "B");
122 
123 }
124 
125 //***************************************************************************
126 // CONSTRUCTOR:
127 // ossimFfRevb::ossimFfRevb(const char* headerFile)
128 //
129 // Takes a filename representing an IRS-1C Fast Format rev C header.
130 //***************************************************************************
131 ossimFfRevb::ossimFfRevb(const char* headerFile)
132  :
133  theErrorStatus(OSSIM_OK)
134 {
135  std::shared_ptr<ossim::istream> is = ossim::StreamFactoryRegistry::instance()->
136  createIstream(ossimString(headerFile), std::ios_base::in);
137 
138  if (!is)
139  {
141 
142  ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::ossimFfRevb(header):"
143  << "Cannot open header = " << headerFile << "\n"
144  << "Returning from constructor." << std::endl;
145 
146  return;
147  }
148 
149  loadFromStream( *is );
150 }
151 
152 
153 //***************************************************************************
154 // PUBLIC METHOD:
155 // int ossimFfRevb::path(int sceneNbr) const
156 //
157 // Convenience method to parse the path from the path/row string. Returns
158 // zero if stream is not opened. Current loacation field is:
159 // path/row/fraction/subscene in ppp/rrrff format.
160 //***************************************************************************
161 int ossimFfRevb::path() const
162 {
163  char tmpBuff[4];
164  int path = 0;
165 
167 
168  if (is)
169  {
170  is.get(tmpBuff, 4);
171  tmpBuff[3] = '\0';
172  path = atoi(tmpBuff);
173  }
174 
175  return path;
176 }
177 
178 
179 //***************************************************************************
180 // PUBLIC METHOD:
181 // int ossimFfRevb::row(int sceneNbr) const
182 //
183 // Convenience method to parse the row from the path/row string. Returns
184 // zero if stream is not opened. Current loacation field is:
185 // path/row/fraction/subscene in ppp/rrrff format.
186 //***************************************************************************
187 int ossimFfRevb::row() const
188 {
189  char tmpBuff[4];
190  int row = 0;
191 
193 
194  if (is)
195  {
196  is.seekg(4, std::ios_base::beg);
197  is.get(tmpBuff, 4);
198  tmpBuff[3] = '\0';
199  row = atoi(tmpBuff);
200  }
201 
202  return row;
203 }
204 
205 
206 //***************************************************************************
207 // PUBLIC METHOD:
208 // int ossimFfRevb::fraction(int sceneNbr) const
209 //
210 // Convenience method to parse the fraction from the path/row string. Returns
211 // zero if stream is not opened. Current loacation field is:
212 // path/row/fraction/subscene in ppp/rrrff format.
213 //***************************************************************************
215 {
216  char tmpBuff[3];
217  int fraction = 0;
218 
220 
221  if (is)
222  {
223  is.seekg(7, std::ios_base::beg);
224  is.get(tmpBuff, 3);
225  tmpBuff[2] = '\0';
226  fraction = atoi(tmpBuff);
227  }
228 
229  return fraction;
230 }
231 
232 //***************************************************************************
233 // PUBLIC METHOD:
234 // double ossimFfRevb::projParam(int paramNumber) const
235 //
236 // Returns the projection parameter as a double from the string taken from
237 // the header. There are fifteen parameters so the possible range for
238 // paramNumber is 0 to 14.
239 //***************************************************************************
240 double ossimFfRevb::projParam(int paramNumber) const
241 {
242  if (paramNumber >= NUMBER_OF_PROJECTION_PARAMETERS)
243  {
244  ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::projParam: "
245  << "Parameter out of range: " << paramNumber
246  << "\nValid range: 0 - 14" << std::endl;
247  return 0.0;
248  }
249 
250  //***
251  // The USGS Projection Parameters in a rev b header have a "D" to
252  // denote the exponent. This simply substitutes the "D" with an
253  // "E" so that atof works properly.
254  //***
255  ossimString tmp = theUsgsProjParam[paramNumber];
256  tmp.gsub("D", "E");
257 
258  return atof(tmp.chars());
259 }
260 
261 //***************************************************************************
262 // PUBLIC METHOD:
263 // void ossimFfRevb::print(ostream& os) const
264 //
265 // Prints data members.
266 //***************************************************************************
268 {
269  os << std::setiosflags(std::ios_base::left | std::ios_base::fixed)
270  << std::setw(30) << "\nimage_id:"
272  << std::setw(30) << "\npath_row_number:"
274  << std::setw(30) << "\nacquisition_date:"
276  << std::setw(30) << "\nsatellite_name:"
277  << theSatNumber
278  << std::setw(30) << "\nsensor_name:"
280  << std::setw(30) << "\nproduct_type:"
281  << theProductType
282  << std::setw(30) << "\nproduct_size:"
283  << theProductSize
284  << std::setw(30) << "\nprocessing_type:"
286  << std::setw(30) << "\nresamp_algorithm:"
288 
289  int i;
290  for (i=0; i<NUMBER_OF_BANDS; i++)
291  {
292  os << "\nband" << i+1 << std::setw(25) << "_radiance:"
293  << theBandRadiance[i];
294  }
295 
296  os << std::setw(30) << "\ntape_volume_number:"
297  << theVolumeNumber
298  << std::setw(30) << "\nfirst_line_in_volume:"
300  << std::setw(30) << "\nlines_per_volume:"
302  << std::setw(30) << "\norientation_angle:"
303  << std::setprecision(2) << theOrientationAngle
304  << std::setw(30) << "\nprojection_type:"
305  << theMapProjName
306  << std::setw(30) << "\nusgs_projection_number:"
308  << std::setw(30) << "\nmap_zone:"
309  << theUsgsMapZone;
310 
311 // os << std::setprecision(15);
312  os << std::setiosflags(std::ios_base::right);
313  for (i=0; i<NUMBER_OF_PROJECTION_PARAMETERS; i++)
314  {
315  os << "\nprojection_parameter_" << i+1 << std::setw(10) << ":"
316  << std::setw(24) << theUsgsProjParam[i];
317  }
318  os << std::resetiosflags(std::ios_base::right);
319 
320 
321  os << std::setw(30) << "\nellipsoid:"
322  << theEllipsoid
323  << std::setw(30) << "\nsemi_major_axis:"
324  << std::setprecision(3) << std::setw(11) << theSemiMajorAxis
325  << std::setw(30) << "\nsemi_minor_axis:"
326  << std::setw(11) << theSemiMinorAxis
327  << std::setw(30) << "\ngsd:"
328  << std::setprecision(2) << std::setw(5) << theGsd
329  << std::setw(30) << "\nnumber_samples:"
331  << std::setw(30) << "\nnumber_lines:"
333  << std::setprecision(3)
334  << std::setw(30) << "\nul_longitude:"
335  << theUlLon
336  << std::setw(30) << "\nul_latitude:"
337  << theUlLat
338  << std::setw(30) << "\nul_easting:"
339  << std::setw(13) << theUlEasting
340  << std::setw(30) << "\nul_northing:"
341  << std::setw(13) << theUlNorthing
342  << std::setw(30) << "\nur_longitude:"
343  << theUrLon
344  << std::setw(30) << "\nur_latitude:"
345  << theUrLat
346  << std::setw(30) << "\nur_easting:"
347  << std::setw(13) << theUrEasting
348  << std::setw(30) << "\nur_northing:"
349  << std::setw(13) << theUrNorthing
350  << std::setw(30) << "\nlr_longitude:"
351  << theLrLon
352  << std::setw(30) << "\nlr_latitude:"
353  << theLrLat
354  << std::setw(30) << "\nlr_easting:"
355  << std::setw(13) << theLrEasting
356  << std::setw(30) << "\nlr_northing:"
357  << std::setw(13) << theLrNorthing
358  << std::setw(30) << "\nll_longitude:"
359  << theLlLon
360  << std::setw(30) << "\nll_latitude:"
361  << theLlLat
362  << std::setw(30) << "\nll_easting:"
363  << std::setw(13) << theLlEasting
364  << std::setw(30) << "\nll_northing:"
365  << std::setw(13) << theLlNorthing
366  << std::setw(30) << "\nbands_present_string:"
368  << std::setw(30) << "\ntape_blocking_factor:"
370  << std::setw(30) << "\nrecord_size:"
371  << theRecordSize
372  << std::setw(30) << "\nillum_elevation:"
373  << theSunElevation
374  << std::setw(30) << "\nillum_azimuth:"
375  << theSunAzimuth
376  << std::setw(30) << "\ncenter_longitude:"
377  << theCenterLon
378  << std::setw(30) << "\ncenter_latitude:"
379  << theCenterLat
380  << std::setw(30) << "\ncenter_easting:"
381  << std::setw(13) << theCenterEasting
382  << std::setw(30) << "\ncenter_northing:"
383  << std::setw(13) << theCenterNorthing
384  << std::setw(30) << "\ncenter_sample:"
385  << theCenterSample
386  << std::setw(30) << "\ncenter_line:"
387  << theCenterLine
388  << std::setw(30) << "\nhorizontal_offset:"
389  << theOffset
390  << std::setw(30) << "\nformat_version:"
392  << std::endl;
393 
394 }
395 
396 //***************************************************************************
397 // PUBLIC METHOD:
398 // void ossimFfRevb::write(ostream& os) const
399 //
400 // Writes an EOSAT Fast Format Rev B formatted header.
401 //***************************************************************************
403 {
404  const char PRODUCT_ID_DESC [PRODUCT_ORDER_NUMBER_DESC_SIZE + 1]
405  = "PRODUCT =";
406 
407  const char WRS_DESC [WRS_DESC_SIZE + 1]
408  = " WRS =";
409 
410  const char DATE_DESC [DATE_DESC_SIZE + 1]
411  = " ACQUISITION DATE =";
412 
413  const char SATELLITE_NUMBER_DESC [SAT_NUMBER_DESC_SIZE + 1]
414  = " SATELLITE =";
415 
416  const char INSTRUMENT_TYPE_DESC [INSTRUMENT_TYPE_DESC_SIZE + 1]
417  = " INSTRUMENT =";
418 
419  const char PRODUCT_TYPE_DESC [PRODUCT_TYPE_DESC_SIZE + 1]
420  = " PRODUCT TYPE =";
421 
422  const char PRODUCT_SIZE_DESC [PRODUCT_SIZE_DESC_SIZE + 1]
423  = " PRODUCT SIZE =";
424 
425  const char PROCESSING_TYPE_DESC [PROCESSING_TYPE_DESC_SIZE + 1]
426  = " TYPE OF GEODETIC PROCESSING =";
427 
428  const char RESAMPLING_ALGO_DESC [RESAMPLING_ALGO_DESC_SIZE + 1]
429  = " RESAMPLING =";
430 
431  const char RADIANCE_DESC [RADIANCE_DESC_SIZE + 1]
432  = " RAD GAINS/BIASES = ";
433 
434  const char VOLUME_NUMBER_DESC [VOLUME_NUMBER_DESC_SIZE + 1]
435  = " TAPE SPANNING FLAG=";
436 
437  const char FIRST_LINE_DESC [FIRST_LINE_DESC_SIZE + 1]
438  = " START LINE #=";
439 
440  const char LINES_PER_VOLUME_DESC [LINES_PER_VOLUME_DESC_SIZE + 1]
441  = " LINES PER VOL=";
442 
443  const char ORIENTATION_ANGLE_DESC [ORIENTATION_ANGLE_DESC_SIZE + 1]
444  = " ORIENTATION =";
445 
446  const char MAP_PROJ_NAME_DESC [MAP_PROJ_NAME_DESC_SIZE + 1]
447  = " PROJECTION =";
448 
449  const char USGS_PROJ_NUMBER_DESC [USGS_PROJ_NUMBER_DESC_SIZE + 1]
450  = " USGS PROJECTION # =";
451 
452  const char USGS_MAP_ZONE_DESC [USGS_MAP_ZONE_DESC_SIZE + 1]
453  = " USGS MAP ZONE =";
454 
455  const char PROJECTION_PARAMETER_DESC [USGS_PROJ_PARAMS_DESC_SIZE + 1]
456  = " USGS PROJECTION PARAMETERS =";
457 
458  const char ELLIPSOID_DESC [ELLIPSOID_DESC_SIZE + 1]
459  = " EARTH ELLIPSOID =";
460 
461  const char MAJOR_AXIS_DESC [MAJOR_AXIS_DESC_SIZE+ 1]
462  = " SEMI-MAJOR AXIS =";
463 
464  const char MINOR_AXIS_DESC [MINOR_AXIS_DESC_SIZE+ 1]
465  = " SEMI-MINOR AXIS =";
466 
467  const char PIXEL_GSD_DESC [PIXEL_GSD_DESC_SIZE + 1]
468  = " PIXEL SIZE =";
469 
470  const char PIXELS_PER_LINE_DESC [PIXELS_PER_LINE_DESC_SIZE + 1]
471  = " PIXELS PER LINE=";
472 
473  const char LINES_PER_IMAGE_DESC [LINES_PER_IMAGE_DESC_SIZE + 1]
474  = " LINES PER IMAGE=";
475 
476  const char UL_DESC [CORNER_DESC_SIZE + 1]
477  = " UL ";
478 
479  const char UR_DESC [CORNER_DESC_SIZE + 1]
480  = " UR ";
481 
482  const char LR_DESC [CORNER_DESC_SIZE + 1]
483  = " LR ";
484 
485  const char LL_DESC [CORNER_DESC_SIZE + 1]
486  = " LL ";
487 
488  const char BANDS_PRESENT_DESC [BANDS_PRESENT_DESC_SIZE + 1]
489  = " BANDS PRESENT =";
490 
491  const char BLOCKING_FACTOR_DESC [BLOCKING_FACTOR_DESC_SIZE + 1]
492  = " BLOCKING FACTOR =";
493 
494  const char RECORD_LENGTH_DESC [RECORD_LENGTH_DESC_SIZE + 1]
495  = " RECORD LENGTH =";
496 
497  const char SUN_ELEVATION_DESC [SUN_ELEVATION_DESC_SIZE + 1]
498  = " SUN ELEVATION =";
499 
500  const char SUN_AZIMUTH_DESC [SUN_AZIMUTH_DESC_SIZE + 1]
501  = " SUN AZIMUTH =";
502 
503  const char CENTER_DESC [CENTER_DESC_SIZE + 1]
504  = " CENTER ";
505 
506  const char OFFSET_DESC [OFFSET_DESC_SIZE + 1]
507  = " OFFSET=";
508 
509  const char REV_DESC [REV_DESC_SIZE + 1]
510  = " REV";
511 
512  const char SPACE[] = " ";
513 
514  //***
515  // Start at beginning of the stream.
516  //***
517  os.seekp(0, std::ios_base::beg);
518  os << std::setiosflags(std::ios_base::fixed) // Disable scientific mode.
519  << std::setiosflags(std::ios_base::left)
520 
521  << PRODUCT_ID_DESC
522  << std::setw(PRODUCT_ORDER_NUMBER_SIZE)
524 
525  << WRS_DESC
526  << std::setw(PATH_ROW_NUMBER_SIZE)
528 
529  << DATE_DESC
530  << std::setw(DATE_SIZE)
532 
533  << SATELLITE_NUMBER_DESC
534  << std::setw(SAT_NUMBER_SIZE)
535  << theSatNumber
536 
537  << INSTRUMENT_TYPE_DESC
538  << std::setw(INSTRUMENT_TYPE_SIZE)
540 
541  << PRODUCT_TYPE_DESC
542  << std::setw(PRODUCT_TYPE_SIZE)
543  << theProductType
544 
545  << PRODUCT_SIZE_DESC
546  << std::setw(PRODUCT_SIZE_SIZE)
547  << theProductSize
548 
549  << std::setw(MAP_SHEET_SIZE)
550  << theMapSheetName
551 
552  << PROCESSING_TYPE_DESC
553  << std::setw(PROCESSING_TYPE_SIZE)
555 
556  << RESAMPLING_ALGO_DESC
557  << std::setw(RESAMPLING_ALGO_SIZE)
559 
560  << RADIANCE_DESC;
561 
562  int i;
563  for (i=0; i<NUMBER_OF_BANDS-1; i++) // Output six of the seven bands.
564  {
565  os << std::setw(RADIANCE_SIZE) << theBandRadiance[i] << SPACE;
566  }
567 
568  os << std::setw(RADIANCE_SIZE) << theBandRadiance[6] // Last one no space.
569 
570  << VOLUME_NUMBER_DESC
571  << std::setw(VOLUME_NUMBER_SIZE)
572  << theVolumeNumber
573 
574  << std::resetiosflags(std::ios_base::left)
575  << std::setiosflags(std::ios_base::right)
576 
577  << FIRST_LINE_DESC
578  << std::setw(FIRST_LINE_IN_VOLUME_SIZE)
580 
581  << LINES_PER_VOLUME_DESC
582  << std::setw(LINES_PER_VOLUME_SIZE)
584 
585  << ORIENTATION_ANGLE_DESC
586  << std::setprecision(2) << std::setw(ORIENTATION_ANGLE_SIZE)
588 
589  << MAP_PROJ_NAME_DESC
590  << std::setw(MAP_PROJ_NAME_SIZE)
591  << theMapProjName
592 
593  << USGS_PROJ_NUMBER_DESC
594  << std::setw(USGS_PROJ_NUMBER_SIZE)
596 
597  << USGS_MAP_ZONE_DESC
598  << std::setw(USGS_MAP_ZONE_SIZE)
599  << theUsgsMapZone
600 
601  << PROJECTION_PARAMETER_DESC;
602 
603  for (i=0; i<NUMBER_OF_PROJECTION_PARAMETERS; i++)
604  {
605  os << std::setw(USGS_PROJ_PARAMS_SIZE)
606  << theUsgsProjParam[i];
607  }
608 
609 
610  os << std::setiosflags(std::ios_base::left)
611 
612  << ELLIPSOID_DESC
613  << std::setw(ELLIPSOID_SIZE)
614  << theEllipsoid
615  << std::resetiosflags(std::ios_base::left)
616  << std::setprecision(3)
617 
618  << std::setiosflags(std::ios_base::right)
619 
620  << MAJOR_AXIS_DESC
621  << std::setw(MAJOR_AXIS_SIZE)
622  << theSemiMajorAxis
623 
624  << MINOR_AXIS_DESC
625  << std::setw(MINOR_AXIS_SIZE)
627 
628  << std::setprecision(2)
629 
630  << PIXEL_GSD_DESC
631  << std::setw(PIXEL_GSD_SIZE)
632  << theGsd
633 
634  << PIXELS_PER_LINE_DESC
635  << std::setw(PIXELS_PER_LINE_SIZE)
637 
638  << LINES_PER_IMAGE_DESC
639  << std::setw(LINES_PER_IMAGE_SIZE)
641 
642  << std::setprecision(3)
643 
644  << UL_DESC
645  << std::setw(LON_SIZE)
646  << theUlLon
647  << SPACE
648  << std::setw(LAT_SIZE)
649  << theUlLat
650  << SPACE
651  << std::setw(EASTING_SIZE)
652  << theUlEasting
653  << SPACE
654  << std::setw(NORTHING_SIZE)
655  << theUlNorthing
656 
657  << UR_DESC
658  << std::setw(LON_SIZE)
659  << theUrLon
660  << SPACE
661  << std::setw(LAT_SIZE)
662  << theUrLat
663  << SPACE
664  << std::setw(EASTING_SIZE)
665  << theUrEasting
666  << SPACE
667  << std::setw(NORTHING_SIZE)
668  << theUrNorthing
669 
670  << LR_DESC
671  << std::setw(LON_SIZE)
672  << theLrLon
673  << SPACE
674  << std::setw(LAT_SIZE)
675  << theLrLat
676  << SPACE
677  << std::setw(EASTING_SIZE)
678  << theLrEasting
679  << SPACE
680  << std::setw(NORTHING_SIZE)
681  << theLrNorthing
682 
683  << LL_DESC
684  << std::setw(LON_SIZE)
685  << theLlLon
686  << SPACE
687  << std::setw(LAT_SIZE)
688  << theLlLat
689  << SPACE
690  << std::setw(EASTING_SIZE)
691  << theLlEasting
692  << SPACE
693  << std::setw(NORTHING_SIZE)
694  << theLlNorthing
695 
696  << std::resetiosflags(std::ios_base::right);
697 
698  os << BANDS_PRESENT_DESC
699  << std::setw(BANDS_PRESENT_SIZE)
701 
702  << BLOCKING_FACTOR_DESC
703  << std::setw(BLOCKING_FACTOR_SIZE)
705 
706  << RECORD_LENGTH_DESC
707  << std::setw(RECORD_LENGTH_SIZE)
708  << theRecordSize
709 
710  << SUN_ELEVATION_DESC
711  << std::setw(SUN_ELEVATION_SIZE)
712  << theSunElevation
713 
714  << SUN_AZIMUTH_DESC
715  << std::setw(SUN_AZIMUTH_SIZE)
716  << theSunAzimuth
717 
718  << CENTER_DESC
719  << std::setw(LON_SIZE)
720  << theCenterLon
721  << SPACE
722  << std::setw(LAT_SIZE)
723  << theCenterLat
724  << SPACE
725  << std::setiosflags(std::ios_base::right)
726  << std::setw(EASTING_SIZE)
728  << SPACE
729  << std::setw(NORTHING_SIZE)
731  << std::setw(CENTER_SAMPLE_SIZE)
732  << theCenterSample
733  << std::setw(CENTER_LINE_SIZE)
734  << theCenterLine
735 
736  << OFFSET_DESC
737  << std::setw(OFFSET_SIZE)
738  << theOffset
739 
740  << REV_DESC
741  << std::setw(FORMAT_VERSION_SIZE)
742  << theFormatVersion << std::flush; // Byte count of file should be 1536.
743 
744 }
745 
746 
747 //***************************************************************************
748 // PRIVATE METHOD:
749 // ossimFfRevb::loadFromStream(istream& is)
750 // Initializes data members from an EOSAT Fast Format Rev B header.
751 //***************************************************************************
753 {
754  if (!is)
755  {
757 
758  ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFfRevb::loadFromStream:\n"
759  << "Null stream passed in. Returning from method."
760  << std::endl;
761  return;
762  }
763 
764  //***
765  // See .h for enumerations for field sizes and offsets.
766  //***
767 
768  //***
769  // NOTE: Because of header inconsistencies all seeks will be relative to
770  // the beginning of the stream.
771  //***
772 
773  //***
774  // Temporary buffer for fields that need to be converted to integers or
775  // floats.
776  //***
777  char tmpBuff[25];
778 
779  int i; // For iterations.
780 
781  is.seekg(PRODUCT_ORDER_NUMBER_OFFSET, std::ios_base::beg);
782  is.get(theProductOrderNumber,
784  ' ');
785  if (checkStream(is)) return;
786 
787  is.seekg(PATH_ROW_NUMBER_OFFSET, std::ios_base::beg);
789  if (checkStream(is)) return;
790 
791  is.seekg(DATE_OFFSET, std::ios_base::beg);
792  is.get(theAcquisitionDate, DATE_SIZE + 1);
793  if (checkStream(is)) return;
794 
795  is.seekg(SAT_NUMBER_OFFSET, std::ios_base::beg);
796  is.get(theSatNumber, SAT_NUMBER_SIZE + 1);
797  if (checkStream(is)) return;
798 
799  is.seekg(INSTRUMENT_TYPE_OFFSET, std::ios_base::beg);
801  if (checkStream(is)) return;
802 
803  is.seekg(PRODUCT_TYPE_OFFSET, std::ios_base::beg);
804  is.get(theProductType, PRODUCT_TYPE_SIZE+ 1);
805  if (checkStream(is)) return;
806 
807  is.seekg(PRODUCT_SIZE_OFFSET, std::ios_base::beg);
808  is.get(theProductSize, PRODUCT_SIZE_SIZE+ 1);
809  if (checkStream(is)) return;
810 
811  is.seekg(MAP_SHEET_NAME_OFFSET, std::ios_base::beg);
812  is.get(theMapSheetName, MAP_SHEET_SIZE + 1);
813  if (checkStream(is)) return;
814 
815  is.seekg(PROCESSING_TYPE_OFFSET, std::ios_base::beg);
817  if (checkStream(is)) return;
818 
819  is.seekg(RESAMPLING_ALGO_OFFSET, std::ios_base::beg);
821  if (checkStream(is)) return;
822 
823  for (i=0; i<NUMBER_OF_BANDS; i++)
824  {
825  is.seekg(RADIANCE_OFFSET[i], std::ios_base::beg);
826  is.get(theBandRadiance[i], RADIANCE_SIZE + 1);
827  if (checkStream(is)) return;
828  }
829 
830  is.seekg(VOLUME_NUMBER_OFFSET, std::ios_base::beg);
831  is.get(theVolumeNumber, VOLUME_NUMBER_SIZE + 1);
832  if (checkStream(is)) return;
833 
834  is.seekg(FIRST_LINE_IN_VOLUME_OFFSET, std::ios_base::beg);
835  is.get(tmpBuff, FIRST_LINE_IN_VOLUME_SIZE + 1);
836  if (checkStream(is)) return;
837 
838  the1stLineInVolume = atoi(tmpBuff);
839 
840  is.seekg(LINES_PER_VOLUME_OFFSET, std::ios_base::beg);
841  is.get(tmpBuff, LINES_PER_VOLUME_SIZE + 1);
842  if (checkStream(is)) return;
843 
844  theLinesPerVolume = atoi(tmpBuff);
845 
846  is.seekg(ORIENTATION_ANGLE_OFFSET, std::ios_base::beg);
847  is.get(tmpBuff, ORIENTATION_ANGLE_SIZE + 1);
848  if (checkStream(is)) return;
849 
850  theOrientationAngle = atof(tmpBuff);
851 
852  is.seekg(MAP_PROJ_NAME_OFFSET, std::ios_base::beg);
853  is.get(theMapProjName, MAP_PROJ_NAME_SIZE + 1);
854  if (checkStream(is)) return;
855 
856  is.seekg(USGS_PROJ_NUMBER_OFFSET, std::ios_base::beg);
857  is.get(tmpBuff, USGS_PROJ_NUMBER_SIZE + 1);
858  if (checkStream(is)) return;
859 
860  theUsgsProjNumber = atoi(tmpBuff);
861 
862  is.seekg(USGS_MAP_ZONE_OFFSET, std::ios_base::beg);
863  is.get(tmpBuff, USGS_MAP_ZONE_SIZE + 1);
864  if (checkStream(is)) return;
865 
866  theUsgsMapZone = atoi(tmpBuff);
867 
868  //***
869  // Get the fifteen projection parameters.
870  //***
871  for (i=0; i < NUMBER_OF_PROJECTION_PARAMETERS; i++)
872  {
873  is.seekg(PROJ_PARAM_OFFSET[i], std::ios_base::beg);
874  is.get(theUsgsProjParam[i], USGS_PROJ_PARAMS_SIZE + 1);
875  if (checkStream(is)) return;
876  }
877 
878  is.seekg(ELLIPSOID_OFFSET, std::ios_base::beg);
879  is.get(theEllipsoid, ELLIPSOID_SIZE + 1);
880  if (checkStream(is)) return;
881 
882  is.seekg(MAJOR_AXIS_OFFSET, std::ios_base::beg);
883  is.get(tmpBuff, MAJOR_AXIS_SIZE+ 1);
884  if (checkStream(is)) return;
885 
886  theSemiMajorAxis = atof(tmpBuff);
887 
888  is.seekg(MINOR_AXIS_OFFSET, std::ios_base::beg);
889  is.get(tmpBuff, MINOR_AXIS_SIZE+ 1);
890  if (checkStream(is)) return;
891 
892  theSemiMinorAxis = atof(tmpBuff);
893 
894  is.seekg(PIXEL_GSD_OFFSET, std::ios_base::beg);
895  is.get(tmpBuff, PIXEL_GSD_SIZE + 1);
896  if (checkStream(is)) return;
897 
898  theGsd = atof(tmpBuff);
899 
900  is.seekg(PIXELS_PER_LINE_OFFSET, std::ios_base::beg);
901  is.get(tmpBuff, PIXELS_PER_LINE_SIZE + 1);
902  if (checkStream(is)) return;
903 
904  thePixelsPerLine = atoi(tmpBuff);
905 
906  is.seekg(LINES_PER_IMAGE_OFFSET, std::ios_base::beg);
907  is.get(tmpBuff, LINES_PER_IMAGE_SIZE + 1);
908  if (checkStream(is)) return;
909 
910  theLinesPerImage = atoi(tmpBuff);
911 
912  //***
913  // Start of upper left data: longitude, latitude, easting, and northing.
914  //***
915  is.seekg(UL_LON_OFFSET, std::ios_base::beg);
916  is.get(theUlLon, LON_SIZE + 1);
917  if (checkStream(is)) return;
918 
919  is.seekg(UL_LAT_OFFSET, std::ios_base::beg);
920  is.get(theUlLat, LAT_SIZE + 1);
921  if (checkStream(is)) return;
922 
923  is.seekg(UL_EASTING_OFFSET, std::ios_base::beg);
924  is.get(tmpBuff, EASTING_SIZE + 1);
925  if (checkStream(is)) return;
926 
927  theUlEasting = atof(tmpBuff);
928 
929  is.seekg(UL_NORTHING_OFFSET, std::ios_base::beg);
930  is.get(tmpBuff, NORTHING_SIZE + 1);
931  if (checkStream(is)) return;
932 
933  theUlNorthing = atof(tmpBuff);
934 
935  //***
936  // End of upper left data.
937  //***
938 
939  //***
940  // Start of upper right data: longitude, latitude, easting, and northing.
941  //***
942  is.seekg(UR_LON_OFFSET, std::ios_base::beg);
943  is.get(theUrLon, LON_SIZE + 1);
944  if (checkStream(is)) return;
945 
946  is.seekg(UR_LAT_OFFSET, std::ios_base::beg);
947  is.get(theUrLat, LAT_SIZE + 1);
948  if (checkStream(is)) return;
949 
950  is.seekg(UR_EASTING_OFFSET, std::ios_base::beg);
951  is.get(tmpBuff, EASTING_SIZE + 1);
952  if (checkStream(is)) return;
953 
954  theUrEasting = atof(tmpBuff);
955 
956  is.seekg(UR_NORTHING_OFFSET, std::ios_base::beg);
957  is.get(tmpBuff, NORTHING_SIZE + 1);
958  if (checkStream(is)) return;
959 
960  theUrNorthing = atof(tmpBuff);
961 
962  //***
963  // End of upper right data.
964  //***
965 
966  //***
967  // Start of lower right data: longitude, latitude, easting, and northing.
968  //***
969  is.seekg(LR_LON_OFFSET, std::ios_base::beg);
970  is.get(theLrLon, LON_SIZE + 1);
971  if (checkStream(is)) return;
972 
973  is.seekg(LR_LAT_OFFSET, std::ios_base::beg);
974  is.get(theLrLat, LAT_SIZE + 1);
975  if (checkStream(is)) return;
976 
977  is.seekg(LR_EASTING_OFFSET, std::ios_base::beg);
978  is.get(tmpBuff, EASTING_SIZE + 1);
979  if (checkStream(is)) return;
980 
981  theLrEasting = atof(tmpBuff);
982 
983  is.seekg(LR_NORTHING_OFFSET, std::ios_base::beg);
984  is.get(tmpBuff, NORTHING_SIZE + 1);
985  if (checkStream(is)) return;
986 
987  theLrNorthing = atof(tmpBuff);
988 
989  //***
990  // End of lower right data.
991  //***
992 
993  //***
994  // Start of lower left data: longitude, latitude, easting, and northing.
995  //***
996  is.seekg(LL_LON_OFFSET, std::ios_base::beg);
997  is.get(theLlLon, LON_SIZE + 1);
998  if (checkStream(is)) return;
999 
1000  is.seekg(LL_LAT_OFFSET, std::ios_base::beg);
1001  is.get(theLlLat, LAT_SIZE + 1);
1002  if (checkStream(is)) return;
1003 
1004  is.seekg(LL_EASTING_OFFSET, std::ios_base::beg);
1005  is.get(tmpBuff, EASTING_SIZE + 1);
1006  if (checkStream(is)) return;
1007 
1008  theLlEasting = atof(tmpBuff);
1009 
1010  is.seekg(LL_NORTHING_OFFSET, std::ios_base::beg);
1011  is.get(tmpBuff, NORTHING_SIZE + 1);
1012  if (checkStream(is)) return;
1013 
1014  theLlNorthing = atof(tmpBuff);
1015 
1016  //***
1017  // End of lower left data.
1018  //***
1019 
1020  is.seekg(BANDS_PRESENT_OFFSET, std::ios_base::beg);
1022  if (checkStream(is)) return;
1023 
1024  is.seekg(BLOCKING_FACTOR_OFFSET, std::ios_base::beg);
1025  is.get(tmpBuff, BLOCKING_FACTOR_SIZE + 1);
1026  if (checkStream(is)) return;
1027 
1028  theBlockingFactor = atoi(tmpBuff);
1029 
1030  is.seekg(RECORD_LENGTH_OFFSET, std::ios_base::beg);
1031  is.get(tmpBuff, RECORD_LENGTH_SIZE + 1);
1032  if (checkStream(is)) return;
1033 
1034  theRecordSize = atoi(tmpBuff);
1035 
1036  is.seekg(SUN_ELEVATION_OFFSET, std::ios_base::beg);
1037  is.get(tmpBuff, SUN_ELEVATION_SIZE + 1);
1038  if (checkStream(is)) return;
1039 
1040  theSunElevation = atoi(tmpBuff);
1041 
1042  is.seekg(SUN_AZIMUTH_OFFSET, std::ios_base::beg);
1043  is.get(tmpBuff, SUN_AZIMUTH_SIZE + 1);
1044  if (checkStream(is)) return;
1045 
1046  theSunAzimuth = atoi(tmpBuff);
1047 
1048  //***
1049  // Start of scene center data: longitude, latitude, easting, northing,
1050  // sample, line.
1051  //***
1052  is.seekg(CENTER_LON_OFFSET, std::ios_base::beg);
1053  is.get(theCenterLon, LON_SIZE + 1);
1054  if (checkStream(is)) return;
1055 
1056  is.seekg(CENTER_LAT_OFFSET, std::ios_base::beg);
1057  is.get(theCenterLat, LAT_SIZE + 1);
1058  if (checkStream(is)) return;
1059 
1060  is.seekg(CENTER_EASTING_OFFSET, std::ios_base::beg);
1061  is.get(tmpBuff, EASTING_SIZE + 1);
1062  if (checkStream(is)) return;
1063 
1064  theCenterEasting = atof(tmpBuff);
1065 
1066  is.seekg(CENTER_NORTHING_OFFSET, std::ios_base::beg);
1067  is.get(tmpBuff, NORTHING_SIZE + 1);
1068  if (checkStream(is)) return;
1069 
1070  theCenterNorthing = atof(tmpBuff);
1071 
1072  is.seekg(CENTER_SAMPLE_OFFSET, std::ios_base::beg);
1073  is.get(tmpBuff, CENTER_SAMPLE_SIZE + 1);
1074  if (checkStream(is)) return;
1075 
1076  theCenterSample = atoi(tmpBuff);
1077 
1078  is.seekg(CENTER_LINE_OFFSET, std::ios_base::beg);
1079  is.get(tmpBuff, CENTER_LINE_SIZE + 1);
1080  if (checkStream(is)) return;
1081 
1082  theCenterLine = atoi(tmpBuff);
1083 
1084  //***
1085  // End of scene center data.
1086  //***
1087 
1088  is.seekg(OFFSET_OFFSET, std::ios_base::beg);
1089  is.get(tmpBuff, OFFSET_SIZE + 1);
1090  if (checkStream(is)) return;
1091 
1092  theOffset = atoi(tmpBuff);
1093 
1094  is.seekg(FORMAT_VERSION_OFFSET, std::ios_base::beg);
1096  if (checkStream(is)) return;
1097 
1098 }
1099 
1100 //***************************************************************************
1101 // PRIVATE METHOD:
1102 // ossimFfRevb::checkStream(istream& is)
1103 //
1104 // Checks the stream. If an error has occurred it sets theErrorStatus.
1105 // Returns: theErrorStatus ( 0 = OK, 1 = ERROR )
1106 //***************************************************************************
1108 {
1109  //***
1110  // istreams set fault bits and the operator! is overloaded to return
1111  // true if an error has occurred.
1112  //***
1113  if (!is)
1114  {
1116  ossimNotify(ossimNotifyLevel_FATAL) << "ossimFfRevb::checkStream ERROR: "
1117  << "Stream corrupted. Returning from method."
1118  << std::endl;
1119  }
1120  return theErrorStatus;
1121 }
1122 
1123 //***************************************************************************
1124 // Function:
1125 // ostream& operator<<(ostream& os, const ossimFfRevb& head)
1126 //***************************************************************************
1128 {
1129  head.print(os);
1130 
1131  return os;
1132 }
int fraction() const
char theInstrumentType[INSTRUMENT_TYPE_SIZE+1]
Definition: ossimFfRevb.h:213
double theSemiMajorAxis
Definition: ossimFfRevb.h:241
double theUlNorthing
Definition: ossimFfRevb.h:250
char theFormatVersion[FORMAT_VERSION_SIZE+1]
Definition: ossimFfRevb.h:280
char thePathRowNumber[PATH_ROW_NUMBER_SIZE+1]
Definition: ossimFfRevb.h:206
void loadFromStream(std::istream &is)
ErrorStatus theErrorStatus
Definition: ossimFfRevb.h:287
int theUsgsProjNumber
Definition: ossimFfRevb.h:231
void write(std::ostream &os) const
double theUlEasting
Definition: ossimFfRevb.h:249
double theLrEasting
Definition: ossimFfRevb.h:259
char theProductType[PRODUCT_TYPE_SIZE+1]
Definition: ossimFfRevb.h:216
char theUrLat[LAT_SIZE+1]
Definition: ossimFfRevb.h:253
char theAcquisitionDate[DATE_SIZE+1]
Definition: ossimFfRevb.h:207
char theUrLon[LON_SIZE+1]
Definition: ossimFfRevb.h:252
int the1stLineInVolume
Definition: ossimFfRevb.h:227
char theProductSize[PRODUCT_SIZE_SIZE+1]
Definition: ossimFfRevb.h:217
int theCenterLine
Definition: ossimFfRevb.h:278
int theCenterSample
Definition: ossimFfRevb.h:277
const int RADIANCE_OFFSET[7]
Definition: ossimFfRevb.cpp:23
double theLlEasting
Definition: ossimFfRevb.h:264
double theCenterNorthing
Definition: ossimFfRevb.h:276
char theUlLat[LAT_SIZE+1]
Definition: ossimFfRevb.h:248
int checkStream(std::istream &is)
int theRecordSize
Definition: ossimFfRevb.h:269
static StreamFactoryRegistry * instance()
char theProductOrderNumber[PRODUCT_ORDER_NUMBER_SIZE+1]
Definition: ossimFfRevb.h:205
char theUlLon[LON_SIZE+1]
Definition: ossimFfRevb.h:247
#define SPACE
Definition: vpfio.h:25
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
void print(std::ostream &os) const
char theCenterLat[LAT_SIZE+1]
Definition: ossimFfRevb.h:274
char theProcessingType[PROCESSING_TYPE_SIZE+1]
Definition: ossimFfRevb.h:221
double theUrNorthing
Definition: ossimFfRevb.h:255
char theSatNumber[SAT_NUMBER_SIZE+1]
Definition: ossimFfRevb.h:210
double projParam(int paramNumber) const
char theResampAlgorithm[RESAMPLING_ALGO_SIZE+1]
Definition: ossimFfRevb.h:224
char theLlLat[LAT_SIZE+1]
Definition: ossimFfRevb.h:263
const char * chars() const
For backward compatibility.
Definition: ossimString.h:77
char theBandsPresentString[BANDS_PRESENT_SIZE+1]
Definition: ossimFfRevb.h:267
int path() const
int theSunAzimuth
Definition: ossimFfRevb.h:271
char theLrLon[LON_SIZE+1]
Definition: ossimFfRevb.h:257
char theMapSheetName[MAP_SHEET_SIZE+1]
Definition: ossimFfRevb.h:220
int thePixelsPerLine
Definition: ossimFfRevb.h:244
int theLinesPerVolume
Definition: ossimFfRevb.h:228
char theLrLat[LAT_SIZE+1]
Definition: ossimFfRevb.h:258
int row() const
char theMapProjName[MAP_PROJ_NAME_SIZE+1]
Definition: ossimFfRevb.h:230
double theSemiMinorAxis
Definition: ossimFfRevb.h:242
int theUsgsMapZone
Definition: ossimFfRevb.h:232
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
std::ostream & operator<<(std::ostream &os, const ossimFfRevb &head)
int theSunElevation
Definition: ossimFfRevb.h:270
int theLinesPerImage
Definition: ossimFfRevb.h:245
char theVolumeNumber[VOLUME_NUMBER_SIZE+1]
Definition: ossimFfRevb.h:226
double theCenterEasting
Definition: ossimFfRevb.h:275
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.
std::basic_istringstream< char > istringstream
Class for char input memory streams.
Definition: ossimIosFwd.h:32
int theBlockingFactor
Definition: ossimFfRevb.h:268
double theLlNorthing
Definition: ossimFfRevb.h:265
char theEllipsoid[ELLIPSOID_SIZE+1]
Definition: ossimFfRevb.h:240
double theOrientationAngle
Definition: ossimFfRevb.h:229
char theCenterLon[LON_SIZE+1]
Definition: ossimFfRevb.h:273
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
double theLrNorthing
Definition: ossimFfRevb.h:260
double theUrEasting
Definition: ossimFfRevb.h:254