OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimNitfRpcBase.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: Garrett Potts
8 //
9 // Description: Nitf support class for RPC00A -
10 // Rational Polynomial Coefficient extension.
11 //
12 //********************************************************************
13 // $Id: ossimNitfRpcBase.cpp 22013 2012-12-19 17:37:20Z dburken $
14 
15 #include <algorithm>
16 #include <iostream>
17 #include <iomanip>
18 #include <vector>
22 #include <ossim/base/ossimTrace.h>
24 
25 static const ossimTrace traceDebug(ossimString("ossimNitfRpcBase:debug"));
26 static const ossimString ERR_BIAS_KW = "ERR_BIAS";
27 static const ossimString ERR_RAND_KW = "ERR_RAND";
28 static const ossimString LINE_OFF_KW = "LINE_OFF";
29 static const ossimString SAMP_OFF_KW = "SAMP_OFF";
30 static const ossimString LAT_OFF_KW = "LAT_OFF";
31 static const ossimString LONG_OFF_KW = "LONG_OFF";
32 static const ossimString HEIGHT_OFF_KW = "HEIGHT_OFF";
33 static const ossimString LINE_SCALE_KW = "LINE_SCALE";
34 static const ossimString SAMP_SCALE_KW = "SAMP_SCALE";
35 static const ossimString LAT_SCALE_KW = "LAT_SCALE";
36 static const ossimString LONG_SCALE_KW = "LONG_SCALE";
37 static const ossimString HEIGHT_SCALE_KW = "HEIGHT_SCALE";
38 static const ossimString LINE_NUM_COEFF_KW = "LINE_NUM_COEFF_";
39 static const ossimString LINE_DEN_COEFF_KW = "LINE_DEN_COEFF_";
40 static const ossimString SAMP_NUM_COEFF_KW = "SAMP_NUM_COEFF_";
41 static const ossimString SAMP_DEN_COEFF_KW = "SAMP_DEN_COEFF_";
42 
44 
45 
48 {
49  // Set the tag length in base.
50  setTagLength(1041);
51 
52  clearFields();
53 }
54 
56 {
57  clearFields();
58 
59  in.read(theSuccess, SUCCESS_SIZE);
60  in.read(theErrorBias, ERROR_BIAS_SIZE);
61  in.read(theErrRand, ERR_RAND_SIZE);
67  in.read(theLineScale, LINE_SCALE_SIZE);
72 
73  ossim_uint32 idx = 0;
74 
75  char temp1[LINE_NUMERATOR_COEFFICIENT_SIZE+1];
76  temp1[LINE_NUMERATOR_COEFFICIENT_SIZE] = '\0';
77  for(idx = 0; idx < LINE_NUMERATOR_COEFFICIENT_COUNT; ++idx)
78  {
79  in.read(temp1, LINE_NUMERATOR_COEFFICIENT_SIZE);
80  theLineNumeratorCoefficient[idx] = temp1;
81  }
82 
85  for(idx = 0; idx < LINE_DENOMINATOR_COEFFICIENT_COUNT; ++idx)
86  {
87  in.read(temp2, LINE_DENOMINATOR_COEFFICIENT_SIZE);
88  theLineDenominatorCoefficient[idx] = temp2;
89  }
90 
93  for(idx = 0; idx < SAMPLE_NUMERATOR_COEFFICIENT_COUNT; ++idx)
94  {
95  in.read(temp3, SAMPLE_NUMERATOR_COEFFICIENT_SIZE);
96  theSampleNumeratorCoefficient[idx] = temp3;
97  }
98 
101  for(idx = 0; idx < SAMPLE_DENOMINATOR_COEFFICIENT_COUNT; ++idx)
102  {
103  in.read(temp4, SAMPLE_DENOMINATOR_COEFFICIENT_SIZE);
104  theSampleDenominatorCoefficient[idx] = temp4;
105  }
106 }
107 
109 {
110  ossim_uint32 idx = 0;
111 
112  out.write(theSuccess, SUCCESS_SIZE);
113  out.write(theErrorBias, ERROR_BIAS_SIZE);
114  out.write(theErrRand, ERR_RAND_SIZE);
115  out.write(theLineOffset, LINE_OFFSET_SIZE);
120  out.write(theLineScale, LINE_SCALE_SIZE);
121  out.write(theSampleScale, SAMPLE_SCALE_SIZE);
125  for(idx = 0; idx < LINE_NUMERATOR_COEFFICIENT_COUNT; ++idx)
126  {
127  out.write(theLineNumeratorCoefficient[idx].c_str(),
129  }
130  for(idx = 0; idx < LINE_DENOMINATOR_COEFFICIENT_COUNT; ++idx)
131  {
132  out.write(theLineDenominatorCoefficient[idx].c_str(),
134  }
135  for(idx = 0; idx < SAMPLE_NUMERATOR_COEFFICIENT_COUNT; ++idx)
136  {
137  out.write(theSampleNumeratorCoefficient[idx].c_str(),
139  }
140  for(idx = 0; idx < SAMPLE_DENOMINATOR_COEFFICIENT_COUNT; ++idx)
141  {
142  out.write(theSampleDenominatorCoefficient[idx].c_str(),
144  }
145 }
146 
148 {
149  theSuccess[0] = '1';
150  memcpy(theErrorBias, "0000.00", 7);
151  memcpy(theErrRand, "0000.00", 7);
152  memcpy(theLineOffset, "000000", 6);
153  memcpy(theSampleOffset, "00000", 5);
154  memcpy(theGeodeticLatOffset, "+00.0000", 8);
155  memcpy(theGeodeticLonOffset, "+000.0000", 9);
156  memcpy(theGeodeticHeightOffset, "+0000", 5);
157  memcpy(theLineScale, "000001", 6);
158  memcpy(theSampleScale, "00001", 5);
159  memcpy(theGeodeticLatScale, "+00.0000", 8);
160  memcpy(theGeodeticLonScale, "+000.0000", 9);
161  memcpy(theGeodeticHeightScale, "+0000", 5);
162 
163  theSuccess[1] = '\0';
164  theErrorBias[7] = '\0';
165  theErrRand[7] = '\0';
166  theLineOffset[6] = '\0';
167  theSampleOffset[5] = '\0';
168  theGeodeticLatOffset[8]='\0';
169  theGeodeticLonOffset[9]='\0';
170  theGeodeticHeightOffset[5]='\0';
171  theLineScale[6]='\0';
172  theSampleScale[5]='\0';
173  theGeodeticLatScale[8]='\0';
174  theGeodeticLonScale[9]='\0';
175  theGeodeticHeightScale[5]='\0';
176 
177  theLineNumeratorCoefficient.resize(20);
181  ossim_uint32 idx = 0;
182  const char* zeroString = "+0.000000E+0";
183 
184  for(idx = 0; idx < theLineNumeratorCoefficient.size();++idx)
185  {
186  theLineNumeratorCoefficient[idx] = zeroString;
187  theLineDenominatorCoefficient[idx] = zeroString;;
188  theSampleNumeratorCoefficient[idx] = zeroString;;
189  theSampleDenominatorCoefficient[idx] = zeroString;;
190  }
191 }
192 
194 {
195  theSuccess[0] = '0';
196  if (!rpc)
197  return;
198 
199  theSuccess[0] = '1';
202  setLineOffset((int) rpc->theLineOffset);
203  setSampleOffset((int) rpc->theSampOffset);
207  setLineScale((int) rpc->theLineScale);
208  setSampleScale((int) rpc->theSampScale);
212 
213  int idx;
214  vector<double> coef (20);
215  for(idx = 0; idx < 20; ++idx)
216  coef.push_back(rpc->theLineNumCoef[idx]);
217  setLineNumeratorCoeff(coef);
218 
219  for(idx = 0; idx < 20; ++idx)
220  coef[idx] = rpc->theLineDenCoef[idx];
222 
223  for(idx = 0; idx < 20; ++idx)
224  coef[idx] = rpc->theSampNumCoef[idx];
226 
227  for(idx = 0; idx < 20; ++idx)
228  coef[idx] = rpc->theSampDenCoef[idx];
230 }
231 
233 {
234  return (theSuccess[0] == '1');
235 }
236 
238 {
239  theSuccess[0] = success?'1':'0';
240 }
241 
243 {
244  return theErrorBias;
245 }
246 
248 {
250  2,
252  setErrorBias(os);
253 }
254 
256 {
257  memset(theErrorBias, ' ', ERROR_BIAS_SIZE);
258  memcpy(theErrorBias, errorBias.c_str(), std::min((size_t)ERROR_BIAS_SIZE, errorBias.length()));
259 }
260 
262 {
263  return theErrRand;
264 }
265 
267 {
269  2,
271  setErrorRand(os);
272 }
273 
275 {
276  memset(theErrRand, ' ', ERR_RAND_SIZE);
277  memcpy(theErrRand, errorRand.c_str(), std::min((size_t)ERR_RAND_SIZE, errorRand.length()));
278 }
279 
281 {
282  return theLineOffset;
283 }
284 
286 {
289  setLineOffset(os);
290 }
291 
293 {
294  memset(theLineOffset, ' ', LINE_OFFSET_SIZE);
295  memcpy(theLineOffset, lineOffset.c_str(), std::min((size_t)LINE_OFFSET_SIZE, lineOffset.length()));
296 }
297 
299 {
300  return theSampleOffset;
301 }
302 
304 {
307  setSampleOffset(os);
308 }
309 
311 {
312  memset(theSampleOffset, ' ', SAMPLE_OFFSET_SIZE);
313  memcpy(theSampleOffset, sampleOffset.c_str(), std::min((size_t)SAMPLE_OFFSET_SIZE, sampleOffset.length()));
314 }
315 
317 {
318  return theGeodeticLatOffset;
319 }
320 
322  const ossim_float64& geodeticLatOffset)
323 {
324  if ( (geodeticLatOffset >= -90.0) && (geodeticLatOffset <= 90.0) )
325  {
326  ossimString os =
327  ossimNitfCommon::convertToDoubleString(geodeticLatOffset,
328  4,
331  }
332 }
333 
335  const ossimString& geodeticLatOffset)
336 {
338  memcpy(theGeodeticLatOffset, geodeticLatOffset.c_str(), std::min((size_t)GEODETIC_LAT_OFFSET_SIZE, geodeticLatOffset.length()));
339 }
340 
342 {
343  return theGeodeticLonOffset;
344 }
345 
347  const ossim_float64& geodeticLonOffset)
348 {
349  if ( (geodeticLonOffset >= -180.0) && (geodeticLonOffset <= 180.0) )
350  {
351  ossimString os =
352  ossimNitfCommon::convertToDoubleString(geodeticLonOffset,
353  4,
356  }
357 }
358 
360 {
362  memcpy(theGeodeticLonOffset, geodeticLonOffset.c_str(), std::min((size_t)GEODETIC_LON_OFFSET_SIZE, geodeticLonOffset.length()));
363 }
364 
366 {
368 }
369 
371  ossim_int32 geodeticHeightOffset)
372 {
373  ossimString os =
374  ossimNitfCommon::convertToIntString(geodeticHeightOffset,
377 }
378 
380 {
382  memcpy(theGeodeticHeightOffset, geodeticHeightOffset.c_str(), std::min((size_t)GEODETIC_HEIGHT_OFFSET_SIZE, geodeticHeightOffset.length()));
383 }
384 
386 {
387  return theLineScale;
388 }
389 
391 {
394  setLineScale(os);
395 }
396 
398 {
399  memset(theLineScale, ' ', LINE_SCALE_SIZE);
400  memcpy(theLineScale, lineScale.c_str(), std::min((size_t)LINE_SCALE_SIZE, lineScale.length()));
401 }
402 
404 {
405  return theSampleScale;
406 }
407 
409 {
412  setSampleScale(os);
413 }
414 
416 {
417  memset(theSampleScale, ' ', SAMPLE_SCALE_SIZE);
418  memcpy(theSampleScale, sampleScale.c_str(), std::min((size_t)SAMPLE_SCALE_SIZE, sampleScale.length()));
419 }
420 
422 {
423  return theGeodeticLatScale;
424 }
425 
427  const ossim_float64& geodeticLatScale)
428 {
429  if (geodeticLatScale == 0.0)
430  {
431  // Error scale cannot be zero.
432  return;
433  }
434 
435  if ( (geodeticLatScale >= -90.0) && (geodeticLatScale <= 90.0) )
436  {
438  4,
441  }
442 }
443 
445 {
447  memcpy(theGeodeticLatScale, geodeticLatScale.c_str(), std::min((size_t)GEODETIC_LAT_SCALE_SIZE, geodeticLatScale.length()));
448 }
449 
451 {
452  return theGeodeticLonScale;
453 }
454 
456  const ossim_float64& geodeticLonScale)
457 {
458  if (geodeticLonScale == 0.0)
459  {
460  // Error scale cannot be zero.
461  return;
462  }
463 
464  if ( (geodeticLonScale >= -180.0) && (geodeticLonScale <= 180.0) )
465  {
467  4,
470  }
471 }
472 
474 {
476  memcpy(theGeodeticLonScale, geodeticLonScale.c_str(), std::min((size_t)GEODETIC_LON_SCALE_SIZE, geodeticLonScale.length()));
477 }
478 
480 {
481  return theGeodeticHeightScale;
482 }
483 
485 {
486  ossimString os =
487  ossimNitfCommon::convertToIntString(geodeticHeightScale,
490 }
491 
493  const ossimString& geodeticHeightScale)
494 {
496  memcpy(theGeodeticHeightScale, geodeticHeightScale.c_str(), std::min((size_t)GEODETIC_HEIGHT_SCALE_SIZE, geodeticHeightScale.length()));
497 }
498 
499 /* Temp comment out until range error handling is decided.*/
500 #if 0
501 // The assert here will be ignored when compiled with -DNDEBUG so ossimSetError and fix the index
502 #define ASSERT_ARRAY_CONSTRAINT(expression, idx, correctedValue, module) \
503  assert(expression); \
504  ossimSetError(getClassName().c_str(), ossimErrorCodes::OSSIM_ERROR, \
505  "File %s line %d Module %s Error:\nArray index constraint error.\n", \
506  __FILE__, __LINE__, module); \
507  if (! (expression) ) idx = correctedValue;
508 
509 #endif
510 
512 {
513 //ASSERT_ARRAY_CONSTRAINT(idx >= 0 && idx < LINE_NUMERATOR_COEFFICIENT_COUNT,idx,0,"ossimNitfRpcBase::getLineNumeratorCoeff");
514 
516  {
517  if (traceDebug())
518  {
520  << "ossimNitfRpcBase::getLineNumeratorCoeff range error!"
521  << std::endl;
522  }
523  return ossimString();
524  }
525 
526  return theLineNumeratorCoefficient[idx];
527 }
528 
530  const std::vector<ossim_float64>& coeff)
531 {
532  if (coeff.size() != LINE_NUMERATOR_COEFFICIENT_COUNT)
533  {
534  // Error...
535  if (traceDebug())
536  {
538  << "ossimNitfRpcBase::setLineNumeratorCoeff WARNING:"
539  << "\nArray not of correct size!"
540  << std::endl;
541  }
542  return;
543  }
544 
545  for (ossim_uint32 i = 0; i < LINE_NUMERATOR_COEFFICIENT_COUNT; ++i)
546  {
549  setLineNumeratorCoeff(i, os);
550  }
551 }
552 
554  const ossimString& coeff)
555 {
556  // ASSERT_ARRAY_CONSTRAINT(idx >= 0 && idx < LINE_NUMERATOR_COEFFICIENT_COUNT,idx,0,"ossimNitfRpcBase::setLineNumeratorCoeff");
557 
559  {
561  << "ossimNitfRpcBase::setLineNumeratorCoeff range error!"
562  << std::endl;
563  return;
564  }
565 
566  std::string s(coeff, 0, LINE_NUMERATOR_COEFFICIENT_SIZE);
567  theLineNumeratorCoefficient[idx] = s;
568 }
569 
571 {
572  // ASSERT_ARRAY_CONSTRAINT(idx >= 0 && idx < LINE_DENOMINATOR_COEFFICIENT_COUNT,idx,0,"ossimNitfRpcBase::getLineDenominatorCoeff");
573 
575  {
577  << "ossimNitfRpcBase::getLineDenominatorCoeff range error!"
578  << std::endl;
579  return ossimString();
580  }
581 
582  return theLineDenominatorCoefficient[idx];
583 }
584 
586  const std::vector<ossim_float64>& coeff)
587 {
588  if (coeff.size() != LINE_DENOMINATOR_COEFFICIENT_COUNT)
589  {
590  // Error...
591  if (traceDebug())
592  {
594  << "ossimNitfRpcBase::setLineDenominatorCoeff WARNING:"
595  << "\nArray not of correct size!"
596  << std::endl;
597  }
598  return;
599  }
600 
602  {
606  }
607 }
608 
610  const ossimString& coeff)
611 {
612  // ASSERT_ARRAY_CONSTRAINT(idx >= 0 && idx < LINE_DENOMINATOR_COEFFICIENT_COUNT,idx,0,"ossimNitfRpcBase::setLineDenominatorCoeff");
613 
615  {
617  << "ossimNitfRpcBase::setLineDenominatorCoeff range error!"
618  << std::endl;
619  return;
620  }
621 
622  std::string s(coeff, 0, LINE_DENOMINATOR_COEFFICIENT_SIZE);
624 }
625 
627 {
628  // ASSERT_ARRAY_CONSTRAINT(idx >= 0 && idx < SAMPLE_NUMERATOR_COEFFICIENT_COUNT,idx,0,"ossimNitfRpcBase::getSampleNumeratorCoeff");
629 
631  {
633  << "ossimNitfRpcBase::getSampleNumeratorCoeff range error!"
634  << std::endl;
635  return ossimString();
636  }
637  return theSampleNumeratorCoefficient[idx];
638 }
639 
641  const std::vector<ossim_float64>& coeff)
642 {
643  if (coeff.size() != SAMPLE_NUMERATOR_COEFFICIENT_COUNT)
644  {
645  // Error...
646  if (traceDebug())
647  {
649  << "ossimNitfRpcBase::setSampleNumeratorCoeff WARNING:"
650  << "\nArray not of correct size!"
651  << std::endl;
652  }
653  return;
654  }
655 
657  {
661  }
662 }
663 
665  const ossimString& coeff)
666 {
667  // ASSERT_ARRAY_CONSTRAINT(idx >= 0 && idx < SAMPLE_NUMERATOR_COEFFICIENT_COUNT,idx,0,"ossimNitfRpcBase::setSampleNumeratorCoeff");
668 
670  {
672  << "ossimNitfRpcBase::setSampleNumeratorCoeff range error!"
673  << std::endl;
674  return;
675  }
676 
677  std::string s(coeff, 0, SAMPLE_NUMERATOR_COEFFICIENT_SIZE);
679 }
680 
682 {
683  // ASSERT_ARRAY_CONSTRAINT(idx >= 0 && idx < SAMPLE_DENOMINATOR_COEFFICIENT_COUNT,idx,0,"ossimNitfRpcBase::getSampleDenominatorCoeff");
684 
686  {
688  << "ossimNitfRpcBase::getSampleDenominatorCoeff range error!"
689  << std::endl;
690  return ossimString();
691  }
692 
694 }
695 
697  const std::vector<ossim_float64>& coeff)
698 {
699  if (coeff.size() != SAMPLE_DENOMINATOR_COEFFICIENT_COUNT)
700  {
701  // Error...
702  if (traceDebug())
703  {
705  << "ossimNitfRpcBase::setSampleDenominatorCoeff WARNING:"
706  << "\nArray not of correct size!"
707  << std::endl;
708  }
709  return;
710  }
711 
713  {
717  }
718 }
719 
721  ossim_uint32 idx, const ossimString& coeff)
722 {
723  // ASSERT_ARRAY_CONSTRAINT(idx >= 0 && idx < SAMPLE_DENOMINATOR_COEFFICIENT_COUNT,idx,0,"ossimNitfRpcBase::setSampleDenominatorCoeff");
724 
726  {
728  << "ossimNitfRpcBase::setSampleDenominatorCoeff range error!"
729  << std::endl;
730  return;
731  }
732 
733  std::string s(coeff, 0, SAMPLE_DENOMINATOR_COEFFICIENT_SIZE);
736 }
737 
739  const std::string& prefix) const
740 {
741  std::string pfx = prefix;
742  pfx += getTagName();
743  pfx += ".";
744 
745  out << setiosflags(std::ios::left)
746  << pfx << std::setw(24) << "CETAG:"
747  << getTagName() << "\n"
748  << pfx << std::setw(24) << "CEL:"
749  << getSizeInBytes() << "\n"
750  << pfx << std::setw(24) << "SUCCESS:"
751  << theSuccess << "\n"
752  << pfx << std::setw(24) << "ERR_BIAS:"
753  << theErrorBias << "\n"
754  << pfx << std::setw(24) << "ERR_RAND:"
755  <<theErrRand << "\n"
756  << pfx << std::setw(24) << "LINE_OFF:"
757  << theLineOffset << "\n"
758  << pfx << std::setw(24) << "SAMP_OFF:"
759  << theSampleOffset << "\n"
760  << pfx << std::setw(24) << "LAT_OFF:"
761  << theGeodeticLatOffset << "\n"
762  << pfx << std::setw(24) << "LONG_OFF:"
763  << theGeodeticLonOffset << "\n"
764  << pfx << std::setw(24) << "HEIGHT_OFF:"
765  << theGeodeticHeightOffset << "\n"
766  << pfx << std::setw(24) << "LINE_SCALE:"
767  << theLineScale << "\n"
768  << pfx << std::setw(24)
769  << "SAMP_SCALE:" << theSampleScale << "\n"
770  << pfx << std::setw(24) << "LAT_SCALE:"
771  << theGeodeticLatScale << "\n"
772  << pfx << std::setw(24) << "LONG_SCALE:"
773  << theGeodeticLonScale << "\n"
774  << pfx << std::setw(24) << "HEIGHT_SCALE:"
775  << theGeodeticHeightScale << "\n";
776 
777  ossim_int32 i;
778  ossimString s;
779 
780  for (i=0; i<LINE_NUMERATOR_COEFFICIENT_COUNT; ++i)
781  {
782  s = "LINE_NUM_COEFF_";
783  s += ossimString::toString(i);
784  s += ":";
785  out << pfx << std::setw(24) << s
786  << theLineNumeratorCoefficient[i] << "\n";
787  }
788 
789  for (i=0; i<LINE_DENOMINATOR_COEFFICIENT_COUNT; ++i)
790  {
791  s = "LINE_DEN_COEFF_";
792  s += ossimString::toString(i);
793  s += ":";
794  out << pfx << std::setw(24) << s
795  << theLineDenominatorCoefficient[i] << "\n";
796  }
797 
798  for (i=0; i<LINE_NUMERATOR_COEFFICIENT_COUNT; ++i)
799  {
800  s = "SAMP_NUM_COEFF_";
801  s += ossimString::toString(i);
802  s += ":";
803  out << pfx << std::setw(24) << s
804  << theSampleNumeratorCoefficient[i] << "\n";
805  }
806 
807  for (i=0; i<LINE_DENOMINATOR_COEFFICIENT_COUNT; ++i)
808  {
809  s = "SAMP_DEN_COEFF_";
810  s += ossimString::toString(i);
811  s += ":";
812  out << pfx << std::setw(24) << s
813  << theSampleDenominatorCoefficient[i] << "\n";
814  }
815 
816  out.flush();
817 
818  return out;
819 }
820 
822 {
823 
824 }
825 
827 {
828  ossimProperty* result = 0;
829  if(name == ERR_BIAS_KW)
830  {
831  result = new ossimStringProperty(name, theErrorBias);
832  }
833  else if(name == ERR_RAND_KW)
834  {
835  result = new ossimStringProperty(name, theErrRand);
836  }
837  else if(name == LINE_OFF_KW)
838  {
839  result = new ossimStringProperty(name, theLineOffset);
840  }
841  else if(name == SAMP_OFF_KW)
842  {
843  result = new ossimStringProperty(name, theSampleOffset);
844  }
845  else if(name == LAT_OFF_KW)
846  {
847  result = new ossimStringProperty(name, theGeodeticLatOffset);
848  }
849  else if(name == LONG_OFF_KW)
850  {
851  result = new ossimStringProperty(name, theGeodeticLonOffset);
852  }
853  else if(name == HEIGHT_OFF_KW)
854  {
855  result = new ossimStringProperty(name, theGeodeticHeightOffset);
856  }
857  else if(name == LINE_SCALE_KW)
858  {
859  result = new ossimStringProperty(name, theLineScale);
860  }
861  else if(name == SAMP_SCALE_KW)
862  {
863  result = new ossimStringProperty(name,theSampleScale );
864  }
865  else if(name == LAT_SCALE_KW)
866  {
867  result = new ossimStringProperty(name, theGeodeticLatScale);
868  }
869  else if(name == LONG_SCALE_KW)
870  {
871  result = new ossimStringProperty(name, theGeodeticLonScale);
872  }
873  else if(name == HEIGHT_SCALE_KW)
874  {
875  result = new ossimStringProperty(name, theGeodeticHeightScale);
876  }
877  else if(name.contains(LINE_NUM_COEFF_KW))
878  {
879  ossim_uint32 idx = 0;
880 
881  idx = ossimString(name.begin()+LINE_NUM_COEFF_KW.length(),
882  name.end()).toUInt32();
883  --idx;
884 
885  if(idx < theLineNumeratorCoefficient.size())
886  {
887  result = new ossimStringProperty(name, theLineNumeratorCoefficient[idx]);
888  }
889  }
890  else if(name.contains(LINE_DEN_COEFF_KW))
891  {
892  ossim_uint32 idx = 0;
893 
894  idx = ossimString(name.begin()+LINE_DEN_COEFF_KW.length(),
895  name.end()).toUInt32();
896  --idx;
897 
898  if(idx < theLineDenominatorCoefficient.size())
899  {
900  result = new ossimStringProperty(name, theLineDenominatorCoefficient[idx]);
901  }
902  }
903  else if(name.contains(SAMP_NUM_COEFF_KW))
904  {
905  ossim_uint32 idx = 0;
906 
907  idx = ossimString(name.begin()+SAMP_NUM_COEFF_KW.length(),
908  name.end()).toUInt32();
909  --idx;
910 
911  if(idx < theSampleNumeratorCoefficient.size())
912  {
913  result = new ossimStringProperty(name, theSampleNumeratorCoefficient[idx]);
914  }
915  }
916  else if(name.contains(SAMP_DEN_COEFF_KW))
917  {
918  ossim_uint32 idx = 0;
919 
920  idx = ossimString(name.begin()+SAMP_DEN_COEFF_KW.length(),
921  name.end()).toUInt32();
922  --idx;
923 
924  if(idx < theSampleDenominatorCoefficient.size())
925  {
926  result = new ossimStringProperty(name, theSampleDenominatorCoefficient[idx]);
927  }
928  }
929 
930  return result;
931 }
932 
933 void ossimNitfRpcBase::getPropertyNames(std::vector<ossimString>& propertyNames)const
934 {
935  ossim_uint32 idx = 0;
936 
937  propertyNames.push_back(ERR_BIAS_KW);
938  propertyNames.push_back(ERR_RAND_KW);
939  propertyNames.push_back(LINE_OFF_KW);
940  propertyNames.push_back(SAMP_OFF_KW);
941  propertyNames.push_back(LAT_OFF_KW);
942  propertyNames.push_back(LONG_OFF_KW);
943  propertyNames.push_back(HEIGHT_OFF_KW);
944  propertyNames.push_back(LINE_SCALE_KW);
945  propertyNames.push_back(SAMP_SCALE_KW);
946  propertyNames.push_back(LAT_SCALE_KW);
947  propertyNames.push_back(LONG_SCALE_KW);
948  propertyNames.push_back(HEIGHT_SCALE_KW);
949 
950  for(idx = 1; idx <= 20; ++idx)
951  {
952  propertyNames.push_back(LINE_NUM_COEFF_KW+ossimString::toString(idx));
953  }
954  for(idx = 1; idx <= 20; ++idx)
955  {
956  propertyNames.push_back(LINE_DEN_COEFF_KW+ossimString::toString(idx));
957  }
958  for(idx = 1; idx <= 20; ++idx)
959  {
960  propertyNames.push_back(SAMP_NUM_COEFF_KW+ossimString::toString(idx));
961  }
962  for(idx = 1; idx <= 20; ++idx)
963  {
964  propertyNames.push_back(SAMP_DEN_COEFF_KW+ossimString::toString(idx));
965  }
966 }
967 
968 bool ossimNitfRpcBase::loadState(const ossimKeywordlist& kwl, const char* prefix)
969 {
970  bool result = ossimNitfRegisteredTag::loadState(kwl, prefix);
971  const char* lookup;
972 
973  if(!result) return result;
974  lookup = kwl.find(prefix, "SUCCESS");
975  if(lookup)
976  {
977  strcpy(theSuccess, lookup);
978  }
979  lookup = kwl.find(prefix, "ERR_BIAS");
980  if(lookup)
981  {
982  strcpy(theErrorBias, lookup);
983  }
984  lookup = kwl.find(prefix, "ERR_RAND");
985  if(lookup)
986  {
987  strcpy(theErrRand, lookup);
988  }
989  lookup = kwl.find(prefix, "LINE_OFF");
990  if(lookup)
991  {
992  strcpy(theLineOffset, lookup);
993  }
994  lookup = kwl.find(prefix, "SAMP_OFF");
995  if(lookup)
996  {
997  strcpy(theSampleOffset, lookup);
998  }
999  lookup = kwl.find(prefix, "LAT_OFF");
1000  if(lookup)
1001  {
1002  strcpy(theGeodeticLatOffset, lookup);
1003  }
1004  lookup = kwl.find(prefix, "LONG_OFF");
1005  if(lookup)
1006  {
1007  strcpy(theGeodeticLonOffset, lookup);
1008  }
1009  lookup = kwl.find(prefix, "HEIGHT_OFF");
1010  if(lookup)
1011  {
1012  strcpy(theGeodeticHeightOffset, lookup);
1013  }
1014  lookup = kwl.find(prefix, "LINE_SCALE");
1015  if(lookup)
1016  {
1017  strcpy(theLineScale, lookup);
1018  }
1019  lookup = kwl.find(prefix, "SAMP_SCALE");
1020  if(lookup)
1021  {
1022  strcpy(theSampleScale, lookup);
1023  }
1024  lookup = kwl.find(prefix, "LAT_SCALE");
1025  if(lookup)
1026  {
1027  strcpy(theGeodeticLatScale, lookup);
1028  }
1029  lookup = kwl.find(prefix, "LONG_SCALE");
1030  if(lookup)
1031  {
1032  strcpy(theGeodeticLonScale, lookup);
1033  }
1034  lookup = kwl.find(prefix, "HEIGHT_SCALE");
1035  if(lookup)
1036  {
1037  strcpy(theGeodeticHeightScale, lookup);
1038  }
1039  for (ossim_uint32 i = 0; i < 20; ++i)
1040  {
1041  ossimString line_num_coeff = "LINE_NUM_COEFF_" + ossimString::toString(i);
1042  lookup = kwl.find(prefix, line_num_coeff);
1043  if(lookup)
1044  {
1045  theLineNumeratorCoefficient[i] = ossimString(lookup); //temp.substr(0,1) + "0." + temp.substr(1,6) + "E" + temp.substr(7,2);
1046  }
1047  }
1048  for (ossim_uint32 i = 0; i < 20; ++i)
1049  {
1050  ossimString line_den_coeff = "LINE_DEN_COEFF_" + ossimString::toString(i);
1051  lookup = kwl.find(prefix, line_den_coeff);
1052  if(lookup)
1053  {
1054  theLineDenominatorCoefficient[i] = ossimString(lookup); //temp.substr(0,1) + "0." + temp.substr(1,6) + "E" + temp.substr(7,2);
1055  }
1056  }
1057  for (ossim_uint32 i = 0; i < 20; ++i)
1058  {
1059  ossimString samp_num_coeff = "SAMP_NUM_COEFF_" + ossimString::toString(i);
1060  lookup = kwl.find(prefix, samp_num_coeff);
1061  if(lookup)
1062  {
1063  theSampleNumeratorCoefficient[i] = ossimString(lookup); //temp.substr(0,1) + "0." + temp.substr(1,6) + "E" + temp.substr(7,2);
1064  }
1065  }
1066  for (ossim_uint32 i = 0; i < 20; ++i)
1067  {
1068  ossimString samp_den_coeff = "SAMP_DEN_COEFF_" + ossimString::toString(i);
1069  lookup = kwl.find(prefix, samp_den_coeff);
1070  if(lookup)
1071  {
1072  theSampleDenominatorCoefficient[i] = ossimString(lookup); //temp.substr(0,1) + "0." + temp.substr(1,6) + "E" + temp.substr(7,2);
1073  }
1074  }
1075 
1076  return result;
1077 }
double theSampOffset
ossimString getLineScale() const
double theSampNumCoef[20]
std::vector< ossimString > theLineNumeratorCoefficient
FIELD: LINE_NUM_COEFF_1 through LINE_NUM_COEFF_20.
virtual const std::string & getTagName() const
This will return the name of the registered tag for this user defined header.
virtual void parseStream(std::istream &in)
Parse method.
ossimString getGeodeticHeightScale() const
bool loadState(const ossimKeywordlist &kwl, const char *prefix)
char theGeodeticLonScale[GEODETIC_LON_SCALE_SIZE+1]
FIELD: LON_SCALE.
std::vector< ossimString > theSampleNumeratorCoefficient
FIELD: SAMP_NUM_COEFF_1 through SAMP_NUM_COEFF_20.
ossimString getLineDenominatorCoeff(ossim_uint32 idx) const
Represents serializable keyword/value map.
char theErrorBias[ERROR_BIAS_SIZE+1]
FIELD: ERR_BIAS.
RTTI_DEF1(ossimNitfRpcBase, "ossimNitfRpcBase", ossimNitfRegisteredTag)
const char * find(const char *key) const
bool getSuccess() const
char theLineScale[LINE_SCALE_SIZE+1]
FIELD: LINE_SCALE.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
bool contains(char aChar) const
Definition: ossimString.h:58
virtual void writeStream(std::ostream &out)
Write method.
static ossimString toString(bool aValue)
Numeric to string methods.
virtual void setRpcModelParams(ossimRefPtr< ossimRpcModel > rpc)
For generating the RPC tag from existing RPC Model.
void setLineScale(ossim_uint32 lineScale)
ossimString getSampleOffset() const
virtual void getPropertyNames(std::vector< ossimString > &propertyNames) const
std::vector< ossimString > theSampleDenominatorCoefficient
FIELD: SAMP_DEN_COEFF_1 through SAMP_DEN_COEFF_20.
void setSuccess(bool success)
void setGeodeticLatOffset(const ossim_float64 &geodeticLatOffset)
void setSampleScale(ossim_uint32 sampleScale)
double theLonScale
virtual void setTagLength(ossim_uint32 length)
Set the tag length.
void setSampleDenominatorCoeff(const std::vector< ossim_float64 > &coeff)
double theLineScale
char theSampleScale[SAMPLE_SCALE_SIZE+1]
FIELD: SAMP_SCALE.
std::string::iterator end()
Definition: ossimString.h:423
ossimNitfRpcBase()
default constructor
ossimString getSampleDenominatorCoeff(ossim_uint32 idx) const
void setGeodeticLatScale(const ossim_float64 &geodeticLatScale)
double theSampDenCoef[20]
ossimString getLineOffset() const
double theLineNumCoef[20]
double theLatOffset
double ossim_float64
void setGeodeticLonOffset(const ossim_float64 &geodeticLonOffset)
static ossimString convertToDoubleString(const ossim_float64 &aValue, ossim_uint32 precision, ossim_uint32 size)
This method takes a value and converts to a string of size with requested precision with a &#39;0&#39; fill...
char theGeodeticHeightScale[GEODETIC_HEIGHT_SCALE_SIZE+1]
FIELD: HEIGHT_SCALE.
double theHgtOffset
double theLonOffset
ossimString getGeodeticHeightOffset() const
double theRandError
void setSampleNumeratorCoeff(const std::vector< ossim_float64 > &coeff)
void setErrorRand(const ossim_float64 &errorRand)
char theErrRand[ERR_RAND_SIZE+1]
FIELD ERR_RAND.
std::string::size_type length() const
Definition: ossimString.h:408
virtual ossimRefPtr< ossimProperty > getProperty(const ossimString &name) const
static ossimString convertToScientificString(const ossim_float64 &aValue, ossim_uint32 size)
This method takes a value and a size(or width) and converts it to a scientific notation sting in the ...
double theLatScale
std::string::iterator begin()
Definition: ossimString.h:420
char theGeodeticLatOffset[GEODETIC_LAT_OFFSET_SIZE+1]
FIELD: LAT_OFF.
unsigned int ossim_uint32
void setSampleOffset(ossim_uint32 sampleOffset)
virtual std::ostream & print(std::ostream &out, const std::string &prefix=std::string()) const
Print method that outputs a key/value type format adding prefix to keys.
void setGeodeticLonScale(const ossim_float64 &geodeticLonScale)
char theSuccess[SUCCESS_SIZE+1]
FIELD: SUCCESS.
char theGeodeticLatScale[GEODETIC_LAT_SCALE_SIZE+1]
FIELD: LAT_SCALE.
void setLineOffset(ossim_uint32 lineOffset)
char theGeodeticHeightOffset[GEODETIC_HEIGHT_OFFSET_SIZE+1]
FIELD: HEIGHT_OFF.
ossimString getErrorBias() const
ossimString getLineNumeratorCoeff(ossim_uint32 idx) const
static ossimString convertToUIntString(ossim_uint32 aValue, ossim_uint32 size)
This method takes a value and converts to a string of size with with a &#39;0&#39; fill.
void setErrorBias(const ossim_float64 &errorBias)
std::basic_istream< char > istream
Base class for char input streams.
Definition: ossimIosFwd.h:20
ossimString getSampleNumeratorCoeff(ossim_uint32 idx) const
virtual ossim_uint32 getSizeInBytes() const
Returns the length in bytes of the tag from the CEL or REL field.
ossimString getGeodeticLatScale() const
virtual void clearFields()
Clears all string fields within the record to some default nothingness.
const char * c_str() const
Returns a pointer to a null-terminated array of characters representing the string&#39;s contents...
Definition: ossimString.h:396
ossimString getErrorRand() const
double theSampScale
char theGeodeticLonOffset[GEODETIC_LON_OFFSET_SIZE+1]
FIELD: LONG_OFF.
char theSampleOffset[SAMPLE_OFFSET_SIZE+1]
FIELD: SAMP_OFF.
char theLineOffset[LINE_OFFSET_SIZE+1]
FIELD: LINE_OFF.
ossimString getGeodeticLonOffset() const
static ossimString convertToIntString(ossim_int32 aValue, ossim_uint32 size)
Just like convertToUIntString only takes a signed value.
void setLineDenominatorCoeff(const std::vector< ossim_float64 > &coeff)
virtual void setProperty(ossimRefPtr< ossimProperty > property)
ossimString getSampleScale() const
double theLineDenCoef[20]
ossimString getGeodeticLatOffset() const
double theLineOffset
double theHgtScale
double theBiasError
error
ossimString getGeodeticLonScale() const
void setGeodeticHeightScale(ossim_int32 geodeticHeightScale)
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::vector< ossimString > theLineDenominatorCoefficient
FIELD: LINE_DEN_COEFF_1 through LINE_DEN_COEFF_20.
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
void setLineNumeratorCoeff(const std::vector< ossim_float64 > &coeff)
void setGeodeticHeightOffset(ossim_int32 geodeticHeightOffset)
#define min(a, b)
Definition: auxiliary.h:75
int ossim_int32