OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
Public Member Functions | Protected Attributes | Static Protected Attributes | Friends | List of all members
ossimplugins::Data Class Reference

This class is able to read the data file of the RadarSat file structure. More...

#include <Data.h>

Public Member Functions

 Data ()
 Constructor. More...
 
 ~Data ()
 Destructor. More...
 
 Data (const Data &rhs)
 Copy constructor. More...
 
Dataoperator= (const Data &rhs)
 Copy operator. More...
 
void ClearRecords ()
 Removes all the previous records from the Data. More...
 
void InsertRecord (int id, RadarSatRecord *record)
 Inserts an existing record in the Data. More...
 
ImageOptionsFileDescriptorget_ImageOptionsFileDescriptor ()
 
ProcessedDataRecordget_FirstProcessedDataRecord ()
 
ProcessedDataRecordget_LastProcessedDataRecord ()
 

Protected Attributes

std::map< int, RadarSatRecord * > _records
 

Static Protected Attributes

static const int ImageOptionsFileDescriptorID = 1
 
static const int FirstProcessedDataRecordID = 2
 
static const int LastProcessedDataRecordID = 3
 

Friends

std::ostream & operator<< (std::ostream &os, const Data &data)
 This function writes the Data in a stream. More...
 
std::istream & operator>> (std::istream &is, Data &data)
 This function reads a Data from a stream. More...
 

Detailed Description

This class is able to read the data file of the RadarSat file structure.

Author
Magellium, Pacome Dentraygues
Version
1.0
Date
23-11-07

Definition at line 31 of file Data.h.

Constructor & Destructor Documentation

◆ Data() [1/2]

ossimplugins::Data::Data ( )

Constructor.

Definition at line 28 of file Data.cpp.

29 {
30 }

◆ ~Data()

ossimplugins::Data::~Data ( )

Destructor.

Definition at line 32 of file Data.cpp.

References ClearRecords().

33 {
34  ClearRecords();
35 }
void ClearRecords()
Removes all the previous records from the Data.
Definition: Data.cpp:205

◆ Data() [2/2]

ossimplugins::Data::Data ( const Data rhs)

Copy constructor.

Definition at line 175 of file Data.cpp.

References _records.

176 {
177  std::map<int, RadarSatRecord*>::const_iterator it = rhs._records.begin();
178  while(it != rhs._records.end())
179  {
180  _records[(*it).first] = (*it).second->Clone();
181  ++it;
182  }
183 }
std::map< int, RadarSatRecord * > _records
Definition: Data.h:78

Member Function Documentation

◆ ClearRecords()

void ossimplugins::Data::ClearRecords ( )

Removes all the previous records from the Data.

Definition at line 205 of file Data.cpp.

References _records.

Referenced by ossimplugins::operator>>(), and ~Data().

206 {
207  std::map<int, RadarSatRecord*>::const_iterator it = _records.begin();
208  while(it != _records.end())
209  {
210  delete (*it).second;
211  ++it;
212  }
213  _records.clear();
214 }
std::map< int, RadarSatRecord * > _records
Definition: Data.h:78

◆ get_FirstProcessedDataRecord()

ProcessedDataRecord * ossimplugins::Data::get_FirstProcessedDataRecord ( )

Definition at line 226 of file Data.cpp.

References _records, and FirstProcessedDataRecordID.

Referenced by ossimplugins::ossimRadarSatModel::internalSaveState().

227 {
228  return (ProcessedDataRecord*)_records[FirstProcessedDataRecordID];
229 }
std::map< int, RadarSatRecord * > _records
Definition: Data.h:78
static const int FirstProcessedDataRecordID
Definition: Data.h:80

◆ get_ImageOptionsFileDescriptor()

ImageOptionsFileDescriptor * ossimplugins::Data::get_ImageOptionsFileDescriptor ( )

Definition at line 221 of file Data.cpp.

References _records, and ImageOptionsFileDescriptorID.

Referenced by ossimplugins::ossimRadarSatModel::internalSaveState(), and ossimplugins::operator>>().

222 {
223  return (ImageOptionsFileDescriptor*)_records[ImageOptionsFileDescriptorID];
224 }
static const int ImageOptionsFileDescriptorID
Definition: Data.h:79
std::map< int, RadarSatRecord * > _records
Definition: Data.h:78

◆ get_LastProcessedDataRecord()

ProcessedDataRecord * ossimplugins::Data::get_LastProcessedDataRecord ( )

Definition at line 231 of file Data.cpp.

References _records, and LastProcessedDataRecordID.

Referenced by ossimplugins::ossimRadarSatModel::internalSaveState().

232 {
233  return (ProcessedDataRecord*)_records[LastProcessedDataRecordID];
234 }
static const int LastProcessedDataRecordID
Definition: Data.h:81
std::map< int, RadarSatRecord * > _records
Definition: Data.h:78

◆ InsertRecord()

void ossimplugins::Data::InsertRecord ( int  id,
RadarSatRecord record 
)

Inserts an existing record in the Data.

Definition at line 216 of file Data.cpp.

References _records.

217 {
218  _records[id] = record;
219 }
std::map< int, RadarSatRecord * > _records
Definition: Data.h:78

◆ operator=()

Data & ossimplugins::Data::operator= ( const Data rhs)

Copy operator.

Definition at line 185 of file Data.cpp.

References _records.

186 {
187  std::map<int, RadarSatRecord*>::const_iterator it = _records.begin();
188  while(it != _records.end())
189  {
190  delete (*it).second;
191  ++it;
192  }
193  _records.clear();
194 
195  it = rhs._records.begin();
196  while(it != rhs._records.end())
197  {
198  _records[(*it).first] = (*it).second->Clone();
199  ++it;
200  }
201 
202  return *this;
203 }
std::map< int, RadarSatRecord * > _records
Definition: Data.h:78

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Data data 
)
friend

This function writes the Data in a stream.

Definition at line 37 of file Data.cpp.

38 {
39  std::map<int, RadarSatRecord*>::const_iterator it = data._records.begin();
40  while(it != data._records.end())
41  {
42  (*it).second->Write(os);
43  ++it;
44  }
45  return os;
46 
47 }

◆ operator>>

std::istream& operator>> ( std::istream &  is,
Data data 
)
friend

This function reads a Data from a stream.

Definition at line 49 of file Data.cpp.

50 {
51  DataFactory factory;
52 
53  data.ClearRecords();
54 
55  if (sizeof(int)!=4) ossimNotify(ossimNotifyLevel_WARN) << "RadarSat Data WARNING : (int) not coded over 32 bits, metadata might not be byte swapped correctly"<< std::endl ;
56  if (sizeof(float)!=4) ossimNotify(ossimNotifyLevel_WARN) << "RadarSat Data WARNING : (float) not coded over 32 bits, metadata might not be byte swapped correctly"<< std::endl ;
57  if (sizeof(double)!=8) ossimNotify(ossimNotifyLevel_WARN) << "RadarSat Data WARNING : (double) not coded over 64 bits, metadata might not be byte swapped correctly"<< std::endl ;
58 
59  RadarSatRecordHeader header;
60  bool eof = false;
61 
62  int nbLin = 0 ; // number of image lines
63  int lineLength = 0 ; // size of any ProcessedDataRecord
64 
65  is.seekg(0, std::ios::end) ;
66  int lengthOfFile = is.tellg(); // total length of file
67  is.seekg(0, std::ios::beg);
68  while(!eof)
69  {
70  is>>header;
71  if(is.eof())
72  {
73  eof = true;
74  }
75  else
76  {
77  if (header.get_rec_seq() == 1)
78  { // ImageOptionsFileDescriptor
79  RadarSatRecord* record = factory.Instanciate(header.get_rec_seq());
80  if (record != NULL)
81  {
82  record->Read(is);
83  data._records[Data::ImageOptionsFileDescriptorID] = record;
84 
85  nbLin = ((ImageOptionsFileDescriptor *) record)->get_nlin() ;
86  if (nbLin == -1)
87  {
88  ossimNotify(ossimNotifyLevel_DEBUG) << "WARNING: nbLin is not read in the file !" << std::endl;
89  }
90  }
91  else
92  {
93  char* buff = new char[header.get_length()-12];
94  is.read(buff, header.get_length()-12);
95  delete[] buff;
96  }
97  }
98  else if ((header.get_rec_seq() == 2))
99  { // First line ProcessedDataRecord
100  lineLength = header.get_length() ;
101  RadarSatRecord* record = factory.Instanciate(2);
102  if (record != NULL)
103  {
104  record->Read(is);
105  data._records[Data::FirstProcessedDataRecordID] = record;
106 
107  char* buff = new char[header.get_length()-192];
108  is.read(buff, header.get_length()-192); // Reads the rest of the line
109  delete[] buff;
110  }
111  else
112  {
113  char* buff = new char[header.get_length()-12];
114  is.read(buff, header.get_length()-12);
115  delete[] buff;
116  }
117  }
118  else if ((header.get_rec_seq() == (1+nbLin)))
119  { // Last line ProcessedDataRecord
120  RadarSatRecord* record = factory.Instanciate(2);
121  if (record != NULL)
122  {
123  record->Read(is);
124  data._records[Data::LastProcessedDataRecordID] = record;
125 
126  char* buff = new char[header.get_length()-192];
127  is.read(buff, header.get_length()-192); // Reads the rest of the line
128  delete[] buff;
129  }
130  else
131  {
132  char* buff = new char[header.get_length()-12];
133  is.read(buff, header.get_length()-12);
134  delete[] buff;
135  }
136  }
137  else
138  {
139  // all lines between the first and last ones are skipped
140  if (lineLength != 0)
141  {
142  if (nbLin == -1)
143  {
144  // Compute the number of line per dataset from the size of file and current position
145  int nbLines = ( ( lengthOfFile - is.tellg() ) / lineLength ) + 2;
146  ossimNotify(ossimNotifyLevel_DEBUG) << "To move in the dat file we compute the nb of lines = " << nbLines << std::endl;
147 
148  // We move in the file to the last line
149  is.seekg((nbLines - 2) * lineLength - 12, std::ios::cur);
150 
151  // We save the nbLines computed in data
152  nbLin = nbLines;
153  ImageOptionsFileDescriptor* record = data.get_ImageOptionsFileDescriptor();
154  record->set_nlin(nbLin);
155  data._records[Data::ImageOptionsFileDescriptorID] = record;
156  }
157  else
158  {
159  // We move in the file
160  is.seekg((nbLin - 2) * lineLength - 12, std::ios::cur);
161  }
162  }
163  else
164  {
165  // We move to the end of the file
166  is.seekg(0, std::ios::end) ;
167  }
168  }
169  }
170  }
171  return is;
172 }
static const int LastProcessedDataRecordID
Definition: Data.h:81
static const int ImageOptionsFileDescriptorID
Definition: Data.h:79
static const int FirstProcessedDataRecordID
Definition: Data.h:80
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)

Member Data Documentation

◆ _records

std::map<int, RadarSatRecord*> ossimplugins::Data::_records
protected

◆ FirstProcessedDataRecordID

const int ossimplugins::Data::FirstProcessedDataRecordID = 2
staticprotected

Definition at line 80 of file Data.h.

Referenced by get_FirstProcessedDataRecord(), and ossimplugins::operator>>().

◆ ImageOptionsFileDescriptorID

const int ossimplugins::Data::ImageOptionsFileDescriptorID = 1
staticprotected

Definition at line 79 of file Data.h.

Referenced by get_ImageOptionsFileDescriptor(), and ossimplugins::operator>>().

◆ LastProcessedDataRecordID

const int ossimplugins::Data::LastProcessedDataRecordID = 3
staticprotected

Definition at line 81 of file Data.h.

Referenced by get_LastProcessedDataRecord(), and ossimplugins::operator>>().


The documentation for this class was generated from the following files: