OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimRadarSat2ProductDoc.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 // Description: Utility class to encapsulate parsing RadarSat2 product.xml
8 // file.
9 //
10 //----------------------------------------------------------------------------
11 // $Id$
12 
14 #include <ossimPluginCommon.h>
15 #include <otb/CivilDateTime.h>
16 #include <otb/Ephemeris.h>
18 #include <otb/JSDDateTime.h>
19 #include <otb/PlatformPosition.h>
20 #include <otb/SarSensor.h>
21 #include <otb/SensorParams.h>
22 #include <otb/RefPoint.h>
23 #include <ossim/base/ossimDpt.h>
25 #include <ossim/base/ossimGpt.h>
26 #include <ossim/base/ossimIpt.h>
27 #include <ossim/base/ossimNotify.h>
28 #include <ossim/base/ossimRefPtr.h>
29 #include <ossim/base/ossimString.h>
30 #include <ossim/base/ossimTrace.h>
33 
34 #include <sstream>
35 #include <vector>
36 
37 using namespace std;
38 
39 
40 namespace ossimplugins
41 {
42 
43 
44 // Static trace for debugging
45 static ossimTrace traceDebug("ossimRadarSat2ProductDoc:debug");
46 
47 
48 ossimRadarSat2ProductDoc::ossimRadarSat2ProductDoc()
49 {
50 }
51 
52 ossimRadarSat2ProductDoc::~ossimRadarSat2ProductDoc()
53 {
54 }
55 
56 bool ossimRadarSat2ProductDoc::isRadarSat2(const ossimXmlDocument* xdoc) const
57 {
58  bool result = false;
59  if (xdoc)
60  {
61  ossimString s;
62  getSatellite(xdoc, s);
63  if (s.upcase() == "RADARSAT-2")
64  {
65  result = true;
66  }
67  }
68  return result;
69 }
70 
71 bool ossimRadarSat2ProductDoc::initPlatformPosition(
72  const ossimXmlDocument* xdoc, PlatformPosition* pos) const
73 {
74  static const char MODULE[] =
75  "ossimRadarSat2ProductDoc::initPlatformPosition";
76  if (traceDebug())
77  {
78  ossimNotify(ossimNotifyLevel_DEBUG)<< MODULE << " entered...\n";
79  }
80 
81  bool result = true;
82 
83  if ( xdoc && pos )
84  {
85  // Get all the stateVector nodes.
86  ossimString path =
87  "/product/sourceAttributes/orbitAndAttitude/orbitInformation/stateVector";
88  std::vector<ossimRefPtr<ossimXmlNode> > xnodes;
89  xdoc->findNodes(path, xnodes);
90  if ( xnodes.size() )
91  {
92  const std::vector<ossimRefPtr<ossimXmlNode> >::size_type COUNT =
93  xnodes.size();
94 
95  Ephemeris** ephemeris = new Ephemeris*[COUNT];
96  for (ossim_uint32 idx = 0; idx < COUNT; ++idx)
97  {
98  ephemeris[idx] = 0;
99  }
100 
101  int nbrData = 0; // to keep track of good stateVector count.
102 
103  ossimRefPtr<ossimXmlNode> svNode = 0; // stateVector node
104 
105  for (ossim_uint32 i = 0 ; i < COUNT; ++i)
106  {
107  svNode = xnodes[i];
108  if ( !svNode )
109  {
110  result = false;
111  break;
112  }
113 
114  double pos[3];
115  double vit[3];
116  CivilDateTime eph_civil_date;
117  ossimString s;
118 
119  path = "timeStamp";
120  result = ossim::findFirstNode(path, svNode, s);
121  if (result)
122  {
123  ossim::iso8601TimeStringToCivilDate(s, eph_civil_date);
124  }
125  else
126  {
127  result = false;
129  << MODULE << " ERROR:\nNode not found: " << path
130  << std::endl;
131  break;
132  }
133 
134  path = "xPosition";
135  result = ossim::findFirstNode(path, svNode, s);
136  if (result)
137  {
138  pos[0] = s.toDouble();
139  }
140  else
141  {
142  result = false;
144  << MODULE << " ERROR:\nNode not found: " << path
145  << std::endl;
146  break;
147  }
148 
149  path = "yPosition";
150  result = ossim::findFirstNode(path, svNode, s);
151  if (result)
152  {
153  pos[1] = s.toDouble();
154  }
155  else
156  {
157  result = false;
159  << MODULE << " ERROR:\nNode not found: " << path
160  << std::endl;
161  break;
162  }
163 
164  path = "zPosition";
165  result = ossim::findFirstNode(path, svNode, s);
166  if (result)
167  {
168  pos[2] = s.toDouble();
169  }
170  else
171  {
172  result = false;
174  << MODULE << " ERROR:\nNode not found: " << path
175  << std::endl;
176  break;
177  }
178 
179  path = "xVelocity";
180  result = ossim::findFirstNode(path, svNode, s);
181  if (result)
182  {
183  vit[0] = s.toDouble();
184  }
185  else
186  {
187  result = false;
189  << MODULE << " ERROR:\nNode not found: " << path
190  << std::endl;
191  break;
192  }
193 
194  path = "yVelocity";
195  result = ossim::findFirstNode(path, svNode, s);
196  if (result)
197  {
198  vit[1] = s.toDouble();
199  }
200  else
201  {
202  result = false;
204  << MODULE << " ERROR:\nNode not found: " << path
205  << std::endl;
206  break;
207  }
208 
209  path = "zVelocity";
210  result = ossim::findFirstNode(path, svNode, s);
211  if (result)
212  {
213  vit[2] = s.toDouble();
214  }
215  else
216  {
217  result = false;
219  << MODULE << " ERROR:\nNode not found: " << path
220  << std::endl;
221  break;
222  }
223 
224  JSDDateTime eph_jsd_date(eph_civil_date);
225  GeographicEphemeris* eph =
226  new GeographicEphemeris(eph_jsd_date, pos, vit);
227  ephemeris[i] = eph;
228  ++nbrData;
229 
230  } // matches: for (int i = 0 ; i < nbrData; ++i)
231 
232  if (result)
233  {
234  if (traceDebug())
235  {
237  << " DEBUG\nnbrData: " << nbrData << "\n";
238  }
239  pos->setData(ephemeris, nbrData);
240  }
241 
242  // Clean up. Note: PlatformPosition::setData clones the ephemeris stuff.
243  for (int idx = 0; idx < nbrData; ++idx)
244  {
245  delete ephemeris[idx];
246  }
247  delete [] ephemeris;
248  ephemeris = 0;
249 
250  } // matches: if ( xnodes.size() )
251  else
252  {
253  result = false;
255  << MODULE << " ERROR:\nNodes not found: " << path << std::endl;
256  }
257 
258  } // matches: if (xdoc && pos)
259  else
260  {
261  result = false;
262  }
263 
264  if (traceDebug())
265  {
267  << MODULE << " exit status = " << (result?"true\n":"false\n");
268  }
269 
270  return result;
271 }
272 
273 bool ossimRadarSat2ProductDoc::initSensorParams(const ossimXmlDocument* xdoc,
274  SensorParams* sp) const
275 {
276  bool result = true;
277 
278  if (xdoc && sp)
279  {
280  ossimString s;
281 
282  // Get the number of azimuth looks.
283  if ( getNumberOfAzimuthLooks(xdoc, s) )
284  {
285  sp->set_nAzimuthLook(s.toDouble());
286  }
287  else
288  {
289  result = false;
290  }
291 
292  //---
293  // drb ???
294  // Get the nominal PRF
295  //---
296  double prf;
297  if ( getNominalPrf(xdoc, prf) )
298  {
299  //sp->set_prf(prf * sp->get_nAzimuthLook() );
300  sp->set_prf(prf);
301  }
302  else
303  {
304  result = false;
305  }
306 
307  // Get the Sampling frequency.
308  if ( getAdcSamplingRate(xdoc, s) )
309  {
310  sp->set_sf(s.toDouble());
311  }
312  else
313  {
314  result = false;
315  }
316 
317  // Get the radar wave length.
318  if ( getRadarCenterFrequency(xdoc, s) )
319  {
320  const double CLUM = 2.99792458e+8 ;
321  double waveLength = CLUM / s.toDouble();
322  sp->set_rwl(waveLength);
323  }
324  else
325  {
326  result = false;
327  }
328 
329  // Get columns direction (1=increasing, -1=decreasing).
330  if ( getLineTimeOrdering(xdoc, s) )
331  {
332  if (s.downcase() == "increasing")
333  {
334  sp->set_col_direction(1);
335  }
336  else
337  {
338  sp->set_col_direction(-1);
339  }
340  }
341  else
342  {
343  result = false;
344  }
345 
346  // Get lines direction (1=increasing, -1=decreasing).
347  if ( getPixelTimeOrdering(xdoc, s) )
348  {
349  if (s.downcase() == "increasing")
350  {
351  sp->set_lin_direction(1);
352  }
353  else
354  {
355  sp->set_lin_direction(-1);
356  }
357  }
358  else
359  {
360  result = false;
361  }
362 
363  // Get the antenna pointing direction.
364  if ( getAntennaPointing(xdoc, s) )
365  {
366  if ( s.downcase() == "right")
367  {
368  sp->set_sightDirection(SensorParams::Right);
369  }
370  else
371  {
372  sp->set_sightDirection(SensorParams::Left);
373  }
374  }
375  else
376  {
377  result = false;
378  }
379 
380  // Get the ellipsoid semi_major axis, m, Default : WGS84
381  if ( getSemiMajorAxis(xdoc, s) )
382  {
383  sp->set_semiMajorAxis(s.toDouble());
384  }
385  else
386  {
387  result = false;
388  }
389 
390  // Get the ellipsoid semi_minor axis, m, Default : WGS84
391  if ( getSemiMinorAxis(xdoc, s) )
392  {
393  sp->set_semiMinorAxis(s.toDouble());
394  }
395  else
396  {
397  result = false;
398  }
399 
400 
401  // Get the number of range looks.
402  if ( getNumberOfRangeLooks(xdoc, s) )
403  {
404  sp->set_nRangeLook(s.toDouble());
405  }
406  else
407  {
408  result = false;
409  }
410 
411  } // matches: if (xdoc && sp)
412  else
413  {
414  result = false;
415  }
416 
417  return result;
418 }
419 
420 bool ossimRadarSat2ProductDoc::initImageSize(const ossimXmlDocument* xdoc,
421  ossimIpt& imageSize) const
422 {
423  bool result = true;
424 
425  if (xdoc)
426  {
427  ossimString s;
428  if ( getNumberOfSamplesPerLine(xdoc, s) )
429  {
430  imageSize.x = static_cast<ossim_int32>(s.toFloat64());
431  }
432  else
433  {
434  result = false;
435  }
436  if ( getNumberOfLines(xdoc, s) )
437  {
438  imageSize.y = static_cast<ossim_int32>(s.toFloat64());
439  }
440  else
441  {
442  result = false;
443  }
444  }
445  else
446  {
447  result = false;
448  }
449 
450  if (traceDebug())
451  {
453  << "ossimRadarSat2ProductDoc::initImageSize DEBUG:\nimage size: "
454  << imageSize
455  << "\nexit status = " << (result?"true":"false")
456  << std::endl;
457  }
458 
459  return result;
460 }
461 
462 bool ossimRadarSat2ProductDoc::initGsd(const ossimXmlDocument* xdoc,
463  ossimDpt& gsd) const
464 {
465  bool result = true;
466 
467  if (xdoc)
468  {
469  ossimString s;
470  if ( getSampledPixelSpacing(xdoc, s) )
471  {
472  gsd.x = s.toFloat64();
473  }
474  else
475  {
476  result = false;
477  }
478  if ( getSampledLineSpacing(xdoc, s) )
479  {
480  gsd.y = s.toFloat64(s);
481  }
482  else
483  {
484  result = false;
485  }
486  }
487  else
488  {
489  result = false;
490  }
491 
492  if (traceDebug())
493  {
495  << "ossimRadarSat2ProductDoc::initGsd DEBUG:\ngsd: " << gsd
496  << "\nexit status = " << (result?"true":"false")
497  << std::endl;
498  }
499 
500  return result;
501 }
502 
503 bool ossimRadarSat2ProductDoc::initTiePoints(const ossimXmlDocument* xdoc,
504  std::list<ossimGpt>& gcp,
505  std::list<ossimDpt>& icp) const
506 {
507  static const char MODULE[] = "ossimRadarSat2ProductDoc::initTiePoints";
508 
509  bool result = true;
510 
511  if (traceDebug())
512  {
513  ossimNotify(ossimNotifyLevel_DEBUG) << MODULE << " DEBUG:\n";
514  }
515 
516  if (xdoc)
517  {
518  ossimString path = "/product/imageAttributes/geographicInformation/geolocationGrid/imageTiePoint";
519  std::vector<ossimRefPtr<ossimXmlNode> > xnodes;
520  xdoc->findNodes(path, xnodes);
521  if ( xnodes.size() )
522  {
523  for (ossim_uint32 i = 0; i < xnodes.size(); ++i)
524  {
525  if (xnodes[i].valid())
526  {
527  ossimRefPtr<ossimXmlNode> icNode = 0; // imageCoordinate
528  icNode =
529  xnodes[i]->findFirstNode(ossimString("imageCoordinate"));
530  if (icNode.valid())
531  {
532  ossimString s;
533  ossimDpt dpt;
534  result = ossim::findFirstNode(ossimString("line"),
535  icNode, s);
536  if (result)
537  {
538  dpt.y = s.toDouble();
539  }
540  result = ossim::findFirstNode(ossimString("pixel"),
541  icNode, s);
542  if (result)
543  {
544  dpt.x = s.toDouble();
545  }
546  icp.push_back(dpt);
547 
548  if (traceDebug())
549  {
551  << "dpt" << i << ": " << dpt
552  << "\n";
553  }
554  }
555  else
556  {
557  result = false;
558  }
559 
560  ossimRefPtr<ossimXmlNode> gcNode = 0; // geodeticCoordinate
561  gcNode = xnodes[i]->findFirstNode(
562  ossimString("geodeticCoordinate"));
563  if (gcNode.valid())
564  {
565  ossimString s;
566  ossimGpt gpt;
567  result = ossim::findFirstNode(ossimString("latitude"),
568  gcNode, s);
569  if (result)
570  {
571  gpt.lat = s.toDouble();
572  }
573  result = ossim::findFirstNode(ossimString("longitude"),
574  gcNode, s);
575  if (result)
576  {
577  gpt.lon = s.toDouble();
578  }
579  result = ossim::findFirstNode(ossimString("height"),
580  gcNode, s);
581  if (result)
582  {
583  gpt.hgt = s.toDouble();
584  }
585  gcp.push_back(gpt);
586 
587  if (traceDebug())
588  {
590  << "gpt" << i << ": " << gpt
591  << "\n";
592  }
593 
594  } // matches: if (gcNode.valid())
595  else
596  {
597  result = false;
598  }
599 
600  } // if (xnodes[i].valid())
601 
602  } // mathches: for (ossim_uint32 i = 0; i < xnodes.size(); ++i)
603 
604  } // matches: if ( xnodes.size() )
605  else
606  {
607  result = false; // No nodes found.
608  }
609  } // matches: if (xdoc)
610  else
611  {
612  result = false; // Null pointer passed in.
613  }
614 
615  if (traceDebug())
616  {
618  << MODULE << " DEBUG: exit status = " << (result?"true":"false")
619  << std::endl;
620  }
621 
622  return result;
623 }
624 
625 
626 RPCModel ossimRadarSat2ProductDoc::getRpcData(const ossimXmlDocument* xdoc) const
627 {
628  ossimString path = "/product/imageAttributes/geographicInformation/rationalFunctions/satellite";
629 
630  RPCModel model;
631 
632  ossimString searchbiasError = "/product/imageAttributes/geographicInformation/rationalFunctions/biasError"; //the line (y-coordinate)
633  ossimString searchrandomError = "/product/imageAttributes/geographicInformation/rationalFunctions/randomError"; //the line (y-coordinate)
634  ossimString searchlineFitQuality = "/product/imageAttributes/geographicInformation/rationalFunctions/lineFitQuality"; //the line (y-coordinate)
635  ossimString searchpixelFitQuality = "/product/imageAttributes/geographicInformation/rationalFunctions/pixelFitQuality"; //the line (y-coordinate)
636  ossimString searchlineOffset = "/product/imageAttributes/geographicInformation/rationalFunctions/lineOffset"; //the line (y-coordinate)
637  ossimString searchpixelOffset = "/product/imageAttributes/geographicInformation/rationalFunctions/pixelOffset"; //the line (y-coordinate)
638  ossimString searchlatitudeOffset = "/product/imageAttributes/geographicInformation/rationalFunctions/latitudeOffset"; //the line (y-coordinate)
639  ossimString searchlongitudeOffset = "/product/imageAttributes/geographicInformation/rationalFunctions/longitudeOffset"; //the line (y-coordinate)
640  ossimString searchheightOffset = "/product/imageAttributes/geographicInformation/rationalFunctions/heightOffset"; //the line (y-coordinate)
641  ossimString searchlineScale = "/product/imageAttributes/geographicInformation/rationalFunctions/lineScale"; //the line (y-coordinate)
642  ossimString searchpixelScale = "/product/imageAttributes/geographicInformation/rationalFunctions/pixelScale"; //the line (y-coordinate)
643  ossimString searchlatitudeScale = "/product/imageAttributes/geographicInformation/rationalFunctions/latitudeScale"; //the line (y-coordinate)
644  ossimString searchlongitudeScale = "/product/imageAttributes/geographicInformation/rationalFunctions/longitudeScale"; //the line (y-coordinate)
645  ossimString searchheightScale = "/product/imageAttributes/geographicInformation/rationalFunctions/heightScale"; //the line (y-coordinate)
646 
647  ossimString searchlineNumeratorCoefficients = "/product/imageAttributes/geographicInformation/rationalFunctions/lineNumeratorCoefficients"; //the line (y-coordinate)
648  ossimString searchlineDenominatorCoefficients = "/product/imageAttributes/geographicInformation/rationalFunctions/lineDenominatorCoefficients"; //the line (y-coordinate)
649  ossimString searchpixelNumeratorCoefficients = "/product/imageAttributes/geographicInformation/rationalFunctions/pixelNumeratorCoefficients"; //the line (y-coordinate)
650  ossimString searchpixelDenominatorCoefficients = "/product/imageAttributes/geographicInformation/rationalFunctions/pixelDenominatorCoefficients"; //the line (y-coordinate)
651 
652 
653  // strings to hold values found
654  ossimString biasErrorStr;;
655  ossimString randomErrorStr;
656  ossimString lineFitQualityStr;
657  ossimString pixelFitQualityStr;
658  ossimString lineOffsetStr;
659  ossimString pixelOffsetStr;
660  ossimString latitudeOffsetStr;
661  ossimString longitudeOffsetStr;
662  ossimString heightOffsetStr;
663  ossimString lineScaleStr;
664  ossimString pixelScaleStr;
665  ossimString latitudeScaleStr;
666  ossimString longitudeScaleStr;
667  ossimString heightScaleStr;
668 
669  std::vector<ossimString> lineNumeratorCoefficientsStr;
670  std::vector<ossimString> lineDenominatorCoefficientsStr;
671  std::vector<ossimString> pixelNumeratorCoefficientsStr;
672  std::vector<ossimString> pixelDenominatorCoefficientsStr;
673 
674 
675  // doubles to hold values found
676  double biasError = 0;
677  double randomError = 0;
678  double lineFitQuality = 0;
679  double pixelFitQuality = 0;
680  double lineOffset = 0;
681  double pixelOffset = 0;
682  double latitudeOffset = 0;
683  double longitudeOffset = 0;
684  double heightOffset = 0;
685  double lineScale = 0;
686  double pixelScale = 0;
687  double latitudeScale = 0;
688  double longitudeScale = 0;
689  double heightScale = 0;
690 
691  vector<double> lineNumeratorCoefficients = vector<double>(20,0);
692  vector<double> lineDenominatorCoefficients = vector<double>(20,0);
693  vector<double> pixelNumeratorCoefficients = vector<double>(20,0);
694  vector<double> pixelDenominatorCoefficients = vector<double>(20,0);
695 
696  //the final string outputs to the text file
697 
698  //check if this function is being called on the correct SAR data type
699  //function is only applicable for RS2 product.xml files
700  bool rs2Check = isRadarSat2(xdoc);
701  if (rs2Check)
702  {
703  if (!ossim::getPath(searchbiasError, xdoc, biasErrorStr))
704  ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
705  biasError = biasErrorStr.toDouble();
706 
707  if (!ossim::getPath(searchrandomError, xdoc, randomErrorStr))
708  ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
709  randomError = randomErrorStr.toDouble();
710 
711  if (!ossim::getPath(searchlineFitQuality, xdoc, lineFitQualityStr))
712  ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
713  lineFitQuality = lineFitQualityStr.toDouble();
714 
715  if (!ossim::getPath(searchpixelFitQuality, xdoc, pixelFitQualityStr))
716  ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
717  pixelFitQuality = pixelFitQualityStr.toDouble();
718 
719  if (!ossim::getPath(searchlineOffset, xdoc, lineOffsetStr))
720  ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
721  lineOffset = lineOffsetStr.toDouble();
722 
723  if (!ossim::getPath(searchpixelOffset, xdoc, pixelOffsetStr))
724  ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
725  pixelOffset = pixelOffsetStr.toDouble();
726 
727  if (!ossim::getPath(searchlatitudeOffset, xdoc, latitudeOffsetStr))
728  ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
729  latitudeOffset = latitudeOffsetStr.toDouble();
730 
731  if (!ossim::getPath(searchlongitudeOffset, xdoc, longitudeOffsetStr))
732  ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
733  longitudeOffset = longitudeOffsetStr.toDouble();
734 
735  if (!ossim::getPath(searchheightOffset, xdoc, heightOffsetStr))
736  ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
737  heightOffset = heightOffsetStr.toDouble();
738 
739  // --------------
740 
741  if (!ossim::getPath(searchlineScale, xdoc, lineScaleStr))
742  ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
743  lineScale = lineScaleStr.toDouble();
744 
745 
746  if (!ossim::getPath(searchpixelScale, xdoc, pixelScaleStr))
747  ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
748  pixelScale = pixelScaleStr.toDouble();
749 
750 
751  if (!ossim::getPath(searchlatitudeScale, xdoc, latitudeScaleStr))
752  ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
753  latitudeScale = latitudeScaleStr.toDouble();
754 
755  // -----------------------
756 
757  if (!ossim::getPath(searchlongitudeScale, xdoc, longitudeScaleStr))
758  ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
759  longitudeScale = longitudeScaleStr.toDouble();
760 
761 
762  if (!ossim::getPath(searchheightScale, xdoc, heightScaleStr))
763  ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
764  heightScale = heightScaleStr.toDouble();
765 
766  // ---- parameters for reading in coeefs ------------
767 
768  double val=0;
769 
770  // -------------------------------------
771 
772 
773  if (!ossim::getPath(searchlineNumeratorCoefficients, xdoc, lineNumeratorCoefficientsStr))
774  ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
775 
776 
777  string lineNumeratorCoefficientsStr_N = lineNumeratorCoefficientsStr[0];
778  // place into a stream
779  std::stringstream LNstream(lineNumeratorCoefficientsStr_N);
780 
781  for (int i=0; i < 20; i ++)
782  {
783  LNstream >> val;
784  lineNumeratorCoefficients[i] = val;
785  }
786 
787  // ------------------
788 
789  if (!ossim::getPath(searchlineDenominatorCoefficients, xdoc, lineDenominatorCoefficientsStr))
790  ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
791 
792 
793  string lineDenominatorCoefficientsStr_N = lineDenominatorCoefficientsStr[0];
794 
795  // place into a stream
796  std::stringstream LDstream(lineDenominatorCoefficientsStr_N);
797 
798  for (int i=0; i < 20; i ++)
799  {
800  LDstream >> val;
801  lineDenominatorCoefficients[i] = val;
802  }
803 
804  // ------------------
805 
806  if (!ossim::getPath(searchpixelNumeratorCoefficients, xdoc, pixelNumeratorCoefficientsStr))
807  ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
808 
809  string pixelNumeratorCoefficientsStr_N = pixelNumeratorCoefficientsStr[0];
810 
811  // place into a stream
812  std::stringstream PNstream(pixelNumeratorCoefficientsStr_N);
813 
814  for (int i=0; i < 20; i ++)
815  {
816  PNstream >> val;
817  pixelNumeratorCoefficients[i] = val;
818  }
819 
820  // ------------------
821 
822  if (!ossim::getPath(searchpixelDenominatorCoefficients, xdoc, pixelDenominatorCoefficientsStr))
823  ossimNotify(ossimNotifyLevel_WARN) << "ERROR: UNABLE TO FIND RS2 RPC COEFFICIENT INFORMATION" << endl;
824 
825  string pixelDenominatorCoefficientsStr_N = pixelDenominatorCoefficientsStr[0];
826 
827  // place into a stream
828  std::stringstream PDstream(pixelDenominatorCoefficientsStr_N);
829 
830  for (int i=0; i < 20; i ++)
831  {
832  PDstream >> val;
833  pixelDenominatorCoefficients[i] = val;
834  }
835 
836  // end character search term
837 
838  model.biasError = biasError;
839  model.randomError = randomError;
840  model.lineFitQuality = lineFitQuality;
841  model.pixelFitQuality = pixelFitQuality;
842  model.lineOffset = lineOffset;
843  model.pixelOffset = pixelOffset;
844  model.latitudeOffset = latitudeOffset;
845  model.longitudeOffset = longitudeOffset;
846  model.heightOffset = heightOffset;
847  model.lineScale = lineScale;
848  model.pixelScale = pixelScale;
849  model.latitudeScale = latitudeScale;
850  model.longitudeScale = longitudeScale;
851  model.heightScale = heightScale;
852  model.lineNumeratorCoefficients = lineNumeratorCoefficients;
853  model.lineDenominatorCoefficients = lineDenominatorCoefficients;
854  model.pixelNumeratorCoefficients = pixelNumeratorCoefficients;
855  model.pixelDenominatorCoefficients = pixelDenominatorCoefficients;
856  }
857 
858  return model;
859 }
860 
861 bool ossimRadarSat2ProductDoc::getSatellite(const ossimXmlDocument* xdoc,
862  ossimString& s) const
863 {
864  ossimString path = "/product/sourceAttributes/satellite";
865  // The saved File is an ossimKeywordlist
866 
867  return ossim::getPath(path, xdoc, s);
868 }
869 
870 bool ossimRadarSat2ProductDoc::getSensor(const ossimXmlDocument* xdoc,
871  ossimString& s) const
872 {
873  ossimString path = "/product/sourceAttributes/sensor";
874  return ossim::getPath(path, xdoc, s);
875 }
876 
877 bool ossimRadarSat2ProductDoc::getBeamModeMnemonic(
878  const ossimXmlDocument* xdoc, ossimString& s) const
879 {
880  ossimString path = "/product/sourceAttributes/beamModeMnemonic";
881  return ossim::getPath(path, xdoc, s);
882 }
883 
884 bool ossimRadarSat2ProductDoc::getImageId(const ossimXmlDocument* xdoc,
885  ossimString& s) const
886 {
887  ossimString path = "/product/sourceAttributes/imageId";
888  return ossim::getPath(path, xdoc, s);
889 }
890 
891 bool ossimRadarSat2ProductDoc::getImageFile(const ossimXmlDocument* xdoc,
892  ossimString& s) const
893 {
894  bool result = false;
895  ossimString fileName;
896 
897  ossimString path = "/product/imageAttributes/fullResolutionImageData";
898 
899  if ( ossim::getPath(path, xdoc, fileName) )
900  {
901  result = true;
902  s = fileName;
903  }
904 
905  return result;
906 }
907 
908 bool ossimRadarSat2ProductDoc::getAcquisitionType(
909  const ossimXmlDocument* xdoc, ossimString& s) const
910 {
911  ossimString path =
912  "/product/sourceAttributes/radarParameters/acquisitionType";
913  return ossim::getPath(path, xdoc, s);
914 }
915 
916 bool ossimRadarSat2ProductDoc::getRadarCenterFrequency(
917  const ossimXmlDocument* xdoc, ossimString& s) const
918 {
919  ossimString path =
920  "/product/sourceAttributes/radarParameters/radarCenterFrequency";
921  return ossim::getPath(path, xdoc, s);
922 }
923 
924 //---
925 // drb ???
926 //
927 // Temporary until we decide how to get nominal prf from multiple nodes.
928 // drb - 15 April 2009
929 //---
930 bool ossimRadarSat2ProductDoc::getNominalPrf(const ossimXmlDocument* xdoc,
931  double& prf) const
932 {
933  bool result = false;
934  std::vector<ossimString> v;
935  if ( getPulseRepetitionFrequency(xdoc, v) )
936  {
937  if (v.size())
938  {
939  double d = 0;
940  std::vector<ossimString>::const_iterator i = v.begin();
941  while (i < v.end())
942  {
943  d += (*i).toDouble();
944  ++i;
945  }
946  prf = d / v.size();
947  result = true;
948  }
949  }
950  if (traceDebug())
951  {
953  << "ossimRadarSat2ProductDoc::getNominalPrf DEBUG:\nprf = "
954  << prf << "\nexit status = " << (result?"true":"false")
955  << std::endl;
956  }
957  return result;
958 }
959 
960 bool ossimRadarSat2ProductDoc::getPulseRepetitionFrequency(
961  const ossimXmlDocument* xdoc, std::vector<ossimString>& v) const
962 {
963  ossimString path =
964  "/product/sourceAttributes/radarParameters/pulseRepetitionFrequency";
965  return ossim::getPath(path, xdoc, v);
966 }
967 
968 bool ossimRadarSat2ProductDoc::getAntennaPointing(
969  const ossimXmlDocument* xdoc, ossimString& s) const
970 {
971  ossimString path =
972  "/product/sourceAttributes/radarParameters/antennaPointing";
973  return ossim::getPath(path, xdoc, s);
974 }
975 
976 bool ossimRadarSat2ProductDoc::getAdcSamplingRate(
977  const ossimXmlDocument* xdoc, ossimString& s) const
978 {
979  ossimString path =
980  "/product/sourceAttributes/radarParameters/adcSamplingRate";
981  return ossim::getPath(path, xdoc, s);
982 }
983 
984 bool ossimRadarSat2ProductDoc::getPassDirection(
985  const ossimXmlDocument* xdoc, ossimString& s) const
986 {
987  ossimString path =
988  "/product/sourceAttributes/orbitAndAttitude/orbitInformation/passDirection";
989  return ossim::getPath(path, xdoc, s);
990 }
991 
992 bool ossimRadarSat2ProductDoc::getProductType(
993  const ossimXmlDocument* xdoc, ossimString& s) const
994 {
995  ossimString path =
996  "/product/imageGenerationParameters/generalProcessingInformation/productType";
997  return ossim::getPath(path, xdoc, s);
998 }
999 
1000 bool ossimRadarSat2ProductDoc::getZeroDopplerTimeFirstLine(
1001  const ossimXmlDocument* xdoc, ossimString& s) const
1002 {
1003  ossimString path =
1004  "/product/imageGenerationParameters/sarProcessingInformation/zeroDopplerTimeFirstLine";
1005  return ossim::getPath(path, xdoc, s);
1006 }
1007 
1008 bool ossimRadarSat2ProductDoc::getNumberOfRangeLooks(
1009  const ossimXmlDocument* xdoc, ossimString& s) const
1010 {
1011  ossimString path =
1012  "/product/imageGenerationParameters/sarProcessingInformation/numberOfRangeLooks";
1013  return ossim::getPath(path, xdoc, s);
1014 }
1015 
1016 bool ossimRadarSat2ProductDoc::getNumberOfAzimuthLooks(
1017  const ossimXmlDocument* xdoc, ossimString& s) const
1018 {
1019  ossimString path =
1020  "/product/imageGenerationParameters/sarProcessingInformation/numberOfAzimuthLooks";
1021  return ossim::getPath(path, xdoc, s);
1022 }
1023 
1024 bool ossimRadarSat2ProductDoc::getSlantRangeNearEdge(
1025  const ossimXmlDocument* xdoc, ossimString& s) const
1026 {
1027  ossimString path =
1028  "/product/imageGenerationParameters/sarProcessingInformation/slantRangeNearEdge";
1029  return ossim::getPath(path, xdoc, s);
1030 }
1031 
1032 bool ossimRadarSat2ProductDoc::getZeroDopplerAzimuthTime(
1033  const ossimXmlDocument* xdoc, std::vector<ossimString>& v) const
1034 {
1035  ossimString path =
1036  "/product/imageGenerationParameters/slantRangeToGroundRange/zeroDopplerAzimuthTime";
1037  return ossim::getPath(path, xdoc, v);
1038 }
1039 
1040 bool ossimRadarSat2ProductDoc::getGroundRangeOrigin(
1041  const ossimXmlDocument* xdoc, std::vector<ossimString>& v) const
1042 {
1043  ossimString path =
1044  "/product/imageGenerationParameters/slantRangeToGroundRange/groundRangeOrigin";
1045  return ossim::getPath(path, xdoc, v);
1046 }
1047 
1048 bool ossimRadarSat2ProductDoc::getGroundToSlantRangeCoefficients(
1049  const ossimXmlDocument* xdoc, std::vector<ossimString>& v) const
1050 {
1051  ossimString path =
1052  "/product/imageGenerationParameters/slantRangeToGroundRange/groundToSlantRangeCoefficients";
1053  return ossim::getPath(path, xdoc, v);
1054 }
1055 
1056 bool ossimRadarSat2ProductDoc::getSemiMajorAxis(
1057  const ossimXmlDocument* xdoc, ossimString& s) const
1058 {
1059  ossimString path =
1060  "/product/imageAttributes/geographicInformation/referenceEllipsoidParameters/semiMajorAxis";
1061  return ossim::getPath(path, xdoc, s);
1062 }
1063 
1064 bool ossimRadarSat2ProductDoc::getSemiMinorAxis(
1065  const ossimXmlDocument* xdoc, ossimString& s) const
1066 {
1067  ossimString path =
1068  "/product/imageAttributes/geographicInformation/referenceEllipsoidParameters/semiMinorAxis";
1069  return ossim::getPath(path, xdoc, s);
1070 }
1071 
1072 bool ossimRadarSat2ProductDoc::getNumberOfSamplesPerLine(
1073  const ossimXmlDocument* xdoc, ossimString& s) const
1074 {
1075  ossimString path =
1076  "/product/imageAttributes/rasterAttributes/numberOfSamplesPerLine";
1077  return ossim::getPath(path, xdoc, s);
1078 }
1079 
1080 bool ossimRadarSat2ProductDoc::getNumberOfLines(
1081  const ossimXmlDocument* xdoc, ossimString& s) const
1082 {
1083  ossimString path =
1084  "/product/imageAttributes/rasterAttributes/numberOfLines";
1085  return ossim::getPath(path, xdoc, s);
1086 }
1087 
1088 bool ossimRadarSat2ProductDoc::getSampledPixelSpacing(
1089  const ossimXmlDocument* xdoc, ossimString& s) const
1090 {
1091  ossimString path =
1092  "/product/imageAttributes/rasterAttributes/sampledPixelSpacing";
1093  return ossim::getPath(path, xdoc, s);
1094 }
1095 
1096 bool ossimRadarSat2ProductDoc::getSampledLineSpacing(
1097  const ossimXmlDocument* xdoc, ossimString& s) const
1098 {
1099  ossimString path =
1100  "/product/imageAttributes/rasterAttributes/sampledLineSpacing";
1101  return ossim::getPath(path, xdoc, s);
1102 }
1103 
1104 bool ossimRadarSat2ProductDoc::getLineTimeOrdering(
1105  const ossimXmlDocument* xdoc, ossimString& s) const
1106 {
1107  ossimString path =
1108  "/product/imageAttributes/rasterAttributes/lineTimeOrdering";
1109  return ossim::getPath(path, xdoc, s);
1110 }
1111 
1112 bool ossimRadarSat2ProductDoc::getPixelTimeOrdering(
1113  const ossimXmlDocument* xdoc, ossimString& s) const
1114 {
1115  ossimString path =
1116  "/product/imageAttributes/rasterAttributes/pixelTimeOrdering";
1117  return ossim::getPath(path, xdoc, s);
1118 }
1119 
1120 bool ossimRadarSat2ProductDoc::getIncidenceAngleNearRange(
1121  const ossimXmlDocument* xdoc, ossimString& s) const
1122 {
1123  ossimString path =
1124  "/product/imageGenerationParameters/sarProcessingInformation/incidenceAngleNearRange";
1125  return ossim::getPath(path, xdoc, s);
1126 }
1127 
1128 bool ossimRadarSat2ProductDoc::getIncidenceAngleFarRange(
1129  const ossimXmlDocument* xdoc, ossimString& s) const
1130 {
1131  ossimString path =
1132  "/product/imageGenerationParameters/sarProcessingInformation/incidenceAngleFarRange ";
1133  return ossim::getPath(path, xdoc, s);
1134 }
1135 
1136 bool ossimRadarSat2ProductDoc::getSatelliteHeight(
1137  const ossimXmlDocument* xdoc, ossimString& s) const
1138 {
1139  ossimString path =
1140  "/product/imageGenerationParameters/sarProcessingInformation/satelliteHeight";
1141  return ossim::getPath(path, xdoc, s);
1142 }
1143 
1144 bool ossimRadarSat2ProductDoc::getGeodeticTerrainHeight(
1145  const ossimXmlDocument* xdoc, ossimString& s) const
1146 {
1147  ossimString path =
1148  "/product/imageAttributes/geographicInformation/referenceEllipsoidParameters/geodeticTerrainHeight";
1149  return ossim::getPath(path, xdoc, s);
1150 }
1151 
1152 } // matches: namespace ossimplugins
This class represent an ephemeris in Geographic coordinates system.
void set_sightDirection(SightDirection sight)
Definition: SensorParams.h:93
This class represents a date and time in the civil format.
Definition: CivilDateTime.h:30
static ossimString upcase(const ossimString &aString)
Definition: ossimString.cpp:34
std::basic_stringstream< char > stringstream
Class for char mixed input and output memory streams.
Definition: ossimIosFwd.h:38
void set_rwl(double rwl)
Definition: SensorParams.h:83
This class handles the platform position.
bool valid() const
Definition: ossimRefPtr.h:75
double y
Definition: ossimDpt.h:165
void set_lin_direction(int dir)
Definition: SensorParams.h:128
ossim_float64 hgt
Height in meters above the ellipsiod.
Definition: ossimGpt.h:274
vector< double > pixelNumeratorCoefficients
bool iso8601TimeStringToCivilDate(const std::string &dataString, CivilDateTime &outputDate)
Converts date string from ISO 8601 format to CivilDateTime.
This class handles the sensor parameters.
Definition: SensorParams.h:29
const ossimRefPtr< ossimXmlNode > & findFirstNode(const ossimString &rel_xpath) const
void set_semiMinorAxis(double value)
Definition: SensorParams.h:158
This class represents an ephemeris.
Definition: Ephemeris.h:28
ossim_float64 lon
Definition: ossimGpt.h:266
unsigned int ossim_uint32
double toDouble() const
ossim_float64 toFloat64() const
void set_semiMajorAxis(double value)
Definition: SensorParams.h:153
static ossimString downcase(const ossimString &aString)
Definition: ossimString.cpp:48
void set_nRangeLook(double look)
Definition: SensorParams.h:138
vector< double > lineNumeratorCoefficients
vector< double > pixelDenominatorCoefficients
void setData(Ephemeris **data, int nbrData)
vector< double > lineDenominatorCoefficients
ossim_int32 y
Definition: ossimIpt.h:142
bool findFirstNode(const ossimString &path, ossimRefPtr< ossimXmlNode > node, ossimString &s)
Finds from node with path from node and initializes string.
double x
Definition: ossimDpt.h:164
void set_nAzimuthLook(double look)
Definition: SensorParams.h:133
ossim_int32 x
Definition: ossimIpt.h:141
ossim_float64 lat
Definition: ossimGpt.h:265
bool getPath(const ossimString &path, const ossimXmlDocument *xdoc, ossimString &s)
Gets path from doc and initializes string.
void set_prf(double prf)
Definition: SensorParams.h:73
void findNodes(const ossimString &xpath, std::vector< ossimRefPtr< ossimXmlNode > > &nodelist) const
Appends any matching nodes to the list supplied (should be empty):
void set_col_direction(int dir)
Definition: SensorParams.h:123
This class represents a date.
Definition: JSDDateTime.h:30
void set_sf(double sf)
Definition: SensorParams.h:78
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
int ossim_int32