OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimNitfBlockaTag.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // License: LGPL
4 //
5 // See LICENSE.txt file in the top level directory for more details.
6 //
7 // Author: David Burken
8 //
9 // Description: BLOCKA tag class declaration.
10 //
11 //----------------------------------------------------------------------------
12 // $Id: ossimNitfBlockaTag.cpp 23245 2015-04-08 20:53:04Z rashadkm $
13 
14 #include <cstring> /* for memcpy */
15 #include <sstream>
16 #include <iomanip>
17 
21 #include <ossim/base/ossimTrace.h>
22 #include <ossim/base/ossimDms.h>
23 #include <ossim/base/ossimDpt.h>
24 
25 static const ossimTrace traceDebug(ossimString("ossimNitfBlockaTag:debug"));
26 
28 
30  : ossimNitfRegisteredTag(std::string("BLOCKA"), 123)
31 {
32  clearFields();
33 }
34 
36 {
37  clearFields();
38 
40  in.read(theNGray, N_GRAY_SIZE);
41  in.read(theLLines, L_LINES_SIZE);
44  in.read(theField6, FIELD_6_SIZE);
45  in.read(theFrlcLoc, FRLC_LOC_SIZE);
46  in.read(theLrlcLoc, LRLC_LOC_SIZE);
47  in.read(theLrfcLoc, LRFC_LOC_SIZE);
48  in.read(theFrfcLoc, FRFC_LOC_SIZE);
49  in.read(theField11, FIELD_11_SIZE);
50 
51 }
52 
54 {
56  out.write(theNGray, N_GRAY_SIZE);
57  out.write(theLLines, L_LINES_SIZE);
60  out.write(theField6, FIELD_6_SIZE);
61  out.write(theFrlcLoc, FRLC_LOC_SIZE);
62  out.write(theLrlcLoc, LRLC_LOC_SIZE);
63  out.write(theLrfcLoc, LRFC_LOC_SIZE);
64  out.write(theFrfcLoc, FRFC_LOC_SIZE);
65  out.write(theField11, FIELD_11_SIZE);
66 }
67 
69 {
71  memset(theNGray, 0, N_GRAY_SIZE);
72  memset(theLLines, 0, L_LINES_SIZE);
73  memset(theLayoverAngle, ' ', LAYOVER_ANGLE_SIZE);
74  memset(theShadowAngle, ' ', SHADOW_ANGLE_SIZE);
75  memset(theField6, ' ', FIELD_6_SIZE);
76  memset(theFrlcLoc, ' ', FRLC_LOC_SIZE);
77  memset(theLrlcLoc, ' ', LRLC_LOC_SIZE);
78  memset(theLrfcLoc, ' ', LRFC_LOC_SIZE);
79  memset(theFrfcLoc, ' ', FRFC_LOC_SIZE);
80  memcpy(theField11, "010.0", FIELD_11_SIZE);
81 
83  theNGray[N_GRAY_SIZE] = '\0';
84  theLLines[L_LINES_SIZE] = '\0';
87  theField6[FIELD_6_SIZE] = '\0';
88  theFrlcLoc[FRLC_LOC_SIZE] = '\0';
89  theLrlcLoc[LRLC_LOC_SIZE] = '\0';
90  theLrfcLoc[LRFC_LOC_SIZE] = '\0';
91  theFrfcLoc[FRFC_LOC_SIZE] = '\0';
92  theField11[FIELD_11_SIZE] = '\0';
93 }
94 
96  const std::string& prefix) const
97 {
98  std::string pfx = prefix;
99  pfx += getTagName();
100  pfx += ".";
101 
102  // Grab the corners parsed into points.
103  ossimDpt ulPt;
104  ossimDpt urPt;
105  ossimDpt lrPt;
106  ossimDpt llPt;
107  getFrfcLoc(ulPt);
108  getFrlcLoc(urPt);
109  getLrlcLoc(lrPt);
110  getLrfcLoc(llPt);
111 
112  out << setiosflags(ios::left)
113  << pfx << std::setw(24) << "CETAG:" << getTagName() << "\n"
114  << pfx << std::setw(24) << "CEL:" << getTagLength() << "\n"
115  << pfx << std::setw(24) << "BLOCK_INSTANCE:" << theBlockInstance << "\n"
116  << pfx << std::setw(24) << "N_GRAY:" << theNGray << "\n"
117  << pfx << std::setw(24) << "L_LINES:" << theLLines << "\n"
118  << pfx << std::setw(24) << "LAYOVER_ANGLE:" << theLayoverAngle << "\n"
119  << pfx << std::setw(24) << "SHADOW_ANGLE:" << theShadowAngle << "\n"
120  << pfx << std::setw(24) << "FIELD_6:" << theField6 << "\n"
121  << pfx << std::setw(24) << "FRLC_LOC:" << theFrlcLoc << "\n"
122  << pfx << std::setw(24) << "LRLC_LOC:" << theLrlcLoc << "\n"
123  << pfx << std::setw(24) << "LRFC_LOC:" << theLrfcLoc << "\n"
124  << pfx << std::setw(24) << "FRFC_LOC:" << theFrfcLoc << "\n"
125  << pfx << std::setw(24) << "FIELD_11:" << theField11 << "\n"
126  << pfx << std::setw(24) << "upper left:" << ulPt << "\n"
127  << pfx << std::setw(24) << "upper right:" << urPt << "\n"
128  << pfx << std::setw(24) << "lower right:" << lrPt << "\n"
129  << pfx << std::setw(24) << "lower left:" << llPt << "\n";
130 
131  return out;
132 }
133 
135 {
136  if ( (block > 0) && (block < 100) )
137  {
138  ossimString os =
142  }
143 }
144 
146 {
148 }
149 
151 {
152  if (grayCount < 100000)
153  {
154  ossimString os =
156  N_GRAY_SIZE);
157  memcpy(theNGray, os.c_str(), N_GRAY_SIZE);
158  }
159 }
160 
162 {
163  return ossimString(theNGray);
164 }
165 
167 {
168  if (lines < 100000)
169  {
170  ossimString os =
172  memcpy(theLLines, os.c_str(), L_LINES_SIZE);
173  }
174 }
175 
177 {
178  return ossimString(theLLines);
179 }
180 
182 {
183  if (angle < 360)
184  {
185  ossimString os =
188  }
189 }
190 
192 {
194 }
195 
197 {
198  if (angle < 360)
199  {
200  ossimString os =
202  memcpy(theShadowAngle, os.c_str(), SHADOW_ANGLE_SIZE);
203  }
204 }
205 
207 {
208  return ossimString(theShadowAngle);
209 }
210 
212 {
214  memcpy(theFrlcLoc, os.c_str(), FRLC_LOC_SIZE);
215 }
216 
218 {
219  return ossimString(theFrlcLoc);
220 }
221 
223 {
224  ossimString os = theFrlcLoc;
225  converLocStringToPt(os, pt);
226 }
227 
229 {
231  memcpy(theLrlcLoc, os.c_str(), LRLC_LOC_SIZE);
232 }
233 
235 {
236  return ossimString(theLrlcLoc);
237 }
238 
240 {
241  ossimString os = theLrlcLoc;
242  converLocStringToPt(os, pt);
243 }
244 
246 {
248  memcpy(theLrfcLoc, os.c_str(), LRFC_LOC_SIZE);
249 }
250 
252 {
253  return ossimString(theLrfcLoc);
254 }
255 
257 {
258  ossimString os = theLrfcLoc;
259  converLocStringToPt(os, pt);
260 }
261 
263 {
265  memcpy(theFrfcLoc, os.c_str(), FRFC_LOC_SIZE);
266 }
267 
269 {
270  return ossimString(theFrfcLoc);
271 }
272 
274 {
275  ossimString os = theFrfcLoc;
276  converLocStringToPt(os, pt);
277 }
278 
280  ossimDpt& pt) const
281 {
282  if (locationString.size() != 21) return;
283 
284  std::string s = locationString;
285 
286  std::string lat(s, 0, 10);
287  std::string lon(s, 10, 11);
288 
289  if ( (lat[0] == 'N') || (lat[0] == 'S') )
290  {
291  // Need to enter spaces for ossimDms to parse correctly
292  std::ostringstream latStream;
293  latStream << lat.substr(0, 3) << " " << lat.substr(3, 2)
294  << " " << lat.substr(5);
295  lat = latStream.str();
296 
297  // Use the dms class to parse.
298  ossimDms dms(0.0, true);
299  dms.setDegrees(lat.c_str());
300  pt.y = dms.getDegrees();
301  }
302  else
303  {
304  ossimString os = lat;
305  pt.y = os.toDouble();
306  }
307  if ( (lon[0] == 'E') || (lon[0] == 'W') )
308  {
309  // Need to enter spaces for ossimDms to parse correctly
310  std::ostringstream lonStream;
311  lonStream << lon.substr(0, 4) << " " << lon.substr(4, 2)
312  << " " << lon.substr(6);
313  lon = lonStream.str();
314 
315  // Use the dms class to parse.
316  ossimDms dms(0.0, false);
317  dms.setDegrees(lon.c_str());
318  pt.x = dms.getDegrees();
319  }
320  else
321  {
322  ossimString os = lon;
323  pt.x = os.toDouble();
324  }
325 }
virtual void parseStream(ossim::istream &in)
Parse method.
virtual const std::string & getTagName() const
This will return the name of the registered tag for this user defined header.
char theFrlcLoc[FRLC_LOC_SIZE+1]
FIELD: FRLC_LOC.
char theFrfcLoc[FRFC_LOC_SIZE+1]
FIELD: FRFC_LOC.
char theNGray[N_GRAY_SIZE+1]
FIELD: N_GRAY.
void setFrlcLoc(const ossimDpt &pt)
Convert latitude and logitude to theFrlcLoc string.
virtual std::ostream & print(std::ostream &out, const std::string &prefix) const
Print method that outputs a key/value type format adding prefix to keys.
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
ossimString getFrlcLoc() const
ossimString getLayoverAngle() const
ossimString getBlockInstance() const
ossimString getFrfcLoc() const
void setLrfcLoc(const ossimDpt &pt)
Convert latitude and logitude to theLrfcLoc string.
virtual void clearFields()
Clears all string fields within the record to some default nothingness.
void setNGray(ossim_uint32 grayCount)
char theField6[FIELD_6_SIZE+1]
FIELD: FIELD_6.
void setLrlcLoc(const ossimDpt &pt)
Convert latitude and logitude to theLrlcLoc string.
void setLayoverAngle(ossim_uint32 angle)
ossimString getNGray() const
void setBlockInstance(ossim_uint32 block)
double y
Definition: ossimDpt.h:165
char theLrlcLoc[LRLC_LOC_SIZE+1]
FIELD: LRLC_LOC.
char theShadowAngle[SHADOW_ANGLE_SIZE+1]
FIELD: SHADOW_ANGLE.
ossimNitfBlockaTag()
default constructor
char theLLines[L_LINES_SIZE+1]
FIELD: L_LINES.
ossimString getLrfcLoc() const
ossimString getLLines() const
virtual ossim_uint32 getTagLength() const
Returns the length in bytes of the tag from the CEL or REL field.
char theLayoverAngle[LAYOVER_ANGLE_SIZE+1]
FIELD: LAYOVER_ANGLE.
static ossimString convertToDdLatLonLocString(const ossimDpt &pt, ossim_uint32 precision)
Converts pt to a decimal degrees latitude longitude location string.
void setFrfcLoc(const ossimDpt &pt)
Convert latitude and logitude to theFrfcLoc string.
std::string::size_type size() const
Definition: ossimString.h:405
unsigned int ossim_uint32
bool setDegrees(const std::string &value)
setDegrees(char*).
Definition: ossimDms.cpp:79
double toDouble() const
char theLrfcLoc[LRFC_LOC_SIZE+1]
FIELD: LRFC_LOC.
double getDegrees() const
Definition: ossimDms.h:71
ossimString getLrlcLoc() const
void setLLines(ossim_uint32 lines)
static ossimString convertToUIntString(ossim_uint32 aValue, ossim_uint32 size)
This method takes a value and converts to a string of size with with a &#39;0&#39; fill.
char theBlockInstance[BLOCK_INSTANCE_SIZE+1]
FIELD: BLOCK_INSTANCE.
ossimString getShadowAngle() const
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
void setShadowAngle(ossim_uint32 angle)
double x
Definition: ossimDpt.h:164
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
static ossimString convertToIntString(ossim_int32 aValue, ossim_uint32 size)
Just like convertToUIntString only takes a signed value.
char theField11[FIELD_11_SIZE+1]
FIELD: FIELD_11.
void converLocStringToPt(const ossimString &locationString, ossimDpt &pt) const
Parses location string and initializes pt with result.
virtual void writeStream(ossim::ostream &out)
Write method.
RTTI_DEF1(ossimNitfBlockaTag, "ossimNitfBlockaTag", ossimNitfRegisteredTag)
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23