OSSIM - Open Source Software Image Map  Version 1.9.0 (20180803)
ossimBuckeyeSensor.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 //
8 //*******************************************************************
9 // $Id: ossimBuckeyeSensor.cpp $
10 
14 #include <ossim/base/ossimTrace.h>
18 static ossimTrace traceDebug("ossimBuckeyeSensor:debug");
19 
20 RTTI_DEF1(ossimBuckeyeSensor, "ossimBuckeyeSensor", ossimSensorModel);
21 
22 ossimBuckeyeSensor::ossimBuckeyeSensor()
23 {
24  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::ossimBuckeyeSensor(): entering..." << std::endl;
25 
26  theCompositeMatrix = ossimMatrix4x4::createIdentity();
27  theCompositeMatrixInverse = ossimMatrix4x4::createIdentity();
28  theRoll = 0.0;
29  thePitch = 0.0;
30  theHeading = 0.0;
31  theFocalLength = 0.0;
32  thePixelSize = ossimDpt(0.0, 0.0);
33  thePrincipalPoint = ossimDpt(0.0, 0.0);
34  theEcefPlatformPosition = ossimGpt(0.0, 0.0, 0.0);
35  theAdjEcefPlatformPosition = ossimGpt(0.0, 0.0, 0.0);
36  theLensDistortion = new ossimSmacCallibrationSystem();
37 
38  theGSD.makeNan();
39  initAdjustableParameters();
40 
41  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::ossimBuckeyeSensor(): returning..." << std::endl;
42 }
43 ossimBuckeyeSensor::ossimBuckeyeSensor(const ossimDrect& imageRect,
44  const ossimGpt& platformPosition,
45  double roll,
46  double pitch,
47  double heading,
48  const ossimDpt& /* principalPoint */, // in millimeters
49  double focalLength, // in millimeters
50  const ossimDpt& pixelSize) // in millimeters
51 {
52  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::ossimBuckeyeSensor(imageRect,platformPosition,roll,pitch,heading,ossimDpt,focalLength,pixelSize): entering..." << std::endl;
53 
54  theImageClipRect = imageRect;
55  theRefImgPt = theImageClipRect.midPoint();
56  theCompositeMatrix = ossimMatrix4x4::createIdentity();
57  theCompositeMatrixInverse = ossimMatrix4x4::createIdentity();
58  theRoll = roll;
59  thePitch = pitch;
60  theHeading = heading;
61  theFocalLength = focalLength;
62  thePixelSize = pixelSize;
63  theEcefPlatformPosition = platformPosition;
64  theAdjEcefPlatformPosition = platformPosition;
65  theLensDistortion = new ossimSmacCallibrationSystem();
66  theGSD.makeNan();
67 
68  initAdjustableParameters();
69  updateModel();
70 
71  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::ossimBuckeyeSensor(imageRect,platformPosition,roll,pitch,heading,ossimDpt,focalLength,pixelSize): returning..." << std::endl;
72 }
73 
74 ossimBuckeyeSensor::ossimBuckeyeSensor(const ossimBuckeyeSensor& src)
75  :ossimSensorModel(src)
76 {
77  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::ossimBuckeyeSensor(src): entering..." << std::endl;
78 
79  initAdjustableParameters();
80 
81  if(src.theLensDistortion.valid())
82  {
83  theLensDistortion = new ossimSmacCallibrationSystem(*(src.theLensDistortion.get()));
84  }
85  else
86  {
87  theLensDistortion = new ossimSmacCallibrationSystem();
88  }
89  theGSD.makeNan();
90 
91  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::ossimBuckeyeSensor(src): returning..." << std::endl;
92 }
93 
94 ossimObject* ossimBuckeyeSensor::dup()const
95 {
96  return new ossimBuckeyeSensor(*this);
97 }
98 
99 void ossimBuckeyeSensor::imagingRay(const ossimDpt& image_point,
100  ossimEcefRay& image_ray) const
101 {
102  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "ossimBuckeyeSensor::imagingRay: ..... entered" << std::endl;
103 
104  ossimDpt f1 ((image_point) - theRefImgPt);
105  f1.x *= thePixelSize.x;
106  f1.y *= -thePixelSize.y;
107  ossimDpt film (f1 - thePrincipalPoint);
108 
109  if(traceDebug())
110  {
111  ossimNotify(ossimNotifyLevel_DEBUG) << "pixel size = " << thePixelSize << std::endl;
112  ossimNotify(ossimNotifyLevel_DEBUG) << "principal pt = " << thePrincipalPoint << std::endl;
113  ossimNotify(ossimNotifyLevel_DEBUG) << "film pt = " << film << std::endl;
114  }
115 
116  if (theLensDistortion.valid())
117  {
118  ossimDpt filmOut;
119  theLensDistortion->undistort(film, filmOut);
120  film = filmOut;
121  }
122 
123  ossimColumnVector3d cam_ray_dir (film.x,
124  film.y,
125  -theFocalLength);
126  ossimEcefVector ecf_ray_dir (theCompositeMatrix*cam_ray_dir);
127  ecf_ray_dir = ecf_ray_dir*(1.0/ecf_ray_dir.magnitude());
128 
129  image_ray.setOrigin(theAdjEcefPlatformPosition);
130  image_ray.setDirection(ecf_ray_dir);
131 
132  if(traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "ossimBuckeyeSensor::imagingRay: ..... leaving" << std::endl;
133 }
134 
135 void ossimBuckeyeSensor::lineSampleToWorld(const ossimDpt& image_point,
136  ossimGpt& gpt) const
137 {
138  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::lineSampleToWorld:entering..." << std::endl;
139 
140  if(image_point.hasNans())
141  {
142  gpt.makeNan();
143  return;
144  }
145 
146  //***
147  // Determine imaging ray and invoke elevation source object's services to
148  // intersect ray with terrain model:
149  //***
150 
151  ossimEcefRay ray;
152  imagingRay(image_point, ray);
154 
155  if (traceDebug())
156  {
157  ossimNotify(ossimNotifyLevel_DEBUG) << "image_point = " << image_point << std::endl;
158  ossimNotify(ossimNotifyLevel_DEBUG) << "ray = " << ray << std::endl;
159  ossimNotify(ossimNotifyLevel_DEBUG) << "gpt = " << gpt << std::endl;
160  }
161 
162  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::lineSampleToWorld: returning..." << std::endl;
163  return;
164 }
165 
166 void ossimBuckeyeSensor::lineSampleHeightToWorld(const ossimDpt& image_point,
167  const double& heightEllipsoid,
168  ossimGpt& worldPoint) const
169 {
170  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::lineSampleHeightToWorld: entering..." << std::endl;
171  if (!insideImage(image_point))
172  {
173  worldPoint.makeNan();
174  }
175  else
176  {
177  //***
178  // First establish imaging ray from image point:
179  //***
180  ossimEcefRay ray;
181  imagingRay(image_point, ray);
182  ossimEcefPoint Pecf (ray.intersectAboveEarthEllipsoid(heightEllipsoid));
183  worldPoint = ossimGpt(Pecf);
184  }
185  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::lineSampleHeightToWorld: returning..." << std::endl;
186 }
187 
188 void ossimBuckeyeSensor::worldToLineSample(const ossimGpt& world_point,
189  ossimDpt& image_point) const
190 {
191  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::worldToLineSample: entering..." << std::endl;
192  if((theBoundGndPolygon.getNumberOfVertices() > 0)&&
193  (!theBoundGndPolygon.hasNans()))
194  {
195  if (!(theBoundGndPolygon.pointWithin(world_point)))
196  {
197  image_point.makeNan();
198  return;
199  }
200  }
201  ossimEcefPoint g_ecf(world_point);
202  ossimEcefVector ecfRayDir(g_ecf - theAdjEcefPlatformPosition);
203  ossimColumnVector3d camRayDir (theCompositeMatrixInverse*ecfRayDir.data());
204 
205 
206  double scale = -theFocalLength/camRayDir[2];
207  ossimDpt film (scale*camRayDir[0], scale*camRayDir[1]);
208 
209  if (theLensDistortion.valid())
210  {
211  ossimDpt filmOut;
212  theLensDistortion->distort(film, filmOut);
213  film = filmOut;
214  }
215 
216  ossimDpt f1(film + thePrincipalPoint);
217  ossimDpt p1(f1.x/thePixelSize.x,
218  -f1.y/thePixelSize.y);
219 
220  ossimDpt p0 (p1.x + theRefImgPt.x,
221  p1.y + theRefImgPt.y);
222 
223  image_point = p0;
224  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::worldToLineSample: returning..." << std::endl;
225 }
226 
227 void ossimBuckeyeSensor::updateModel()
228 {
229  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::updateModel: entering..." << std::endl;
230  ossimGpt gpt;
231  ossimGpt wgs84Pt;
232  double metersPerDegree = wgs84Pt.metersPerDegree().x;
233  double degreePerMeter = 1.0/metersPerDegree;
234  double latShift = -computeParameterOffset(1)*degreePerMeter;
235  double lonShift = computeParameterOffset(0)*degreePerMeter;
236 
237  gpt = theEcefPlatformPosition;
238  double height = gpt.height();
239  gpt.height(height + computeParameterOffset(5));
240  gpt.latd(gpt.latd() + latShift);
241  gpt.lond(gpt.lond() + lonShift);
242  theAdjEcefPlatformPosition = gpt;
243  ossimLsrSpace lsrSpace(theAdjEcefPlatformPosition, theHeading+computeParameterOffset(4));
244 
245  // make a left handed rotational matrix;
246  ossimMatrix4x4 lsrMatrix(lsrSpace.lsrToEcefRotMatrix());
247  NEWMAT::Matrix orientation = (ossimMatrix4x4::createRotationXMatrix(thePitch+computeParameterOffset(3), OSSIM_LEFT_HANDED)*
248  ossimMatrix4x4::createRotationYMatrix(theRoll+computeParameterOffset(2), OSSIM_LEFT_HANDED));
249  theCompositeMatrix = (lsrMatrix.getData()*orientation);
250  theCompositeMatrixInverse = theCompositeMatrix.i();
251 
252  theBoundGndPolygon.resize(4);
253 
254  theExtrapolateImageFlag = false;
255  theExtrapolateGroundFlag = false;
256 
257  try
258  {
259  // Method throws ossimException.
260  computeGsd();
261  }
262  catch (const ossimException& e)
263  {
265  << "ossimBuckeyeSensor Constructor caught Exception:\n"
266  << e.what() << std::endl;
267  }
268 
269  lineSampleToWorld(theImageClipRect.ul(),gpt);
270  theBoundGndPolygon[0] = gpt;
271  lineSampleToWorld(theImageClipRect.ur(),gpt);
272  theBoundGndPolygon[1] = gpt;
273  lineSampleToWorld(theImageClipRect.lr(),gpt);
274  theBoundGndPolygon[2] = gpt;
275  lineSampleToWorld(theImageClipRect.ll(),gpt);
276  theBoundGndPolygon[3] = gpt;
277  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::updateModel: returning..." << std::endl;
278 }
279 
280 void ossimBuckeyeSensor::initAdjustableParameters()
281 {
282  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::initAdjustableParameters: entering..." << std::endl;
283  resizeAdjustableParameterArray(6);
284 
285  setAdjustableParameter(0, 0.0);
286  setParameterDescription(0, "x_offset");
287  setParameterUnit(0, "pixels");
288 
289  setAdjustableParameter(1, 0.0);
290  setParameterDescription(1, "y_offset");
291  setParameterUnit(1, "pixels");
292 
293  setAdjustableParameter(2, 0.0);
294  setParameterDescription(2, "roll");
295  setParameterUnit(2, "degrees");
296 
297  setAdjustableParameter(3, 0.0);
298  setParameterDescription(3, "pitch");
299  setParameterUnit(3, "degrees");
300 
301  setAdjustableParameter(4, 0.0);
302  setParameterDescription(4, "heading");
303  setParameterUnit(4, "degrees");
304 
305  setAdjustableParameter(5, 0.0);
306  setParameterDescription(5, "altitude");
307  setParameterUnit(5, "meters");
308 
309  // TODO: default to correct default values, or just leave it up to the input file, since we have different offsets for the B100, 182, and Metroliner, also need a z offset
310  setParameterSigma(0, 1.0);
311  setParameterSigma(1, 1.0);
312  setParameterSigma(2, 0);
313  setParameterSigma(3, 0);
314  setParameterSigma(4, 0);
315  setParameterSigma(5, 1000);
316  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::initAdjustableParameters: returning..." << std::endl;
317 }
318 
319 void ossimBuckeyeSensor::setLensDistortion(ossimSmacCallibrationSystem* lensDistortion)
320 {
321  theLensDistortion = lensDistortion;
322  updateModel();
323 }
324 
325 bool ossimBuckeyeSensor::saveState(ossimKeywordlist& kwl,
326  const char* prefix) const
327 {
328  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::saveState: entering..." << std::endl;
329  ossimSensorModel::saveState(kwl, prefix);
330 
331  kwl.add(prefix, "type", "ossimBuckeyeSensor", true);
332 
333  kwl.add(prefix, "roll", theRoll, true);
334  kwl.add(prefix, "pitch", thePitch, true);
335  kwl.add(prefix, "heading", theHeading, true);
336  kwl.add(prefix, "principal_point", "("+ossimString::toString(thePrincipalPoint.x) + "," + ossimString::toString(thePrincipalPoint.y)+")");
337  kwl.add(prefix, "pixel_size", "("+ossimString::toString(thePixelSize.x) + "," + ossimString::toString(thePixelSize.y)+")");
338  kwl.add(prefix, "focal_length", theFocalLength);
339  kwl.add(prefix, "ecef_platform_position",
340  ossimString::toString(theEcefPlatformPosition.x()) + " " +
341  ossimString::toString(theEcefPlatformPosition.y()) + " " +
342  ossimString::toString(theEcefPlatformPosition.z()));
343 
344  if(theLensDistortion.valid())
345  {
346  ossimString lensPrefix = ossimString(prefix)+"distortion.";
347  theLensDistortion->saveState(kwl,
348  lensPrefix.c_str());
349  }
350  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::saveState: returning..." << std::endl;
351  return true;
352 }
353 
354 bool ossimBuckeyeSensor::loadState(const ossimKeywordlist& kwl,
355  const char* prefix)
356 {
357  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::loadState: entering..." << std::endl;
358 
359  ossimSensorModel::loadState(kwl, prefix);
360 
361  // If theRefImgPt remains unset by ossimSensorModel::loadState(),
362  // set it to the image center.
363  if ( theRefImgPt == ossimDpt(0, 0) )
364  {
365  theRefImgPt = theImageClipRect.midPoint();
366  }
367 
368  if(getNumberOfAdjustableParameters() < 1)
369  {
370  initAdjustableParameters();
371  }
372 
373  ossimString framemeta_gsti = kwl.find(prefix, "framemeta_gsti");
374  ossimString framemeta = kwl.find(prefix,"framemeta");
375  ossimString frame_number = kwl.find(prefix, "frame_number");
376  ossimString pixel_size = kwl.find(prefix, "pixel_size");
377  ossimString principal_point = kwl.find(prefix, "principal_point");
378  ossimString focal_length = kwl.find(prefix, "focal_length");
379  ossimString smac_radial = kwl.find(prefix, "smac_radial");
380  ossimString smac_decent = kwl.find(prefix, "smac_decent");
381  ossimString roll;
382  ossimString pitch;
383  ossimString yaw;
384  ossimString platform_position;
385  ossimFilename file_to_load;
386 
387  ossimString FRAME_STRING = "Frame#";
388  ossimString ROLL_STRING = "Roll(deg)";
389  ossimString PITCH_STRING = "Pitch(deg)";
390  ossimString YAW_STRING = "Yaw(deg)";
391  ossimString LAT_STRING = "Lat(deg)";
392  ossimString LON_STRING = "Lon(deg)";
393  ossimString HAE_STRING = "HAE(m)";
394 
395  // Deal with the fact that there are 3 different types of 'FrameMeta' file
396  if (framemeta_gsti.empty() && !framemeta.empty() && !frame_number.empty())
397  {
398  file_to_load.setFile(framemeta);
399  YAW_STRING = "Azimuth(deg)";
400  }
401  else if (!framemeta_gsti.empty() && framemeta.empty() && !frame_number.empty())
402  {
403  file_to_load.setFile(framemeta_gsti);
404  }
405 
406  if (file_to_load.exists() && !frame_number.empty())
407  {
408  ossimCsvFile csv(" \t"); // we will use tab or spaces as separator
409  if(csv.open(file_to_load))
410  {
411  if(csv.readHeader())
412  {
413  ossimCsvFile::StringListType heads = csv.fieldHeaderList();
414  // Try to see if you can find the first header item, if not, then you either have a file that doesn't work in this case, or it's uppercase
415  if (std::find(heads.begin(), heads.end(), FRAME_STRING) == heads.end())
416  {
417  FRAME_STRING = FRAME_STRING.upcase();
418  ROLL_STRING = ROLL_STRING.upcase();
419  PITCH_STRING = PITCH_STRING.upcase();
420  YAW_STRING = YAW_STRING.upcase();
421  LAT_STRING = LAT_STRING.upcase();
422  LON_STRING = LON_STRING.upcase();
423  HAE_STRING = HAE_STRING.upcase();
424  }
425 
427  bool foundFrameNumber = false;
428  while( ((record = csv.nextRecord()).valid()) && !foundFrameNumber)
429  {
430  if( (*record)[FRAME_STRING] == frame_number)
431  {
432  foundFrameNumber = true;
433  roll = (*record)[ROLL_STRING];
434  pitch = (*record)[PITCH_STRING];
435  yaw = (*record)[YAW_STRING];
436  platform_position = (*record)[LAT_STRING] + " "
437  + (*record)[LON_STRING]+ " "
438  + (*record)[HAE_STRING] + " WGE";
439  }
440  }
441  }
442  }
443  csv.close();
444  }
445  else
446  {
447  roll = kwl.find(prefix, "roll");
448  pitch = kwl.find(prefix, "pitch");
449  yaw = kwl.find(prefix, "heading");
450  platform_position = kwl.find(prefix, "ecef_platform_position");
451  }
452 
453  bool result = (!pixel_size.empty()&&
454  !principal_point.empty()&&
455  !focal_length.empty()&&
456  !platform_position.empty());
457 
458  if(!focal_length.empty())
459  {
460  theFocalLength = focal_length.toDouble();
461  }
462  if(!pixel_size.empty())
463  {
464  thePixelSize.toPoint(pixel_size);
465  }
466  if(!roll.empty())
467  {
468  theRoll = roll.toDouble();
469  }
470  if(!pitch.empty())
471  {
472  thePitch = pitch.toDouble();
473  }
474  if(!yaw.empty())
475  {
476  theHeading = yaw.toDouble();
477  }
478  if(!principal_point.empty())
479  {
480  thePrincipalPoint.toPoint(principal_point);
481  }
482  if(platform_position.contains("WGE"))
483  {
484  std::vector<ossimString> splitString;
485  ossimString tempString(platform_position);
486  tempString.split(splitString, ossimString(" "));
487  std::string datumString;
488  double lat=0.0, lon=0.0, h=0.0;
489  if(splitString.size() > 2)
490  {
491  lat = splitString[0].toDouble();
492  lon = splitString[1].toDouble();
493  h = splitString[2].toDouble();
494  }
495 
496  theEcefPlatformPosition = ossimGpt(lat,lon,h);
497  } else {
498  std::vector<ossimString> splitString;
499  ossimString tempString(platform_position);
500  tempString.split(splitString, ossimString(" "));
501  std::string datumString;
502  double x=0.0, y=0.0, z=0.0;
503  if(splitString.size() > 2)
504  {
505  x = splitString[0].toDouble();
506  y = splitString[1].toDouble();
507  z = splitString[2].toDouble();
508  }
509  theEcefPlatformPosition = ossimEcefPoint(x, y, z);
510  }
511  theLensDistortion = 0;
512  if(!smac_radial.empty()&&
513  !smac_decent.empty())
514  {
515  std::vector<ossimString> radial;
516  std::vector<ossimString> decent;
517  smac_radial.split(radial, " ");
518  smac_decent.split(decent, " ");
519  if((radial.size() == 5)&&
520  (decent.size() == 4))
521  {
522  // Just for debugging really.. optimization will make this sleeker
523  double k0 = radial[0].toDouble();
524  double k1 = radial[1].toDouble();
525  double k2 = radial[2].toDouble();
526  double k3 = radial[3].toDouble();
527  double k4 = radial[4].toDouble();
528 
529  double p0 = decent[0].toDouble();
530  double p1 = decent[1].toDouble();
531  double p2 = decent[2].toDouble();
532  double p3 = decent[3].toDouble();
533 
534  theLensDistortion = new ossimSmacCallibrationSystem(k0,k1,k2,k3,k4,p0,p1,p2,p3);
535  }
536  }
537  theImageSize = ossimDpt(theImageClipRect.width(),
538  theImageClipRect.height());
539 
540  updateModel();
541 
542  if (traceDebug()) ossimNotify(ossimNotifyLevel_DEBUG) << "DEBUG ossimBuckeyeSensor::loadState: returning..." << std::endl;
543  return result;
544 }
545 
546 bool ossimBuckeyeSensor::setupOptimizer(const ossimString& init_file)
547 {
548  ossimKeywordlist kwl;
549  kwl.addFile(init_file.c_str());
550 
551  return loadState(kwl);
552 }
553 
554 void ossimBuckeyeSensor::setPrincipalPoint(ossimDpt principalPoint)
555 {
556  thePrincipalPoint = principalPoint;
557 }
558 
559 void ossimBuckeyeSensor::setRollPitchHeading(double roll,
560  double pitch,
561  double heading)
562 {
563  theRoll = roll;
564  thePitch = pitch;
565  theHeading = heading;
566 
567  updateModel();
568 }
569 
570 void ossimBuckeyeSensor::setPixelSize(const ossimDpt& pixelSize)
571 {
572  thePixelSize = pixelSize;
573 }
574 
575 void ossimBuckeyeSensor::setImageRect(const ossimDrect& rect)
576 {
577  theImageClipRect = rect;
578  theRefImgPt = rect.midPoint();
579 }
580 
581 void ossimBuckeyeSensor::setFocalLength(double focalLength)
582 {
583  theFocalLength = focalLength;
584 }
585 
586 void ossimBuckeyeSensor::setPlatformPosition(const ossimGpt& gpt)
587 {
588  theRefGndPt = gpt;
589  theEcefPlatformPosition = gpt;
590  updateModel();
591 
592 }
593 
594 bool ossimBuckeyeSensor::getImageGeometry(
595  const ossimString& ref, const ossimString& value,
596  ossimKeywordlist& geomKwl ) const
597 {
598  if ( ref == ossimString( "parameters/fsmmgSensorImage/collectionTime" ) )
599  {
600  /* not currently used */
601  }
602  else
603  if ( ref == ossimString( "parameters/fsmmgSensorSession/sensorType" ) )
604  {
605  /* not currently used */
606  }
607  else
608  if ( ref == ossimString( "parameters/fsmmgSensorSession/focus/focalLength" ) )
609  {
610  geomKwl.add( "focal_length", value.toDouble() );
611  }
612  else
613  if ( ref == ossimString( "parameters/fsmmgSensorSession/pixelGridCharacteristics/numberOfRowsInImage" ) )
614  {
615  /* Add check to value already set from limits/GridEnvelope/low,high: should be equal */
616  }
617  else
618  if ( ref == ossimString( "parameters/fsmmgSensorSession/pixelGridCharacteristics/numberOfColumnsInImage" ) )
619  {
620  /* Add check to value already set from limits/GridEnvelope/low,high: should be equal */
621  }
622  else
623  if ( ref == ossimString( "parameters/fsmmgSensorSession/pixelGridCharacteristics/rowSpacing" ) )
624  {
625  ossimDpt point = ossimDpt();
626  ossimString pixel_size = geomKwl.find( "pixel_size" );
627  if ( !pixel_size.empty() )
628  {
629  point.toPoint( pixel_size );
630  }
631  point.y = value.toDouble();
632  geomKwl.add( "pixel_size", point.toString().c_str() );
633  }
634  else
635  if ( ref == ossimString( "parameters/fsmmgSensorSession/pixelGridCharacteristics/columnSpacing" ) )
636  {
637  ossimDpt point = ossimDpt();
638  ossimString pixel_size = geomKwl.find( "pixel_size" );
639  if ( !pixel_size.empty() )
640  {
641  point.toPoint( pixel_size );
642  }
643  point.x = value.toDouble();
644  geomKwl.add( "pixel_size", point.toString().c_str() );
645  }
646  else
647  if ( ref == ossimString( "parameters/fsmmgSensorImage/positionOrientationState/perspectiveCenter/geocentric-x-y-z" ) )
648  {
649  // first remove trailing spaces
650  size_t first_space = value.find_first_of( ' ', 0 );
651  ossimString truncatedValue = value.beforePos( first_space );
652  // change commas into spaces
653  ossimString platformPositionStr = truncatedValue.substitute( ossimString( "," ), ossimString( " " ), true );
654  // add to keywordlist
655  geomKwl.add( "ecef_platform_position", platformPositionStr );
656  }
657  else
658  if ( ref == ossimString( "parameters/fsmmgSensorImage/velocity/components/geocentric-x-y-z" ) )
659  {
660  /* not currently used */
661  }
662  else
663  if ( ref == ossimString( "parameters/fsmmgSensorSession/principalPointOffset/components/imagePlaneCRS-x0-y0" ) )
664  {
665  ossimDpt principal_point_offset;
666  size_t first_comma = value.find_first_of( ',', 0 );
667  ossimString offsetxStr = value.beforePos( first_comma );
668  ossimString offsetyStr = value.afterPos( first_comma );
669  principal_point_offset.x = offsetxStr.toDouble();
670  principal_point_offset.y = offsetyStr.toDouble();
671  geomKwl.add( "principal_point", principal_point_offset.toString().c_str() );
672  }
673  else
674  if ( ref == ossimString( "parameters/fsmmgSensorSession/radialDistortion/coefficients/k0-k1-k2-k3-k4" ) )
675  {
676  // first remove trailing spaces
677  size_t first_space = value.find_first_of( ' ', 0 );
678  ossimString truncatedValue = value.beforePos( first_space );
679  // change commas into spaces
680  ossimString radialDistortionStr = truncatedValue.substitute( ossimString( "," ), ossimString( " " ), true );
681  // add to keywordlist
682  geomKwl.add( "smac_radial", radialDistortionStr );
683  }
684  else
685  if ( ref == ossimString( "parameters/fsmmgSensorSession/decenteringDistortion/coefficients/p0-p1-p2-p3" ) )
686  {
687  // first remove trailing spaces
688  size_t first_space = value.find_first_of( ' ', 0 );
689  ossimString truncatedValue = value.beforePos( first_space );
690  // change commas into spaces
691  ossimString decenteringDistortionStr = truncatedValue.substitute( ossimString( "," ), ossimString( " " ), true );
692  // add to keywordlist
693  geomKwl.add( "smac_decent", decenteringDistortionStr );
694  }
695  else
696  if ( ref == ossimString( "parameters/fsmmgPlatformImage/positionOrientationState/externalOrientation/platformCS-roll-pitch-yaw" ) )
697  {
698  size_t pos_comma = value.find_first_of( ',', 0 );
699  ossimString rollStr = value.beforePos( pos_comma );
700  ossimString remainderStr0 = value.afterPos( pos_comma );
701 
702  pos_comma = remainderStr0.find_first_of( ',', 0 );
703  ossimString pitchStr = remainderStr0.beforePos( pos_comma );
704  ossimString remainderStr1 = remainderStr0.afterPos( pos_comma );
705 
706  pos_comma = remainderStr1.find_first_of( ',', 0 );
707  ossimString yawStr = remainderStr1.beforePos( pos_comma );
708 
709  geomKwl.add( "roll", rollStr.toDouble() );
710  geomKwl.add( "pitch", pitchStr.toDouble() );
711  geomKwl.add( "heading", yawStr.toDouble() );
712  }
713  else // need to add in all supported parameters from the primary SensorML document
714  {
715  /* Add debug message */
716  return false;
717  }
718 
719  return true;
720 }
ossim_uint32 x
ossimString substitute(const ossimString &searchKey, const ossimString &replacementValue, bool replaceAll=false) const
Substitutes searchKey string with replacementValue and returns a string.
static ossimString upcase(const ossimString &aString)
Definition: ossimString.cpp:34
static NEWMAT::Matrix createRotationYMatrix(double angle, ossimCoordSysOrientMode orientationMode=OSSIM_RIGHT_HANDED)
virtual bool loadState(const ossimKeywordlist &kwl, const char *prefix=0)
ossimMatrix4x4 & i()
double lond() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:97
ossimFilename & setFile(const ossimString &f)
ossimEcefPoint intersectAboveEarthEllipsoid(const double &heightAboveEllipsoid, const ossimDatum *aDatum=ossimDatumFactory::instance() ->wgs84()) const
Represents serializable keyword/value map.
bool addFile(const char *file)
ossim_uint32 y
bool intersectRay(const ossimEcefRay &ray, ossimGpt &gpt, double defaultElevValue=0.0)
METHOD: intersectRay()
const char * find(const char *key) const
ossimString afterPos(std::string::size_type pos) const
double y
Definition: ossimDpt.h:165
bool contains(char aChar) const
Definition: ossimString.h:58
void makeNan()
Definition: ossimGpt.h:130
static ossimString toString(bool aValue)
Numeric to string methods.
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.
static ossimElevManager * instance()
METHOD: instance() Implements singelton pattern.
void setOrigin(const ossimEcefPoint &orig)
Definition: ossimEcefRay.h:81
double latd() const
Will convert the radian measure to degrees.
Definition: ossimGpt.h:87
std::string::size_type find_first_of(char c, std::string::size_type pos=0) const
Equivalent to find(c, pos).
Definition: ossimString.h:801
void add(const char *prefix, const ossimKeywordlist &kwl, bool overwrite=true)
bool exists() const
RTTI_DEF1(ossimBuckeyeSensor, "ossimBuckeyeSensor", ossimSensorModel)
virtual const char * what() const
Returns the error message.
static NEWMAT::Matrix createRotationXMatrix(double angle, ossimCoordSysOrientMode orientationMode=OSSIM_RIGHT_HANDED)
void toPoint(const std::string &s)
Initializes this point from string.
Definition: ossimDpt.cpp:192
double height() const
Definition: ossimGpt.h:107
double toDouble() const
virtual bool saveState(ossimKeywordlist &kwl, const char *prefix=0) const
bool hasNans() const
Definition: ossimDpt.h:67
Proecedure for compensation of aerial camera lens distortion as computed by the Simultaneous Multif...
ossimString toString(ossim_uint32 precision=15) const
Definition: ossimDpt.cpp:160
static NEWMAT::Matrix createIdentity()
ossimDpt midPoint() const
Definition: ossimDrect.h:817
double x
Definition: ossimDpt.h:164
ossimString beforePos(std::string::size_type pos) 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
bool empty() const
Definition: ossimString.h:411
ossimDpt metersPerDegree() const
Definition: ossimGpt.cpp:498
void setDirection(const ossimEcefVector &d)
Definition: ossimEcefRay.h:82
OSSIMDLLEXPORT std::ostream & ossimNotify(ossimNotifyLevel level=ossimNotifyLevel_WARN)
std::vector< ossimString > StringListType
Definition: ossimCsvFile.h:15
void makeNan()
Definition: ossimDpt.h:65