OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimNitfProjectionParameterTag.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: Garrett Potts
8 // Description: Nitf support class
9 //
10 //********************************************************************
11 // $Id: ossimNitfProjectionParameterTag.cpp 22013 2012-12-19 17:37:20Z dburken $
13 #include <sstream>
14 #include <iomanip>
15 
17  :ossimNitfRegisteredTag(std::string("PRJPSB"), 0 )
18 {
19  clearFields();
20 }
21 
23 {
24 }
25 
27 {
28  clearFields();
29 
30  in.read(theProjectionName, 80);
31  in.read(theProjectionCode, 2);
32  in.read(theNumberOfParameters, 1);
33 
35 
36  for(ossim_uint32 i = 0; i < numberOfParameters; ++i)
37  {
38  char param[15];
39 
40  in.read(param, 15);
41  theProjectionParameters.push_back(ossimString(param,
42  param + 15));
43  }
44  in.read(theFalseXOrigin, 15);
45  in.read(theFalseYOrigin, 15);
46 
47  // Set the base tag length.
49 }
50 
52 {
53  out.write(theProjectionName, 80);
54  out.write(theProjectionCode, 2);
55 
56  {
57  std::ostringstream tempOut;
58 
59  tempOut << std::setw(1)
60  << theProjectionParameters.size();
61  theNumberOfParameters[0] = *(tempOut.str().c_str());
62  }
63  out.write(theNumberOfParameters, 1);
65 
66  for(ossim_uint32 i = 0; i < numberOfParameters; ++i)
67  {
68  out.write(theProjectionParameters[i].c_str(), 15);
69  }
70  out.write(theFalseXOrigin, 15);
71  out.write(theFalseYOrigin, 15);
72 }
73 
75 {
76  return (113 + (ossim_uint32)theProjectionParameters.size()*15);
77 }
78 
80  std::ostream& out, const std::string& prefix) const
81 {
82  std::string pfx = prefix;
83  pfx += getRegisterTagName();
84  pfx += ".";
85 
86  out << setiosflags(std::ios::left)
87  << pfx << std::setw(24) << "CETAG:" << getRegisterTagName() << "\n"
88  << pfx << std::setw(24) << "CEL:" << getTagLength() << "\n"
89  << pfx << std::setw(24) << "PRN:" << theProjectionName << "\n"
90  << pfx << std::setw(24) << "PCO:" << theProjectionCode << "\n"
91  << pfx << std::setw(24) << "NUM_PRJ:" << theNumberOfParameters << "\n";
92 
93  for (ossim_uint32 i = 0; i < theProjectionParameters.size(); ++i)
94  {
95  ossimString s = "PRJ";
96  s += ossimString::toString(i);
97  s += ":";
98  out << pfx << std::setw(24) << s
99  << theProjectionParameters[i] << "\n";
100  }
101 
102  out << pfx << std::setw(24) << "XOR:" <<theFalseXOrigin << "\n"
103  << pfx << std::setw(24) << "YOR:" <<theFalseYOrigin << std::endl;
104 
105  return out;
106 }
107 
109 {
110  theProjectionParameters.clear();
111 
112  memset(theProjectionName, ' ', 80);
113  memset(theProjectionCode, ' ', 2);
114  memset(theNumberOfParameters, '0', 1);
115  memset(theFalseXOrigin, '0', 15);
116  memset(theFalseYOrigin, '0', 15);
117 
118  theProjectionName[80] = '\0';
119  theProjectionCode[2] = '\0';
120  theNumberOfParameters[1] = '\0';
121  theFalseXOrigin[15] = '\0';
122  theFalseYOrigin[15] = '\0';
123 
124  // Set the base tag length.
125  setTagLength( 0 );
126 }
127 
129 {
130  theProjectionParameters.clear();
131  theNumberOfParameters[0] = '0';
132 }
133 
135 {
136  std::ostringstream out;
137 
138  out << std::setw(15)
139  << std::setfill('0')
140  << param.c_str();
141 
142  theProjectionParameters.push_back(out.str());
143 }
144 
146 {
148 }
149 
151 {
152  std::ostringstream out;
153 
154  out << std::setw(80)
155  << std::setfill(' ')
156  << name.c_str();
157 
158  memcpy(theProjectionName, out.str().c_str(), 80);
159 }
160 
162 {
163  std::ostringstream out;
164 
165  out << std::setw(2)
166  << std::setfill(' ')
167  << code.c_str();
168 
169  memcpy(theProjectionCode, out.str().c_str(), 2);
170 }
171 
173 {
175 }
176 
178 {
180 }
181 
183 {
184  std::ostringstream out;
185  out << std::setw(15)
186  << std::setprecision(15)
187  << std::setfill('0')
188  << falseX;
189 
190  memcpy(theFalseXOrigin, out.str().c_str(), 15);
191 }
192 
194 {
195  std::ostringstream out;
196  out << std::setw(15)
197  << std::setprecision(15)
198  << std::setfill('0')
199  << falseY;
200 
201  memcpy(theFalseYOrigin, out.str().c_str(), 15);
202 }
203 
205 {
207 }
208 
210 {
212 }
std::basic_ostringstream< char > ostringstream
Class for char output memory streams.
Definition: ossimIosFwd.h:35
virtual std::string getRegisterTagName() const
This will return the name of the registered tag for this user defined header.
std::vector< ossimString > theProjectionParameters
FIELD(S): PRJn.
static ossimString toString(bool aValue)
Numeric to string methods.
ossim_uint32 toUInt32() const
virtual void setTagLength(ossim_uint32 length)
Set the tag length.
double ossim_float64
virtual ossim_uint32 getTagLength() const
Returns the length in bytes of the tag from the CEL or REL field.
unsigned int ossim_uint32
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
double toDouble() const
virtual void writeStream(std::ostream &out)
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
virtual std::ostream & print(std::ostream &out, const std::string &prefix=std::string()) const
Print method that outputs a key/value type format adding prefix to keys.
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
virtual void addParameter(const ossimString &param)
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
virtual ossim_uint32 getSizeInBytes() const
Returns the length in bytes of the tag from the CEL or REL field.