1 //*******************************************************************
2
3 // LICENSE: LGPL
4 //
5 // see top level LICENSE.txt
6 //
7 // Author: Walt Bunch
8 //
9 // Description: Nitf support class for SENSRA - Sensor parameters extension.
10 //
11 //********************************************************************
12 // $Id: ossimNitfSensraTag.cpp 22013 2012-12-19 17:37:20Z dburken $
13
14 #include <istream>
15 #include <iomanip>
16 #include <ossim/support_data/ossimNitfSensraTag.h>
17
18 RTTI_DEF1(ossimNitfSensraTag, "ossimNitfSensraTag", ossimNitfRegisteredTag);
19
20
ossimNitfSensraTag()21 ossimNitfSensraTag::ossimNitfSensraTag()
22 : ossimNitfRegisteredTag(std::string("SENSRA"), 132)
23 {
24 clearFields();
25 }
26
~ossimNitfSensraTag()27 ossimNitfSensraTag::~ossimNitfSensraTag()
28 {
29 }
30
parseStream(std::istream & in)31 void ossimNitfSensraTag::parseStream(std::istream& in)
32 {
33 clearFields();
34
35 in.read(theRefRow, REF_ROW_SIZE);
36 in.read(theRefCol, REF_COL_SIZE);
37 in.read(theSensorModel, SENSOR_MODEL_SIZE);
38 in.read(theSensorMount, SENSOR_MOUNT_SIZE);
39 in.read(theSensorLoc, SENSOR_LOC_SIZE);
40 in.read(theSensorAltSrc, SENSOR_ALT_SRC_SIZE);
41 in.read(theSensorAlt, SENSOR_ALT_SIZE);
42 in.read(theSensorAltUnit, SENSOR_ALT_UNIT_SIZE);
43 in.read(theSensorAgl, SENSOR_AGL_SIZE);
44 in.read(theSensorPitch, SENSOR_PITCH_SIZE);
45 in.read(theSensorRoll, SENSOR_ROLL_SIZE);
46 in.read(theSensorYaw, SENSOR_YAW_SIZE);
47 in.read(thePlatformPitch, PLATFORM_PITCH_SIZE);
48 in.read(thePlatformRoll, PLATFORM_ROLL_SIZE);
49 in.read(thePlatformHdg, PLATFORM_HDG_SIZE);
50 in.read(theGroundSpdSrc, GROUND_SPD_SRC_SIZE);
51 in.read(theGroundSpeed, GROUND_SPEED_SIZE);
52 in.read(theGroundSpdUnit, GROUND_SPD_UNIT_SIZE);
53 in.read(theGroundTrack, GROUND_TRACK_SIZE);
54 in.read(theVerticalVel, VERTICAL_VEL_SIZE);
55 in.read(theVertVelUnit, VERT_VEL_UNIT_SIZE);
56 in.read(theSwathFrames, SWATH_FRAMES_SIZE);
57 in.read(theNSwaths, N_SWATHS_SIZE);
58 in.read(theSpotNum, SPOT_NUM_SIZE);
59 }
60
writeStream(std::ostream & out)61 void ossimNitfSensraTag::writeStream(std::ostream& out)
62 {
63 out.write(theRefRow, REF_ROW_SIZE);
64 out.write(theRefCol, REF_COL_SIZE);
65 out.write(theSensorModel, SENSOR_MODEL_SIZE);
66 out.write(theSensorMount, SENSOR_MOUNT_SIZE);
67 out.write(theSensorLoc, SENSOR_LOC_SIZE);
68 out.write(theSensorAltSrc, SENSOR_ALT_SRC_SIZE);
69 out.write(theSensorAlt, SENSOR_ALT_SIZE);
70 out.write(theSensorAltUnit, SENSOR_ALT_UNIT_SIZE);
71 out.write(theSensorAgl, SENSOR_AGL_SIZE);
72 out.write(theSensorPitch, SENSOR_PITCH_SIZE);
73 out.write(theSensorRoll, SENSOR_ROLL_SIZE);
74 out.write(theSensorYaw, SENSOR_YAW_SIZE);
75 out.write(thePlatformPitch, PLATFORM_PITCH_SIZE);
76 out.write(thePlatformRoll, PLATFORM_ROLL_SIZE);
77 out.write(thePlatformHdg, PLATFORM_HDG_SIZE);
78 out.write(theGroundSpdSrc, GROUND_SPD_SRC_SIZE);
79 out.write(theGroundSpeed, GROUND_SPEED_SIZE);
80 out.write(theGroundSpdUnit, GROUND_SPD_UNIT_SIZE);
81 out.write(theGroundTrack, GROUND_TRACK_SIZE);
82 out.write(theVerticalVel, VERTICAL_VEL_SIZE);
83 out.write(theVertVelUnit, VERT_VEL_UNIT_SIZE);
84 out.write(theSwathFrames, SWATH_FRAMES_SIZE);
85 out.write(theNSwaths, N_SWATHS_SIZE);
86 out.write(theSpotNum, SPOT_NUM_SIZE);
87 }
88
clearFields()89 void ossimNitfSensraTag::clearFields()
90 {
91 memset(theRefRow, ' ', REF_ROW_SIZE);
92 memset(theRefCol, ' ', REF_COL_SIZE);
93 memset(theSensorModel, ' ', SENSOR_MODEL_SIZE);
94 memset(theSensorMount, ' ', SENSOR_MOUNT_SIZE);
95 memset(theSensorLoc, ' ', SENSOR_LOC_SIZE);
96 memset(theSensorAltSrc, ' ', SENSOR_ALT_SRC_SIZE);
97 memset(theSensorAlt, ' ', SENSOR_ALT_SIZE);
98 memset(theSensorAltUnit, ' ', SENSOR_ALT_UNIT_SIZE);
99 memset(theSensorAgl, ' ', SENSOR_AGL_SIZE);
100 memset(theSensorPitch, ' ', SENSOR_PITCH_SIZE);
101 memset(theSensorRoll, ' ', SENSOR_ROLL_SIZE);
102 memset(theSensorYaw, ' ', SENSOR_YAW_SIZE);
103 memset(thePlatformPitch, ' ', PLATFORM_PITCH_SIZE);
104 memset(thePlatformRoll, ' ', PLATFORM_ROLL_SIZE);
105 memset(thePlatformHdg, ' ', PLATFORM_HDG_SIZE);
106 memset(theGroundSpdSrc, ' ', GROUND_SPD_SRC_SIZE);
107 memset(theGroundSpeed, ' ', GROUND_SPEED_SIZE);
108 memset(theGroundSpdUnit, ' ', GROUND_SPD_UNIT_SIZE);
109 memset(theGroundTrack, ' ', GROUND_TRACK_SIZE);
110 memset(theVerticalVel, ' ', VERTICAL_VEL_SIZE);
111 memset(theVertVelUnit, ' ', VERT_VEL_UNIT_SIZE);
112 memset(theSwathFrames, ' ', SWATH_FRAMES_SIZE);
113 memset(theNSwaths, ' ', N_SWATHS_SIZE);
114 memset(theSpotNum, ' ', SPOT_NUM_SIZE);
115
116 theRefRow[REF_ROW_SIZE] = '\0';
117 theRefCol[REF_COL_SIZE] = '\0';
118 theSensorModel[SENSOR_MODEL_SIZE] = '\0';
119 theSensorMount[SENSOR_MOUNT_SIZE] = '\0';
120 theSensorLoc[SENSOR_LOC_SIZE] = '\0';
121 theSensorAltSrc[SENSOR_ALT_SRC_SIZE] = '\0';
122 theSensorAlt[SENSOR_ALT_SIZE] = '\0';
123 theSensorAltUnit[SENSOR_ALT_UNIT_SIZE] = '\0';
124 theSensorAgl[SENSOR_AGL_SIZE] = '\0';
125 theSensorPitch[SENSOR_PITCH_SIZE] = '\0';
126 theSensorRoll[SENSOR_ROLL_SIZE] = '\0';
127 theSensorYaw[SENSOR_YAW_SIZE] = '\0';
128 thePlatformPitch[PLATFORM_PITCH_SIZE] = '\0';
129 thePlatformRoll[PLATFORM_ROLL_SIZE] = '\0';
130 thePlatformHdg[PLATFORM_HDG_SIZE] = '\0';
131 theGroundSpdSrc[GROUND_SPD_SRC_SIZE] = '\0';
132 theGroundSpeed[GROUND_SPEED_SIZE] = '\0';
133 theGroundSpdUnit[GROUND_SPD_UNIT_SIZE] = '\0';
134 theGroundTrack[GROUND_TRACK_SIZE] = '\0';
135 theVerticalVel[VERTICAL_VEL_SIZE] = '\0';
136 theVertVelUnit[VERT_VEL_UNIT_SIZE] = '\0';
137 theSwathFrames[SWATH_FRAMES_SIZE] = '\0';
138 theNSwaths[N_SWATHS_SIZE] = '\0';
139 theSpotNum[SPOT_NUM_SIZE] = '\0';
140 }
141
print(std::ostream & out,const std::string & prefix) const142 std::ostream& ossimNitfSensraTag::print(
143 std::ostream& out, const std::string& prefix) const
144 {
145 std::string pfx = prefix;
146 pfx += getTagName();
147 pfx += ".";
148
149 out << std::setiosflags(std::ios::left)
150 << pfx << std::setw(24) << "CETAG:"
151 << getTagName() << "\n"
152 << pfx << std::setw(24) << "CEL:" << getTagLength() << "\n"
153 << pfx << std::setw(24) << "REFROW:" << theRefRow << "\n"
154 << pfx << std::setw(24) << "REFCOL:" << theRefCol << "\n"
155 << pfx << std::setw(24) << "SENSORMODEL:" << theSensorModel<< "\n"
156 << pfx << std::setw(24) << "SENSORMOUNT:" << theSensorMount << "\n"
157 << pfx << std::setw(24) << "SENSORLOC:" << theSensorLoc << "\n"
158 << pfx << std::setw(24) << "SENSORALTSRC:" << theSensorAltSrc<< "\n"
159 << pfx << std::setw(24) << "SENSORALT:" << theSensorAlt << "\n"
160 << pfx << std::setw(24) << "SENSORALTUNIT:" << theSensorAltUnit << "\n"
161 << pfx << std::setw(24) << "SENSORAGL:" << theSensorAgl << "\n"
162 << pfx << std::setw(24) << "SENSORPITCH:" << theSensorPitch << "\n"
163 << pfx << std::setw(24) << "SENSORROLL:" << theSensorRoll<< "\n"
164 << pfx << std::setw(24) << "SENSORYAW:" << theSensorYaw << "\n"
165 << pfx << std::setw(24) << "PLATFORMPITCH:" << thePlatformPitch << "\n"
166 << pfx << std::setw(24) << "PLATFORMROLL:" << thePlatformRoll << "\n"
167 << pfx << std::setw(24) << "PLATFORMHDG:" << thePlatformHdg << "\n"
168 << pfx << std::setw(24) << "GROUNDSPDSRC:" << theGroundSpdSrc << "\n"
169 << pfx << std::setw(24) << "GROUNDSPEED:" << theGroundSpeed << "\n"
170 << pfx << std::setw(24) << "GROUNDSPDUNIT:" << theGroundSpdUnit << "\n"
171 << pfx << std::setw(24) << "GROUNDTRACK:" << theGroundTrack << "\n"
172 << pfx << std::setw(24) << "VERTICALVEL:" << theVerticalVel<< "\n"
173 << pfx << std::setw(24) << "VERTVELUNIT:" << theVertVelUnit << "\n"
174 << pfx << std::setw(24) << "SWATHFRAMES:" << theSwathFrames<< "\n"
175 << pfx << std::setw(24) << "NSWATHS:" << theNSwaths << "\n"
176 << pfx << std::setw(24) << "SPOTNUM:" << theSpotNum << "\n";
177
178 return out;
179 }
180
getRefRow() const181 ossimString ossimNitfSensraTag::getRefRow()const
182 {
183 return theRefRow;
184 }
185
setRefRow(ossimString refRow)186 void ossimNitfSensraTag::setRefRow(ossimString refRow)
187 {
188 memset(theRefRow, ' ', REF_ROW_SIZE);
189 memcpy(theRefRow, refRow.c_str(), std::min((size_t)REF_ROW_SIZE, refRow.length()));
190 }
191
getRefCol() const192 ossimString ossimNitfSensraTag::getRefCol()const
193 {
194 return theRefCol;
195 }
196
setRefCol(ossimString refCol)197 void ossimNitfSensraTag::setRefCol(ossimString refCol)
198 {
199 memset(theRefCol, ' ', REF_COL_SIZE);
200 memcpy(theRefCol, refCol.c_str(), std::min((size_t)REF_COL_SIZE, refCol.length()));
201 }
202
getSensorModel() const203 ossimString ossimNitfSensraTag::getSensorModel()const
204 {
205 return theSensorModel;
206 }
207
setSensorModel(ossimString sensorModel)208 void ossimNitfSensraTag::setSensorModel(ossimString sensorModel)
209 {
210 memset(theSensorModel, ' ', SENSOR_MODEL_SIZE);
211 memcpy(theSensorModel, sensorModel.c_str(), std::min((size_t)SENSOR_MODEL_SIZE, sensorModel.length()));
212 }
213
getSensorMount() const214 ossimString ossimNitfSensraTag::getSensorMount()const
215 {
216 return theSensorMount;
217 }
218
setSensorMount(ossimString sensorMount)219 void ossimNitfSensraTag::setSensorMount(ossimString sensorMount)
220 {
221 memset(theSensorMount, ' ', SENSOR_MOUNT_SIZE);
222 memcpy(theSensorMount, sensorMount.c_str(), std::min((size_t)SENSOR_MOUNT_SIZE, sensorMount.length()));
223 }
224
getSensorLoc() const225 ossimString ossimNitfSensraTag::getSensorLoc()const
226 {
227 return theSensorLoc;
228 }
229
setSensorLoc(ossimString sensorLoc)230 void ossimNitfSensraTag::setSensorLoc(ossimString sensorLoc)
231 {
232 memset(theSensorLoc, ' ', SENSOR_LOC_SIZE);
233 memcpy(theSensorLoc, sensorLoc.c_str(), std::min((size_t)SENSOR_LOC_SIZE, sensorLoc.length()));
234 }
235
getSensorAltSrc() const236 ossimString ossimNitfSensraTag::getSensorAltSrc()const
237 {
238 return theSensorAltSrc;
239 }
240
setSensorAltSrc(ossimString sensorAltSrc)241 void ossimNitfSensraTag::setSensorAltSrc(ossimString sensorAltSrc)
242 {
243 memset(theSensorAltSrc, ' ', SENSOR_ALT_SRC_SIZE);
244 memcpy(theSensorAltSrc, sensorAltSrc.c_str(), std::min((size_t)SENSOR_ALT_SRC_SIZE, sensorAltSrc.length()));
245 }
246
getSensorAlt() const247 ossimString ossimNitfSensraTag::getSensorAlt()const
248 {
249 return theSensorAlt;
250 }
251
setSensorAlt(ossimString sensorAlt)252 void ossimNitfSensraTag::setSensorAlt(ossimString sensorAlt)
253 {
254 memset(theSensorAlt, ' ', SENSOR_ALT_SIZE);
255 memcpy(theSensorAlt, sensorAlt.c_str(), std::min((size_t)SENSOR_ALT_SIZE, sensorAlt.length()));
256 }
257
getSensorAltUnit() const258 ossimString ossimNitfSensraTag::getSensorAltUnit()const
259 {
260 return theSensorAltUnit;
261 }
262
setSensorAltUnit(ossimString sensorAltUnit)263 void ossimNitfSensraTag::setSensorAltUnit(ossimString sensorAltUnit)
264 {
265 memset(theSensorAltUnit, ' ', SENSOR_ALT_UNIT_SIZE);
266 memcpy(theSensorAltUnit, sensorAltUnit.c_str(), std::min((size_t)SENSOR_ALT_UNIT_SIZE, sensorAltUnit.length()));
267 }
268
getSensorAgl() const269 ossimString ossimNitfSensraTag::getSensorAgl()const
270 {
271 return theSensorAgl;
272 }
273
setSensorAgl(ossimString sensorAgl)274 void ossimNitfSensraTag::setSensorAgl(ossimString sensorAgl)
275 {
276 memset(theSensorAgl, ' ', SENSOR_AGL_SIZE);
277 memcpy(theSensorAgl, sensorAgl.c_str(), std::min((size_t)SENSOR_AGL_SIZE, sensorAgl.length()));
278 }
279
getSensorPitch() const280 ossimString ossimNitfSensraTag::getSensorPitch()const
281 {
282 return theSensorPitch;
283 }
284
setSensorPitch(ossimString sensorPitch)285 void ossimNitfSensraTag::setSensorPitch(ossimString sensorPitch)
286 {
287 memset(theSensorPitch, ' ', SENSOR_PITCH_SIZE);
288 memcpy(theSensorPitch, sensorPitch.c_str(), std::min((size_t)SENSOR_PITCH_SIZE, sensorPitch.length()));
289 }
290
getSensorRoll() const291 ossimString ossimNitfSensraTag::getSensorRoll()const
292 {
293 return theSensorRoll;
294 }
295
setSensorRoll(ossimString sensorRoll)296 void ossimNitfSensraTag::setSensorRoll(ossimString sensorRoll)
297 {
298 memset(theSensorRoll, ' ', SENSOR_ROLL_SIZE);
299 memcpy(theSensorRoll, sensorRoll.c_str(), std::min((size_t)SENSOR_ROLL_SIZE, sensorRoll.length()));
300 }
301
getSensorYaw() const302 ossimString ossimNitfSensraTag::getSensorYaw()const
303 {
304 return theSensorYaw;
305 }
306
setSensorYaw(ossimString sensorYaw)307 void ossimNitfSensraTag::setSensorYaw(ossimString sensorYaw)
308 {
309 memset(theSensorYaw, ' ', SENSOR_YAW_SIZE);
310 memcpy(theSensorYaw, sensorYaw.c_str(), std::min((size_t)SENSOR_YAW_SIZE, sensorYaw.length()));
311 }
312
getPlatformPitch() const313 ossimString ossimNitfSensraTag::getPlatformPitch()const
314 {
315 return thePlatformPitch;
316 }
317
setPlatformPitch(ossimString platformPitch)318 void ossimNitfSensraTag::setPlatformPitch(ossimString platformPitch)
319 {
320 memset(thePlatformPitch, ' ', PLATFORM_PITCH_SIZE);
321 memcpy(thePlatformPitch, platformPitch.c_str(), std::min((size_t)PLATFORM_PITCH_SIZE, platformPitch.length()));
322 }
323
getPlatformRoll() const324 ossimString ossimNitfSensraTag::getPlatformRoll()const
325 {
326 return thePlatformRoll;
327 }
328
setPlatformRoll(ossimString platformRoll)329 void ossimNitfSensraTag::setPlatformRoll(ossimString platformRoll)
330 {
331 memset(thePlatformRoll, ' ', PLATFORM_ROLL_SIZE);
332 memcpy(thePlatformRoll, platformRoll.c_str(), std::min((size_t)PLATFORM_ROLL_SIZE, platformRoll.length()));
333 }
334
getPlatformHdg() const335 ossimString ossimNitfSensraTag::getPlatformHdg()const
336 {
337 return thePlatformHdg;
338 }
339
setPlatformHdg(ossimString platformHdg)340 void ossimNitfSensraTag::setPlatformHdg(ossimString platformHdg)
341 {
342 memset(thePlatformHdg, ' ', PLATFORM_HDG_SIZE);
343 memcpy(thePlatformHdg, platformHdg.c_str(), std::min((size_t)PLATFORM_HDG_SIZE, platformHdg.length()));
344 }
345
getGroundSpdSrc() const346 ossimString ossimNitfSensraTag::getGroundSpdSrc()const
347 {
348 return theGroundSpdSrc;
349 }
350
setGroundSpdSrc(ossimString groundSpdSrc)351 void ossimNitfSensraTag::setGroundSpdSrc(ossimString groundSpdSrc)
352 {
353 memset(theGroundSpdSrc, ' ', GROUND_SPD_SRC_SIZE);
354 memcpy(theGroundSpdSrc, groundSpdSrc.c_str(), std::min((size_t)GROUND_SPD_SRC_SIZE, groundSpdSrc.length()));
355 }
356
getGroundSpeed() const357 ossimString ossimNitfSensraTag::getGroundSpeed()const
358 {
359 return theGroundSpeed;
360 }
361
setGroundSpeed(ossimString groundSpeed)362 void ossimNitfSensraTag::setGroundSpeed(ossimString groundSpeed)
363 {
364 memset(theGroundSpeed, ' ', GROUND_SPEED_SIZE);
365 memcpy(theGroundSpeed, groundSpeed.c_str(), std::min((size_t)GROUND_SPEED_SIZE, groundSpeed.length()));
366 }
367
getGroundSpdUnit() const368 ossimString ossimNitfSensraTag::getGroundSpdUnit()const
369 {
370 return theGroundSpdUnit;
371 }
372
setGroundSpdUnit(ossimString groundSpdUnit)373 void ossimNitfSensraTag::setGroundSpdUnit(ossimString groundSpdUnit)
374 {
375 memset(theGroundSpdUnit, ' ', GROUND_SPD_UNIT_SIZE);
376 memcpy(theGroundSpdUnit, groundSpdUnit.c_str(), std::min((size_t)GROUND_SPD_UNIT_SIZE, groundSpdUnit.length()));
377 }
378
getGroundTrack() const379 ossimString ossimNitfSensraTag::getGroundTrack()const
380 {
381 return theGroundTrack;
382 }
383
setGroundTrack(ossimString groundTrack)384 void ossimNitfSensraTag::setGroundTrack(ossimString groundTrack)
385 {
386 memset(theGroundTrack, ' ', GROUND_TRACK_SIZE);
387 memcpy(theGroundTrack, groundTrack.c_str(), std::min((size_t)GROUND_TRACK_SIZE, groundTrack.length()));
388 }
389
getVerticalVel() const390 ossimString ossimNitfSensraTag::getVerticalVel()const
391 {
392 return theVerticalVel;
393 }
394
setVerticalVel(ossimString verticalVel)395 void ossimNitfSensraTag::setVerticalVel(ossimString verticalVel)
396 {
397 memset(theVerticalVel, ' ', VERTICAL_VEL_SIZE);
398 memcpy(theVerticalVel, verticalVel.c_str(), std::min((size_t)VERTICAL_VEL_SIZE, verticalVel.length()));
399 }
400
getVertVelUnit() const401 ossimString ossimNitfSensraTag::getVertVelUnit()const
402 {
403 return theVertVelUnit;
404 }
405
setVertVelUnit(ossimString vertVelUnit)406 void ossimNitfSensraTag::setVertVelUnit(ossimString vertVelUnit)
407 {
408 memset(theVertVelUnit, ' ', VERT_VEL_UNIT_SIZE);
409 memcpy(theVertVelUnit, vertVelUnit.c_str(), std::min((size_t)VERT_VEL_UNIT_SIZE, vertVelUnit.length()));
410 }
411
getSwathFrames() const412 ossimString ossimNitfSensraTag::getSwathFrames()const
413 {
414 return theSwathFrames;
415 }
416
setSwathFrames(ossimString swathFrames)417 void ossimNitfSensraTag::setSwathFrames(ossimString swathFrames)
418 {
419 memset(theSwathFrames, ' ', SWATH_FRAMES_SIZE);
420 memcpy(theSwathFrames, swathFrames.c_str(), std::min((size_t)SWATH_FRAMES_SIZE, swathFrames.length()));
421 }
422
getNSwaths() const423 ossimString ossimNitfSensraTag::getNSwaths()const
424 {
425 return theNSwaths;
426 }
427
setNSwaths(ossimString nSwaths)428 void ossimNitfSensraTag::setNSwaths(ossimString nSwaths)
429 {
430 memset(theNSwaths, ' ', N_SWATHS_SIZE);
431 memcpy(theNSwaths, nSwaths.c_str(), std::min((size_t)N_SWATHS_SIZE, nSwaths.length()));
432 }
433
getSpotNum() const434 ossimString ossimNitfSensraTag::getSpotNum()const
435 {
436 return theSpotNum;
437 }
438
setSpotNum(ossimString spotNum)439 void ossimNitfSensraTag::setSpotNum(ossimString spotNum)
440 {
441 memset(theSpotNum, ' ', SPOT_NUM_SIZE);
442 memcpy(theSpotNum, spotNum.c_str(), std::min((size_t)SPOT_NUM_SIZE, spotNum.length()));
443 }
444
445