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 _MSC_VER
15 #pragma warning( disable : 4786 )
16 #endif
17 
18 
19 #include "sb_Iref.h"
20 
21 #include <float.h>
22 #include <limits.h>
23 
24 #include <iostream>
25 
26 #include <string>
27 
28 #ifndef INCLUDED_SB_UTILS_H
29 #include <sdts++/builder/sb_Utils.h>
30 #endif
31 
32 #ifdef NOT_IMPLEMENTED
33 #ifndef INCLUDED_SB_FOREIGNID_H
34 #include <sdts++/builder/sb_ForeignID.h>
35 #endif
36 #endif
37 
38 #ifndef INCLUDED_SC_RECORD_H
39 #include <sdts++/container/sc_Record.h>
40 #endif
41 
42 #ifndef INCLUDED_SC_FIELD_H
43 #include <sdts++/container/sc_Field.h>
44 #endif
45 
46 #ifndef INCLUDED_SC_SUBFIELD_H
47 #include <sdts++/container/sc_Subfield.h>
48 #endif
49 
50 
51 #ifndef INCLUDED_SIO_8211CONVERTER_H
52 #include <sdts++/io/sio_8211Converter.h>
53 #endif
54 
55 
56 using namespace std;
57 
58 
59 static const char* ident_ = "$Id: sb_Iref.cpp,v 1.9 2002/11/24 22:07:42 mcoletti Exp $";
60 
61 // Strings and integers are initialized with these values; they're used
62 // to indicate whether a given module value has been assigned a value or not.
63 
64 // (XXX I arbitrarily chose 0x4 as the sentinal value.  I hate ad hoc crap.)
65 
66 static const string  UNVALUED_STRING(1, static_cast<string::value_type>(0x4) );
67 
68 static const long    UNVALUED_LONG   = INT_MIN;
69 
70 static const double  UNVALUED_DOUBLE = DBL_MAX;
71 
72 static sio_8211Schema iref_schema_; // iref module schema, which will be
73                                 // defined by build_iref_schema
74 
75 static sio_8211Converter_I converter_I; // XXX should define these in
76 static sio_8211Converter_A converter_A; // XXX sio_8211Converter.h
77 static sio_8211Converter_R converter_R;
78 
79 
80 struct
81 sb_Iref_Imp
82 {
83   string comment_;
84 
85   string spatialAddType_;
86   string spatialAddXCompLbl_;
87   string spatialAddYCompLbl_;
88   string horizontalCompFmt_;
89   string verticalCompFmt_;
90 
91   double scaleFactX_;
92   double scaleFactY_;
93   double scaleFactZ_;
94   double xOrigin_;
95   double yOrigin_;
96   double zOrigin_;
97 
98   double xCompHorizRes_;
99   double yCompHorizRes_;
100   double verticalResComp_;
101 
102 #ifdef NOT_IMPLEMENTED
103   vector<sb_ForeignID> dimensionID_;
104 #endif
105 
sb_Iref_Impsb_Iref_Imp106   sb_Iref_Imp()
107     : comment_( UNVALUED_STRING ),
108       spatialAddType_( UNVALUED_STRING ),
109       spatialAddXCompLbl_( UNVALUED_STRING ),
110       spatialAddYCompLbl_( UNVALUED_STRING ),
111       horizontalCompFmt_( UNVALUED_STRING ),
112       verticalCompFmt_( UNVALUED_STRING ),
113       scaleFactX_( UNVALUED_DOUBLE ),
114       scaleFactY_( UNVALUED_DOUBLE ),
115       scaleFactZ_( UNVALUED_DOUBLE ),
116       xOrigin_( UNVALUED_DOUBLE ),
117       yOrigin_( UNVALUED_DOUBLE ),
118       zOrigin_( UNVALUED_DOUBLE ),
119       xCompHorizRes_( UNVALUED_DOUBLE ),
120       yCompHorizRes_( UNVALUED_DOUBLE ),
121       verticalResComp_( UNVALUED_DOUBLE )
122     {}
123 
124 }; // sb_Iref_Imp
125 
126 
127 
128 
129 
130 
sb_Iref()131 sb_Iref::sb_Iref()
132   : imp_( new sb_Iref_Imp )
133 {
134   setMnemonic( "IREF" );        // set reasonable module mnemonic and
135   setID( 1 );                   // record id defaults
136 }
137 
138 
~sb_Iref()139 sb_Iref::~sb_Iref()
140 {
141   delete imp_;
142 }
143 
144 
145 
146 sio_8211Schema&
schema_()147 sb_Iref::schema_()
148 {
149    return iref_schema_;
150 } // sb_Iref::schema_()
151 
152 
153 
154 //
155 // builds a schema suitable for writing an SDTS IREF module
156 //
157 void
buildSpecificSchema_()158 sb_Iref::buildSpecificSchema_( )
159 {
160   schema_().push_back( sio_8211FieldFormat() );
161 
162   sio_8211FieldFormat& field_format = schema_().back();
163 
164   field_format.setDataStructCode( sio_8211FieldFormat::vector );
165   field_format.setDataTypeCode( sio_8211FieldFormat::mixed_data_type );
166   field_format.setName( "INTERNAL SPATIAL REFERENCE" );
167   field_format.setTag( "IREF" );
168 
169   field_format.push_back( sio_8211SubfieldFormat() );
170 
171   field_format.back().setLabel( "MODN" );
172   field_format.back().setType( sio_8211SubfieldFormat::A );
173   field_format.back().setFormat( sio_8211SubfieldFormat::variable );
174   field_format.back().setConverter( &converter_A );
175 
176   field_format.push_back( sio_8211SubfieldFormat() );
177 
178   field_format.back().setLabel( "RCID" );
179   field_format.back().setType( sio_8211SubfieldFormat::I );
180   field_format.back().setFormat( sio_8211SubfieldFormat::variable );
181   field_format.back().setConverter( &converter_I );
182 
183 
184   field_format.push_back( sio_8211SubfieldFormat() );
185 
186   field_format.back().setLabel( "COMT" );
187   field_format.back().setType( sio_8211SubfieldFormat::A );
188   field_format.back().setFormat( sio_8211SubfieldFormat::variable );
189   field_format.back().setConverter( &converter_A );
190 
191 
192   field_format.push_back( sio_8211SubfieldFormat() );
193 
194   field_format.back().setLabel( "SATP" );
195   field_format.back().setType( sio_8211SubfieldFormat::A );
196   field_format.back().setFormat( sio_8211SubfieldFormat::variable );
197   field_format.back().setConverter( &converter_A );
198 
199 
200   field_format.push_back( sio_8211SubfieldFormat() );
201 
202   field_format.back().setLabel( "XLBL" );
203   field_format.back().setType( sio_8211SubfieldFormat::A );
204   field_format.back().setFormat( sio_8211SubfieldFormat::variable );
205   field_format.back().setConverter( &converter_A );
206 
207 
208   field_format.push_back( sio_8211SubfieldFormat() );
209 
210   field_format.back().setLabel( "YLBL" );
211   field_format.back().setType( sio_8211SubfieldFormat::A );
212   field_format.back().setFormat( sio_8211SubfieldFormat::variable );
213   field_format.back().setConverter( &converter_A );
214 
215 
216   field_format.push_back( sio_8211SubfieldFormat() );
217 
218   field_format.back().setLabel( "HFMT" );
219   field_format.back().setType( sio_8211SubfieldFormat::A );
220   field_format.back().setFormat( sio_8211SubfieldFormat::variable );
221   field_format.back().setConverter( &converter_A );
222 
223 
224 #ifdef NOT_RASTER_PROFILE
225   field_format.push_back( sio_8211SubfieldFormat() );
226 
227   field_format.back().setLabel( "VFMT" );
228   field_format.back().setType( sio_8211SubfieldFormat::A );
229   field_format.back().setFormat( sio_8211SubfieldFormat::variable );
230   field_format.back().setConverter( &converter_A );
231 #endif
232 
233   field_format.push_back( sio_8211SubfieldFormat() );
234 
235   field_format.back().setLabel( "SFAX" );
236   field_format.back().setType( sio_8211SubfieldFormat::R );
237   field_format.back().setFormat( sio_8211SubfieldFormat::variable );
238   field_format.back().setConverter( &converter_R );
239 
240 
241 
242   field_format.push_back( sio_8211SubfieldFormat() );
243 
244   field_format.back().setLabel( "SFAY" );
245   field_format.back().setType( sio_8211SubfieldFormat::R );
246   field_format.back().setFormat( sio_8211SubfieldFormat::variable );
247   field_format.back().setConverter( &converter_R );
248 
249 
250 #ifdef NOT_RASTER_PROFILE
251   field_format.push_back( sio_8211SubfieldFormat() );
252 
253   field_format.back().setLabel( "SFAZ" );
254   field_format.back().setType( sio_8211SubfieldFormat::R );
255   field_format.back().setFormat( sio_8211SubfieldFormat::variable );
256   field_format.back().setConverter( &converter_R );
257 #endif
258 
259 
260   field_format.push_back( sio_8211SubfieldFormat() );
261 
262   field_format.back().setLabel( "XORG" );
263   field_format.back().setType( sio_8211SubfieldFormat::R );
264   field_format.back().setFormat( sio_8211SubfieldFormat::variable );
265   field_format.back().setConverter( &converter_R );
266 
267 
268 
269   field_format.push_back( sio_8211SubfieldFormat() );
270 
271   field_format.back().setLabel( "YORG" );
272   field_format.back().setType( sio_8211SubfieldFormat::R );
273   field_format.back().setFormat( sio_8211SubfieldFormat::variable );
274   field_format.back().setConverter( &converter_R );
275 
276 
277 
278 #ifdef NOT_RASTER_PROFILE
279   field_format.push_back( sio_8211SubfieldFormat() );
280 
281   field_format.back().setLabel( "ZORG" );
282   field_format.back().setType( sio_8211SubfieldFormat::R );
283   field_format.back().setFormat( sio_8211SubfieldFormat::variable );
284   field_format.back().setConverter( &converter_R );
285 #endif
286 
287 
288   field_format.push_back( sio_8211SubfieldFormat() );
289 
290   field_format.back().setLabel( "XHRS" );
291   field_format.back().setType( sio_8211SubfieldFormat::R );
292   field_format.back().setFormat( sio_8211SubfieldFormat::variable );
293   field_format.back().setConverter( &converter_R );
294 
295 
296 
297   field_format.push_back( sio_8211SubfieldFormat() );
298 
299   field_format.back().setLabel( "YHRS" );
300   field_format.back().setType( sio_8211SubfieldFormat::R );
301   field_format.back().setFormat( sio_8211SubfieldFormat::variable );
302   field_format.back().setConverter( &converter_R );
303 
304 
305 
306 #ifdef NOT_RASTER_PROFILE
307   field_format.push_back( sio_8211SubfieldFormat() );
308 
309   field_format.back().setLabel( "VRES" );
310   field_format.back().setType( sio_8211SubfieldFormat::R );
311   field_format.back().setFormat( sio_8211SubfieldFormat::variable );
312   field_format.back().setConverter( &converter_R );
313 #endif
314 
315   // DMID
316 
317   schema_().push_back( sio_8211FieldFormat() );
318 
319   schema_().back().setDataStructCode( sio_8211FieldFormat::array );
320   schema_().back().setDataTypeCode( sio_8211FieldFormat::mixed_data_type );
321   schema_().back().setName( "DIMENSION ID" );
322   schema_().back().setTag( "DMID" );
323 
324   schema_().back().push_back( sio_8211SubfieldFormat() );
325 
326   schema_().back().back().setLabel( "MODN" );
327   schema_().back().back().setType( sio_8211SubfieldFormat::A );
328   schema_().back().back().setFormat( sio_8211SubfieldFormat::variable );
329   schema_().back().back().setConverter( &converter_A );
330 
331   schema_().back().push_back( sio_8211SubfieldFormat() );
332 
333   schema_().back().back().setLabel( "RCID" );
334   schema_().back().back().setType( sio_8211SubfieldFormat::I );
335   schema_().back().back().setFormat( sio_8211SubfieldFormat::variable );
336   schema_().back().back().setConverter( &converter_I );
337 
338 
339 
340 } // build__iref_schema
341 
342 
343 
344 
345 
346 
347 //
348 // Build an sb_Iref from an sc_Record
349 //
350 
351 static
352 bool
ingest_record_(sb_Iref & iref,sb_Iref_Imp & iref_imp,sc_Record const & record)353 ingest_record_( sb_Iref & iref,
354                 sb_Iref_Imp & iref_imp,
355                 sc_Record const & record )
356 {
357 
358   // Make sure we have a record from a Internal Spatial Reference module.
359 
360   sc_FieldCntr::const_iterator curfield;
361   if ( ! sb_Utils::getFieldByMnem( record, "IREF", curfield ) )
362     {
363 #ifdef SDTSXX_DEBUG
364       cerr << "sb_Iref::sb_Iref(sc_Record const&): "
365            << "Not an Internal Spatial Reference record.";
366       cerr << endl;
367 #endif;
368       return false;
369     }
370 
371   // We have a primary field from a  module. Start
372   // picking it apart.
373 
374   sc_SubfieldCntr::const_iterator cursubfield;
375 
376   // MODN
377   if ( sb_Utils::getSubfieldByMnem( *curfield, "MODN", cursubfield ) )
378     {
379       string tmp;
380 
381       cursubfield->getA(  tmp  );
382       iref.setMnemonic(  tmp  );
383     }
384 
385 
386   // RCID
387   if ( sb_Utils::getSubfieldByMnem( *curfield, "RCID", cursubfield ) )
388     {
389       long tmp;
390       cursubfield->getI(  tmp  );
391       iref.setID(  tmp  );
392     }
393 
394 
395    // COMT
396   if ( sb_Utils::getSubfieldByMnem( *curfield, "COMT", cursubfield ) )
397     cursubfield->getA( iref_imp.comment_ );
398 
399    // SATP
400   if ( sb_Utils::getSubfieldByMnem( *curfield, "SATP", cursubfield ) )
401     cursubfield->getA( iref_imp.spatialAddType_ );
402 
403    // XLBL
404   if ( sb_Utils::getSubfieldByMnem( *curfield, "XLBL", cursubfield ) )
405     cursubfield->getA( iref_imp.spatialAddXCompLbl_ );
406 
407    // YLBL
408   if ( sb_Utils::getSubfieldByMnem( *curfield, "YLBL", cursubfield ) )
409     cursubfield->getA( iref_imp.spatialAddYCompLbl_ );
410 
411    // HFMT
412   if ( sb_Utils::getSubfieldByMnem( *curfield, "HFMT", cursubfield ) )
413     cursubfield->getA( iref_imp.horizontalCompFmt_ );
414 
415 #ifdef NOT_RASTER_PROFILE
416    // VFMT
417   if ( sb_Utils::getSubfieldByMnem( *curfield, "VFMT", cursubfield ) )
418     cursubfield->getA( iref_imp.verticalCompFmt_ );
419 #endif
420 
421    // SFAX
422   if ( sb_Utils::getSubfieldByMnem( *curfield, "SFAX", cursubfield ) )
423     sb_Utils::getDoubleFromSubfield( cursubfield, iref_imp.scaleFactX_ );
424 
425    // SFAY
426   if ( sb_Utils::getSubfieldByMnem( *curfield, "SFAY", cursubfield ) )
427     sb_Utils::getDoubleFromSubfield( cursubfield, iref_imp.scaleFactY_ );
428 
429 #ifdef NOT_RASTER_PROFILE
430    // SFAZ
431   if ( sb_Utils::getSubfieldByMnem( *curfield, "SFAZ", cursubfield ) )
432     sb_Utils::getDoubleFromSubfield( cursubfield, iref_imp.scaleFactZ_ );
433 #endif
434 
435    // XORG
436   if ( sb_Utils::getSubfieldByMnem( *curfield, "XORG", cursubfield ) )
437     sb_Utils::getDoubleFromSubfield( cursubfield, iref_imp.xOrigin_ );
438 
439    // YORG
440   if ( sb_Utils::getSubfieldByMnem( *curfield, "YORG", cursubfield ) )
441     sb_Utils::getDoubleFromSubfield( cursubfield, iref_imp.yOrigin_ );
442 
443 #ifdef NOT_RASTER_PROFILE
444    // ZORG
445   if ( sb_Utils::getSubfieldByMnem( *curfield, "ZORG", cursubfield ) )
446     sb_Utils::getDoubleFromSubfield( cursubfield, iref_imp.zOrigin_ );
447 #endif
448 
449   // XHRS
450   if ( sb_Utils::getSubfieldByMnem( *curfield, "XHRS", cursubfield ) )
451     sb_Utils::getDoubleFromSubfield(  cursubfield,  iref_imp.xCompHorizRes_ );
452 
453    // YHRS
454   if ( sb_Utils::getSubfieldByMnem( *curfield, "YHRS", cursubfield ) )
455     sb_Utils::getDoubleFromSubfield(  cursubfield, iref_imp.yCompHorizRes_ );
456 
457 #ifdef NOT_RASTER_PROFILE
458    // VRES
459   if ( sb_Utils::getSubfieldByMnem( *curfield, "VRES", cursubfield ) )
460     sb_Utils::getDoubleFromSubfield(  cursubfield,  iref_imp.verticalResComp_ );
461 #endif
462 
463 
464   // Secondary Fields
465 
466 #ifdef NOT_IMPLEMENTED
467   sc_FieldCntr const& fields = record;
468   for ( curfield  = fields.begin( );
469         curfield != fields.end( );
470         curfield++ )
471     {
472       if ( curfield->getMnemonic(  ) == "DMID" )
473         iref_imp.dimensionID_.push_back( sb_ForeignID( *curfield )  );
474     }
475 #endif
476 
477    return true;
478 
479 } // ingest__record
480 
481 
482 
483 
484 bool
getComment(string & val) const485 sb_Iref::getComment(  string& val  ) const
486 {
487   if ( imp_->comment_ == UNVALUED_STRING )
488     {
489       return false;
490     }
491   val = imp_->comment_;
492   return true;
493 }
494 
495 
496 bool
getSpatialAddressType(string & val) const497 sb_Iref::getSpatialAddressType(  string& val  ) const
498 {
499   if ( imp_->spatialAddType_ == UNVALUED_STRING )
500     {
501       return false;
502     }
503   val = imp_->spatialAddType_;
504   return true;
505 }
506 
507 
508 bool
getSpatialAddressXLabel(string & val) const509 sb_Iref::getSpatialAddressXLabel(  string& val  ) const
510 {
511   if ( imp_->spatialAddXCompLbl_ == UNVALUED_STRING )
512     {
513       return false;
514     }
515   val = imp_->spatialAddXCompLbl_;
516   return true;
517 }
518 
519 
520 bool
getSpatialAddressYLabel(string & val) const521 sb_Iref::getSpatialAddressYLabel(  string& val  ) const
522 {
523   if ( imp_->spatialAddYCompLbl_ == UNVALUED_STRING )
524     {
525       return false;
526     }
527   val = imp_->spatialAddYCompLbl_;
528   return true;
529 }
530 
531 
532 bool
getHorizontalComponentFormat(string & val) const533 sb_Iref::getHorizontalComponentFormat(  string& val  ) const
534 {
535   if ( imp_->horizontalCompFmt_ == UNVALUED_STRING )
536     {
537       return false;
538     }
539   val = imp_->horizontalCompFmt_;
540   return true;
541 }
542 
543 
544 #ifdef NOT_RASTER_PROFILE
545 bool
getVerticalComponentFormat(string & val) const546 sb_Iref::getVerticalComponentFormat(  string& val  ) const
547 {
548   if ( imp_->verticalCompFmt_ == UNVALUED_STRING )
549     {
550       return false;
551     }
552   val = imp_->verticalCompFmt_;
553   return true;
554 }
555 #endif
556 
557 
558 bool
getScaleFactorX(double & val) const559 sb_Iref::getScaleFactorX(  double& val  ) const
560 {
561   if ( imp_->scaleFactX_ == UNVALUED_DOUBLE )
562     {
563       return false;
564     }
565   val = imp_->scaleFactX_;
566   return true;
567 }
568 
569 
570 bool
getScaleFactorY(double & val) const571 sb_Iref::getScaleFactorY(  double& val  ) const
572 {
573   if ( imp_->scaleFactY_ == UNVALUED_DOUBLE )
574     {
575       return false;
576     }
577   val = imp_->scaleFactY_;
578   return true;
579 }
580 
581 
582 #ifdef NOT_RASTER_PROFILE
583 bool
getScaleFactorZ(double & val) const584 sb_Iref::getScaleFactorZ(  double& val  ) const
585 {
586   if ( imp_->scaleFactZ_ == UNVALUED_DOUBLE )
587     {
588       return false;
589     }
590   val = imp_->scaleFactZ_;
591   return true;
592 }
593 #endif
594 
595 
596 bool
getXOrigin(double & val) const597 sb_Iref::getXOrigin(  double& val  ) const
598 {
599   if ( imp_->xOrigin_ == UNVALUED_DOUBLE )
600     {
601       return false;
602     }
603   val = imp_->xOrigin_;
604   return true;
605 }
606 
607 
608 bool
getYOrigin(double & val) const609 sb_Iref::getYOrigin(  double& val  ) const
610 {
611   if ( imp_->yOrigin_ == UNVALUED_DOUBLE )
612     {
613       return false;
614     }
615   val = imp_->yOrigin_;
616   return true;
617 }
618 
619 
620 #ifdef NOT_RASTER_PROFILE
621 bool
getZOrigin(double & val) const622 sb_Iref::getZOrigin(  double& val  ) const
623 {
624   if ( imp_->zOrigin_ == UNVALUED_DOUBLE )
625     {
626       return false;
627     }
628   val = imp_->zOrigin_;
629   return true;
630 }
631 #endif
632 
633 
634 bool
getXComponentHorizontalResolution(double & val) const635 sb_Iref::getXComponentHorizontalResolution(  double& val  ) const
636 {
637   if ( imp_->xCompHorizRes_ == UNVALUED_DOUBLE )
638     {
639       return false;
640     }
641   val = imp_->xCompHorizRes_;
642   return true;
643 }
644 
645 
646 bool
getYComponentHorizontalResolution(double & val) const647 sb_Iref::getYComponentHorizontalResolution(  double& val  ) const
648 {
649   if ( imp_->yCompHorizRes_ == UNVALUED_DOUBLE )
650     {
651       return false;
652     }
653   val = imp_->yCompHorizRes_;
654   return true;
655 }
656 
657 
658 #ifdef NOT_RASTER_PROFILE
659 bool
getVerticalResolutionComponent(double & val) const660 sb_Iref::getVerticalResolutionComponent(  double& val  ) const
661 {
662   if ( imp_->verticalResComp_ == UNVALUED_DOUBLE )
663     {
664       return false;
665     }
666   val = imp_->verticalResComp_;
667   return true;
668 }
669 #endif
670 
671 
672 #ifdef NOT_IMPLEMENTED
673 bool
getDimensionID(vector<sb_ForeignID> & fids) const674 sb_Iref::getDimensionID(  vector<sb_ForeignID>& fids  ) const
675 {
676   if (  imp_->dimensionID_.empty(  )  ) return false;
677 
678   fids = imp_->dimensionID_;
679 
680   return true;
681 }
682 #endif
683 
684 
685 bool
getRecord(sc_Record & record) const686 sb_Iref::getRecord( sc_Record & record ) const
687 {
688 
689   record.clear();               // start with a clean slate
690 
691   // IREF field
692 
693   record.push_back( sc_Field() );
694 
695   record.back().setMnemonic( "IREF" );
696 
697   string tmp_str;
698   double tmp_double;
699 
700   getMnemonic( tmp_str );
701   sb_Utils::add_subfield( record.back(), "MODN", tmp_str );
702   sb_Utils::add_subfield( record.back(), "RCID", getID() );
703 
704 
705   // Add each field and subfield to the record.  Bail if a mandatory
706   // subfield hasn't been set.
707 
708   if ( getCOMT( tmp_str ) )
709     {
710       sb_Utils::add_subfield( record.back(), "COMT", tmp_str );
711     }
712   else
713     {
714       sb_Utils::add_empty_subfield( record.back(), "COMT", sc_Subfield::is_A );
715     }
716 
717   set<string> SATP_domain;      // XXX this needs to be static const somewhere
718   SATP_domain.insert( TWO_TUPLE );
719   SATP_domain.insert( THREE_TUPLE );
720 
721   string SATP;
722 
723   if ( ! ( getSATP( SATP ) &&
724            sb_Utils::valid_domain( SATP, SATP_domain ) ) )
725     {
726       return false;
727     }
728   sb_Utils::add_subfield( record.back(), "SATP", SATP );
729 
730 
731   string XLBL;
732 
733   if ( ! getXLBL( XLBL ) )
734     {
735       return false;
736     }
737   sb_Utils::add_subfield( record.back(), "XLBL", XLBL );
738 
739 
740 
741   if ( ! getYLBL( tmp_str ) )   // some basic sanity checking
742     {
743       return false;
744     }
745   else if ( XLBL == LONGITUDE )
746     {
747       if ( tmp_str != LATITUDE ) return false;
748     }
749   else if ( XLBL == LATITUDE )
750     {
751       if ( tmp_str != LONGITUDE ) return false;
752     }
753   else if ( XLBL == EASTING )
754     {
755       if ( tmp_str != NORTHING ) return false;
756     }
757   else if ( XLBL == NORTHING )
758     {
759       if ( tmp_str != EASTING ) return false;
760     }
761 
762   sb_Utils::add_subfield( record.back(), "YLBL", tmp_str );
763 
764 
765   set<string> FMT_domain;
766   FMT_domain.insert( "I" );
767   FMT_domain.insert( "R" );
768   FMT_domain.insert( "S" );
769   FMT_domain.insert( "BI8" );
770   FMT_domain.insert( "BI16" );
771   FMT_domain.insert( "BI24" );
772   FMT_domain.insert( "BI32" );
773   FMT_domain.insert( "BUI" );
774   FMT_domain.insert( "BUI8" );
775   FMT_domain.insert( "BUI16" );
776   FMT_domain.insert( "BUI24" );
777   FMT_domain.insert( "BUI32" );
778   FMT_domain.insert( "BFP32" );
779   FMT_domain.insert( "BFP64" );
780 
781 
782   if ( ! ( getHFMT( tmp_str )  &&
783            sb_Utils::valid_domain( tmp_str, FMT_domain) ) )
784     {
785       return false;
786     }
787   sb_Utils::add_subfield( record.back(), "HFMT", tmp_str );
788 
789 
790 
791 #ifdef NOT_RASTER_PROFILE
792   if ( SATP == THREE_TUPLE )
793   {
794     if ( ! ( getVFMT( tmp_str )   &&
795              sb_Utils::valid_domain( tmp_str, FMT_domain) ) )
796     {
797       return false;
798     }
799     sb_Utils::add_subfield( record.back(), "VFMT", tmp_str );
800   }
801   else
802     {
803       sb_Utils::add_empty_subfield( record.back(), "VFMT", sc_Subfield::is_A );
804     }
805 #endif
806 
807 
808   if ( ! getSFAX( tmp_double ) )
809     {
810       return false;
811     }
812   sb_Utils::add_subfield( record.back(), "SFAX", tmp_double );
813 
814 
815 
816   if ( ! getSFAY( tmp_double ) )
817     {
818       return false;
819     }
820   sb_Utils::add_subfield( record.back(), "SFAY", tmp_double );
821 
822 
823 
824 #ifdef NOT_RASTER_PROFILE
825   if ( SATP == THREE_TUPLE )
826   {
827     if ( ! getSFAZ( tmp_double ) )
828     {
829       return false;
830     }
831     sb_Utils::add_subfield( record.back(), "SFAZ", tmp_double );
832   }
833   else
834     {
835       sb_Utils::add_empty_subfield( record.back(), "SFAZ", sc_Subfield::is_A );
836     }
837 #endif
838 
839 
840   if ( ! getXORG( tmp_double ) )
841     {
842       return false;
843     }
844   sb_Utils::add_subfield( record.back(), "XORG", tmp_double );
845 
846 
847 
848   if ( ! getYORG( tmp_double ) )
849     {
850       return false;
851     }
852   sb_Utils::add_subfield( record.back(), "YORG", tmp_double );
853 
854 
855 #ifdef NOT_RASTER_PROFILE
856   if ( SATP == THREE_TUPLE )
857   {
858     if ( ! getZORG( tmp_double ) )
859     {
860       return false;
861     }
862     sb_Utils::add_subfield( record.back(), "ZORG", tmp_double );
863   }
864   else
865     {
866       sb_Utils::add_empty_subfield( record.back(), "ZORG", sc_Subfield::is_A );
867     }
868 #endif
869 
870 
871   if ( ! getXHRS( tmp_double ) )
872     {
873       return false;
874     }
875   sb_Utils::add_subfield( record.back(), "XHRS", tmp_double );
876 
877 
878 
879   if ( ! getYHRS( tmp_double ) )
880     {
881       return false;
882     }
883   sb_Utils::add_subfield( record.back(), "YHRS", tmp_double );
884 
885 
886 
887 #ifdef NOT_RASTER_PROFILE
888   if ( SATP == THREE_TUPLE )
889   {
890     if ( ! getVRES( tmp_double ) )
891     {
892       return false;
893     }
894     sb_Utils::add_subfield( record.back(), "VRES", tmp_double );
895 
896   }
897   else
898     {
899       sb_Utils::add_empty_subfield( record.back(), "VRES", sc_Subfield::is_A );
900     }
901 #endif
902 
903   // XXX Dimension ID
904 
905 
906   return true;
907 
908 } // sb_Iref::getRecord
909 
910 
911 
912 
913 void
setComment(string const & val)914 sb_Iref::setComment( string const & val )
915 {
916   imp_->comment_ = val;
917 } // sb_Iref::setComment
918 
919 
920 void
setSpatialAddressType(string const & val)921 sb_Iref::setSpatialAddressType( string const & val )
922 {
923   imp_->spatialAddType_ = val;
924 } // sb_Iref::setSpatialAddressType
925 
926 
927 void
setSpatialAddressXLabel(string const & val)928 sb_Iref::setSpatialAddressXLabel( string const & val )
929 {
930   imp_->spatialAddXCompLbl_ = val;
931 } // sb_Iref::setSpatialAddressXLabel
932 
933 
934 void
setSpatialAddressYLabel(string const & val)935 sb_Iref::setSpatialAddressYLabel( string const & val )
936 {   imp_->spatialAddYCompLbl_ = val;
937 } // sb_Iref::setSpatialAddressYLabel
938 
939 
940 
941 void
setHorizontalComponentFormat(string const & val)942 sb_Iref::setHorizontalComponentFormat( string const & val )
943 {   imp_->horizontalCompFmt_ = val;
944 } // sb_Iref::setHorizontalComponentFormat
945 
946 
947 
948 #ifdef NOT_RASTER_PROFILE
949 void
setVerticalComponentFormat(string const & val)950 sb_Iref::setVerticalComponentFormat( string const & val )
951 {   imp_->verticalCompFmt_ = val;
952 } // sb_Iref::setVerticalComponentFormat
953 #endif
954 
955 
956 void
setScaleFactorX(double const & val)957 sb_Iref::setScaleFactorX( double const & val )
958 {   imp_->scaleFactX_ = val;
959 } // sb_Iref::setScaleFactorX
960 
961 
962 
963 void
setScaleFactorY(double const & val)964 sb_Iref::setScaleFactorY( double const & val )
965 {   imp_->scaleFactY_ = val;
966 } // sb_Iref::setScaleFactorY
967 
968 
969 
970 #ifdef NOT_RASTER_PROFILE
971 void
setScaleFactorZ(double const & val)972 sb_Iref::setScaleFactorZ( double const & val )
973 {   imp_->scaleFactZ_ = val;
974 } // sb_Iref::setScaleFactorZ
975 #endif
976 
977 
978 void
setXOrigin(double const & val)979 sb_Iref::setXOrigin( double const & val )
980 {   imp_->xOrigin_ = val;
981 } // sb_Iref::setXOrigin
982 
983 
984 
985 void
setYOrigin(double const & val)986 sb_Iref::setYOrigin( double const & val )
987 {   imp_->yOrigin_ = val;
988 } // sb_Iref::setYOrigin
989 
990 
991 
992 #ifdef NOT_RASTER_PROFILE
993 void
setZOrigin(double const & val)994 sb_Iref::setZOrigin( double const & val )
995 {   imp_->zOrigin_ = val;
996 } // sb_Iref::setZOrigin
997 #endif
998 
999 
1000 
1001 void
setXComponentHorizontalResolution(double const & val)1002 sb_Iref::setXComponentHorizontalResolution( double const & val )
1003 {   imp_->xCompHorizRes_ = val;
1004 } // sb_Iref::setXComponentHorizontalResolution
1005 
1006 
1007 
1008 void
setYComponentHorizontalResolution(double const & val)1009 sb_Iref::setYComponentHorizontalResolution( double const & val )
1010 {   imp_->yCompHorizRes_ = val;
1011 } // sb_Iref::setYComponentHorizontalResolution
1012 
1013 
1014 
1015 #ifdef NOT_RASTER_PROFILE
1016 void
setVerticalResolutionComponent(double const & val)1017 sb_Iref::setVerticalResolutionComponent( double const & val )
1018 {   imp_->verticalResComp_ = val;
1019 } // sb_Iref::setVerticalResolutionComponent
1020 #endif
1021 
1022 
1023 
1024 #ifdef NOT_IMPLEMENTED
1025 void
setDimensionID(vector<sb_ForeignID> const & val)1026 sb_Iref::setDimensionID( vector<sb_ForeignID> const & val )
1027 {   imp_->dimensionID_ = val;
1028 } // sb_Iref::setDimensionID
1029 #endif
1030 
1031 
1032 
1033 
1034 
1035 bool
setRecord(sc_Record const & record)1036 sb_Iref::setRecord( sc_Record const & record )
1037 {
1038   return ingest_record_( *this, *(this->imp_), record );
1039 } // sb_Iref::setRecord
1040 
1041 
1042 
1043