OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimApplanixUtmModel.cpp
Go to the documentation of this file.
1 //*******************************************************************
2 // Copyright (C) 2005 Garrett Potts
3 //
4 // LGPL
5 //
6 // Author: Garrett Potts
7 //
8 //*******************************************************************
9 // $Id: ossimApplanixUtmModel.cpp 23564 2015-10-02 14:12:25Z dburken $
10 #include <sstream>
16 #include <ossim/base/ossimDatum.h>
18 #include <ossim/base/ossimTrace.h>
24 static ossimTrace traceDebug("ossimApplanixUtmModel:debug");
25 
26 RTTI_DEF1(ossimApplanixUtmModel, "ossimApplanixUtmModel", ossimSensorModel);
27 
28 #ifdef OSSIM_ID_ENABLED
29 static const char OSSIM_ID[] = "$Id: ossimApplanixUtmModel.cpp 23564 2015-10-02 14:12:25Z dburken $";
30 #endif
31 
33  :theOmega(0.0),
34  thePhi(0.0),
35  theKappa(0.0),
36  theBoreSightTx(0.0),
37  theBoreSightTy(0.0),
38  theBoreSightTz(0.0)
39 {
42  theFocalLength = 55.0;
43  thePixelSize = ossimDpt(.009, .009);
44  theEcefPlatformPosition = ossimGpt(0.0,0.0, 1000.0);
45  theGSD.x = 0.1524;
46  theGSD.y = 0.1524;
47  theMeanGSD = 0.1524;
50 
51  if (traceDebug())
52  {
54  << "ossimApplanixUtmModel::ossimApplanixUtmModel DEBUG:" << endl;
55 #ifdef OSSIM_ID_ENABLED
56  ossimNotify(ossimNotifyLevel_DEBUG)<< "OSSIM_ID: " << OSSIM_ID << endl;
57 #endif
58  }
59 }
60 
62  :ossimSensorModel(src),
63  theCompositeMatrix(src.theCompositeMatrix),
64  theCompositeMatrixInverse(src.theCompositeMatrixInverse),
65  theOmega(src.theOmega),
66  thePhi(src.thePhi),
67  theKappa(src.theKappa),
68  theBoreSightTx(src.theBoreSightTx),
69  theBoreSightTy(src.theBoreSightTy),
70  theBoreSightTz(src.theBoreSightTz),
71  thePrincipalPoint(src.thePrincipalPoint),
72  thePixelSize(src.thePixelSize),
73  theFocalLength(src.theFocalLength),
74  theEcefPlatformPosition(src.theEcefPlatformPosition),
75  thePlatformPosition(src.thePlatformPosition),
76  theUtmZone(src.theUtmZone),
77  theUtmHemisphere(src.theUtmHemisphere),
78  theUtmPlatformPosition(src.theUtmPlatformPosition)
79 {
80  if(src.theLensDistortion.valid())
81  {
83  }
84  else
85  {
87  }
88 }
89 
91 {
92  return new ossimApplanixUtmModel(*this);
93 }
94 
96  ossimEcefRay& image_ray) const
97 {
98 // if(traceDebug())
99 // {
100 // ossimNotify(ossimNotifyLevel_DEBUG) << "ossimApplanixUtmModel::imagingRay: ..... entered" << std::endl;
101 // }
102  ossimDpt f1 ((image_point) - theRefImgPt);
103  f1.x *= thePixelSize.x;
104  f1.y *= -thePixelSize.y;
105  ossimDpt film (f1 - thePrincipalPoint);
106 // if(traceDebug())
107 // {
108 // ossimNotify(ossimNotifyLevel_DEBUG) << "pixel size = " << thePixelSize << std::endl;
109 // ossimNotify(ossimNotifyLevel_DEBUG) << "principal pt = " << thePrincipalPoint << std::endl;
110 // ossimNotify(ossimNotifyLevel_DEBUG) << "film pt = " << film << std::endl;
111 // }
112  if (theLensDistortion.valid())
113  {
114  ossimDpt filmOut;
115  theLensDistortion->undistort(film, filmOut);
116  film = filmOut;
117  }
118 
119  ossimColumnVector3d cam_ray_dir (film.x,
120  film.y,
121  -theFocalLength);
122  ossimEcefVector ecf_ray_dir (theCompositeMatrix*cam_ray_dir);
123  ecf_ray_dir = ecf_ray_dir*(1.0/ecf_ray_dir.magnitude());
124 
126  image_ray.setDirection(ecf_ray_dir);
127 
128 // if(traceDebug())
129 // {
130 // ossimNotify(ossimNotifyLevel_DEBUG) << "ossimApplanixUtmModel::imagingRay: ..... leaving" << std::endl;
131 // }
132 }
133 
135  ossimGpt& gpt) const
136 {
137  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimApplanixEcefModel::lineSampleToWorld:entering..." << std::endl;
138 
139  if(image_point.hasNans())
140  {
141  gpt.makeNan();
142  return;
143  }
144  //***
145  // Extrapolate if image point is outside image:
146  //***
147  // if (!insideImage(image_point))
148  // {
149  // gpt.makeNan();
150 // gpt = extrapolate(image_point);
151  // return;
152  //}
153 
154  //***
155  // Determine imaging ray and invoke elevation source object's services to
156  // intersect ray with terrain model:
157  //***
158  ossimEcefRay ray;
159  imagingRay(image_point, ray);
161 
162  if (traceDebug())
163  {
164  ossimNotify(ossimNotifyLevel_DEBUG) << "image_point = " << image_point << std::endl;
165  ossimNotify(ossimNotifyLevel_DEBUG) << "ray = " << ray << std::endl;
166  ossimNotify(ossimNotifyLevel_DEBUG) << "gpt = " << gpt << std::endl;
167  }
168 
169  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimSensorModel::lineSampleToWorld: returning..." << std::endl;
170  return;
171 }
172 
174  const double& heightEllipsoid,
175  ossimGpt& worldPoint) const
176 {
177 // if (!insideImage(image_point))
178 // {
179  //worldPoint.makeNan();
180 // worldPoint = extrapolate(image_point, heightEllipsoid);
181 // }
182 // else
183  {
184  //***
185  // First establish imaging ray from image point:
186  //***
187  ossimEcefRay ray;
188  imagingRay(image_point, ray);
189  ossimEcefPoint Pecf (ray.intersectAboveEarthEllipsoid(heightEllipsoid));
190  worldPoint = ossimGpt(Pecf);
191  }
192 }
193 
195  ossimDpt& image_point) const
196 {
197 #if 0
200  {
201  if (!(theBoundGndPolygon.pointWithin(world_point)))
202  {
203  image_point.makeNan();
204 // image_point = extrapolate(world_point);
205  return;
206  }
207  }
208 #endif
209  ossimEcefPoint g_ecf(world_point);
210  ossimEcefVector ecfRayDir(g_ecf - theAdjEcefPlatformPosition);
211  ossimColumnVector3d camRayDir (theCompositeMatrixInverse*ecfRayDir.data());
212 
213 
214  double scale = -theFocalLength/camRayDir[2];
215  ossimDpt film (scale*camRayDir[0], scale*camRayDir[1]);
216 
217  if (theLensDistortion.valid())
218  {
219  ossimDpt filmOut;
220  theLensDistortion->distort(film, filmOut);
221  film = filmOut;
222  }
223 
224  ossimDpt f1(film + thePrincipalPoint);
225  ossimDpt p1(f1.x/thePixelSize.x,
226  -f1.y/thePixelSize.y);
227 
228  ossimDpt p0 (p1.x + theRefImgPt.x,
229  p1.y + theRefImgPt.y);
230 
231  image_point = p0;
232 }
233 
235 {
236 
237  ossimGpt wgs84Pt;
238  double metersPerDegree = wgs84Pt.metersPerDegree().x;
239  double degreePerMeter = 1.0/metersPerDegree;
240  double latShift = -computeParameterOffset(1)*theMeanGSD*degreePerMeter;
241  double lonShift = computeParameterOffset(0)*theMeanGSD*degreePerMeter;
242 
244 // gpt.height(0.0);
245  double height = gpt.height();
246  gpt.height(height + computeParameterOffset(5));
247  gpt.latd(gpt.latd() + latShift);
248  gpt.lond(gpt.lond() + lonShift);
249 
252  // ORIENT TO A UTM AXIS
253  //
254  NEWMAT::ColumnVector v(3);
255 
256  v[0] = 0.0;
257  v[1] = 0.0;
258  v[2] = 1.0;
259  NEWMAT::ColumnVector v2 = lsrSpace.lsrToEcefRotMatrix()*v;
260  ossimEcefVector zVector(v2[0], v2[1], v2[2]);
261  zVector.normalize();
262 
263  // now lets create a UTM axis by creating a derivative at the center
264  // by shift over a few pixels and subtracting
265  //
266  ossimUtmProjection utmProj;
267 
268  utmProj.setZone(theUtmZone);
269  utmProj.setZone(theUtmHemisphere);
270  utmProj.setMetersPerPixel(ossimDpt(1.0,1.0));
272  ossimDpt rPt = midPt + ossimDpt(10, 0.0);
273  ossimDpt uPt = midPt + ossimDpt(0.0, 10.0);
274  ossimGpt wMidPt = utmProj.inverse(midPt);
275  ossimGpt wRPt = utmProj.inverse(rPt);
276  ossimGpt wUPt = utmProj.inverse(uPt);
277 
278  ossimEcefPoint ecefMidPt = wMidPt;
279  ossimEcefPoint ecefRPt = wRPt;
280  ossimEcefPoint ecefUPt = wUPt;
281 
282  ossimEcefVector east = ecefRPt-ecefMidPt;
283  ossimEcefVector north = ecefUPt-ecefMidPt;
284  east.normalize();
285  north.normalize();
286 
287  // now use the lsr space constructors to construct an orthogonal set of axes
288  //
290  0,
291  north,
292  east.cross(north));
293 // lsrSpace = ossimLsrSpace(thePlatformPosition);
294  // DONE ORIENT TO UTM AXIS
295 
296  NEWMAT::Matrix platformLsrMatrix = lsrSpace.lsrToEcefRotMatrix();
300 
301  theCompositeMatrix = platformLsrMatrix*orientationMatrix;
303 
304 // theAdjEcefPlatformPosition = theEcefPlatformPosition;
305 
307  // ossim_float64 w = theImageClipRect.width();//*2.0;
308  // ossim_float64 h = theImageClipRect.height();//*2.0;
309 
310  lineSampleToWorld(theImageClipRect.ul(),gpt);//+ossimDpt(-w, -h), gpt);
311  theBoundGndPolygon[0] = gpt;
312  lineSampleToWorld(theImageClipRect.ur(),gpt);//+ossimDpt(w, -h), gpt);
313  theBoundGndPolygon[1] = gpt;
314  lineSampleToWorld(theImageClipRect.lr(),gpt);//+ossimDpt(w, h), gpt);
315  theBoundGndPolygon[2] = gpt;
316  lineSampleToWorld(theImageClipRect.ll(),gpt);//+ossimDpt(-w, h), gpt);
317  theBoundGndPolygon[3] = gpt;
318 }
319 
321 {
323 
324  setAdjustableParameter(0, 0.0);
325  setParameterDescription(0, "x_offset");
326  setParameterUnit(0, "pixels");
327 
328  setAdjustableParameter(1, 0.0);
329  setParameterDescription(1, "y_offset");
330  setParameterUnit(1, "pixels");
331 
332  setAdjustableParameter(2, 0.0);
333  setParameterDescription(2, "orientation x");
334  setParameterUnit(2, "degrees");
335 
336  setAdjustableParameter(3, 0.0);
337  setParameterDescription(3, "orientation y");
338  setParameterUnit(3, "degrees");
339 
340  setAdjustableParameter(4, 0.0);
341  setParameterDescription(4, "orientation z");
342  setParameterUnit(4, "degrees");
343 
344  setAdjustableParameter(5, 0.0);
345  setParameterDescription(5, "Altitude delta");
346  setParameterUnit(5, "meters");
347 
348 
349 
350  setParameterSigma(0, 20.0);
351  setParameterSigma(1, 20.0);
352  setParameterSigma(2, .1);
353  setParameterSigma(3, .1);
354  setParameterSigma(4, .1);
355  setParameterSigma(5, 50);
356 }
357 
359 {
360  thePrincipalPoint = principalPoint;
361 }
362 
364 {
365  thePixelSize = pixelSize;
366 }
367 
369 {
370  theImageClipRect = rect;
371  theRefImgPt = rect.midPoint();
372 }
373 
375 {
376  theFocalLength = focalLength;
377 }
378 
380 {
381  theRefGndPt = gpt;
383  updateModel();
384 
385 }
386 
388  const char* prefix) const
389 {
390  ossimSensorModel::saveState(kwl, prefix);
391 
392  kwl.add(prefix, "type", "ossimApplanixUtmModel", true);
393 
394  kwl.add(prefix, "omega", theOmega, true);
395  kwl.add(prefix, "phi", thePhi, true);
396  kwl.add(prefix, "kappa", theKappa, true);
397  kwl.add(prefix, "bore_sight_tx", theBoreSightTx*60, true);
398  kwl.add(prefix, "bore_sight_ty", theBoreSightTy*60, true);
399  kwl.add(prefix, "bore_sight_tz", theBoreSightTz*60, true);
400  kwl.add(prefix, "principal_point", ossimString::toString(thePrincipalPoint.x) + " " + ossimString::toString(thePrincipalPoint.y));
401  kwl.add(prefix, "pixel_size", ossimString::toString(thePixelSize.x) + " " + ossimString::toString(thePixelSize.y));
402  kwl.add(prefix, "focal_length", theFocalLength);
403  kwl.add(prefix, "ecef_platform_position",
407  kwl.add(prefix, "latlonh_platform_position",
412  kwl.add(prefix,
413  "utm_platform_position",
418  true);
419  kwl.add(prefix,
420  "utm_zone",
421  theUtmZone,
422  true);
423  kwl.add(prefix,
424  "utm_hemisphere",
426  true);
427  kwl.add(prefix,
428  "shift_values",
432  true);
434  {
435  ossimString lensPrefix = ossimString(prefix)+"distortion.";
437  lensPrefix.c_str());
438  }
439 
440  return true;
441 }
442 
444  const char* prefix)
445 {
446  if(traceDebug())
447  {
448  std::cout << "ossimApplanixUtmModel::loadState: ......... entered" << std::endl;
449  }
450  theImageClipRect = ossimDrect(0,0,4076,4091);
451  theRefImgPt = ossimDpt(2046.0, 2038.5);
452 
453  ossimSensorModel::loadState(kwl, prefix);
454 
456  {
458  }
459 
460  const char* eo_file = kwl.find(prefix, "eo_file");
461  const char* eo_id = kwl.find(prefix, "eo_id");
462  const char* omega = kwl.find(prefix, "omega");
463  const char* phi = kwl.find(prefix, "phi");
464  const char* kappa = kwl.find(prefix, "kappa");
465  const char* bore_sight_tx = kwl.find(prefix, "bore_sight_tx");
466  const char* bore_sight_ty = kwl.find(prefix, "bore_sight_ty");
467  const char* bore_sight_tz = kwl.find(prefix, "bore_sight_tz");
468 
469  const char* principal_point = kwl.find(prefix, "principal_point");
470  const char* pixel_size = kwl.find(prefix, "pixel_size");
471  const char* focal_length = kwl.find(prefix, "focal_length");
472  const char* latlonh_platform_position = kwl.find(prefix, "latlonh_platform_position");
473  const char* utm_platform_position = kwl.find(prefix, "utm_platform_position");
474  const char* compute_gsd_flag = kwl.find(prefix, "compute_gsd_flag");
475  const char* utm_zone = kwl.find(prefix, "utm_zone");
476  const char* utm_hemisphere = kwl.find(prefix, "utm_hemisphere");
477  const char* camera_file = kwl.find(prefix, "camera_file");
478  const char* shift_values = kwl.find(prefix, "shift_values");
479 
482  theOmega = 0.0;
483  thePhi = 0.0;
484  theKappa = 0.0;
485  theBoreSightTx = 0.0;
486  theBoreSightTy = 0.0;
487  theBoreSightTz = 0.0;
488  theFocalLength = 55.0;
489  thePixelSize = ossimDpt(.009, .009);
490  theEcefPlatformPosition = ossimGpt(0.0,0.0, 1000.0);
491 
492  bool loadedFromEoFile = false;
493 
494  if(eo_id)
495  {
496  theImageID = eo_id;
497  }
498  // loading from standard eo file with given record id
499  //
500  if(eo_file)
501  {
502  ossimApplanixEOFile eoFile;
503 
504  if(eoFile.parseFile(ossimFilename(eo_file)))
505  {
507 
508  if(record.valid())
509  {
510  loadedFromEoFile = true;
511  theBoreSightTx = eoFile.getBoreSightTx()/60.0;
512  theBoreSightTy = eoFile.getBoreSightTy()/60.0;
513  theBoreSightTz = eoFile.getBoreSightTz()/60.0;
515  eoFile.getShiftValuesY(),
516  eoFile.getShiftValuesZ());
517  ossim_int32 easting = eoFile.getFieldIdxLike("EASTING");
518  ossim_int32 northing = eoFile.getFieldIdxLike("NORTHING");
519  ossim_int32 height = eoFile.getFieldIdxLike("HEIGHT");
520  ossim_int32 omega = eoFile.getFieldIdxLike("OMEGA");
521  ossim_int32 phi = eoFile.getFieldIdxLike("PHI");
522  ossim_int32 kappa = eoFile.getFieldIdxLike("KAPPA");
523 
524  if((omega>=0)&&
525  (phi>=0)&&
526  (kappa>=0)&&
527  (height>=0)&&
528  (easting>=0)&&
529  (northing>=0))
530  {
531  theOmega = (*record)[omega].toDouble();
532  thePhi = (*record)[phi].toDouble();
533  theKappa = (*record)[kappa].toDouble();
534  double h = (*record)[height].toDouble();
535  ossimString heightType = kwl.find(prefix, "height_type");
536  if(eoFile.isUtmFrame())
537  {
538  theUtmZone = eoFile.getUtmZone();
539  theUtmHemisphere = eoFile.getUtmHemisphere()=="North"?'N':'S';
540  ossimUtmProjection utmProj;
541  utmProj.setZone(theUtmZone);
542  utmProj.setHemisphere((char)theUtmHemisphere);
543  theUtmPlatformPosition.x = (*record)[easting].toDouble();
544  theUtmPlatformPosition.y = (*record)[northing].toDouble();
549 
550  if(eoFile.isHeightAboveMSL())
551  {
553  if(!ossim::isnan(offset))
554  {
555  thePlatformPosition.height(h + offset);
556  theUtmPlatformPosition.z = h + offset;
557  }
558  }
559  }
560  else
561  {
562  return false;
563  }
564  }
566  }
567  else
568  {
569  return false;
570  }
571  }
572  }
573  if(!loadedFromEoFile)
574  {
575  if(shift_values)
576  {
577  std::vector<ossimString> splitString;
578  ossimString tempString(shift_values);
579  tempString = tempString.trim();
580  tempString.split(splitString, " " );
581  if(splitString.size() == 3)
582  {
583  theShiftValues = ossimEcefVector(splitString[0].toDouble(),
584  splitString[1].toDouble(),
585  splitString[2].toDouble());
586  }
587  }
588  if(omega&&phi&&kappa)
589  {
590  theOmega = ossimString(omega).toDouble();
591  thePhi = ossimString(phi).toDouble();
592  theKappa = ossimString(kappa).toDouble();
593  }
594  if(bore_sight_tx&&bore_sight_ty&&bore_sight_tz)
595  {
596  theBoreSightTx = ossimString(bore_sight_tx).toDouble()/60.0;
597  theBoreSightTy = ossimString(bore_sight_ty).toDouble()/60.0;
598  theBoreSightTz = ossimString(bore_sight_tz).toDouble()/60.0;
599  }
600  double lat=0.0, lon=0.0, h=0.0;
601  if(utm_zone)
602  {
603  theUtmZone = ossimString(utm_zone).toInt32();
604  }
605  if(utm_hemisphere)
606  {
607  ossimString hem = utm_hemisphere;
608  hem = hem.trim();
609  hem = hem.upcase();
610  theUtmHemisphere = *(hem.begin());
611  }
612  if(utm_platform_position)
613  {
614  ossimUtmProjection utmProj;
615  std::vector<ossimString> splitString;
616  ossimString tempString(utm_platform_position);
617  tempString = tempString.trim();
618  ossimString datumString;
619  utmProj.setZone(theUtmZone);
620  utmProj.setHemisphere((char)theUtmHemisphere);
621  tempString.split(splitString, " ");
622  if(splitString.size() > 2)
623  {
624  theUtmPlatformPosition.x = splitString[0].toDouble();
625  theUtmPlatformPosition.y = splitString[1].toDouble();
626  theUtmPlatformPosition.z = splitString[2].toDouble();
627  }
628  if(splitString.size() > 3)
629  {
630  datumString = splitString[3];
631  }
632  const ossimDatum* datum = ossimDatumFactory::instance()->create(datumString);
633  if(datum)
634  {
635  utmProj.setDatum(datum);
636  }
637 
641 
642  ossimString heightType = kwl.find(prefix, "height_type");
643  if(heightType == "msl")
644  {
646  if(ossim::isnan(offset) == false)
647  {
650  }
651  }
653  }
654  else if(latlonh_platform_position)
655  {
656  std::vector<ossimString> splitString;
657  ossimString tempString(latlonh_platform_position);
658  std::string datumString;
659  tempString = tempString.trim();
660  tempString.split(splitString, " ");
661  if(splitString.size() > 2)
662  {
663  lat = splitString[0].toDouble();
664  lon = splitString[1].toDouble();
665  h = splitString[2].toDouble();
666  }
667  if(splitString.size() > 3)
668  {
669  datumString = splitString[3].string();
670  }
674  const ossimDatum* datum = ossimDatumFactory::instance()->create(datumString);
675  if(datum)
676  {
677  thePlatformPosition.datum(datum);
678  }
679  ossimString heightType = kwl.find(prefix, "height_type");
680  if(heightType == "msl")
681  {
683  if(ossim::isnan(offset) == false)
684  {
686  }
687  }
689  }
690  }
691  if(principal_point)
692  {
693  std::vector<ossimString> splitString;
694  ossimString tempString(principal_point);
695  tempString = tempString.trim();
696  tempString.split(splitString, " ");
697  if(splitString.size() == 2)
698  {
699  thePrincipalPoint.x = splitString[0].toDouble();
700  thePrincipalPoint.y = splitString[1].toDouble();
701  }
702  }
703  if(pixel_size)
704  {
705  std::vector<ossimString> splitString;
706  ossimString tempString(principal_point);
707  tempString = tempString.trim();
708  tempString.split(splitString, " ");
709  if(splitString.size() == 2)
710  {
711  thePixelSize.x = splitString[0].toDouble();
712  thePixelSize.y = splitString[1].toDouble();
713  }
714  }
715  if(focal_length)
716  {
717  theFocalLength = ossimString(focal_length).toDouble();
718  }
719 
720  if(camera_file)
721  {
722  ossimKeywordlist cameraKwl;
723  ossimKeywordlist lensKwl;
724  cameraKwl.add(camera_file);
725  const char* sensor = cameraKwl.find("sensor");
726  const char* image_size = cameraKwl.find(prefix, "image_size");
727  principal_point = cameraKwl.find("principal_point");
728  focal_length = cameraKwl.find("focal_length");
729  pixel_size = cameraKwl.find(prefix, "pixel_size");
730  focal_length = cameraKwl.find(prefix, "focal_length");
731  const char* distortion_units = cameraKwl.find(prefix, "distortion_units");
733  ossimUnitType unitType = OSSIM_MILLIMETERS;
734 
735  if(distortion_units)
736  {
737  unitType = (ossimUnitType)ossimUnitTypeLut::instance()->getEntryNumber(distortion_units);
738 
739  if(unitType == OSSIM_UNIT_UNKNOWN)
740  {
741  unitType = OSSIM_MILLIMETERS;
742  }
743  }
744  if(image_size)
745  {
746  std::vector<ossimString> splitString;
747  ossimString tempString(image_size);
748  tempString = tempString.trim();
749  tempString.split(splitString, " ");
750  double w=1, h=1;
751  if(splitString.size() == 2)
752  {
753  w = splitString[0].toDouble();
754  h = splitString[1].toDouble();
755  }
756  theImageClipRect = ossimDrect(0,0,w-1,h-1);
757  theRefImgPt = ossimDpt(w/2.0, h/2.0);
758  theImageSize = ossimDpt(w, h);
759  }
760  if(sensor)
761  {
762  theSensorID = sensor;
763  }
764  if(principal_point)
765  {
766  std::vector<ossimString> splitString;
767  ossimString tempString(principal_point);
768  tempString = tempString.trim();
769  tempString.split(splitString, " ");
770  if(splitString.size() == 2)
771  {
772  thePrincipalPoint.x = splitString[0].toDouble();
773  thePrincipalPoint.y = splitString[1].toDouble();
774  }
775  }
776  if(pixel_size)
777  {
778  std::vector<ossimString> splitString;
779  ossimString tempString(pixel_size);
780  tempString = tempString.trim();
781  tempString.split(splitString, " ");
782  if(splitString.size() == 1)
783  {
784  thePixelSize.x = splitString[0].toDouble();
786  }
787  else if(splitString.size() == 2)
788  {
789  thePixelSize.x = splitString[0].toDouble();
790  thePixelSize.y = splitString[1].toDouble();
791  }
792  }
793  if(focal_length)
794  {
795  theFocalLength = ossimString(focal_length).toDouble();
796  }
797 
798  cameraKwl.trimAllValues();
799 
800 
801  ossimString regExpression = ossimString("^(") + "d[0-9]+)";
802  vector<ossimString> keys;
803  cameraKwl.getSubstringKeyList( keys, regExpression );
804  long numberOfDistortions = (long)keys.size();
805  int offset = (int)ossimString("d").size();
806  ossim_uint32 idx = 0;
807  std::vector<int> numberList(numberOfDistortions);
808  for(idx = 0; idx < numberList.size();++idx)
809  {
810  ossimString numberStr(keys[idx].begin() + offset,
811  keys[idx].end());
812  numberList[idx] = numberStr.toInt();
813  }
814  std::sort(numberList.begin(), numberList.end());
815  double distance=0.0, distortion=0.0;
816 
817  for(idx = 0; idx < numberList.size(); ++idx)
818  {
819  ossimString value = cameraKwl.find(ossimString("d")+ossimString::toString(numberList[idx]));
820  if(!value.empty())
821  {
822  std::istringstream inStr(value.c_str());
823  inStr >> distance;
824  ossim::skipws(inStr);
825  inStr >> distortion;
826 #if 0
827  std::vector<ossimString> splitString;
828  ossimString tempString(value);
829  tempString = tempString.trim();
830  tempString.split(splitString, " ");
831  std::cout << splitString.size() << std::endl;
832  if(splitString.size() >= 2)
833  {
834  distance = splitString[0].toDouble();
835  distortion = splitString[1].toDouble();
836  }
837 #endif
838 
839  tool.setValue(distortion, unitType);
840  lensKwl.add(ossimString("distance") + ossimString::toString(idx),
841  distance,
842  true);
843  lensKwl.add(ossimString("distortion") + ossimString::toString(idx),
844  tool.getMillimeters(),
845  true);
846  }
847  lensKwl.add("convergence_threshold",
848  .00001,
849  true);
850  if(pixel_size)
851  {
852  lensKwl.add("dxdy",
854  true);
855  }
856  else
857  {
858  lensKwl.add("dxdy",
859  ".009 .009",
860  true);
861  }
862  }
864  {
865  theLensDistortion->loadState(lensKwl,"");
866  }
867  }
868  else
869  {
870 
871  if(principal_point)
872  {
873  std::vector<ossimString> splitString;
874  ossimString tempString(principal_point);
875  tempString = tempString.trim();
876  tempString.split(splitString, " ");
877  if(splitString.size() >= 2)
878  {
879  thePrincipalPoint.x = splitString[0].toDouble();
880  thePrincipalPoint.y = splitString[1].toDouble();
881  }
882  }
883  else
884  {
885  if(traceDebug())
886  {
887  ossimNotify(ossimNotifyLevel_DEBUG) << "No principal_point found" << std::endl;
888  return false;
889  }
890  }
891  if(pixel_size)
892  {
893  std::vector<ossimString> splitString;
894  ossimString tempString(pixel_size);
895  tempString = tempString.trim();
896  tempString.split(splitString, " ");
897  if(splitString.size() == 1)
898  {
899  thePixelSize.x = splitString[0].toDouble();
901  }
902  else if(splitString.size() == 2)
903  {
904  thePixelSize.x = splitString[0].toDouble();
905  thePixelSize.y = splitString[1].toDouble();
906  }
907  }
908  else
909  {
910  if(traceDebug())
911  {
912  ossimNotify(ossimNotifyLevel_DEBUG) << "No pixel size found" << std::endl;
913  return false;
914  }
915  }
916  if(focal_length)
917  {
918  theFocalLength = ossimString(focal_length).toDouble();
919  }
920  else
921  {
922  if(traceDebug())
923  {
924  ossimNotify(ossimNotifyLevel_DEBUG) << "No focal length found" << std::endl;
925  return false;
926  }
927  }
928 
930  {
931  ossimString lensPrefix = ossimString(prefix)+"distortion.";
933  lensPrefix.c_str());
934  }
935  }
937 
938  updateModel();
939 
941  if(compute_gsd_flag)
942  {
943  if(ossimString(compute_gsd_flag).toBool())
944  {
945  ossimGpt right;
946  ossimGpt top;
948  right);
950  top);
951 
954 
955  theGSD.x = horizontal.length();
956  theGSD.y = vertical.length();
957  theMeanGSD = (theGSD.x+theGSD.y)*.5;
958  }
959  }
960  if(traceDebug())
961  {
962  ossimNotify(ossimNotifyLevel_DEBUG) << "theOmega: " << theOmega << std::endl
963  << "thePhi: " << thePhi << std::endl
964  << "theKappa: " << theKappa << std::endl;
965  std::cout << "platform position: " << thePlatformPosition << std::endl;
966  std::cout << "platform position ECF: " << theEcefPlatformPosition << std::endl;
967  std::cout << "ossimApplanixModel::loadState: ......... leaving" << std::endl;
968  }
969 
970  return true;
971 }
972 
974 {
975  ossimKeywordlist kwl;
976  kwl.addFile(init_file.c_str());
977 
978  return loadState(kwl);
979 }
ossimString theSensorID
virtual const ossimDatum * create(const ossimString &code) const
create method
static NEWMAT::Matrix createRotationXMatrix(double angle, ossimCoordSysOrientMode orientationMode=OSSIM_RIGHT_HANDED)
void setParameterDescription(ossim_uint32 idx, const ossimString &descrption)
virtual ossimGpt inverse(const ossimDpt &eastingNorthing) const
Will take a point in meters and convert it to ground.
virtual void initAdjustableParameters()
void setImageRect(const ossimDrect &rect)
static ossimString upcase(const ossimString &aString)
Definition: ossimString.cpp:34
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
double z() const
virtual ossimObject * dup() const
double lond() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:97
void lineSampleToWorld(const ossimDpt &image_point, ossimGpt &gpt) const
ossimEcefPoint intersectAboveEarthEllipsoid(const double &heightAboveEllipsoid, const ossimDatum *aDatum=ossimDatumFactory::instance() ->wgs84()) const
ossimUnitType
Represents serializable keyword/value map.
void setPrincipalPoint(ossimDpt principalPoint)
bool addFile(const char *file)
bool intersectRay(const ossimEcefRay &ray, ossimGpt &gpt, double defaultElevValue=0.0)
METHOD: intersectRay()
bool valid() const
Definition: ossimRefPtr.h:75
ossimEcefVector cross(const ossimEcefVector &) const
const char * find(const char *key) const
double getShiftValuesX() const
ossimString theImageID
static NEWMAT::Matrix createRotationYMatrix(double angle, ossimCoordSysOrientMode orientationMode=OSSIM_RIGHT_HANDED)
ossim_int32 getUtmZone() const
NEWMAT::Matrix theCompositeMatrixInverse
double getShiftValuesY() const
const ossimDpt & ul() const
Definition: ossimDrect.h:339
void setValue(double value, ossimUnitType unitType=OSSIM_METERS)
double y
Definition: ossimDpt.h:165
virtual const ossimString & code() const
Definition: ossimDatum.h:57
void makeNan()
Definition: ossimGpt.h:130
static ossimString toString(bool aValue)
Numeric to string methods.
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
double x() const
void split(std::vector< ossimString > &result, const ossimString &separatorList, bool skipBlankFields=false) const
Splits this string into a vector of strings (fields) using the delimiter list specified.
double magnitude() const
virtual ossim_int32 getEntryNumber(const char *entry_string, bool case_insensitive=true) const
static ossimElevManager * instance()
METHOD: instance() Implements singelton pattern.
virtual void lineSampleHeightToWorld(const ossimDpt &image_point, const double &heightEllipsoid, ossimGpt &worldPoint) const
void setOrigin(const ossimEcefPoint &orig)
Definition: ossimEcefRay.h:81
double latd() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:87
virtual void worldToLineSample(const ossimGpt &world_point, ossimDpt &image_point) const
virtual ossimDpt forward(const ossimGpt &latLon) const
All map projections will convert the world coordinate to an easting northing (Meters).
virtual void setMetersPerPixel(const ossimDpt &gsd)
const ossimDatum * datum() const
datum().
Definition: ossimGpt.h:196
ossimEcefPoint theEcefPlatformPosition
ossim_int32 toInt32() const
ossim_int32 getFieldIdxLike(const ossimString &searchKey) const
Is a case insensitive parse of the column names for the orientation record.
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
const NEWMAT::Matrix & lsrToEcefRotMatrix() const
double z
Definition: ossimDpt3d.h:145
OSSIM_DLL std::istream & skipws(std::istream &in)
Definition: ossimCommon.cpp:38
void setPixelSize(const ossimDpt &pixelSize)
std::string::size_type size() const
Definition: ossimString.h:405
std::string::iterator begin()
Definition: ossimString.h:420
unsigned int ossim_uint32
ossimString trim(const ossimString &valueToTrim=ossimString(" \\)) const
this will strip lead and trailing character passed in.
RTTI_DEF1(ossimApplanixUtmModel, "ossimApplanixUtmModel", ossimSensorModel)
ossimPolygon theBoundGndPolygon
ossimEcefPoint theAdjEcefPlatformPosition
static ossimGeoidManager * instance()
Implements singelton pattern:
double height() const
Definition: ossimGpt.h:107
double toDouble() const
static ossimDatumFactory * instance()
bool hasNans() const
will sequence through the polygon and check to see if any values are NAN
NEWMAT::Matrix theCompositeMatrix
uses file path to init model
void setParameterUnit(ossim_uint32 idx, ossimUnitType unit)
virtual void undistort(const ossimDpt &input, ossimDpt &output) const
ossimString getUtmHemisphere() const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
bool pointWithin(const ossimDpt &point) const
METHOD: pointWithin(ossimDpt) Returns TRUE if point is inside polygon.
bool hasNans() const
Definition: ossimDpt.h:67
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
void setZone(const ossimGpt &ground)
const ossimRefPtr< ossimApplanixEORecord > getRecordGivenId(const ossimString &id) const
Given an ID it will search and find an EO record that matches the ID.
double length() const
ossimEcefVector theShiftValues
std::vector< ossimString > getSubstringKeyList(const ossimString &regularExpression) const
ossimRefPtr< ossimMeanRadialLensDistortion > theLensDistortion
ossim_uint32 getNumberOfVertices() const
ossimDrect theImageClipRect
double x() const
static NEWMAT::Matrix createIdentity()
double y() const
ossimDpt midPoint() const
Definition: ossimDrect.h:817
virtual void setAdjustableParameter(ossim_uint32 idx, double value, bool notify=false)
static NEWMAT::Matrix createRotationZMatrix(double angle, ossimCoordSysOrientMode orientationMode=OSSIM_RIGHT_HANDED)
static NEWMAT::Matrix createIdentity()
const ossimDpt & ur() const
Definition: ossimDrect.h:340
double getShiftValuesZ() const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
double y() const
double x
Definition: ossimDpt.h:164
double x
Definition: ossimDpt3d.h:143
void resizeAdjustableParameterArray(ossim_uint32 numberOfParameters)
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
bool empty() const
Definition: ossimString.h:411
const ossimColumnVector3d & data() const
ossimDpt metersPerDegree() const
Definition: ossimGpt.cpp:498
const ossimDpt & ll() const
Definition: ossimDrect.h:342
std::basic_istringstream< char > istringstream
Class for char input memory streams.
Definition: ossimIosFwd.h:32
void setFocalLength(double focalLength)
void resize(ossim_uint32 newSize)
void setDirection(const ossimEcefVector &d)
Definition: ossimEcefRay.h:82
double y
Definition: ossimDpt3d.h:144
virtual bool setupOptimizer(const ossimString &init_file)
ground to image faster (you don&#39;t need DEM) //TBC
bool parseFile(const ossimFilename &file)
Will parse the entire Exterior orientation file and then index any record ID&#39;s found.
virtual void setDatum(const ossimDatum *datum)
Sets theDatum to datum.
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
float distance(double lat1, double lon1, double lat2, double lon2, int units)
static ossimUnitTypeLut * instance()
Returns the static instance of an ossimUnitTypeLut object.
virtual double offsetFromEllipsoid(const ossimGpt &gpt)
const ossimDpt & lr() const
Definition: ossimDrect.h:341
void setHemisphere(const ossimGpt &ground)
virtual void distort(const ossimDpt &input, ossimDpt &output) const
double z() const
void setPlatformPosition(const ossimGpt &gpt)
void setParameterSigma(ossim_uint32 idx, double value, bool notify=false)
int toInt() const
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
void makeNan()
Definition: ossimDpt.h:65
ossim_float64 theMeanGSD
int ossim_int32
ossimKeywordlist & trimAllValues(const ossimString &valueToTrim=ossimString(" \\))
virtual void imagingRay(const ossimDpt &image_point, ossimEcefRay &image_ray) const
bool isnan(const float &v)
isnan Test for floating point Not A Number (NAN) value.
Definition: ossimCommon.h:91