OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimNitfGeolobTag.cpp
Go to the documentation of this file.
1 //---
2 //
3 // License: MIT
4 //
5 // Author: David Burken
6 //
7 // Description: GEOLOB tag class definition.
8 //
9 // References:
10 //
11 // 1) DIGEST 2.1 Part 2 - Annex D
12 // Appendix 1 - NSIF Standard Geospatial Support Data Extension
13 //
14 // 2) STDI-0006
15 //
16 //---
17 // $Id: ossimNitfBlockaTag.cpp 23245 2015-04-08 20:53:04Z rashadkm $
18 
19 #include <cstring> /* for memcpy */
20 #include <sstream>
21 #include <iomanip>
22 
26 #include <ossim/base/ossimTrace.h>
27 #include <ossim/base/ossimDms.h>
28 #include <ossim/base/ossimDpt.h>
29 
30 static const ossimTrace traceDebug(ossimString("ossimNitfBlockaTag:debug"));
31 
33 
35  : ossimNitfRegisteredTag(std::string("GEOLOB"), ossimNitfGeolobTag::TAG_SIZE),
36  m_tagData(ossimNitfGeolobTag::TAG_SIZE, '0')
37 {
38 }
39 
41 {
42  in.read((char*)m_tagData.data(), ossimNitfGeolobTag::TAG_SIZE);
43 }
44 
46 {
47  out.write(m_tagData.data(), ossimNitfGeolobTag::TAG_SIZE);
48 }
49 
51  const std::string& prefix) const
52 {
53  std::string pfx = prefix;
54  pfx += getTagName();
55  pfx += ".";
56 
57  out << setiosflags(ios::left)
58  << pfx << std::setw(24) << "CETAG:" << getTagName() << "\n"
59  << pfx << std::setw(24) << "CEL:" << getTagLength() << "\n"
60  << pfx << std::setw(24) << "ARV:" << getArvString() << "\n"
61  << pfx << std::setw(24) << "BRV:" << getBrvString() << "\n"
62  << pfx << std::setw(24) << "LSO:" << getLsoString() << "\n"
63  << pfx << std::setw(24) << "PSO:" << getPsoString() << "\n";
64 
65  return out;
66 }
67 
68 // Longitude density:
70 {
71  return m_tagData.substr(0, ossimNitfGeolobTag::ARV_SIZE);
72 }
73 
75 {
76  ossim_uint32 result = 0;
77  std::string s = getArvString();
78  if ( s.size() )
79  {
80  result = ossimString(s).toUInt32();
81  }
82  return result;
83 }
84 
86 {
87  ossim_float64 result = 0.0;
88  ossim_uint32 arv = getArv();
89  if ( arv > 0 )
90  {
91  result = 360.0 / arv;
92  }
93  return result;
94 }
95 
97 {
98  if ( (arv >= 2) && (arv <= 999999999) )
99  {
101  s.fill('0');
102  s << std::setw(ossimNitfGeolobTag::ARV_SIZE) << arv;
103  m_tagData.replace( 0, ossimNitfGeolobTag::ARV_SIZE, s.str() );
104  }
105 }
106 
108 {
109  if ( deltaLon > 0.0 )
110  {
111  ossim_uint32 pixels = (ossim_uint32)((1.0/deltaLon)*360.0 + .5);
112  setArv(pixels);
113  }
114 }
115 
116 // Latitude density:
118 {
119  return m_tagData.substr(9, ossimNitfGeolobTag::BRV_SIZE);
120 }
121 
123 {
124  ossim_float64 result = 0.0;
125  ossim_uint32 brv = getBrv();
126  if ( brv > 0 )
127  {
128  result = 360.0 / brv;
129  }
130  return result;
131 }
132 
134 {
135  ossim_uint32 result = 0;
136  std::string s = getBrvString();
137  if ( s.size() )
138  {
139  result = ossimString(s).toUInt32();
140  }
141  return result;
142 }
143 
145 {
146  if ( (brv >= 2) && (brv <= 999999999) )
147  {
149  s.fill('0');
150  s << std::setw(ossimNitfGeolobTag::BRV_SIZE) << brv;
151 
152  m_tagData.replace( 9, ossimNitfGeolobTag::BRV_SIZE, s.str() );
153  }
154 }
155 
157 {
158  if ( deltaLat > 0.0 )
159  {
160  ossim_uint32 pixels = (ossim_uint32)((1.0/deltaLat)*360.0 + .5);
161  setBrv(pixels);
162  }
163 }
164 
165 // Longitude of Reference Origin:
167 {
168  return m_tagData.substr(18, ossimNitfGeolobTag::LSO_SIZE);
169 }
170 
172 {
173  ossim_float64 result = 0;
174  std::string s = getLsoString();
175  if ( s.size() )
176  {
177  result = ossimString(s).toFloat64();
178  }
179  return result;
180 }
181 
183 {
184  if ( (lso >= -180.0) && (lso <= 180.0) )
185  {
187  s.precision(10);
188  s.fill('0');
189  s << std::left << std::showpos << std::fixed
190  << std::setw(ossimNitfGeolobTag::LSO_SIZE) << lso;
191 
192  m_tagData.replace( 18, ossimNitfGeolobTag::LSO_SIZE, s.str() );
193  }
194 }
195 
196 // Latitude of Reference Origin:
198 {
199  return m_tagData.substr(33, ossimNitfGeolobTag::PSO_SIZE);
200 }
201 
203 {
204  ossim_float64 result = 0;
205  std::string s = getPsoString();
206  if ( s.size() )
207  {
208  result = ossimString(s).toFloat64();
209  }
210  return result;
211 }
212 
214 {
215  if ( (pso >= -180.0) && (pso <= 180.0) )
216  {
218  s.precision(10);
219  s.fill('0');
220  s << std::left << std::showpos << std::fixed
221  << std::setw(ossimNitfGeolobTag::PSO_SIZE) << pso;
222 
223  m_tagData.replace( 33, ossimNitfGeolobTag::PSO_SIZE, s.str() );
224  }
225 }
226 
227 
228 
229 
virtual void writeStream(ossim::ostream &out)
Write method.
virtual const std::string & getTagName() const
This will return the name of the registered tag for this user defined header.
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
std::string getLsoString() const
Gets the LSO field.
ossim_float64 getDegreesPerPixelLon() const
Gets degrees per pixel in lonitude direction from BRV field.
RTTI_DEF1(ossimNitfGeolobTag, "ossimNitfGeolobTag", ossimNitfRegisteredTag)
std::string getBrvString() const
Gets the BRV field.
std::string getArvString() const
Gets the ARV field.
ossim_uint32 getBrv() const
Gets the BRV field.
ossim_uint32 toUInt32() const
ossim_float64 getPso() const
Gets the PSO field(Latitude Origin).
std::string getPsoString() const
Gets the PSO field.
double ossim_float64
virtual ossim_uint32 getTagLength() const
Returns the length in bytes of the tag from the CEL or REL field.
virtual void parseStream(ossim::istream &in)
Parse method.
void setDegreesPerPixelLon(const ossim_float64 &deltaLon)
Sets the ARV field from decimal degrees per pixel longitude.
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.
ossimNitfGeolobTag()
default constructor
unsigned int ossim_uint32
ossim_float64 toFloat64() const
void setLso(const ossim_float64 &lso)
Sets the LSO field(Longitude Origin).
ossim_float64 getLso() const
Gets the LSO field(Longitude Origin).
void setBrv(ossim_uint32 brv)
Sets the BRV field.
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
void setPso(const ossim_float64 &pso)
Sets the PSO field(Latitude Origin).
void setDegreesPerPixelLat(const ossim_float64 &deltaLat)
Sets the BRV field from decimal degrees per pixel latitude.
ossim_float64 getDegreesPerPixelLat() const
Gets degrees per pixel in latitude direction from BRV field.
void setArv(ossim_uint32 arv)
Sets the ARV field.
ossim_uint32 getArv() const
Gets the ARV field.
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23