OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimDtedDsi.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: Ken Melero
8 //
9 // Description: This class gives access to the Data Set Identification
10 // (DSI) of a DTED Level 1 file.
11 //
12 //********************************************************************
13 // $Id: ossimDtedDsi.cpp 23276 2015-04-24 21:01:51Z rashadkm $
14 
15 #include <cstdlib>
16 #include <iostream>
17 #include <iomanip>
18 #include <fstream>
19 #include <string>
20 
22 #include <ossim/base/ossimNotify.h>
25 
27  :
28  theRecSen(),
29  theSecurityCode(),
30  theField3(),
31  theField4(),
32  theProductLevel(),
33  theField7(),
34  theField8(),
35  theEdition(),
36  theMatchMergeVersion(),
37  theMaintenanceDate(),
38  theMatchMergeDate(),
39  theMaintenanceCode(),
40  theProducerCode(),
41  theField15(),
42  theProductStockSpecNumber(),
43  theProductSpecNumber(),
44  theProductSpecDate(),
45  theVerticalDatum(),
46  theHorizontalDatum(),
47  theField21(),
48  theCompilationDate(),
49  theField23(),
50  theLatOrigin(),
51  theLonOrigin(),
52  theLatSW(),
53  theLonSW(),
54  theLatNW(),
55  theLonNW(),
56  theLatNE(),
57  theLonNE(),
58  theLatSE(),
59  theLonSE(),
60  theOrientation(),
61  theLatInterval(),
62  theLonInterval(),
63  theNumLatPoints(),
64  theNumLonLines(),
65  theCellIndicator(),
66  theField40(),
67  theField41(),
68  theField42(),
69  theStartOffset(0),
70  theStopOffset(0)
71 {
72 
73 }
74 
75 ossimDtedDsi::ossimDtedDsi(std::shared_ptr<ossim::istream>& str, ossim_int64 offset)
76  :
77  theRecSen(),
78  theSecurityCode(),
79  theField3(),
80  theField4(),
81  theProductLevel(),
82  theField7(),
83  theField8(),
84  theEdition(),
85  theMatchMergeVersion(),
86  theMaintenanceDate(),
87  theMatchMergeDate(),
88  theMaintenanceCode(),
89  theProducerCode(),
90  theField15(),
91  theProductStockSpecNumber(),
92  theProductSpecNumber(),
93  theProductSpecDate(),
94  theVerticalDatum(),
95  theHorizontalDatum(),
96  theField21(),
97  theCompilationDate(),
98  theField23(),
99  theLatOrigin(),
100  theLonOrigin(),
101  theLatSW(),
102  theLonSW(),
103  theLatNW(),
104  theLonNW(),
105  theLatNE(),
106  theLonNE(),
107  theLatSE(),
108  theLonSE(),
109  theOrientation(),
110  theLatInterval(),
111  theLonInterval(),
112  theNumLatPoints(),
113  theNumLonLines(),
114  theCellIndicator(),
115  theField40(),
116  theField41(),
117  theField42(),
118  theStartOffset(0),
119  theStopOffset(0)
120 {
121  if(str)
122  {
123  str->seekg(offset);
124  parse(*str);
125  }
126  else
127  {
129  }
130 }
131 
133 {
135  theStartOffset = in.tellg();
137  char tmp_chars[26]; // For blank field reads.
138 
139  // Seek to the start of the record.
140  in.seekg(theStartOffset, std::ios::beg);
141 
142  // Parse theRecSen
143  in.read(theRecSen, FIELD1_SIZE);
144  theRecSen[FIELD1_SIZE] = '\0';
145  if(!(strncmp(theRecSen, "DSI", 3) == 0))
146  {
148  in.seekg(theStartOffset);
149  return;
150  }
151 
152  // Parse theSecurityCode
153  in.read(theSecurityCode, FIELD2_SIZE);
155 
156  // Parse Field 3
157  in.read(theField3, FIELD3_SIZE);
158  theField3[FIELD3_SIZE] = '\0';
159 
160  // Parse Field 4
161  in.read(theField4, FIELD4_SIZE);
162  theField4[FIELD4_SIZE] = '\0';
163 
164  // Parse Field 5 (currently blank)
165  in.read(tmp_chars, FIELD5_SIZE);
166 
167  // Parse theProductLevel
168  in.read(theProductLevel, FIELD6_SIZE);
170 
171  // Parse Field 7
172  in.read(theField7, FIELD7_SIZE);
173  theField7[FIELD7_SIZE] = '\0';
174 
175  // Parse Field 8
176  in.read(theField8, FIELD8_SIZE);
177  theField8[FIELD8_SIZE] = '\0';
178 
179  // Parse theEdition
180  in.read(theEdition, FIELD9_SIZE);
181  theEdition[FIELD9_SIZE] = '\0';
182 
183  // Parse theMatchMergeVersion
186 
187  // Parse theMaintenanceDate
190 
191  // Parse theMatchMergeDate
194 
195  // Parse theMaintenanceCode
198 
199  // Parse theProducerCode
200  in.read(theProducerCode, FIELD14_SIZE);
202 
203  // Parse Field 15
204  in.read(theField15, FIELD15_SIZE);
205  theField15[FIELD15_SIZE] = '\0';
206 
207  // Parse theProductStockSpecNumber
210 
211  // Parse theProductSpecNumber
214 
215  // Parse theProductSpecDate
218 
219  // Parse theVerticalDatum
220  in.read(theVerticalDatum, FIELD19_SIZE);
222 
223  // Parse theHorizontalDatum
226 
227  // Parse Field 21
228  in.read(theField21, FIELD21_SIZE);
229  theField21[FIELD21_SIZE] = '\0';
230 
231  // Parse theCompilationDate
234 
235  // Parse Field 23
236  in.read(theField23, FIELD23_SIZE);
237  theField23[FIELD23_SIZE] = '\0';
238 
239  // Parse theLatOrigin
240  in.read(theLatOrigin, FIELD24_SIZE);
241  theLatOrigin[FIELD24_SIZE] = '\0';
242 
243  // Parse theLonOrigin
244  in.read(theLonOrigin, FIELD25_SIZE);
245  theLonOrigin[FIELD25_SIZE] = '\0';
246 
247  // Parse theLatSW
248  in.read(theLatSW, FIELD26_SIZE);
249  theLatSW[FIELD26_SIZE] = '\0';
250 
251  // Parse theLonSW
252  in.read(theLonSW, FIELD27_SIZE);
253  theLonSW[FIELD27_SIZE] = '\0';
254 
255  // Parse theLatNW
256  in.read(theLatNW, FIELD28_SIZE);
257  theLatNW[FIELD28_SIZE] = '\0';
258 
259  // Parse theLonNW
260  in.read(theLonNW, FIELD29_SIZE);
261  theLonNW[FIELD29_SIZE] = '\0';
262 
263  // Parse theLatNE
264  in.read(theLatNE, FIELD30_SIZE);
265  theLatNE[FIELD30_SIZE] = '\0';
266 
267  // Parse theLonNE
268  in.read(theLonNE, FIELD31_SIZE);
269  theLonNE[FIELD31_SIZE] = '\0';
270 
271  // Parse theLatSE
272  in.read(theLatSE, FIELD32_SIZE);
273  theLatSE[FIELD32_SIZE] = '\0';
274 
275  // Parse theLonSE
276  in.read(theLonSE, FIELD33_SIZE);
277  theLonSE[FIELD33_SIZE] = '\0';
278 
279  // Parse theOrientation
280  in.read(theOrientation, FIELD34_SIZE);
282 
283  // Parse theLatInterval
284  in.read(theLatInterval, FIELD35_SIZE);
286 
287  // Parse theLonInterval
288  in.read(theLonInterval, FIELD36_SIZE);
290 
291  // Parse theNumLatPoints
292  in.read(theNumLatPoints, FIELD37_SIZE);
294 
295  // Parse theNumLonLines
296  in.read(theNumLonLines, FIELD38_SIZE);
298 
299  // Parse theCellIndicator
300  in.read(theCellIndicator, FIELD39_SIZE);
302 
303  // Parse Field 40
304  in.read(theField40, FIELD40_SIZE);
305  theField40[FIELD40_SIZE] = '\0';
306 
307  // Parse Field 41
308  in.read(theField41, FIELD41_SIZE);
309  theField41[FIELD41_SIZE] = '\0';
310 
311  // Parse Field 42
312  in.read(theField42, FIELD42_SIZE);
313  theField42[FIELD42_SIZE] = '\0';
314 
315  // Set the stop offset.
317 }
318 
320  const ossimString& /* name */) const
321 {
322  ossimRefPtr<ossimProperty> result = 0;
323  return result;
324 }
325 
327  std::vector<ossimString>& propertyNames) const
328 {
329  propertyNames.push_back(ossimString("dted_dsi_record"));
330 }
331 
333 {
334  return theRecSen;
335 }
336 
338 {
340 }
341 
343 {
345 }
346 
348 {
349  return ossimString(theEdition);
350 }
351 
353 {
355 }
356 
358 {
360 }
361 
363 {
365 }
366 
368 {
370 }
371 
373 {
375 }
376 
378 {
380 }
381 
383 {
385 }
386 
388 {
390 }
391 
393 {
395 }
396 
398 {
400 }
401 
403 {
405 }
406 
408 {
409  return ossimString(theLatOrigin);
410 }
411 
413 {
414  return ossimString(theLonOrigin);
415 }
416 
418 {
419  return ossimString(theLatSW);
420 }
421 
423 {
424  return ossimString(theLonSW);
425 }
426 
428 {
429  return ossimString(theLatNW);
430 }
431 
433 {
434  return ossimString(theLonNW);
435 }
436 
438 {
439  return ossimString(theLatNE);
440 }
441 
443 {
444  return ossimString(theLonNE);
445 }
446 
448 {
449  return ossimString(theLatSE);
450 }
451 
453 {
454  return ossimString(theLonSE);
455 }
456 
458 {
459  return ossimString(theOrientation);
460 }
461 
463 {
464  return ossimString(theLatInterval);
465 }
466 
468 {
469  return ossimString(theLonInterval);
470 }
471 
473 {
474  return atoi(theNumLatPoints);
475 }
476 
478 {
479  return atoi(theNumLonLines);
480 }
481 
483 {
484  return atoi(theCellIndicator);
485 }
486 
488 {
489  return theStartOffset;
490 }
492 {
493  return theStopOffset;
494 }
495 
496 //**************************************************************************
497 // operator <<
498 //**************************************************************************
500 {
501  std::string prefix;
502  return dsi.print(os, prefix);
503 }
504 
506  const std::string& prefix) const
507 {
508  std::string pfx = prefix;
509  pfx += "dsi.";
510 
511  out << setiosflags(ios::left)
512  << pfx << setw(28) << "recognition_sentinel:" << theRecSen << "\n"
513  << pfx << setw(28) << "security_code:" << theSecurityCode << "\n"
514  << pfx << setw(28) << "product_level:" << theProductLevel << "\n"
515  << pfx << setw(28) << "edition:" << theEdition << "\n"
516  << pfx << setw(28) << "match_merge_version:" << theMatchMergeVersion
517  << "\n"
518  << pfx << setw(28) << "maintenance_date:" << theMaintenanceDate << "\n"
519  << pfx << setw(28) << "match_merge_date:" << theMatchMergeDate << "\n"
520  << pfx << setw(28) << "maintenance_code:" << theMaintenanceCode << "\n"
521  << pfx << setw(28) << "producer_code:" << theProducerCode << "\n"
522  << pfx << setw(28) << "product_stock_spec_number:"
524  << "\n"
525  << pfx << setw(28) << "product_spec_number:"
526  << theProductSpecNumber << "\n"
527  << pfx << setw(28) << "vertical_datum:" << theVerticalDatum << "\n"
528  << pfx << setw(28) << "horizontal_datum:" << theHorizontalDatum << "\n"
529  << pfx << setw(28) << "compilation_date:" << theCompilationDate << "\n"
530  << pfx << setw(28) << "lat_origin:" << theLatOrigin << "\n"
531  << pfx << setw(28) << "lon_origin:" << theLonOrigin << "\n"
532  << pfx << setw(28) << "lat_sw:" << theLatSW << "\n"
533  << pfx << setw(28) << "lon_sw:" << theLonSW << "\n"
534  << pfx << setw(28) << "lat_nw:" << theLatNW << "\n"
535  << pfx << setw(28) << "lon_nw:" << theLonNW << "\n"
536  << pfx << setw(28) << "lat_ne:" << theLatNE << "\n"
537  << pfx << setw(28) << "lon_ne:" << theLonNE << "\n"
538  << pfx << setw(28) << "lat_se:" << theLatSE << "\n"
539  << pfx << setw(28) << "lon_se:" << theLonSE << "\n"
540  << pfx << setw(28) << "orientation:" << theOrientation << "\n"
541  << pfx << setw(28) << "lat_interval:" << theLatInterval << "\n"
542  << pfx << setw(28) << "lon_interval:" << theLonInterval << "\n"
543  << pfx << setw(28) << "number_of_lat_points:" << theNumLatPoints << "\n"
544  << pfx << setw(28) << "number_of_lon_lines:" << theNumLonLines << "\n"
545  << pfx << setw(28) << "cell_indicator:" << theCellIndicator << "\n"
546  << pfx << setw(28) << "start_offset:" << theStartOffset << "\n"
547  << pfx << setw(28) << "stop_offset:" << theStopOffset
548  << std::endl;
549  return out;
550 }
551 
553 {}
554 
556 {
557  return rhs;
558 }
ossimString orientation() const
char theField23[FIELD23_SIZE+1]
Definition: ossimDtedDsi.h:214
char theLonOrigin[FIELD25_SIZE+1]
Definition: ossimDtedDsi.h:216
ossimString lonNW() const
ossimString lonNE() const
ossimString latSW() const
ossim_int32 theStopOffset
Definition: ossimDtedDsi.h:236
char theField40[FIELD40_SIZE+1]
Definition: ossimDtedDsi.h:231
char theField15[FIELD15_SIZE+1]
Definition: ossimDtedDsi.h:206
char theLatInterval[FIELD35_SIZE+1]
Definition: ossimDtedDsi.h:226
std::ostream & print(std::ostream &out, const std::string &prefix) const
print method that outputs a key/value type format adding prefix to keys.
ossimString productSpecNumber() const
std::ostream & operator<<(std::ostream &os, const ossimDtedDsi &dsi)
char theField8[FIELD8_SIZE+1]
Definition: ossimDtedDsi.h:199
ossimString producerCode() const
char theMatchMergeVersion[FIELD10_SIZE+1]
Definition: ossimDtedDsi.h:201
ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
Gets a property for name.
char theField21[FIELD21_SIZE+1]
Definition: ossimDtedDsi.h:212
char theMaintenanceCode[FIELD13_SIZE+1]
Definition: ossimDtedDsi.h:204
char theLatSE[FIELD32_SIZE+1]
Definition: ossimDtedDsi.h:223
char theField42[FIELD42_SIZE+1]
Definition: ossimDtedDsi.h:233
ossimString latOrigin() const
ossimString productLevel() const
ossimString productStockSpecNumber() const
ossimString latInterval() const
ossimString latNE() const
ossimString lonSE() const
static const ossimErrorCode OSSIM_ERROR
ossimString matchMergeDate() const
char theMatchMergeDate[FIELD12_SIZE+1]
Definition: ossimDtedDsi.h:203
ossimString latSE() const
ossimString horizontalDatum() const
char theProductSpecDate[FIELD18_SIZE+1]
Definition: ossimDtedDsi.h:209
char theMaintenanceDate[FIELD11_SIZE+1]
Definition: ossimDtedDsi.h:202
ossimString lonOrigin() const
char theLonInterval[FIELD36_SIZE+1]
Definition: ossimDtedDsi.h:227
ossimString recognitionSentinel() const
char theProducerCode[FIELD14_SIZE+1]
Definition: ossimDtedDsi.h:205
ossim_int32 numLatPoints() const
char theField41[FIELD41_SIZE+1]
Definition: ossimDtedDsi.h:232
char theCompilationDate[FIELD22_SIZE+1]
Definition: ossimDtedDsi.h:213
ossimString latNW() const
ossim_int32 startOffset() const
ossimString matchMergeVersion() const
ossim_int32 cellIndicator() const
void getPropertyNames(std::vector< ossimString > &propertyNames) const
Adds this class&#39;s properties to list.
char theRecSen[FIELD1_SIZE+1]
Definition: ossimDtedDsi.h:193
char theEdition[FIELD9_SIZE+1]
Definition: ossimDtedDsi.h:200
char theLatNW[FIELD28_SIZE+1]
Definition: ossimDtedDsi.h:219
char theNumLonLines[FIELD38_SIZE+1]
Definition: ossimDtedDsi.h:229
char theVerticalDatum[FIELD19_SIZE+1]
Definition: ossimDtedDsi.h:210
ossimString lonInterval() const
ossimString compilationDate() const
void parse(std::istream &in)
char theField4[FIELD4_SIZE+1]
Definition: ossimDtedDsi.h:196
char theLatOrigin[FIELD24_SIZE+1]
Definition: ossimDtedDsi.h:215
char theNumLatPoints[FIELD37_SIZE+1]
Definition: ossimDtedDsi.h:228
ossimString edition() const
char theProductStockSpecNumber[FIELD16_SIZE+1]
Definition: ossimDtedDsi.h:207
char theOrientation[FIELD34_SIZE+1]
Definition: ossimDtedDsi.h:225
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
char theProductSpecNumber[FIELD17_SIZE+1]
Definition: ossimDtedDsi.h:208
ossimString securityCode() const
char theLonSE[FIELD33_SIZE+1]
Definition: ossimDtedDsi.h:224
ossimString maintanenceDate() const
char theLatSW[FIELD26_SIZE+1]
Definition: ossimDtedDsi.h:217
char theProductLevel[FIELD6_SIZE+1]
Definition: ossimDtedDsi.h:197
ossimString productSpecDate() const
const ossimDtedDsi & operator=(const ossimDtedDsi &rhs)
long long ossim_int64
ossim_int32 stopOffset() const
char theHorizontalDatum[FIELD20_SIZE+1]
Definition: ossimDtedDsi.h:211
char theField7[FIELD7_SIZE+1]
Definition: ossimDtedDsi.h:198
char theCellIndicator[FIELD39_SIZE+1]
Definition: ossimDtedDsi.h:230
char theLonNW[FIELD29_SIZE+1]
Definition: ossimDtedDsi.h:220
char theLonSW[FIELD27_SIZE+1]
Definition: ossimDtedDsi.h:218
char theLonNE[FIELD31_SIZE+1]
Definition: ossimDtedDsi.h:222
ossimString lonSW() const
ossim_int32 theStartOffset
Definition: ossimDtedDsi.h:235
char theSecurityCode[FIELD2_SIZE+1]
Definition: ossimDtedDsi.h:194
char theField3[FIELD3_SIZE+1]
Definition: ossimDtedDsi.h:195
char theLatNE[FIELD30_SIZE+1]
Definition: ossimDtedDsi.h:221
ossimString maintenanceCode() const
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
int ossim_int32
ossim_int32 numLonLines() const
ossimString verticalDatum() const