OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimFormosatModel.cpp
Go to the documentation of this file.
1 //----------------------------------------------------------------------------
2 //
3 // "Copyright Centre National d'Etudes Spatiales"
4 //
5 // License: LGPL
6 //
7 // See LICENSE.txt file in the top level directory for more details.
8 //
9 //----------------------------------------------------------------------------
10 // $Id$
11 
12 
13 #include <iostream>
14 #include <iomanip>
15 #include <fstream>
16 using namespace std;
17 
18 #include <ossimFormosatModel.h>
24 #include <ossim/base/ossimLsrRay.h>
26 #include <ossim/base/ossimDpt3d.h>
29 
31 
32 namespace ossimplugins
33 {
34 RTTI_DEF1(ossimFormosatModel, "ossimFormosatModel", ossimSensorModel);
35 }
36 
37 //---
38 // Define Trace flags for use within this file:
39 //---
40 #include <ossim/base/ossimTrace.h>
41 static ossimTrace traceExec ("ossimFormosatModel:exec");
42 static ossimTrace traceDebug ("ossimFormosatModel:debug");
43 
44 static const ossim_int32 MODEL_VERSION_NUMBER = 1;
45 
46 static const char* PARAM_NAMES[] = { "roll_offset",
47  "pitch_offset",
48  "yaw_offset",
49  "roll_rate",
50  "pitch_rate",
51  "yaw_rate",
52  "focal_length_offset" };
53 
54 static const char* PARAM_UNITS[] = { "degrees", // degrees
55  "degrees", // degrees
56  "degrees", // degrees
57  "degrees", // degrees/sec
58  "degrees", // degrees/sec
59  "degrees", // degrees/sec
60  "unknown" }; // percent deviation from nominal
61 
62 static const ossim_float64 SIGMA[] = { 0.0001, // degrees
63  0.0001, // degrees
64  0.0003, // degrees
65  0.00002, // delta degrees
66  0.00002, // delta degrees
67  0.00005, // delta degrees
68  0.0001 }; // percent
69 
71  :
73  theSupportData (NULL),
74  theMetaDataFile ("NOT ASSIGNED"),
75  theIllumAzimuth (0.0),
76  theIllumElevation (0.0),
77  theSatAzimuth (0.0),
78  thePositionError (0.0),
79  theRefImagingTime (0.0),
80  theRefImagingTimeLine (0.0),
81  theLineSamplingPeriod (0.0),
82 // theSatToOrbRotation (3, 3),
83 // theOrbToEcfRotation (3, 3),
84  theRollOffset (0.0),
85  thePitchOffset (0.0),
86  theYawOffset (0.0),
87  theRollRate (0.0),
88  thePitchRate (0.0),
89  theYawRate (0.0),
90  theFocalLenOffset (0.0)
91 {
93 }
94 
96  :
98  theSupportData (sd),
99  theMetaDataFile ("NOT ASSIGNED"),
100  theIllumAzimuth (0.0),
101  theIllumElevation (0.0),
102  theSatAzimuth (0.0),
103  thePositionError (0.0),
104  theRefImagingTime (0.0),
105  theRefImagingTimeLine (0.0),
106  theLineSamplingPeriod (0.0),
107 // theSatToOrbRotation (3, 3),
108 // theOrbToEcfRotation (3, 3),
109  theRollOffset (0.0),
110  thePitchOffset (0.0),
111  theYawOffset (0.0),
112  theRollRate (0.0),
113  thePitchRate (0.0),
114  theYawRate (0.0),
115  theFocalLenOffset (0.0)
116 {
117  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimFormosatModel(dimap_file) Constructor: entering..." << std::endl;
118 
119  //---
120  // Instantiate the support data classes after establishing the filenames:
121  //---
122  loadSupportData();
123 
125  {
126  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimFormosatModel(dimap_file) Constructor: returning with error..." << std::endl;
127  return;
128  }
129 
130  //---
131  // initialize remaining data members:
132  //---
134  updateModel();
135 
136  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimFormosatModel(dimap_file) Constructor: returning..." << std::endl;
137 }
138 
139 //*****************************************************************************
140 // DESTRUCTOR: ~ossimFormosatModel()
141 //
142 //*****************************************************************************
144 {
145  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG DESTRUCTOR: ~ossimFormosatModel(): entering..." << std::endl;
146 
147  theSupportData = 0;
148 
149  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG DESTRUCTOR: ~ossimFormosatModel(): returning..." << std::endl;
150 }
151 
153  :ossimSensorModel(rhs)
154 {
155  if(rhs.theSupportData.valid())
156  {
158  }
159  loadSupportData();
160  updateModel();
161 }
162 
163 
165 {
166  if (traceExec())
167  {
169  << "DEBUG ossimFormosatModel::computeSatToOrbRotation(): entering..."
170  << std::endl;
171  }
172  //---
173  // Linearly interpolate attitudes angles:
174  //---
175  ossimDpt3d att;
176  theSupportData->getAttitude(t, att);
177 
178  //---
179  // Apply the attitude adjustable parameters:
180  //---
181  double dt = theRefImagingTime - t;
182  att.x += thePitchOffset + dt*thePitchRate;
183  att.y += theRollOffset + dt*theRollRate;
184  att.z += theYawOffset + dt*theYawRate;
185 
186  //---
187  // Compute trig functions to populate rotation matrices: ANGLES IN RADIANS
188  //---
189  double cp = cos(att.x);
190  double sp = sin(att.x);
191  double cr = cos(att.y);
192  double sr = sin(att.y);
193  double cy = cos(att.z);
194  double sy = sin(att.z);
195 
196  //---
197  // Populate rotation matrix:
198  //---
199  result = NEWMAT::Matrix(3,3);
200  result << (cr*cy) << (-cr*sy) << (-sr)
201  << (cp*sy+sp*sr*cy) << (cp*cy-sp*sr*sy) << (sp*cr)
202  << (-sp*sy+cp*sr*cy) << (-sp*cy-cp*sr*sy) << cp*cr;
203 
204 
205  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimFormosatModel::computeSatToOrbRotation(): returning..." << std::endl;
206 }
207 
208 #if 0
209 //*****************************************************************************
210 // METHOD
211 //*****************************************************************************
213 {
214  if (traceExec())
215  {
217  << "DEBUG ossimFormosatModel::computeSatToOrbRotation(): entering..."
218  << std::endl;
219  }
220 
221  //---
222  // Linearly interpolate attitudes angles:
223  //---
224  ossimDpt3d att;
225  theSupportData->getAttitude(t, att);
226 
227  //---
228  // Apply the attitude adjustable parameters:
229  //---
230  double dt = theRefImagingTime - t;
231  att.x += thePitchOffset + dt*thePitchRate;
232  att.y += theRollOffset + dt*theRollRate;
233  att.z += theYawOffset + dt*theYawRate;
234 
235  //---
236  // Compute trig functions to populate rotation matrices: ANGLES IN RADIANS
237  //---
238  double cp = cos(att.x);
239  double sp = sin(att.x);
240  double cr = cos(att.y);
241  double sr = sin(att.y);
242  double cy = cos(att.z);
243  double sy = sin(att.z);
244 
245  //---
246  // Populate rotation matrix:
247  //---
248  theSatToOrbRotation = NEWMAT::Matrix(3,3);
249  theSatToOrbRotation << (cr*cy) << (-cr*sy) << (-sr)
250  << (cp*sy+sp*sr*cy) << (cp*cy-sp*sr*sy) << (sp*cr)
251  << (-sp*sy+cp*sr*cy) << (-sp*cy-cp*sr*sy) << cp*cr;
252 
253 
254  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimFormosatModel::computeSatToOrbRotation(): returning..." << std::endl;
255 }
256 #endif
257 //*****************************************************************************
258 // PUBLIC METHOD: ossimFormosatModel::updateModel()
259 //
260 // Updates the model parameters given the normalized adjustable parameter
261 // array.
262 //
263 //*****************************************************************************
265 {
266  clearErrorStatus();
267 
268  try
269  {
270  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimFormosatModel::updateModel(): entering..." << std::endl;
271 
272  if(getNumberOfAdjustableParameters() < 1)
273  {
274  theRollOffset = 0;
275  thePitchOffset = 0;
276  theYawOffset = 0;
277  theRollRate = 0;
278  thePitchRate = 0;
279  theYawRate = 0;
280  theFocalLenOffset = 0;
281  }
282  else
283  {
284  theRollOffset = computeParameterOffset(0);
285  thePitchOffset = computeParameterOffset(1);
286  theYawOffset = computeParameterOffset(2);
287  theRollRate = computeParameterOffset(3);
288  thePitchRate = computeParameterOffset(4);
289  theYawRate = computeParameterOffset(5);
290  theFocalLenOffset = computeParameterOffset(6);
291  }
292  theSeedFunction = 0;
293  ossimGpt ulg, urg, lrg, llg;
294  lineSampleToWorld(theImageClipRect.ul(), ulg);
295  lineSampleToWorld(theImageClipRect.ur(), urg);
296  lineSampleToWorld(theImageClipRect.lr(), lrg);
297  lineSampleToWorld(theImageClipRect.ll(), llg);
298  theSeedFunction = new ossimBilinearProjection(theImageClipRect.ul(),
299  theImageClipRect.ur(),
300  theImageClipRect.lr(),
301  theImageClipRect.ll(),
302  ulg,
303  urg,
304  lrg,
305  llg);
306 
307  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimFormosatModel::updateModel(): returning..." << std::endl;
308  }
309  catch(...)
310  {
311  setErrorStatus(ossimErrorCodes::OSSIM_ERROR);
312  }
313 }
314 
316 {
317  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimFormosatModel::initAdjustableParameters(): entering..." << std::endl;
318 
319  //---
320  // Allocate storage for adjustables and assign their names and units
321  // strings.
322  //---
323  resizeAdjustableParameterArray(7);
324  ossim_uint32 numParams = getNumberOfAdjustableParameters();
325 
326  //---
327  // Initialize base-class adjustable parameter array:
328  //---
329  for (ossim_uint32 i=0; i<numParams; ++i)
330  {
331  setAdjustableParameter(i, 0.0);
332  setParameterDescription(i, PARAM_NAMES[i]);
333  setParameterUnit(i,PARAM_UNITS[i]);
334  setParameterSigma(i, SIGMA[i]);
335  }
336 
337  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimFormosatModel::initAdjustableParameters(): returning..." << std::endl;
338 }
339 
341 {
342  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "ossimFormosatModel::loadSupportData(): entering..." << std::endl;
343 
344  //---
345  // Check for good support data:
346  //---
347  if (!theSupportData)
348  {
349  setErrorStatus();
350  ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFormosatModel::loadSupportData(): Null FormosatDimapSupportData pointer passed to"
351  << " constructor! Aborting..." << std::endl;
352  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimFormosatModel::loadSupportData(): returning..." << std::endl;
353  return;
354  }
355 
356  if (traceExec())
357  {
358  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimFormosatModel::loadSupportData(): theSupportData->getErrorStatus(): "
359  << theSupportData->getErrorStatus() <<std::endl;
360  }
361 
362  if (theSupportData->getErrorStatus() != ossimErrorCodes::OSSIM_OK)
363  {
364  setErrorStatus();
365  ossimNotify(ossimNotifyLevel_FATAL) << "FATAL ossimFormosatModel::loadSupportData(): Bad FormosatDimapSupportData detected. Aborting..."
366  << std::endl;
367  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimFormosatModel::loadSupportData(): returning..." << std::endl;
368  return;
369  }
370 
371  //---
372  // Initialize some member variables from the support data:
373  //---
374  theSensorID = theSupportData->getSensorID();
375  theImageID = theSupportData->getImageID();
376  theMetaDataFile = theSupportData->getMetadataFile();
377 
378  // Center of frame, sub image if we have one.
379  theSupportData->getRefGroundPoint(theRefGndPt);
380 
381  theSupportData->getSunAzimuth(theIllumAzimuth);
382  theSupportData->getSunElevation(theIllumElevation);
383  theSupportData->getSatAzimuth(theSatAzimuth);
384 
385  ossimDpt sz;
386  theSupportData->getImageSize(sz);
387  theImageSize = sz;
388  theSupportData->getRefLineTime(theRefImagingTime);
389  theSupportData->getRefLineTimeLine(theRefImagingTimeLine);
390 
391  theSupportData->getLineSamplingPeriod(theLineSamplingPeriod);
392  theSupportData->getSubImageOffset(theSpotSubImageOffset);
393 
394  //---
395  // We make this zero base as the base ossimSensorModel does not know about
396  // any sub image we have.
397  //---
398  theSupportData->getImageRect(theImageClipRect);
399  theSupportData->getRefImagePoint(theRefImgPt);
400 
401  ossimGpt p1;
402  ossimGpt p2;
403  ossimGpt p3;
404  ossimGpt p4;
405 
406 
407  // I need to find the nominal scale of the spot 5 dataset
408 
409  //---
410  // Position error is a function of whether star tracker information was
411  // available:
412  //---
413  if (theSupportData->isStarTrackerUsed())
414  {
415  thePositionError = 50.0;
416  }
417  else
418  {
419  thePositionError = 200.0; // meters
420  }
421  updateModel();
422  lineSampleToWorld(theImageClipRect.ul(), p1);
423  lineSampleToWorld(theImageClipRect.ur(), p2);
424  lineSampleToWorld(theImageClipRect.lr(), p3);
425  lineSampleToWorld(theImageClipRect.ll(), p4);
426 
427  ossimDpt v[4]; // temporarily holds vertices for ground polygon
428  v[0] = p1;
429  v[1] = p2;
430  v[2] = p3;
431  v[3] = p4;
432  theBoundGndPolygon = ossimPolygon(4, v);
433 
434 
435  ossimGpt cgpt, hgpt, vgpt;
436  // ossimEcefPoint hVector, vVector;
437  ossimDpt midpt = theImageClipRect.midPoint();
438 
439  lineSampleToWorld(midpt, cgpt);
440  lineSampleToWorld(midpt + ossimDpt(1,0), hgpt);
441  lineSampleToWorld(midpt + ossimDpt(0,1), vgpt);
442 
443  theGSD = ossimDpt((ossimEcefPoint(cgpt) - ossimEcefPoint(hgpt)).magnitude(),
444  (ossimEcefPoint(cgpt) - ossimEcefPoint(vgpt)).magnitude());
445 
446  theMeanGSD = (theGSD.x+theGSD.y)/2.0;
447 
448  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimFormosatModel::loadSupportData(): returning..." << std::endl;
449 }
450 
452 {
453  return new ossimFormosatModel(*this);
454 }
455 
457 {
458  // Capture stream flags since we are going to mess with them.
459  std::ios_base::fmtflags f = out.flags();
460 
461  out << "\nDump of ossimFormosatModel at address " << (hex) << this
462  << (dec)
463  << "\n------------------------------------------------"
464  << "\n theImageID = " << theImageID
465  << "\n theMetadataFile = " << theMetaDataFile
466  << "\n theIllumAzimuth = " << theIllumAzimuth
467  << "\n theIllumElevation = " << theIllumElevation
468  << "\n theSatAzimuth = " << theSatAzimuth
469  << "\n thePositionError = " << thePositionError
470  << "\n theImageSize = " << theImageSize
471  << "\n theRefGndPt = " << theRefGndPt
472  << "\n theRefImgPt = " << theRefImgPt
473  << "\n theRefImagingTime = " << theRefImagingTime
474  << "\n theRefImagingTimeLine = " << theRefImagingTimeLine
475  << "\n theLineSamplingPeriod = " << theLineSamplingPeriod
476  << "\n theRollOffset = " << theRollOffset
477  << "\n thePitchOffset = " << thePitchOffset
478  << "\n theYawOffset = " << theYawOffset
479  << "\n theRollRate = " << theRollRate
480  << "\n thePitchRate = " << thePitchRate
481  << "\n theYawRate = " << theYawRate
482  << "\n theFocalLenOffset = " << theFocalLenOffset
483  << "\n------------------------------------------------"
484  << "\n " << endl;
485 
486  // Set the flags back.
487  out.flags(f);
488 
489  return ossimSensorModel::print(out);
490 }
491 
493  const char* prefix) const
494 {
495  if(theSupportData.valid())
496  {
497  ossimString supportPrefix = ossimString(prefix) + "support_data.";
498  theSupportData->saveState(kwl, supportPrefix);
499  }
500  else
501  {
502  return false;
503  }
504 
505  return ossimSensorModel::saveState(kwl, prefix);
506 }
507 
509  const char* prefix)
510 {
511  ossimString supportPrefix = ossimString(prefix) + "support_data.";
512 
513  if(!theSupportData)
514  {
515  theSupportData = new ossimFormosatDimapSupportData;
516  }
517 
518  if(theSupportData->loadState(kwl, supportPrefix))
519  {
520  if(!ossimSensorModel::loadState(kwl, prefix))
521  {
522  return false;
523  }
524  }
525  else
526  {
527  return false;
528  }
529 
530  loadSupportData();
531  updateModel();
532 
533  return (getErrorStatus()==ossimErrorCodes::OSSIM_OK);
534 }
535 
537  ossimEcefRay& image_ray) const
538 {
539  bool runtime_dbflag = 0;
540  NEWMAT::Matrix satToOrbit;
541  ossimDpt iPt = image_point;
542  iPt.samp += theSpotSubImageOffset.samp;
543  iPt.line += theSpotSubImageOffset.line;
544 
545  //
546  // 1. Establish time of line imaging:
547  //
548  double t_line = theRefImagingTime +
549  theLineSamplingPeriod*(iPt.line - theRefImagingTimeLine);
550  if (traceDebug() || runtime_dbflag)
551  {
552  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG FormosatModel::imagingRay():------------ BEGIN DEBUG PASS ---------------" << std::endl;
553  ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG FormosatModel::imagingRay(): t_line = " << t_line << std::endl;
554  }
555 
556  //
557  // 2. Interpolate ephemeris position and velocity (in ECF):
558  //
559  ossimEcefPoint tempEcefPoint;
560  ossimEcefPoint P_ecf;
561  theSupportData->getPositionEcf(t_line, P_ecf);
562  theSupportData->getVelocityEcf(t_line, tempEcefPoint);
563  ossimEcefVector V_ecf(tempEcefPoint.x(),
564  tempEcefPoint.y(),
565  tempEcefPoint.z());
566  if (traceDebug() || runtime_dbflag)
567  {
569  << "DEBUG:\n\tP_ecf = " << P_ecf
570  << "\n\t V_ecf = " << V_ecf << std::endl;
571  }
572 
573  //
574  // 3. Establish the look direction in Vehicle LSR space (S_sat).
575  // ANGLES IN RADIANS
576  //
577  ossim_float64 Psi_x;
578  theSupportData->getPixelLookAngleX(iPt.samp, Psi_x);
579  ossim_float64 Psi_y;
580  theSupportData->getPixelLookAngleY(iPt.samp, Psi_y);
581  if (traceDebug() || runtime_dbflag)
582  {
584  << "DEBUG:\n\t Psi_x = " << Psi_x
585  << "\n\t Psi_y = " << Psi_y << endl;
586  }
587 
588  ossimColumnVector3d u_sat (-tan(Psi_y), tan(Psi_x), -(1.0 + theFocalLenOffset));
589  if (traceDebug() || runtime_dbflag)
590  {
592  << "DEBUG \n\t u_sat = " << u_sat << endl;
593  }
594 
595  //
596  // 4. Transform vehicle LSR space look direction vector to orbital LSR space
597  // (S_orb):
598  //
599  computeSatToOrbRotation(satToOrbit, t_line);
600 
601  ossimColumnVector3d u_orb = (satToOrbit*u_sat).unit();
602  if (traceDebug() || runtime_dbflag)
603  {
605  << "DEBUG:\n\t theSatToOrbRotation = " << satToOrbit
606  << "\n\t u_orb = " << u_orb << endl;
607  }
608 
609  //
610  // 5. Transform orbital LSR space look direction vector to ECF.
611  //
612  // a. S_orb space Z-axis (Z_orb) is || to the ECF radial vector (P_ecf),
613  // b. X_orb axis is computed as cross-product between velocity and radial,
614  // c. Y_orb completes the orthogonal S_orb coordinate system.
615  //
616  ossimColumnVector3d Z_orb (P_ecf.x(),
617  P_ecf.y(),
618  P_ecf.z());
619  Z_orb = Z_orb.unit();
620 
621  ossimColumnVector3d X_orb = ossimColumnVector3d(V_ecf.x(),
622  V_ecf.y(),
623  V_ecf.z()).cross(Z_orb).unit();
624  ossimColumnVector3d Y_orb = Z_orb.cross(X_orb);
625 
626  NEWMAT::Matrix orbToEcfRotation = NEWMAT::Matrix(3, 3);
627  orbToEcfRotation << X_orb[0] << Y_orb[0] << Z_orb[0]
628  << X_orb[1] << Y_orb[1] << Z_orb[1]
629  << X_orb[2] << Y_orb[2] << Z_orb[2];
630 
631 
632  ossimColumnVector3d u_ecf = (orbToEcfRotation*u_orb);
633  if (traceDebug() || runtime_dbflag)
634  {
636  << "DEBUG:\n\t orbToEcfRotation = " << orbToEcfRotation
637  << "\n\t u_ecf = " << u_ecf << endl;
638  }
639 
640  //
641  // Establish the imaging ray given direction and origin:
642  //
643  image_ray = ossimEcefRay(P_ecf, ossimEcefVector(u_ecf[0], u_ecf[1], u_ecf[2]));
644 
645  if (traceExec())
646  {
648  << "DEBUG FormosatModel::imagingRay(): returning..." << std::endl;
649  }
650 }
651 
653  const ossim_float64& heightEllipsoid,
654  ossimGpt& worldPoint) const
655 {
656  if (!insideImage(image_point))
657  {
658  if(theSeedFunction.valid())
659  {
660  theSeedFunction->lineSampleToWorld(image_point, worldPoint);
661  }
662  else
663  {
664  worldPoint = extrapolate(image_point, heightEllipsoid);
665  }
666  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimFormosatModel::lineSampleHeightToWorld(): returning..." << std::endl;
667  return;
668  }
669 
670  //***
671  // First establish imaging ray from image point:
672  //***
673  ossimEcefRay imaging_ray;
674  imagingRay(image_point, imaging_ray);
675  ossimEcefPoint Pecf (imaging_ray.intersectAboveEarthEllipsoid(heightEllipsoid));
676  worldPoint = ossimGpt(Pecf);
677 }
678 
679 // ossimDpt ossimplugins::ossimFormosatModel::extrapolate (const ossimGpt& gp) const
680 // {
681 // ossimDpt temp;
682 
683 // temp.makeNan();
684 
685 // return temp;
686 
687 // ossimDpt tempGpt = gp;
688 // ossimDpt dest;
689 // theGroundToImageMap.map(tempGpt, dest);
690 
691 // return dest;
692 
693 // }
694 
695 // ossimGpt ossimplugins::ossimFormosatModel::extrapolate (const ossimDpt& ip,
696 // const double& height) const
697 // {
698 // return ossimGpt(ossim::nan(), ossim::nan(), ossim::nan(), 0);
699 
700 // ossimDpt dest;
701 
702 // theImageToGroundMap.map(ip, dest);
703 
704 
705 // return ossimGpt(dest.lat, dest.lon, ossim::nan(), origin().datum());
706 // }
707 
708 bool
710 {
711  ossimFilename FormosatTest = init_file;
712  ossimFilename geomFile = init_file;
713  geomFile = geomFile.setExtension("geom");
714  bool tryKwl = false;
715 
716  if(!FormosatTest.exists())
717  {
718  FormosatTest = geomFile.path();
719  FormosatTest = FormosatTest.dirCat(ossimFilename("METADATA.DIM"));
720  if(FormosatTest.exists() == false)
721  {
722  FormosatTest = geomFile.path();
723  FormosatTest = FormosatTest.dirCat(ossimFilename("metadata.dim"));
724  }
725  }
726  if(FormosatTest.exists())
727  {
729  if(meta->loadXmlFile(FormosatTest))
730  {
731  initFromMetadata(meta.get());
732  if (getErrorStatus())
733  {
734  tryKwl = true;
735  meta=0;
736  }
737  else
738  {
739  return true;
740  }
741  }
742  else
743  {
744  meta=0;
745  tryKwl = true;
746  }
747  }
748  if(tryKwl)
749  {
750  ossimKeywordlist kwl;
751  if(kwl.addFile(init_file.c_str()))
752  {
753  return loadState(kwl);
754  }
755  }
756  return false;
757 }
758 
759 bool
761 {
762  // init parms
763  theSupportData = sd;
764  theMetaDataFile = "NOT ASSIGNED";
765  theIllumAzimuth = 0.0;
766  theIllumElevation = 0.0;
767  theSatAzimuth = 0.0;
768  thePositionError = 0.0;
769  theRefImagingTime = 0.0;
770  theLineSamplingPeriod = 0.0;
771 // theSatToOrbRotation = 0.0; //matrix
772 // theOrbToEcfRotation = 0.0; //matrix
773  theRollOffset = 0.0;
774  thePitchOffset = 0.0;
775  theYawOffset = 0.0;
776  theRollRate = 0.0;
777  thePitchRate = 0.0;
778  theYawRate = 0.0;
779  theFocalLenOffset = 0.0;
780 
781  //---
782  // Instantiate the support data classes after establishing the filenames:
783  //---
784  loadSupportData();
785  if (getErrorStatus() != ossimErrorCodes::OSSIM_OK)
786  {
787  if (traceExec()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimplugins::ossimFormosatModel::initFromMetadata(dimap_file): returning with error..." << std::endl;
788  return false;
789  }
790 
791  //---
792  // initialize remaining data members:
793  //---
794  initAdjustableParameters();
795  updateModel();
796  return true;
797 }
virtual void imagingRay(const ossimDpt &image_point, ossimEcefRay &image_ray) const
ossimColumnVector3d cross(const ossimColumnVector3d &rhs) const
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
ossimEcefPoint intersectAboveEarthEllipsoid(const double &heightAboveEllipsoid, const ossimDatum *aDatum=ossimDatumFactory::instance() ->wgs84()) const
Represents serializable keyword/value map.
bool addFile(const char *file)
static const ossimErrorCode OSSIM_OK
bool valid() const
Definition: ossimRefPtr.h:75
double samp
Definition: ossimDpt.h:164
virtual std::ostream & print(std::ostream &out) const
double x() const
ossimColumnVector3d unit() const
static const ossimErrorCode OSSIM_ERROR
ossimRefPtr< ossimFormosatDimapSupportData > theSupportData
double ossim_float64
double z
Definition: ossimDpt3d.h:145
double line
Definition: ossimDpt.h:165
bool exists() const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=NULL) const
unsigned int ossim_uint32
bool initFromMetadata(ossimFormosatDimapSupportData *sd)
uses file path to init model
virtual void lineSampleHeightToWorld(const ossimDpt &image_point, const ossim_float64 &heightEllipsoid, ossimGpt &worldPoint) const
void computeSatToOrbRotation(NEWMAT::Matrix &result, ossim_float64 t) const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
virtual std::ostream & print(std::ostream &out) const
virtual ossimErrorCode getErrorStatus() const
double y() const
double x
Definition: ossimDpt3d.h:143
ossimFilename dirCat(const ossimFilename &file) const
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
virtual bool setupOptimizer(const ossimString &init_file)
image to ground faster
bool loadXmlFile(const ossimFilename &file)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=NULL)
double y
Definition: ossimDpt3d.h:144
virtual ossimObject * dup() const
ossimFilename & setExtension(const ossimString &e)
Sets the extension of a file name.
double z() const
ossimFilename path() const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
RTTI_DEF1(ossimFormosatModel, "ossimFormosatModel", ossimSensorModel)
std::basic_ostream< char > ostream
Base class for char output streams.
Definition: ossimIosFwd.h:23
int ossim_int32