228 PvlGroup *gp =
new PvlGroup(
"GroundPoint");
233 gp->addKeyword(PvlKeyword(
"Filename"));
234 gp->addKeyword(PvlKeyword(
"Sample"));
235 gp->addKeyword(PvlKeyword(
"Line"));
236 gp->addKeyword(PvlKeyword(
"PixelValue"));
237 gp->addKeyword(PvlKeyword(
"RightAscension"));
238 gp->addKeyword(PvlKeyword(
"Declination"));
239 gp->addKeyword(PvlKeyword(
"PlanetocentricLatitude"));
240 gp->addKeyword(PvlKeyword(
"PlanetographicLatitude"));
241 gp->addKeyword(PvlKeyword(
"PositiveEast360Longitude"));
242 gp->addKeyword(PvlKeyword(
"PositiveEast180Longitude"));
243 gp->addKeyword(PvlKeyword(
"PositiveWest360Longitude"));
244 gp->addKeyword(PvlKeyword(
"PositiveWest180Longitude"));
245 gp->addKeyword(PvlKeyword(
"BodyFixedCoordinate"));
246 gp->addKeyword(PvlKeyword(
"LocalRadius"));
247 gp->addKeyword(PvlKeyword(
"SampleResolution"));
248 gp->addKeyword(PvlKeyword(
"LineResolution"));
249 gp->addKeyword(PvlKeyword(
"ObliqueDetectorResolution"));
250 gp->addKeyword(PvlKeyword(
"ObliquePixelResolution"));
251 gp->addKeyword(PvlKeyword(
"ObliqueLineResolution"));
252 gp->addKeyword(PvlKeyword(
"ObliqueSampleResolution"));
253 gp->addKeyword(PvlKeyword(
"SpacecraftPosition"));
254 gp->addKeyword(PvlKeyword(
"SpacecraftAzimuth"));
255 gp->addKeyword(PvlKeyword(
"SlantDistance"));
256 gp->addKeyword(PvlKeyword(
"TargetCenterDistance"));
257 gp->addKeyword(PvlKeyword(
"SubSpacecraftLatitude"));
258 gp->addKeyword(PvlKeyword(
"SubSpacecraftLongitude"));
259 gp->addKeyword(PvlKeyword(
"SpacecraftAltitude"));
260 gp->addKeyword(PvlKeyword(
"OffNadirAngle"));
261 gp->addKeyword(PvlKeyword(
"SubSpacecraftGroundAzimuth"));
262 gp->addKeyword(PvlKeyword(
"SunPosition"));
263 gp->addKeyword(PvlKeyword(
"SubSolarAzimuth"));
264 gp->addKeyword(PvlKeyword(
"SolarDistance"));
265 gp->addKeyword(PvlKeyword(
"SubSolarLatitude"));
266 gp->addKeyword(PvlKeyword(
"SubSolarLongitude"));
267 gp->addKeyword(PvlKeyword(
"SubSolarGroundAzimuth"));
268 gp->addKeyword(PvlKeyword(
"Phase"));
269 gp->addKeyword(PvlKeyword(
"Incidence"));
270 gp->addKeyword(PvlKeyword(
"Emission"));
271 gp->addKeyword(PvlKeyword(
"NorthAzimuth"));
272 gp->addKeyword(PvlKeyword(
"EphemerisTime"));
273 gp->addKeyword(PvlKeyword(
"UTC"));
274 gp->addKeyword(PvlKeyword(
"LocalSolarTime"));
275 gp->addKeyword(PvlKeyword(
"SolarLongitude"));
276 gp->addKeyword(PvlKeyword(
"LookDirectionBodyFixed"));
277 gp->addKeyword(PvlKeyword(
"LookDirectionJ2000"));
278 gp->addKeyword(PvlKeyword(
"LookDirectionCamera"));
280 if (allowErrors) gp->addKeyword(PvlKeyword(
"Error"));
285 gp->addKeyword(PvlKeyword(
"Filename"));
286 gp->addKeyword(PvlKeyword(
"Sample"));
287 gp->addKeyword(PvlKeyword(
"Line"));
288 gp->addKeyword(PvlKeyword(
"PixelValue"));
289 gp->addKeyword(PvlKeyword(
"RightAscension"));
290 gp->addKeyword(PvlKeyword(
"Declination"));
291 gp->addKeyword(PvlKeyword(
"PlanetocentricLatitude"));
292 gp->addKeyword(PvlKeyword(
"PlanetographicLatitude"));
293 gp->addKeyword(PvlKeyword(
"PositiveEast360Longitude"));
294 gp->addKeyword(PvlKeyword(
"PositiveEast180Longitude"));
295 gp->addKeyword(PvlKeyword(
"PositiveWest360Longitude"));
296 gp->addKeyword(PvlKeyword(
"PositiveWest180Longitude"));
297 gp->addKeyword(PvlKeyword(
"BodyFixedCoordinate"));
298 gp->addKeyword(PvlKeyword(
"LocalRadius"));
299 gp->addKeyword(PvlKeyword(
"SampleResolution"));
300 gp->addKeyword(PvlKeyword(
"LineResolution"));
301 gp->addKeyword(PvlKeyword(
"SpacecraftPosition"));
302 gp->addKeyword(PvlKeyword(
"SpacecraftAzimuth"));
303 gp->addKeyword(PvlKeyword(
"SlantDistance"));
304 gp->addKeyword(PvlKeyword(
"TargetCenterDistance"));
305 gp->addKeyword(PvlKeyword(
"SubSpacecraftLatitude"));
306 gp->addKeyword(PvlKeyword(
"SubSpacecraftLongitude"));
307 gp->addKeyword(PvlKeyword(
"SpacecraftAltitude"));
308 gp->addKeyword(PvlKeyword(
"OffNadirAngle"));
309 gp->addKeyword(PvlKeyword(
"SubSpacecraftGroundAzimuth"));
310 gp->addKeyword(PvlKeyword(
"SunPosition"));
311 gp->addKeyword(PvlKeyword(
"SubSolarAzimuth"));
312 gp->addKeyword(PvlKeyword(
"SolarDistance"));
313 gp->addKeyword(PvlKeyword(
"SubSolarLatitude"));
314 gp->addKeyword(PvlKeyword(
"SubSolarLongitude"));
315 gp->addKeyword(PvlKeyword(
"SubSolarGroundAzimuth"));
316 gp->addKeyword(PvlKeyword(
"Phase"));
317 gp->addKeyword(PvlKeyword(
"Incidence"));
318 gp->addKeyword(PvlKeyword(
"Emission"));
319 gp->addKeyword(PvlKeyword(
"NorthAzimuth"));
320 gp->addKeyword(PvlKeyword(
"EphemerisTime"));
321 gp->addKeyword(PvlKeyword(
"UTC"));
322 gp->addKeyword(PvlKeyword(
"LocalSolarTime"));
323 gp->addKeyword(PvlKeyword(
"SolarLongitude"));
324 gp->addKeyword(PvlKeyword(
"LookDirectionBodyFixed"));
325 gp->addKeyword(PvlKeyword(
"LookDirectionJ2000"));
326 gp->addKeyword(PvlKeyword(
"LookDirectionCamera"));
327 gp->addKeyword(PvlKeyword(
"ObliqueDetectorResolution"));
328 gp->addKeyword(PvlKeyword(
"ObliquePixelResolution"));
329 gp->addKeyword(PvlKeyword(
"ObliqueLineResolution"));
330 gp->addKeyword(PvlKeyword(
"ObliqueSampleResolution"));
331 if (allowErrors) gp->addKeyword(PvlKeyword(
"Error"));
338 bool noErrors = passed;
340 if (!
m_camera->HasSurfaceIntersection()) {
341 error =
"Requested position does not project in camera model; no surface intersection";
343 if (!allowErrors)
throw IException(IException::Unknown, error, _FILEINFO_);
345 if (!
m_camera->InCube() && !allowOutside) {
346 error =
"Requested position does not project in camera model; not inside cube";
348 if (!allowErrors)
throw IException(IException::Unknown, error, _FILEINFO_);
352 for (
int i = 0; i < gp->keywords(); i++) {
353 QString name = (*gp)[i].name();
355 if (name ==
"BodyFixedCoordinate" || name ==
"SpacecraftPosition" ||
356 name ==
"SunPosition" || name ==
"LookDirectionJ2000" ||
357 name ==
"LookDirectionBodyFixed" || name ==
"LookDirectionCamera") {
358 (*gp)[i].addValue(
"NULL");
359 (*gp)[i].addValue(
"NULL");
360 (*gp)[i].addValue(
"NULL");
363 (*gp)[i].setValue(
"NULL");
367 double spB[3], sB[3];
370 gp->findKeyword(
"SpacecraftPosition").clear();
371 gp->findKeyword(
"SpacecraftPosition").addValue(
toString(spB[0]),
"km");
372 gp->findKeyword(
"SpacecraftPosition").addValue(
toString(spB[1]),
"km");
373 gp->findKeyword(
"SpacecraftPosition").addValue(
toString(spB[2]),
"km");
377 gp->findKeyword(
"SunPosition").clear();
378 gp->findKeyword(
"SunPosition").addValue(
toString(sB[0]),
"km");
379 gp->findKeyword(
"SunPosition").addValue(
toString(sB[1]),
"km");
380 gp->findKeyword(
"SunPosition").addValue(
toString(sB[2]),
"km");
382 catch (IException &e) {
383 gp->findKeyword(
"SunPosition").addValue(
"Null");
384 gp->findKeyword(
"SunPosition").addValue(
"Null");
385 gp->findKeyword(
"SunPosition").addValue(
"Null");
388 std::vector<double>lookB =
m_camera->lookDirectionBodyFixed();
389 gp->findKeyword(
"LookDirectionBodyFixed").clear();
390 gp->findKeyword(
"LookDirectionBodyFixed").addValue(
toString(lookB[0]),
"DEGREE");
391 gp->findKeyword(
"LookDirectionBodyFixed").addValue(
toString(lookB[1]),
"DEGREE");
392 gp->findKeyword(
"LookDirectionBodyFixed").addValue(
toString(lookB[2]),
"DEGREE");
395 std::vector<double>lookJ =
m_camera->lookDirectionJ2000();
396 gp->findKeyword(
"LookDirectionJ2000").clear();
397 gp->findKeyword(
"LookDirectionJ2000").addValue(
toString(lookJ[0]),
"DEGREE");
398 gp->findKeyword(
"LookDirectionJ2000").addValue(
toString(lookJ[1]),
"DEGREE");
399 gp->findKeyword(
"LookDirectionJ2000").addValue(
toString(lookJ[2]),
"DEGREE");
401 catch (IException &e) {
402 gp->findKeyword(
"LookDirectionJ2000").addValue(
"Null");
403 gp->findKeyword(
"LookDirectionJ2000").addValue(
"Null");
404 gp->findKeyword(
"LookDirectionJ2000").addValue(
"Null");
410 gp->findKeyword(
"LookDirectionCamera").clear();
411 gp->findKeyword(
"LookDirectionCamera").addValue(
toString(lookC[0]),
"DEGREE");
412 gp->findKeyword(
"LookDirectionCamera").addValue(
toString(lookC[1]),
"DEGREE");
413 gp->findKeyword(
"LookDirectionCamera").addValue(
toString(lookC[2]),
"DEGREE");
415 catch (IException &e) {
416 gp->findKeyword(
"LookDirectionCamera").addValue(
"Null");
417 gp->findKeyword(
"LookDirectionCamera").addValue(
"Null");
418 gp->findKeyword(
"LookDirectionCamera").addValue(
"Null");
423 gp->findKeyword(
"Error").setValue(error);
424 gp->findKeyword(
"FileName").setValue(
m_currentCube->fileName());
427 gp->findKeyword(
"EphemerisTime").setValue(
429 gp->findKeyword(
"EphemerisTime").addComment(
"Time");
430 QString utc =
m_camera->time().UTC();
431 gp->findKeyword(
"UTC").setValue(utc);
432 gp->findKeyword(
"SpacecraftPosition").addComment(
"Spacecraft Information");
433 gp->findKeyword(
"SunPosition").addComment(
"Sun Information");
434 gp->findKeyword(
"Phase").addComment(
"Illumination and Other");
440 int intSamp = (int)(
m_camera->Sample() + 0.5);
441 int intLine = (int)(
m_camera->Line() + 0.5);
445 double pB[3], spB[3], sB[3];
447 double ssplat, ssplon, ocentricLat, ographicLat, pe360Lon, pw360Lon;
450 gp->findKeyword(
"FileName").setValue(
m_currentCube->fileName());
453 gp->findKeyword(
"PixelValue").setValue(PixelToString(b[0]));
455 gp->findKeyword(
"RightAscension").setValue(
toString(
456 m_camera->RightAscension()),
"DEGREE");
458 catch (IException &e) {
459 gp->findKeyword(
"RightAscension").setValue(
"Null");
462 gp->findKeyword(
"Declination").setValue(
toString(
463 m_camera->Declination()),
"DEGREE");
465 catch (IException &e) {
466 gp->findKeyword(
"Declination").setValue(
"Null");
468 ocentricLat =
m_camera->UniversalLatitude();
469 gp->findKeyword(
"PlanetocentricLatitude").setValue(
toString(ocentricLat),
"DEGREE");
475 radii[0].kilometers(),
476 radii[2].kilometers());
477 gp->findKeyword(
"PlanetographicLatitude").setValue(
toString(ographicLat),
"DEGREE");
479 pe360Lon =
m_camera->UniversalLongitude();
480 gp->findKeyword(
"PositiveEast360Longitude").setValue(
toString(pe360Lon),
"DEGREE");
483 gp->findKeyword(
"PositiveEast180Longitude").setValue(
toString(
488 gp->findKeyword(
"PositiveWest360Longitude").setValue(
toString(pw360Lon),
"DEGREE");
491 gp->findKeyword(
"PositiveWest180Longitude").setValue(
495 gp->findKeyword(
"BodyFixedCoordinate").addValue(
toString(pB[0]),
"km");
496 gp->findKeyword(
"BodyFixedCoordinate").addValue(
toString(pB[1]),
"km");
497 gp->findKeyword(
"BodyFixedCoordinate").addValue(
toString(pB[2]),
"km");
499 gp->findKeyword(
"LocalRadius").setValue(
toString(
500 m_camera->LocalRadius().meters()),
"meters");
501 gp->findKeyword(
"SampleResolution").setValue(
toString(
502 m_camera->SampleResolution()),
"meters/pixel");
503 gp->findKeyword(
"LineResolution").setValue(
toString(
504 m_camera->LineResolution()),
"meters/pixel");
506 gp->findKeyword(
"ObliqueDetectorResolution").setValue(
508 gp->findKeyword(
"ObliqueLineResolution").setValue(
510 gp->findKeyword(
"ObliqueSampleResolution").setValue(
512 gp->findKeyword(
"ObliquePixelResolution").setValue(
518 gp->findKeyword(
"SpacecraftPosition").addValue(
toString(spB[0]),
"km");
519 gp->findKeyword(
"SpacecraftPosition").addValue(
toString(spB[1]),
"km");
520 gp->findKeyword(
"SpacecraftPosition").addValue(
toString(spB[2]),
"km");
521 gp->findKeyword(
"SpacecraftPosition").addComment(
"Spacecraft Information");
523 double spacecraftAzi =
m_camera->SpacecraftAzimuth();
524 if (Isis::IsValidPixel(spacecraftAzi)) {
525 gp->findKeyword(
"SpacecraftAzimuth").setValue(
toString(spacecraftAzi),
"DEGREE");
528 gp->findKeyword(
"SpacecraftAzimuth").setValue(
"NULL");
531 gp->findKeyword(
"SlantDistance").setValue(
toString(
533 gp->findKeyword(
"TargetCenterDistance").setValue(
toString(
534 m_camera->targetCenterDistance()),
"km");
535 m_camera->subSpacecraftPoint(ssplat, ssplon);
536 gp->findKeyword(
"SubSpacecraftLatitude").setValue(
toString(ssplat),
"DEGREE");
537 gp->findKeyword(
"SubSpacecraftLongitude").setValue(
toString(ssplon),
"DEGREE");
538 gp->findKeyword(
"SpacecraftAltitude").setValue(
toString(
539 m_camera->SpacecraftAltitude()),
"km");
540 gp->findKeyword(
"OffNadirAngle").setValue(
toString(
541 m_camera->OffNadirAngle()),
"DEGREE");
545 gp->findKeyword(
"SubSpacecraftGroundAzimuth").setValue(
550 gp->findKeyword(
"SunPosition").addValue(
toString(sB[0]),
"km");
551 gp->findKeyword(
"SunPosition").addValue(
toString(sB[1]),
"km");
552 gp->findKeyword(
"SunPosition").addValue(
toString(sB[2]),
"km");
553 gp->findKeyword(
"SunPosition").addComment(
"Sun Information");
555 catch (IException &e) {
556 gp->findKeyword(
"SunPosition").addValue(
"Null");
557 gp->findKeyword(
"SunPosition").addValue(
"Null");
558 gp->findKeyword(
"SunPosition").addValue(
"Null");
559 gp->findKeyword(
"SunPosition").addComment(
"Sun Information");
563 double sunAzi =
m_camera->SunAzimuth();
564 if (Isis::IsValidPixel(sunAzi)) {
565 gp->findKeyword(
"SubSolarAzimuth").setValue(
toString(sunAzi),
"DEGREE");
568 gp->findKeyword(
"SubSolarAzimuth").setValue(
"NULL");
571 catch(IException &e) {
572 gp->findKeyword(
"SubSolarAzimuth").setValue(
"NULL");
576 gp->findKeyword(
"SolarDistance").setValue(
toString(
579 catch(IException &e) {
580 gp->findKeyword(
"SolarDistance").setValue(
"NULL");
584 m_camera->subSolarPoint(sslat, sslon);
585 gp->findKeyword(
"SubSolarLatitude").setValue(
toString(sslat),
"DEGREE");
586 gp->findKeyword(
"SubSolarLongitude").setValue(
toString(sslon),
"DEGREE");
592 gp->findKeyword(
"SubSolarGroundAzimuth").setValue(
toString(subsolgrdaz),
"DEGREE");
594 catch(IException &e) {
595 gp->findKeyword(
"SubSolarGroundAzimuth").setValue(
"NULL");
598 catch(IException &e) {
599 gp->findKeyword(
"SubSolarLatitude").setValue(
"NULL");
600 gp->findKeyword(
"SubSolarLongitude").setValue(
"NULL");
601 gp->findKeyword(
"SubSolarGroundAzimuth").setValue(
"NULL");
604 gp->findKeyword(
"Phase").setValue(
toString(
m_camera->PhaseAngle()),
"DEGREE");
605 gp->findKeyword(
"Phase").addComment(
"Illumination and Other");
606 gp->findKeyword(
"Incidence").setValue(
toString(
607 m_camera->IncidenceAngle()),
"DEGREE");
608 gp->findKeyword(
"Emission").setValue(
toString(
609 m_camera->EmissionAngle()),
"DEGREE");
611 double northAzi =
m_camera->NorthAzimuth();
612 if (Isis::IsValidPixel(northAzi)) {
613 gp->findKeyword(
"NorthAzimuth").setValue(
toString(northAzi),
"DEGREE");
616 gp->findKeyword(
"NorthAzimuth").setValue(
"NULL");
619 gp->findKeyword(
"EphemerisTime").setValue(
toString(
621 gp->findKeyword(
"EphemerisTime").addComment(
"Time");
623 gp->findKeyword(
"UTC").setValue(utc);
625 gp->findKeyword(
"LocalSolarTime").setValue(
toString(
626 m_camera->LocalSolarTime()),
"hour");
628 catch (IException &e) {
629 gp->findKeyword(
"LocalSolarTime").setValue(
"Null");
632 gp->findKeyword(
"SolarLongitude").setValue(
toString(
633 m_camera->solarLongitude().degrees()),
"DEGREE");
635 catch (IException &e) {
636 gp->findKeyword(
"SolarLongitude").setValue(
"Null");
639 std::vector<double>lookB =
m_camera->lookDirectionBodyFixed();
640 gp->findKeyword(
"LookDirectionBodyFixed").addValue(
toString(lookB[0]),
"DEGREE");
641 gp->findKeyword(
"LookDirectionBodyFixed").addValue(
toString(lookB[1]),
"DEGREE");
642 gp->findKeyword(
"LookDirectionBodyFixed").addValue(
toString(lookB[2]),
"DEGREE");
643 gp->findKeyword(
"LookDirectionBodyFixed").addComment(
"Look Direction Unit Vectors in Body Fixed, J2000, and Camera Coordinate Systems.");
646 std::vector<double>lookJ =
m_camera->lookDirectionJ2000();
647 gp->findKeyword(
"LookDirectionJ2000").addValue(
toString(lookJ[0]),
"DEGREE");
648 gp->findKeyword(
"LookDirectionJ2000").addValue(
toString(lookJ[1]),
"DEGREE");
649 gp->findKeyword(
"LookDirectionJ2000").addValue(
toString(lookJ[2]),
"DEGREE");
651 catch (IException &e) {
652 gp->findKeyword(
"LookDirectionJ2000").addValue(
"Null");
653 gp->findKeyword(
"LookDirectionJ2000").addValue(
"Null");
654 gp->findKeyword(
"LookDirectionJ2000").addValue(
"Null");
660 gp->findKeyword(
"LookDirectionCamera").addValue(
toString(lookC[0]),
"DEGREE");
661 gp->findKeyword(
"LookDirectionCamera").addValue(
toString(lookC[1]),
"DEGREE");
662 gp->findKeyword(
"LookDirectionCamera").addValue(
toString(lookC[2]),
"DEGREE");
664 catch (IException &e) {
665 gp->findKeyword(
"LookDirectionCamera").addValue(
"Null");
666 gp->findKeyword(
"LookDirectionCamera").addValue(
"Null");
667 gp->findKeyword(
"LookDirectionCamera").addValue(
"Null");
671 if (allowErrors) gp->findKeyword(
"Error").setValue(
"NULL");