1 //
2 // This file is part of the SDTS++ toolkit, written by the U.S.
3 // Geological Survey.  It is experimental software, written to support
4 // USGS research and cartographic data production.
5 //
6 // SDTS++ is public domain software.  It may be freely copied,
7 // distributed, and modified.  The USGS welcomes user feedback, but makes
8 // no committment to any level of support for this code.  See the SDTS
9 // web site at http://mcmcweb.er.usgs.gov/sdts for more information,
10 // including points of contact.
11 //
12 
13 
14 #ifdef WIN32
15 #pragma warning( disable : 4786 )
16 #endif
17 
18 
19 
20 #include <iostream>
21 #include <fstream>
22 
23 #include <sdts++/io/sio_8211Converter.h>
24 #include <sdts++/io/sio_Reader.h>
25 #include <sdts++/container/sc_Record.h>
26 #include <sdts++/builder/sb_Spdm.h>
27 
28 sio_8211Converter_BI8   converter_bi8;
29 sio_8211Converter_BI16	converter_bi16;
30 sio_8211Converter_BI24  converter_bi24;
31 sio_8211Converter_BI32	converter_bi32;
32 sio_8211Converter_BUI8	converter_bui8;
33 sio_8211Converter_BUI16	converter_bui16;
34 sio_8211Converter_BUI24	converter_bui24;
35 sio_8211Converter_BUI32	converter_bui32;
36 sio_8211Converter_BFP32	converter_bfp32;
37 sio_8211Converter_BFP64 converter_bfp64;
38 
39 using namespace std;
40 
41 int
main(int argc,char ** argv)42 main( int argc, char** argv )
43 {
44 
45   if ( ! argv[1] )
46     {
47       cerr << "usage: " << argv[0] << " SPDM module " << endl;
48       exit( 1 );
49     }
50 
51 #ifdef WIN32
52   ifstream ddf( argv[1], ios::binary );
53 #else
54   ifstream ddf( argv[1] );
55 #endif
56 
57   if ( ! ddf )
58     {
59       cerr << "couldn't open " << argv[1] << endl;
60       exit( 2 );
61     }
62 
63   sio_8211_converter_dictionary converters;
64 
65   // XXX need to be more dynamic about this
66 
67   converters["X"] = &converter_bi32;
68   converters["Y"] = &converter_bi32;
69 
70 
71   sio_8211Reader  reader( ddf, &converters );
72 
73   //  sio_8211Reader  reader( ddf );
74   sc_Record record;
75   sb_Spdm sb_spdm;
76 
77   for( sio_8211ForwardIterator i( reader );
78         ! i.done();
79         ++i )
80    {
81      i.get( record );
82 
83      cout << "raw record:\n" << record << "\n";
84 
85      if ( ! sb_spdm.setRecord( record ) )
86       {
87 	    cerr << " sb_spdm::setRecord() failed\n";
88 	    abort();
89       }
90      else
91      {
92         cout << "what we read in:\n";
93         cout << record << endl;
94 
95         sb_spdm.setRecord( record );
96 
97         cout << "\nand what the SPDM object says it is:\n";
98         cout << sb_spdm << endl;
99 
100 
101       }
102   }
103 
104   exit(0);
105 }
106