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 // $Id: sb_Iden.cpp,v 1.7 2002/11/24 22:07:42 mcoletti Exp $
14
15
16 #include <iostream>
17
18
19 #include <limits.h>
20
21 #include <sdts++/builder/sb_Iden.h>
22
23
24 #ifndef INCLUDED_SB_UTILS_H
25 #include <sdts++/builder/sb_Utils.h>
26 #endif
27
28
29 #ifndef INCLUDED_SB_FOREIGNID_H
30 #include <sdts++/builder/sb_ForeignID.h>
31 #endif
32
33 #ifndef INCLUDED_SC_RECORD_H
34 #include <sdts++/container/sc_Record.h>
35 #endif
36
37
38 #ifndef INCLUDED_SIO_8211CONVERTER_H
39 #include <sdts++/io/sio_8211Converter.h>
40 #endif
41
42
43 using namespace std;
44
45
46 static const char* iden_ = "$Id: sb_Iden.cpp,v 1.7 2002/11/24 22:07:42 mcoletti Exp $";
47
48
49 // Strings and integers are initialized with these values; they're used
50 // to indicate whether a given module value has been assigned a value or not.
51
52 // (XXX I arbitrarily chose 0x4 as the sentinal value. I hate ad hoc crap.)
53
54 static const string UNVALUED_STRING(1, static_cast<string::value_type>(0x4) );
55
56 static const long UNVALUED_LONG = INT_MIN;
57
58 static sio_8211Schema iden__schema; // iden module schema, which will be
59 // defined by build_iden_schema
60
61 static sio_8211Converter_I converter_I; // XXX should define these in
62 static sio_8211Converter_A converter_A; // XXX sio_8211Converter.h
63
64
65
66 sio_8211Schema&
schema_()67 sb_Iden::schema_()
68 {
69 return iden__schema;
70 } // sb_Iden::schema_
71
72
73
74
75 //
76 // builds a schema suitable for writing an SDTS IDEN module
77 //
78 void
buildSpecificSchema_()79 sb_Iden::buildSpecificSchema_( )
80 {
81
82
83
84 // IDENIFICATION field
85
86 schema_().push_back( sio_8211FieldFormat() );
87
88 sio_8211FieldFormat& field_format = schema_().back();
89
90 field_format.setDataStructCode( sio_8211FieldFormat::vector );
91 field_format.setDataTypeCode( sio_8211FieldFormat::mixed_data_type );
92 field_format.setName( "IDENIFICATION" );
93 field_format.setTag( "IDEN" );
94
95 field_format.push_back( sio_8211SubfieldFormat() );
96
97 field_format.back().setLabel( "MODN" );
98 field_format.back().setType( sio_8211SubfieldFormat::A );
99 field_format.back().setFormat( sio_8211SubfieldFormat::variable );
100 field_format.back().setConverter( &converter_A );
101
102 field_format.push_back( sio_8211SubfieldFormat() );
103
104 field_format.back().setLabel( "RCID" );
105 field_format.back().setType( sio_8211SubfieldFormat::I );
106 field_format.back().setFormat( sio_8211SubfieldFormat::variable );
107 field_format.back().setConverter( &converter_I );
108
109 field_format.push_back( sio_8211SubfieldFormat() );
110
111 field_format.back().setLabel( "STID" );
112 field_format.back().setType( sio_8211SubfieldFormat::A );
113 field_format.back().setFormat( sio_8211SubfieldFormat::variable );
114 field_format.back().setConverter( &converter_A );
115
116 field_format.push_back( sio_8211SubfieldFormat() );
117
118 field_format.back().setLabel( "STVS" );
119 field_format.back().setType( sio_8211SubfieldFormat::A );
120 field_format.back().setFormat( sio_8211SubfieldFormat::variable );
121 field_format.back().setConverter( &converter_A );
122
123 field_format.push_back( sio_8211SubfieldFormat() );
124
125 field_format.back().setLabel( "DOCU" );
126 field_format.back().setType( sio_8211SubfieldFormat::A );
127 field_format.back().setFormat( sio_8211SubfieldFormat::variable );
128 field_format.back().setConverter( &converter_A );
129
130 field_format.push_back( sio_8211SubfieldFormat() );
131
132 field_format.back().setLabel( "PRID" );
133 field_format.back().setType( sio_8211SubfieldFormat::A );
134 field_format.back().setFormat( sio_8211SubfieldFormat::variable );
135 field_format.back().setConverter( &converter_A );
136
137 field_format.push_back( sio_8211SubfieldFormat() );
138
139 field_format.back().setLabel( "PRVS" );
140 field_format.back().setType( sio_8211SubfieldFormat::A );
141 field_format.back().setFormat( sio_8211SubfieldFormat::variable );
142 field_format.back().setConverter( &converter_A );
143
144 field_format.push_back( sio_8211SubfieldFormat() );
145
146 field_format.back().setLabel( "PDOC" );
147 field_format.back().setType( sio_8211SubfieldFormat::A );
148 field_format.back().setFormat( sio_8211SubfieldFormat::variable );
149 field_format.back().setConverter( &converter_A );
150
151 field_format.push_back( sio_8211SubfieldFormat() );
152
153 field_format.back().setLabel( "TITL" );
154 field_format.back().setType( sio_8211SubfieldFormat::A );
155 field_format.back().setFormat( sio_8211SubfieldFormat::variable );
156 field_format.back().setConverter( &converter_A );
157
158 field_format.push_back( sio_8211SubfieldFormat() );
159
160 field_format.back().setLabel( "DAID" );
161 field_format.back().setType( sio_8211SubfieldFormat::A );
162 field_format.back().setFormat( sio_8211SubfieldFormat::variable );
163 field_format.back().setConverter( &converter_A );
164
165 field_format.push_back( sio_8211SubfieldFormat() );
166
167 field_format.back().setLabel( "DAST" );
168 field_format.back().setType( sio_8211SubfieldFormat::A );
169 field_format.back().setFormat( sio_8211SubfieldFormat::variable );
170 field_format.back().setConverter( &converter_A );
171
172 field_format.push_back( sio_8211SubfieldFormat() );
173
174 field_format.back().setLabel( "MPDT" );
175 field_format.back().setType( sio_8211SubfieldFormat::A );
176 field_format.back().setFormat( sio_8211SubfieldFormat::variable );
177 field_format.back().setConverter( &converter_A );
178
179 field_format.push_back( sio_8211SubfieldFormat() );
180
181 field_format.back().setLabel( "DCDT" );
182 field_format.back().setType( sio_8211SubfieldFormat::A );
183 field_format.back().setFormat( sio_8211SubfieldFormat::variable );
184 field_format.back().setConverter( &converter_A );
185
186 field_format.push_back( sio_8211SubfieldFormat() );
187
188 field_format.back().setLabel( "SCAL" );
189 field_format.back().setType( sio_8211SubfieldFormat::I );
190 field_format.back().setFormat( sio_8211SubfieldFormat::variable );
191 field_format.back().setConverter( &converter_I );
192
193 field_format.push_back( sio_8211SubfieldFormat() );
194
195 field_format.back().setLabel( "COMT" );
196 field_format.back().setType( sio_8211SubfieldFormat::A );
197 field_format.back().setFormat( sio_8211SubfieldFormat::variable );
198 field_format.back().setConverter( &converter_A );
199
200
201
202 // CONFORMANCE field
203
204 schema_().push_back( sio_8211FieldFormat() );
205
206 schema_().back().setDataStructCode( sio_8211FieldFormat::vector );
207 schema_().back().setDataTypeCode( sio_8211FieldFormat::mixed_data_type );
208 schema_().back().setName( "CONFORMANCE" );
209 schema_().back().setTag( "CONF" );
210
211 schema_().back().push_back( sio_8211SubfieldFormat() );
212
213 schema_().back().back().setLabel( "FFYN" );
214 schema_().back().back().setType( sio_8211SubfieldFormat::A );
215 schema_().back().back().setFormat( sio_8211SubfieldFormat::variable );
216 schema_().back().back().setConverter( &converter_A );
217
218 schema_().back().push_back( sio_8211SubfieldFormat() );
219
220 schema_().back().back().setLabel( "VGYN" );
221 schema_().back().back().setType( sio_8211SubfieldFormat::A );
222 schema_().back().back().setFormat( sio_8211SubfieldFormat::variable );
223 schema_().back().back().setConverter( &converter_A );
224
225 schema_().back().push_back( sio_8211SubfieldFormat() );
226
227 schema_().back().back().setLabel( "GTYN" );
228 schema_().back().back().setType( sio_8211SubfieldFormat::A );
229 schema_().back().back().setFormat( sio_8211SubfieldFormat::variable );
230 schema_().back().back().setConverter( &converter_A );
231
232 schema_().back().push_back( sio_8211SubfieldFormat() );
233
234 schema_().back().back().setLabel( "RCYN" );
235 schema_().back().back().setType( sio_8211SubfieldFormat::A );
236 schema_().back().back().setFormat( sio_8211SubfieldFormat::variable );
237 schema_().back().back().setConverter( &converter_A );
238
239 schema_().back().push_back( sio_8211SubfieldFormat() );
240
241 schema_().back().back().setLabel( "EXSP" );
242 schema_().back().back().setType( sio_8211SubfieldFormat::I );
243 schema_().back().back().setFormat( sio_8211SubfieldFormat::variable );
244 schema_().back().back().setConverter( &converter_I );
245
246 schema_().back().push_back( sio_8211SubfieldFormat() );
247
248 schema_().back().back().setLabel( "FTLV" );
249 schema_().back().back().setType( sio_8211SubfieldFormat::I );
250 schema_().back().back().setFormat( sio_8211SubfieldFormat::variable );
251 schema_().back().back().setConverter( &converter_I );
252
253 schema_().back().push_back( sio_8211SubfieldFormat() );
254
255 schema_().back().back().setLabel( "CDLV" );
256 schema_().back().back().setType( sio_8211SubfieldFormat::I );
257 schema_().back().back().setFormat( sio_8211SubfieldFormat::variable );
258 schema_().back().back().setConverter( &converter_I );
259
260 schema_().back().push_back( sio_8211SubfieldFormat() );
261
262 schema_().back().back().setLabel( "NGDM" );
263 schema_().back().back().setType( sio_8211SubfieldFormat::A );
264 schema_().back().back().setFormat( sio_8211SubfieldFormat::variable );
265 schema_().back().back().setConverter( &converter_A );
266
267
268 // ATTRIBUTE ID field
269
270 schema_().push_back( sio_8211FieldFormat() );
271
272 schema_().back().setDataStructCode( sio_8211FieldFormat::array );
273 schema_().back().setDataTypeCode( sio_8211FieldFormat::mixed_data_type );
274 schema_().back().setName( "ATTRIBUTE ID" );
275 schema_().back().setTag( "ATID" );
276
277 schema_().back().push_back( sio_8211SubfieldFormat() );
278
279 schema_().back().back().setLabel( "MODN" );
280 schema_().back().back().setType( sio_8211SubfieldFormat::A );
281 schema_().back().back().setFormat( sio_8211SubfieldFormat::variable );
282 schema_().back().back().setConverter( &converter_A );
283
284 schema_().back().push_back( sio_8211SubfieldFormat() );
285
286 schema_().back().back().setLabel( "RCID" );
287 schema_().back().back().setType( sio_8211SubfieldFormat::I );
288 schema_().back().back().setFormat( sio_8211SubfieldFormat::variable );
289 schema_().back().back().setConverter( &converter_I );
290
291 } // build_iden_schema
292
293
294
295
296
297 struct sb_Iden_Imp
298 {
299 string standardIden;
300 string standardVer;
301 string standardDocRef;
302 string profileIden;
303 string profileVer;
304 string profileDocRef;
305 string title;
306 string dataID;
307 string dataStruct;
308 string mapDate;
309 string dataSetCreationDate;
310 long scale;
311 string comment;
312
313 string composites;
314 string vectorGeom;
315 string vectorTopol;
316 string raster;
317 long externSpatRef;
318 long featuresLevel;
319 long codingLevel;
320 string nongeoDimension;
321
322
323 #ifdef NOT_IMPLEMENTED
324 sb_ForeignID attrID; // XXX need valued indicator here, too
325 #endif
326
327 bool bad; // true if in bad state
328
sb_Iden_Impsb_Iden_Imp329 sb_Iden_Imp() :
330 bad( false ),
331 standardIden( UNVALUED_STRING ),
332 standardVer( UNVALUED_STRING ),
333 standardDocRef( UNVALUED_STRING ),
334 profileIden( UNVALUED_STRING ),
335 profileVer( UNVALUED_STRING ),
336 profileDocRef( UNVALUED_STRING ),
337 title( UNVALUED_STRING ),
338 dataID( UNVALUED_STRING ),
339 dataStruct( UNVALUED_STRING ),
340 mapDate( UNVALUED_STRING ),
341 dataSetCreationDate( UNVALUED_STRING ),
342 scale( UNVALUED_LONG ),
343 comment( UNVALUED_STRING ),
344 composites( UNVALUED_STRING ),
345 vectorGeom( UNVALUED_STRING ),
346 vectorTopol( UNVALUED_STRING ),
347 raster( UNVALUED_STRING ),
348 externSpatRef( UNVALUED_LONG ),
349 featuresLevel( UNVALUED_LONG ),
350 codingLevel( UNVALUED_LONG ),
351 nongeoDimension( UNVALUED_STRING )
352 {}
353
354 }; // struct sb_Iden_Imp
355
356
357
sb_Iden()358 sb_Iden::sb_Iden() : imp_( new sb_Iden_Imp )
359 {
360 setMnemonic( "IDEN" ); // set reasonable module mnemonic and
361 setID( 0 ); // record id defaults
362 }
363
364
365
~sb_Iden()366 sb_Iden::~sb_Iden()
367 {
368 delete imp_;
369 }
370
371
372 // populate an iden object from the given sc_Record that (hopefully)
373 // contains an IDEN module record
374 static
375 bool
ingest_record_(sb_Iden & iden,sb_Iden_Imp & iden_imp,sc_Record const & record)376 ingest_record_( sb_Iden & iden,
377 sb_Iden_Imp & iden_imp,
378 sc_Record const & record )
379 {
380
381 // Make sure we have a record from a Idenification module.
382
383 sc_FieldCntr::const_iterator curfield;
384
385 if ( ! sb_Utils::getFieldByMnem( record, "IDEN", curfield) )
386 {
387 #ifdef SDTSXX_DEBUG
388 cerr << "sb_Iden::sb_Iden(sc_Record const&): Not a IDEN record.";
389 cerr << endl;
390 #endif
391 return false;
392 }
393
394 // We have a primary field from a Idenification module. Start picking
395 // it apart.
396
397 sc_SubfieldCntr::const_iterator cursubfield;
398
399 // MODN
400 if (sb_Utils::getSubfieldByMnem(*curfield,"MODN",cursubfield))
401 {
402 string tmp;
403
404 cursubfield->getA( tmp );
405 iden.setMnemonic( tmp );
406 }
407
408
409 // RCID
410 if (sb_Utils::getSubfieldByMnem(*curfield,"RCID",cursubfield))
411 {
412 long tmp;
413 cursubfield->getI( tmp );
414 iden.setID( tmp );
415 }
416
417 // STID
418 if (sb_Utils::getSubfieldByMnem(*curfield,"STID",cursubfield))
419 cursubfield->getA(iden_imp.standardIden);
420
421 // STVS
422 if (sb_Utils::getSubfieldByMnem(*curfield,"STVS",cursubfield))
423 cursubfield->getA(iden_imp.standardVer);
424
425 // DOCU
426 if (sb_Utils::getSubfieldByMnem(*curfield,"DOCU",cursubfield))
427 cursubfield->getA(iden_imp.standardDocRef);
428
429 // PRID
430 if (sb_Utils::getSubfieldByMnem(*curfield,"PRID",cursubfield))
431 cursubfield->getA(iden_imp.profileIden);
432
433 // PRVS
434 if (sb_Utils::getSubfieldByMnem(*curfield,"PRVS",cursubfield))
435 cursubfield->getA(iden_imp.profileVer);
436
437 // PDOC
438 if (sb_Utils::getSubfieldByMnem(*curfield,"PDOC",cursubfield))
439 cursubfield->getA(iden_imp.profileDocRef);
440
441 // TITL
442 if (sb_Utils::getSubfieldByMnem(*curfield,"TITL",cursubfield))
443 cursubfield->getA(iden_imp.title);
444
445 // DAID
446 if (sb_Utils::getSubfieldByMnem(*curfield,"DAID",cursubfield))
447 cursubfield->getA(iden_imp.dataID);
448
449 // DAST
450 if (sb_Utils::getSubfieldByMnem(*curfield,"DAST",cursubfield))
451 cursubfield->getA(iden_imp.dataStruct);
452
453 // MPDT
454 if (sb_Utils::getSubfieldByMnem(*curfield,"MPDT",cursubfield))
455 cursubfield->getA(iden_imp.mapDate);
456
457 // DCDT
458 if (sb_Utils::getSubfieldByMnem(*curfield,"DCDT",cursubfield))
459 cursubfield->getA(iden_imp.dataSetCreationDate);
460
461 // SCAL
462 if (sb_Utils::getSubfieldByMnem(*curfield,"SCAL",cursubfield))
463 cursubfield->getI(iden_imp.scale);
464
465 // COMT
466 if (sb_Utils::getSubfieldByMnem(*curfield,"COMT",cursubfield))
467 cursubfield->getA(iden_imp.comment);
468
469 // Secondary Fields
470
471 // Conformance (CONF) Field
472 if (!sb_Utils::getFieldByMnem(record,"CONF",curfield))
473 {
474 #ifdef SDTSXX_DEBUG
475 cerr << "sb_Iden::sb_Iden(sc_Record const&): Not a Conformance "
476 << "field to be found.";
477 cerr << endl;
478 #endif
479 return false;
480 }
481
482 // We have a secondary field from a Idenification module. Start picking
483 // it apart.
484
485 // FFYN
486 if (sb_Utils::getSubfieldByMnem(*curfield,"FFYN",cursubfield))
487 cursubfield->getA(iden_imp.composites);
488
489 // VGYN
490 if (sb_Utils::getSubfieldByMnem(*curfield,"VGYN",cursubfield))
491 cursubfield->getA(iden_imp.vectorGeom);
492
493 // GTYN
494 if (sb_Utils::getSubfieldByMnem(*curfield,"GTYN",cursubfield))
495 cursubfield->getA(iden_imp.vectorTopol);
496
497 // RCYN
498 if (sb_Utils::getSubfieldByMnem(*curfield,"RCYN",cursubfield))
499 cursubfield->getA(iden_imp.raster);
500
501 // EXSP
502 if (sb_Utils::getSubfieldByMnem(*curfield,"EXSP",cursubfield))
503 cursubfield->getI(iden_imp.externSpatRef);
504
505 // FTLV
506 if (sb_Utils::getSubfieldByMnem(*curfield,"FTLV",cursubfield))
507 cursubfield->getI(iden_imp.featuresLevel);
508
509 // CDLV - Coding level (I)
510 if (sb_Utils::getSubfieldByMnem(*curfield,"CDLV",cursubfield))
511 cursubfield->getI(iden_imp.codingLevel);
512
513 // NGDM = nongeospatila deminsions (A)
514 if (sb_Utils::getSubfieldByMnem(*curfield,"NGDM",cursubfield))
515 cursubfield->getA(iden_imp.nongeoDimension);
516
517 #ifdef NOT_IMPLEMENTED
518 // Attribute ID (ATID) Field
519 if (sb_Utils::getFieldByMnem(record,"ATID",curfield))
520 iden_imp.attrID = sb_ForeignID(*curfield);
521 #endif
522
523 return true;
524
525 }; // ingest__record
526
527
528
sb_Iden(sc_Record const & record)529 sb_Iden::sb_Iden( sc_Record const & record )
530 : imp_( new sb_Iden_Imp )
531 {
532 // Build an sb_Iden from an sc_Record.
533 if ( ! ingest_record_( *this, *imp_, record ) )
534 {
535 imp_->bad = true;
536 }
537 } // sb_Iden ctor
538
539
540
541
542
543
544 bool
getStandardIdentification(string & str) const545 sb_Iden::getStandardIdentification( string& str ) const
546 {
547 if ( imp_->standardIden == UNVALUED_STRING )
548 return false;
549
550 str = imp_->standardIden;
551
552 return true;
553 }
554
555
556 bool
getStandardVersion(string & str) const557 sb_Iden::getStandardVersion( string& str ) const
558 {
559 if ( imp_->standardVer == UNVALUED_STRING )
560 return false;
561
562 str = imp_->standardVer;
563
564 return true;
565 }
566
567
568 bool
getStandardDocumentationReference(string & str) const569 sb_Iden::getStandardDocumentationReference( string& str ) const
570 {
571 if ( imp_->standardDocRef == UNVALUED_STRING )
572 return false;
573
574 str = imp_->standardDocRef;
575
576 return true;
577 }
578
579
580 bool
getProfileIdentification(string & str) const581 sb_Iden::getProfileIdentification( string& str ) const
582 {
583 if ( imp_->profileIden == UNVALUED_STRING )
584 return false;
585
586 str = imp_->profileIden;
587
588 return true;
589 }
590
591
592 bool
getProfileVersion(string & str) const593 sb_Iden::getProfileVersion( string& str ) const
594 {
595 if ( imp_->profileVer == UNVALUED_STRING )
596 return false;
597
598 str = imp_->profileVer;
599
600 return true;
601 }
602
603
604 bool
getProfileDocumentationReference(string & str) const605 sb_Iden::getProfileDocumentationReference( string& str ) const
606 {
607 if ( imp_->profileDocRef == UNVALUED_STRING )
608 return false;
609
610 str = imp_->profileDocRef;
611
612 return true;
613 }
614
615
616 bool
getTitle(string & str) const617 sb_Iden::getTitle( string& str ) const
618 {
619 if ( imp_->title == UNVALUED_STRING )
620 return false;
621
622 str = imp_->title;
623
624 return true;
625 }
626
627
628 bool
getDataID(string & str) const629 sb_Iden::getDataID( string& str ) const
630 {
631 if ( imp_->dataID == UNVALUED_STRING )
632 return false;
633
634 str = imp_->dataID;
635
636 return true;
637 }
638
639
640 bool
getDataStructure(string & str) const641 sb_Iden::getDataStructure( string& str ) const
642 {
643 if ( imp_->dataStruct == UNVALUED_STRING )
644 return false;
645
646 str = imp_->dataStruct;
647
648 return true;
649 }
650
651
652 bool
getMapDate(string & str) const653 sb_Iden::getMapDate( string& str ) const
654 {
655 if ( imp_->mapDate == UNVALUED_STRING )
656 return false;
657
658 str = imp_->mapDate;
659
660 return true;
661 }
662
663
664 bool
getDataSetCreationDate(string & str) const665 sb_Iden::getDataSetCreationDate( string& str ) const
666 {
667 if ( imp_->dataSetCreationDate == UNVALUED_STRING )
668 return false;
669
670 str = imp_->dataSetCreationDate;
671
672 return true;
673 }
674
675
676 bool
getScale(long & num) const677 sb_Iden::getScale( long & num ) const
678 {
679 if ( imp_->scale == UNVALUED_LONG )
680 return false;
681
682 num = imp_->scale;
683
684 return true;
685 }
686
687
688 bool
getComment(string & str) const689 sb_Iden::getComment( string& str ) const
690 {
691 if ( imp_->comment == UNVALUED_STRING )
692 return false;
693
694 str = imp_->comment;
695
696 return true;
697 }
698
699
700 bool
getComposites(string & str) const701 sb_Iden::getComposites( string& str ) const
702 {
703 if ( imp_->composites == UNVALUED_STRING )
704 return false;
705
706 str = imp_->composites;
707
708 return true;
709 }
710
711
712 bool
getVectorGeometry(string & str) const713 sb_Iden::getVectorGeometry( string& str ) const
714 {
715 if ( imp_->vectorGeom == UNVALUED_STRING )
716 return false;
717
718 str = imp_->vectorGeom;
719
720 return true;
721 }
722
723
724 bool
getVectorTopology(string & str) const725 sb_Iden::getVectorTopology( string& str ) const
726 {
727 if ( imp_->vectorTopol == UNVALUED_STRING )
728 return false;
729
730 str = imp_->vectorTopol;
731
732 return true;
733 }
734
735
736 bool
getRaster(string & str) const737 sb_Iden::getRaster( string& str ) const
738 {
739 if ( imp_->raster == UNVALUED_STRING )
740 return false;
741
742 str = imp_->raster;
743
744 return true;
745 }
746
747
748 bool
getExternalSpatialReference(long & num) const749 sb_Iden::getExternalSpatialReference( long& num ) const
750 {
751 if ( imp_->externSpatRef == UNVALUED_LONG )
752 return false;
753
754 num = imp_->externSpatRef;
755
756 return true;
757 }
758
759
760 bool
getFeaturesLevel(long & num) const761 sb_Iden::getFeaturesLevel( long & num ) const
762 {
763 if ( imp_->featuresLevel == UNVALUED_LONG )
764 return false;
765
766 num = imp_->featuresLevel;
767
768 return true;
769 }
770
771
772 bool
getCodingLevel(long & num) const773 sb_Iden::getCodingLevel( long & num ) const
774 {
775 if ( imp_->codingLevel == UNVALUED_LONG )
776 return false;
777
778 num = imp_->codingLevel;
779
780 return true;
781 }
782
783
784
785 bool
getNonGeoSpatialDimensions(string & str) const786 sb_Iden::getNonGeoSpatialDimensions( string& str ) const
787 {
788 if ( imp_->nongeoDimension == UNVALUED_STRING )
789 return false;
790
791 str = imp_->nongeoDimension;
792
793 return true;
794 }
795
796
797 #ifdef NOT_IMPLEMENTED
798 bool
getAttributeID(sb_ForeignID & fid) const799 sb_Iden::getAttributeID( sb_ForeignID& fid ) const
800 {
801 fid = imp_->attrID; // XXX need to check for unset state
802 return true;
803 }
804 #endif
805
806
807
808
809
810 bool
getRecord(sc_Record & record) const811 sb_Iden::getRecord( sc_Record& record ) const
812 {
813
814 record.clear(); // start with a clean slate
815
816 // IDEN field
817
818 record.push_back( sc_Field() );
819
820 record.back().setMnemonic( "IDEN" );
821
822 string tmp_str;
823 long tmp_long;
824
825 getMnemonic( tmp_str );
826 sb_Utils::add_subfield( record.back(), "MODN", tmp_str );
827 sb_Utils::add_subfield( record.back(), "RCID", getID() );
828
829 // Add each field and subfield to the record. Bail if a mandatory
830 // subfield hasn't been set.
831
832 if ( ! getStandardIdentification( tmp_str ) )
833 {
834 return false;
835 }
836
837 sb_Utils::add_subfield( record.back(), "STID", tmp_str );
838
839 if ( ! getStandardVersion( tmp_str ) )
840 {
841 return false;
842 }
843
844 sb_Utils::add_subfield( record.back(), "STVS", tmp_str );
845
846
847 if ( getDOCU( tmp_str ) ) // DOCU optional, so only add if set
848 {
849 sb_Utils::add_subfield( record.back(), "DOCU", tmp_str );
850 }
851 else
852 {
853 sb_Utils::add_empty_subfield( record.back(), "DOCU", sc_Subfield::is_A );
854 }
855
856
857 if ( ! getPRID( tmp_str ) )
858 {
859 return false;
860 }
861
862 sb_Utils::add_subfield( record.back(), "PRID", tmp_str );
863
864 if ( ! getPRVS( tmp_str ) )
865 {
866 return false;
867 }
868
869 sb_Utils::add_subfield( record.back(), "PRVS", tmp_str );
870
871
872 if ( getPDOC( tmp_str ) ) // optional subfield; add if have value
873 {
874 sb_Utils::add_subfield( record.back(), "PDOC", tmp_str );
875 }
876 else
877 {
878 sb_Utils::add_empty_subfield( record.back(), "PDOC", sc_Subfield::is_A );
879 }
880
881
882 if ( ! getTitle( tmp_str ) )
883 {
884 return false;
885 }
886
887 sb_Utils::add_subfield( record.back(), "TITL", tmp_str );
888
889 if ( getDataID( tmp_str ) )
890 {
891 sb_Utils::add_subfield( record.back(), "DAID", tmp_str );
892 }
893 else
894 {
895 sb_Utils::add_empty_subfield( record.back(), "DAID", sc_Subfield::is_A );
896 }
897
898
899
900 // The next five subfields are
901 // optional, so they'll only be set if
902 // they've got values.
903
904 if ( getDataStructure( tmp_str ) )
905 {
906 sb_Utils::add_subfield( record.back(), "DAST", tmp_str );
907 }
908 else
909 {
910 sb_Utils::add_empty_subfield( record.back(), "DAST", sc_Subfield::is_A );
911 }
912
913
914 if ( getMapDate( tmp_str ) )
915 {
916 sb_Utils::add_subfield( record.back(), "MPDT", tmp_str );
917 }
918 else
919 {
920 sb_Utils::add_empty_subfield( record.back(), "MPDT", sc_Subfield::is_A );
921 }
922
923
924 if ( getDataSetCreationDate( tmp_str ) )
925 {
926 sb_Utils::add_subfield( record.back(), "DCDT", tmp_str );
927 }
928 else
929 {
930 sb_Utils::add_empty_subfield( record.back(), "DCDT", sc_Subfield::is_A );
931 }
932
933
934 if ( getScale( tmp_long ) )
935 {
936 sb_Utils::add_subfield( record.back(), "SCAL", tmp_long );
937 }
938 else
939 {
940 sb_Utils::add_empty_subfield( record.back(), "SCAL", sc_Subfield::is_I );
941 }
942
943 if ( getComment( tmp_str ) )
944 {
945 sb_Utils::add_subfield( record.back(), "COMT", tmp_str );
946 }
947 else
948 {
949 sb_Utils::add_empty_subfield( record.back(), "COMT", sc_Subfield::is_A );
950 }
951
952
953 // Conformance field
954
955
956
957 record.push_back( sc_Field() );
958
959 record.back().setMnemonic( "CONF" );
960
961
962 if ( ! ( getComposites( tmp_str ) &&
963 sb_Utils::valid_domain( tmp_str, "YN" ) ) )
964 {
965 return false;
966 }
967
968 sb_Utils::add_subfield( record.back(), "FFYN", tmp_str );
969
970 if ( ! ( getVGYN( tmp_str ) &&
971 sb_Utils::valid_domain( tmp_str, "YN" ) ) )
972 {
973 return false;
974 }
975 sb_Utils::add_subfield( record.back(), "VGYN", tmp_str );
976
977 if ( ! ( getGTYN( tmp_str ) &&
978 sb_Utils::valid_domain( tmp_str, "YN" ) ) )
979 {
980 return false;
981 }
982 sb_Utils::add_subfield( record.back(), "GTYN", tmp_str );
983
984 if ( ! ( getRaster( tmp_str ) && sb_Utils::valid_domain( tmp_str, "YN" ) ) )
985 {
986 return false;
987 }
988 sb_Utils::add_subfield( record.back(), "RCYN", tmp_str );
989
990
991 set<long> EXSP_domain;
992 EXSP_domain.insert( 1 );
993 EXSP_domain.insert( 2 );
994 EXSP_domain.insert( 3 );
995
996 // set.insert( NULL ); XXX What is the NULL value?
997
998 if ( ! ( getEXSP( tmp_long ) &&
999 sb_Utils::valid_domain( tmp_long, EXSP_domain ) ) )
1000 {
1001 return false;
1002 }
1003 sb_Utils::add_subfield( record.back(), "EXSP", tmp_long );
1004
1005 set<long> FTLV_domain;
1006 FTLV_domain.insert( 1 );
1007 FTLV_domain.insert( 2 );
1008 FTLV_domain.insert( 3 );
1009 FTLV_domain.insert( 4 );
1010
1011 // set.insert( NULL ); XXX What is the NULL value?
1012
1013
1014 if ( ! ( getFeaturesLevel( tmp_long ) &&
1015 sb_Utils::valid_domain( tmp_long, FTLV_domain ) ) )
1016 {
1017 return false;
1018 }
1019 sb_Utils::add_subfield( record.back(), "FTLV", tmp_long );
1020
1021
1022 if ( getCodingLevel( tmp_long ) ) // this subfield is optional
1023 {
1024 set<long> CDLV_domain;
1025 CDLV_domain.insert( 0 );
1026 CDLV_domain.insert( 1 );
1027 CDLV_domain.insert( 2 );
1028
1029 if ( ! sb_Utils::valid_domain( tmp_long, CDLV_domain ) )
1030 {
1031 return false;
1032 }
1033
1034 sb_Utils::add_subfield( record.back(), "CDLV", tmp_long );
1035 }
1036 else
1037 {
1038 sb_Utils::add_empty_subfield( record.back(), "CDLV", sc_Subfield::is_I );
1039 }
1040
1041 if ( getNGDM( tmp_str ) ) // this subfield is optional
1042 {
1043 if ( ! sb_Utils::valid_domain( tmp_str, "YN" ) )
1044 {
1045 return false;
1046 }
1047
1048 sb_Utils::add_subfield( record.back(), "NGDM", tmp_str );
1049 }
1050 else
1051 {
1052 sb_Utils::add_empty_subfield( record.back(), "NGDM", sc_Subfield::is_A );
1053 }
1054
1055 return true;
1056
1057 } // sb_Iden::getRecord
1058
1059
1060
1061
1062 void
setStandardIdentification(string const & str)1063 sb_Iden::setStandardIdentification( string const & str )
1064 {
1065 imp_->standardIden = str;
1066 }
1067
1068
1069 void
setStandardVersion(string const & str)1070 sb_Iden::setStandardVersion( string const & str )
1071 {
1072 imp_->standardVer = str;
1073 }
1074
1075
1076 void
setStandardDocumentationReference(string const & str)1077 sb_Iden::setStandardDocumentationReference( string const & str )
1078 {
1079 imp_->standardDocRef = str;
1080 }
1081
1082
1083
1084 void
setProfileIdentification(string const & str)1085 sb_Iden::setProfileIdentification( string const & str )
1086 {
1087 imp_->profileIden = str;
1088 }
1089
1090
1091 void
setProfileVersion(string const & str)1092 sb_Iden::setProfileVersion( string const & str )
1093 {
1094 imp_->profileVer = str;
1095 }
1096
1097
1098 void
setProfileDocumentationReference(string const & str)1099 sb_Iden::setProfileDocumentationReference( string const & str )
1100 {
1101 imp_->profileDocRef = str;
1102 }
1103
1104
1105 void
setTitle(string const & str)1106 sb_Iden::setTitle( string const & str )
1107 {
1108 imp_->title = str;
1109 }
1110
1111
1112 void
setDataID(string const & str)1113 sb_Iden::setDataID( string const & str )
1114 {
1115 imp_->dataID = str;
1116 }
1117
1118
1119 void
setDataStructure(string const & str)1120 sb_Iden::setDataStructure( string const & str )
1121 {
1122 imp_->dataStruct = str;
1123 }
1124
1125
1126 void
setMapDate(string const & str)1127 sb_Iden::setMapDate( string const & str )
1128 {
1129 imp_->mapDate = str;
1130 }
1131
1132
1133 void
setDataSetCreationDate(string const & str)1134 sb_Iden::setDataSetCreationDate( string const & str )
1135 {
1136 imp_->dataSetCreationDate = str;
1137 }
1138
1139
1140 void
setScale(long val)1141 sb_Iden::setScale( long val )
1142 {
1143 imp_->scale = val;
1144 }
1145
1146
1147 void
setComment(string const & str)1148 sb_Iden::setComment( string const & str )
1149 {
1150 imp_->comment = str;
1151 }
1152
1153
1154
1155 void
setComposites(string const & str)1156 sb_Iden::setComposites( string const & str )
1157 {
1158 imp_->composites = str;
1159 }
1160
1161
1162 void
setVectorGeometry(string const & str)1163 sb_Iden::setVectorGeometry( string const & str )
1164 {
1165 imp_->vectorGeom = str;
1166 }
1167
1168
1169 void
setVectorTopology(string const & str)1170 sb_Iden::setVectorTopology( string const & str )
1171 {
1172 imp_->vectorTopol = str;
1173 }
1174
1175
1176 void
setRaster(string const & str)1177 sb_Iden::setRaster( string const & str )
1178 {
1179 imp_->raster = str;
1180 }
1181
1182
1183 void
setExternalSpatialReference(long val)1184 sb_Iden::setExternalSpatialReference( long val )
1185 {
1186 imp_->externSpatRef = val;
1187 }
1188
1189
1190 void
setFeaturesLevel(long val)1191 sb_Iden::setFeaturesLevel( long val )
1192 {
1193 imp_->featuresLevel = val;
1194 }
1195
1196
1197 void
setCodingLevel(long val)1198 sb_Iden::setCodingLevel( long val )
1199 {
1200 imp_->codingLevel = val;
1201 }
1202
1203
1204 void
setNonGeoSpatialDimensions(string const & str)1205 sb_Iden::setNonGeoSpatialDimensions( string const & str )
1206 {
1207 imp_->nongeoDimension = str;
1208 }
1209
1210
1211
1212 #ifdef NOT_IMPLEMENTED
1213 void
setAttributeID(sb_ForeignID const & fid)1214 sb_Iden::setAttributeID( sb_ForeignID const & fid )
1215 {
1216 imp_->attrID = fid;
1217 }
1218 #endif
1219
1220
1221
1222 bool
setRecord(sc_Record const & record)1223 sb_Iden::setRecord( sc_Record const& record )
1224 {
1225 // Build an sb_Iden from an sc_Record.
1226 if ( ! ingest_record_( *this, *imp_, record ) )
1227 {
1228 imp_->bad = true;
1229 return false;
1230 }
1231 return true;
1232 } // sb_Iden::setRecord
1233