OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
AlosPalsarData.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // "Copyright Centre National d'Etudes Spatiales"
4 // "Copyright Centre for Remote Imaging, Sensing and Processing"
5 //
6 // License: LGPL
7 //
8 // See LICENSE.txt file in the top level directory for more details.
9 //
10 //----------------------------------------------------------------------------
11 // $Id$
12 
15 
18 
19 #include <ossim/base/ossimTrace.h>
22 
23 // Static trace for debugging
24 static ossimTrace traceDebug("ossimAlosPalsarData:debug");
25 
26 namespace ossimplugins
27 {
28 
31 
33 {
34 
35 }
36 
38 {
39  ClearRecords();
40 }
41 
43 {
44  std::map<int, AlosPalsarRecord*>::const_iterator it = data._records.begin();
45  while (it != data._records.end())
46  {
47  (*it).second->Write(os);
48  ++it;
49  }
50  return os;
51 
52 }
53 
55 {
56 
57  data.ClearRecords();
58 
60 
61  is >> header;
62 
64  if (record != NULL)
65  {
66  record->Read(is);
67  data._records[header.get_rec_seq()] = record;
68  }
69  else
70  {
71  char* buff = new char[header.get_length()-12];
72  is.read(buff, header.get_length() - 12);
73  delete [] buff;
74  }
75 
76  std::streampos filePosition;
77 
78  filePosition = is.tellg();
79  is >> header;
80 
81  record = new AlosPalsarSignalData;
82 
83  if (record != NULL)
84  {
85  record->Read(is);
86  data._records[header.get_rec_seq()] = record;
87 // std::cout << "Record sequence number = " << header.get_rec_seq() << std::endl;
88  }
89  is.seekg(filePosition); // Rewind file pointer to start of record
90  // Then, advance pointer to next record
91  is.seekg(static_cast<std::streamoff>(header.get_length()), std::ios::cur);
92 
93  return is;
94 }
95 
96 
98 {
99  std::map<int, AlosPalsarRecord*>::const_iterator it = rhs._records.begin();
100  while (it != rhs._records.end())
101  {
102  _records[(*it).first] = (*it).second->Clone();
103  ++it;
104  }
105 }
106 
108 {
109  ClearRecords();
110  std::map<int, AlosPalsarRecord*>::const_iterator it = rhs._records.begin();
111  while (it != rhs._records.end())
112  {
113  _records[(*it).first] = (*it).second->Clone();
114  ++it;
115  }
116 
117  return *this;
118 }
119 
121 {
122  std::map<int, AlosPalsarRecord*>::const_iterator it = _records.begin();
123  while (it != _records.end())
124  {
125  delete(*it).second;
126  ++it;
127  }
128  _records.clear();
129 }
130 
132  const char* prefix) const
133 {
134 
135  static const char MODULE[] = "AlosPalsarData::saveState";
136 
137  if (traceDebug())
138  {
139  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " entered...\n";
140  }
141 
142  bool result = true;
143 
144  /*
145  * Adding metadata necessary to the sensor model in the keywordlist
146  */
148  if (datafiledesc != NULL)
149  {
150  kwl.add(prefix, "num_lines", datafiledesc->get_num_lines(), true);
151  kwl.add(prefix, "num_pix_in_line", datafiledesc->get_num_pix_in_line(), true);
152  }
153  else
154  {
155  result = false;
156  }
157 
158  const AlosPalsarSignalData *signalData = get_AlosPalsarSignalData();
159  if (datafiledesc != NULL)
160  {
161  kwl.add(prefix, "pulse_repetition_frequency", signalData->get_pulse_repetition_frequency(), true);
162  // slant range to 1st data sample in metres
163  kwl.add(prefix, "slant_range_to_1st_data_sample", signalData->get_slant_range_to_1st_data_sample(), true);
164  }
165  else
166  {
167  result = false;
168  }
169 
170 
171  return result;
172 }
173 
174 
176 {
177  return dynamic_cast<const AlosPalsarDataFileDescriptor*>(_records.find(AlosPalsarDataFileDescriptorID)->second);
178 }
179 
181 {
182  // TODO: Check if _records[AlosPalsarSignalDataID] works
183  return dynamic_cast<const AlosPalsarSignalData*>(_records.find(AlosPalsarSignalDataID)->second);
184 }
185 
186 }
This class is able to read the header of the Signal Data Records of the image file.
This class is able to read a record header.
Represents serializable keyword/value map.
virtual ~AlosPalsarData()
Destructor.
This class is the base class of all the record classes.
This class is able to read the SAR leader file descriptor record of the leader file.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
static const int AlosPalsarDataFileDescriptorID
std::ostream & operator<<(std::ostream &os, const AlosPalsarData &data)
This class is able to read the Leader file of the AlosPalsar file structure.
AlosPalsarData & operator=(const AlosPalsarData &rhs)
Copy operator.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
Method to save object state to a keyword list.
std::istream & operator>>(std::istream &is, AlosPalsarData &data)
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
const AlosPalsarDataFileDescriptor * get_AlosPalsarDataFileDescriptor() const
static const int AlosPalsarSignalDataID
void ClearRecords()
Remove all the previous records from the AlosPalsarData.
virtual void Read(std::istream &is)=0
Read the class data from a stream.
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
const AlosPalsarSignalData * get_AlosPalsarSignalData() const