Skip to content

Commit 0ad7a74

Browse files
committed
Adding tag initialization from loadState().
1 parent 0e4cb22 commit 0ad7a74

File tree

5 files changed

+331
-163
lines changed

5 files changed

+331
-163
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
//---
2+
//
3+
// License: MIT
4+
//
5+
// Description: For common nitf field names.
6+
//
7+
//---
8+
// $Id$
9+
10+
#ifndef ossimNitfCommonFieldNames_H
11+
#define ossimNitfCommonFieldNames 1
12+
13+
#include <string>
14+
15+
namespace ossim
16+
{
17+
namespace nitf
18+
{
19+
// Alpabetical please:
20+
inline static const std::string A_S_VERT_GSD_KW = "A_S_VERT_GSD";
21+
inline static const std::string ALONG_SCAN_GSD_KW = "ALONG_SCAN_GSD";
22+
inline static const std::string ANGLE_TO_NORTH_KW = "ANGLE_TO_NORTH";
23+
inline static const std::string ASSOC_DES_UUID_KW = "ASSOC_DES_UUID";
24+
inline static const std::string ATM_REFR_FLAG_KW = "ATM_REFR_FLAG";
25+
inline static const std::string AZ_OF_OBLIQUITY_KW = "AZ_OF_OBLIQUITY";
26+
inline static const std::string C_S_VERT_GSD_KW = "C_S_VERT_GSD";
27+
inline static const std::string CIRCL_ERR_KW = "CIRCL_ERR";
28+
inline static const std::string CLOUD_COVER_KW = "CLOUD_COVER";
29+
inline static const std::string CROSS_SCAN_GSD_KW = "CROSS_SCAN_GSD";
30+
inline static const std::string DAY_FIRST_LINE_IMAGE_KW = "DAY_FIRST_LINE_IMAGE";
31+
inline static const std::string DYNAMIC_RANGE_KW = "DYNAMIC_RANGE";
32+
inline static const std::string GSD_BETA_ANGLE_KW = "GSD_BETA_ANGLE";
33+
inline static const std::string GEO_MEAN_GSD_KW = "GEO_MEAN_GSD";
34+
inline static const std::string GEO_MEAN_VERT_GSD_KW = "GEO_MEAN_VERT_GSD";
35+
inline static const std::string GRD_COVER_KW = "GRD_COVER";
36+
inline static const std::string GROUND_REF_POINT_X_KW = "GROUND_REF_POINT_X";
37+
inline static const std::string GROUND_REF_POINT_Y_KW = "GROUND_REF_POINT_Y";
38+
inline static const std::string GROUND_REF_POINT_Z_KW = "GROUND_REF_POINT_Z";
39+
inline static const std::string IMAGE_UUID_KW = "IMAGE_UUID";
40+
inline static const std::string LINEAR_ERR_KW = "LINEAR_ERR";
41+
inline static const std::string MAX_GSD_KW = "MAX_GSD";
42+
inline static const std::string NUM_ASSOC_DES_KW = "NUM_ASSOC_DES";
43+
inline static const std::string NUM_LINES_KW = "NUM_LINES";
44+
inline static const std::string NUM_SAMPLES_KW = "NUM_SAMPLES";
45+
inline static const std::string OBLIQUITY_ANGLE_KW = "OBLIQUITY_ANGLE";
46+
inline static const std::string PAYLOAD_ID_KW = "PAYLOAD_ID";
47+
inline static const std::string PLATFORM_ID_KW = "PLATFORM_ID";
48+
inline static const std::string PREDICTED_NIIRS_KW = "PREDICTED_NIIRS";
49+
inline static const std::string SENSOR_ID_KW = "SENSOR_ID";
50+
inline static const std::string SENSOR_TYPE_KW = "SENSOR_TYPE";
51+
inline static const std::string SNOW_DEPTH_CATEGORY_KW = "SNOW_DEPTH_CATEGORY";
52+
inline static const std::string SUN_AZIMUTH_KW = "SUN_AZIMUTH";
53+
inline static const std::string SUN_ELEVATION_KW = "SUN_ELEVATION";
54+
inline static const std::string TIME_FIRST_LINE_IMAGE_KW = "TIME_FIRST_LINE_IMAGE";
55+
inline static const std::string TIME_IMAGE_DURATION_KW = "TIME_IMAGE_DURATION";
56+
inline static const std::string VEL_ABER_FLAG_KW = "VEL_ABER_FLAG";
57+
58+
} // End: namespace ossim::nitf
59+
60+
} // End: namespace ossim
61+
62+
#endif /* End of "#ifndef ossimNitfCommonFieldNames_H" */

include/ossim/support_data/ossimNitfCsdidaTag.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//----------------------------------------------------------------------------
1+
//---
22
//
33
// License: MIT
44
//
@@ -12,7 +12,7 @@
1212
//
1313
// See document STDI-0006-NCDRD Table 3.3-14 for more info.
1414
//
15-
//----------------------------------------------------------------------------
15+
//---
1616
// $Id
1717

1818
#ifndef ossimNitfCsdidaTag_HEADER
@@ -34,6 +34,16 @@ class OSSIM_DLL ossimNitfCsdidaTag : public ossimNitfRegisteredTag
3434
/** @brief Method to write data to stream. */
3535
virtual void writeStream(std::ostream& out);
3636

37+
/*!
38+
* @brief Method to the load (recreate) the state of the object from a
39+
* keyword list.
40+
* @param kwl
41+
* @param prefix Typically, somthing like: "nitf.CSDIDA."
42+
* @return true on success, false on error.
43+
*/
44+
virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=0);
45+
46+
3747
/** @brief Method to clear all fields including null terminating. */
3848
virtual void clearFields();
3949

@@ -45,6 +55,8 @@ class OSSIM_DLL ossimNitfCsdidaTag : public ossimNitfRegisteredTag
4555
*/
4656
virtual std::ostream& print(std::ostream& out,
4757
const std::string& prefix) const;
58+
59+
static const std::string CETAG_KW;
4860

4961
protected:
5062

include/ossim/support_data/ossimNitfCsexrbTag.h

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -39,43 +39,6 @@ class OSSIM_DLL ossimNitfCsexrbTag : public ossimNitfGenericTag
3939
virtual bool loadState(const ossimKeywordlist& kwl, const char* prefix=0);
4040

4141
static const std::string CETAG_KW;
42-
static const std::string IMAGE_UUID_KW;
43-
static const std::string NUM_ASSOC_DES_KW;
44-
static const std::string ASSOC_DES_UUID_KW;
45-
static const std::string PLATFORM_ID_KW;
46-
static const std::string PAYLOAD_ID_KW;
47-
static const std::string SENSOR_ID_KW;
48-
static const std::string SENSOR_TYPE_KW;
49-
static const std::string DAY_FIRST_LINE_IMAGE_KW;
50-
static const std::string TIME_FIRST_LINE_IMAGE_KW;
51-
static const std::string TIME_IMAGE_DURATION_KW;
52-
static const std::string GROUND_REF_POINT_X_KW;
53-
static const std::string GROUND_REF_POINT_Y_KW;
54-
static const std::string GROUND_REF_POINT_Z_KW;
55-
static const std::string MAX_GSD_KW;
56-
static const std::string ALONG_SCAN_GSD_KW;
57-
static const std::string CROSS_SCAN_GSD_KW;
58-
static const std::string GEO_MEAN_GSD_KW;
59-
static const std::string A_S_VERT_GSD_KW;
60-
static const std::string C_S_VERT_GSD_KW;
61-
static const std::string GEO_MEAN_VERT_GSD_KW;
62-
static const std::string GSD_BETA_ANGLE_KW;
63-
static const std::string DYNAMIC_RANGE_KW;
64-
static const std::string NUM_LINES_KW;
65-
static const std::string NUM_SAMPLES_KW;
66-
static const std::string ANGLE_TO_NORTH_KW;
67-
static const std::string OBLIQUITY_ANGLE_KW;
68-
static const std::string AZ_OF_OBLIQUITY_KW;
69-
static const std::string ATM_REFR_FLAG_KW;
70-
static const std::string VEL_ABER_FLAG_KW;
71-
static const std::string GRD_COVER_KW;
72-
static const std::string SNOW_DEPTH_CATEGORY_KW;
73-
static const std::string SUN_AZIMUTH_KW;
74-
static const std::string SUN_ELEVATION_KW;
75-
static const std::string PREDICTED_NIIRS_KW;
76-
static const std::string CIRCL_ERR_KW;
77-
static const std::string LINEAR_ERR_KW;
78-
static const std::string CLOUD_COVER_KW;
7942

8043
private:
8144

src/support_data/ossimNitfCsdidaTag.cpp

Lines changed: 176 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
//----------------------------------------------------------------------------
1+
//---
22
//
3-
// License: LGPL
4-
//
5-
// See LICENSE.txt file in the top level directory for more details.
3+
// License: MIT
64
//
75
// Author: David Burken
86
//
@@ -12,7 +10,7 @@
1210
//
1311
// See document STDI-0006-NCDRD Table 3.3-14 for more info.
1412
//
15-
//----------------------------------------------------------------------------
13+
//---
1614
// $Id
1715

1816
#include <cstring>
@@ -21,14 +19,16 @@
2119
#include <iomanip>
2220

2321
#include <ossim/support_data/ossimNitfCsdidaTag.h>
22+
#include <ossim/support_data/ossimNitfCommonFieldNames.h>
2423

25-
using namespace std;
24+
RTTI_DEF1(ossimNitfCsdidaTag, "ossimNitfCsdidaTag", ossimNitfRegisteredTag);
2625

26+
static const int FOREVER = 1;
2727

28-
RTTI_DEF1(ossimNitfCsdidaTag, "ossimNitfCsdidaTag", ossimNitfRegisteredTag);
28+
const std::string ossimNitfCsdidaTag::CETAG_KW = "CSDIDA";
2929

3030
ossimNitfCsdidaTag::ossimNitfCsdidaTag()
31-
: ossimNitfRegisteredTag(std::string("CSDIDA"), 70)
31+
: ossimNitfRegisteredTag(CETAG_KW, 70)
3232
{
3333
clearFields();
3434
}
@@ -122,6 +122,174 @@ void ossimNitfCsdidaTag::clearFields()
122122
theSoftwareVersionNumber[10] = '\0';
123123
}
124124

125+
bool ossimNitfCsdidaTag::loadState(const ossimKeywordlist& kwl, const char* prefix)
126+
{
127+
128+
bool status = true;
129+
#if 0
130+
std::string pfx = prefix?prefix:"";
131+
std::string value;
132+
std::string os;
133+
ossim_uint32 fieldSize = 0;
134+
135+
while(FOREVER) // Break on error or at end.
136+
{
137+
fieldSize = 36;
138+
value = kwl.findKey( pfx, IMAGE_UUID_KW );
139+
// Size must be exact. Currently no format check, only size.
140+
if ( value.size() == fieldSize )
141+
{
142+
m_fields_map.insert_or_assign(ossimString(IMAGE_UUID_KW), ossimString(value));
143+
}
144+
else
145+
{
146+
ossimNotify(ossimNotifyLevel_WARN)
147+
<< MODULE << " WARNING: Incorrect length of " << value.size()
148+
<< " for " << IMAGE_UUID_KW << " field!" << std::endl;
149+
status = false;
150+
break;
151+
}
152+
153+
// NUM_ASSOC_DES
154+
155+
// ASSOC_DES_UUID
156+
157+
// PLATFORM_ID
158+
fieldSize = 6;
159+
value = kwl.findKey( pfx, PLATFORM_ID_KW );
160+
if ( value.size() <= fieldSize )
161+
{
162+
if ( value.size() < fieldSize ) // Currently no format check, only size.
163+
{
164+
os = value;
165+
value.resize(fieldSize);
166+
ossimNitfCommon::setField(value.data(), os, fieldSize, std::ios::left, ' ');
167+
}
168+
m_fields_map.insert_or_assign(ossimString(PLATFORM_ID_KW), ossimString(value));
169+
}
170+
else
171+
{
172+
ossimNotify(ossimNotifyLevel_WARN)
173+
<< MODULE << " WARNING:\n" << PLATFORM_ID_KW
174+
<< " key value has incorrect length of "
175+
<< value.size() << " for field!" << " value: " << value << std::endl;
176+
status = false;
177+
break;
178+
}
179+
180+
// PAYLOAD_ID
181+
value = kwl.findKey( pfx, PAYLOAD_ID_KW );
182+
if ( value.size() <= fieldSize )
183+
{
184+
if ( value.size() < fieldSize ) // Currently no format check, only size.
185+
{
186+
os = value;
187+
value.resize(fieldSize);
188+
ossimNitfCommon::setField(value.data(), os, fieldSize, std::ios::left, ' ');
189+
}
190+
m_fields_map.insert_or_assign(ossimString(PAYLOAD_ID_KW), ossimString(value));
191+
}
192+
else
193+
{
194+
ossimNotify(ossimNotifyLevel_WARN)
195+
<< MODULE << " WARNING:\n" << PAYLOAD_ID_KW
196+
<< " key value has incorrect length of "
197+
<< value.size() << " for field!" << " value: " << value << std::endl;
198+
status = false;
199+
break;
200+
}
201+
202+
// SENSOR_ID
203+
value = kwl.findKey( pfx, SENSOR_ID_KW );
204+
if ( value.size() <= fieldSize )
205+
{
206+
if ( value.size() < fieldSize ) // Currently no format check, only size.
207+
{
208+
os = value;
209+
value.resize(fieldSize);
210+
ossimNitfCommon::setField(value.data(), os, fieldSize, std::ios::left, ' ');
211+
}
212+
m_fields_map.insert_or_assign(ossimString(SENSOR_ID_KW), ossimString(value));
213+
}
214+
else
215+
{
216+
ossimNotify(ossimNotifyLevel_WARN)
217+
<< MODULE << " WARNING:\n" << SENSOR_ID_KW
218+
<< " key value has incorrect length of "
219+
<< value.size() << " for field!" << " value: " << value << std::endl;
220+
status = false;
221+
break;
222+
}
223+
224+
// SENSOR_TYPE
225+
fieldSize = 1;
226+
value = kwl.findKey( pfx, SENSOR_TYPE_KW );
227+
if ( value.size() == fieldSize )
228+
{
229+
m_fields_map.insert_or_assign(ossimString(SENSOR_TYPE_KW), ossimString(value));
230+
231+
if ( value == "S" ) // If scan we need these three fields.
232+
{
233+
// DAY_FIRST_LINE_IMAGE:
234+
fieldSize = 8;
235+
value = kwl.findKey( pfx, DAY_FIRST_LINE_IMAGE_KW );
236+
if ( value.size() < fieldSize ) // Currently no format check, only size.
237+
{
238+
os = value;
239+
value.resize(fieldSize);
240+
ossimNitfCommon::setField(value.data(), os, fieldSize, std::ios::left, ' ');
241+
}
242+
m_fields_map.insert_or_assign(
243+
ossimString(DAY_FIRST_LINE_IMAGE_KW), ossimString(value));
244+
245+
// TIME_FIRST_LINE_IMAGE:
246+
fieldSize = 15;
247+
value = kwl.findKey( pfx, TIME_FIRST_LINE_IMAGE_KW );
248+
if ( value.size() < fieldSize ) // Currently no format check, only size.
249+
{
250+
os = value;
251+
value.resize(fieldSize);
252+
ossimNitfCommon::setField(value.data(), os, fieldSize, std::ios::left, ' ');
253+
}
254+
m_fields_map.insert_or_assign(
255+
ossimString(TIME_FIRST_LINE_IMAGE_KW ), ossimString(value));
256+
257+
// TIME_IMAGE_DURATION:
258+
fieldSize = 16;
259+
value = kwl.findKey( pfx, TIME_IMAGE_DURATION_KW );
260+
if ( value.size() < fieldSize ) // Currently no format check, only size.
261+
{
262+
os = value;
263+
value.resize(fieldSize);
264+
ossimNitfCommon::setField(value.data(), os, fieldSize, std::ios::left, ' ');
265+
}
266+
m_fields_map.insert_or_assign(
267+
ossimString(TIME_IMAGE_DURATION_KW), ossimString(value));
268+
}
269+
}
270+
else
271+
{
272+
ossimNotify(ossimNotifyLevel_WARN)
273+
<< MODULE << " WARNING:\n" << SENSOR_TYPE_KW
274+
<< " key value has incorrect length of "
275+
<< value.size() << " for field!" << " value: " << value << std::endl;
276+
status = false;
277+
break;
278+
}
279+
280+
break; // Trailing break from forever loop.
281+
282+
} // Matches: while(FOREVER)
283+
284+
if (traceDebug())
285+
{
286+
ossimNotify(ossimNotifyLevel_DEBUG)
287+
<< MODULE << " exit status" << (status?"true\n":"false\n");
288+
}
289+
#endif
290+
return status;
291+
}
292+
125293
std::ostream& ossimNitfCsdidaTag::print(
126294
std::ostream& out, const std::string& prefix) const
127295
{

0 commit comments

Comments
 (0)