Changeset 19430 for trunk/FACT++
- Timestamp:
- 01/25/19 23:29:40 (6 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/Time.cc
r19215 r19430 400 400 // 401 401 //! @returns 402 //! The time of the previous sun-set, relative to given horizon in degree, 403 //! for the observatory location given (see nova.h). 404 //! If the sun is circumpolar, it simply return the intgeral fraction of 405 //! the current MJD. 406 //! If libnova was not compiled in, it will return the next noon. 407 //! 408 //! @throws 409 //! A runtime_error exception is thrown if the observatory location 410 //! is not defined (see nova.h) 411 // 412 Time Time::GetPrevSunSet(double horizon, const string &obs) const 413 { 414 #ifdef HAVE_NOVA 415 const Nova::LnLatPosn posn(obs); 416 if (!posn.isValid()) 417 throw runtime_error("Observatory location '"+obs+"' unknown."); 418 419 ln_rst_time sun_day; 420 if (ln_get_solar_rst_horizon(JD()-0.5, const_cast<Nova::LnLatPosn*>(&posn), horizon, &sun_day)==1) 421 return Time(floor(Mjd())); 422 423 if (Time(sun_day.set)<*this) 424 return Time(sun_day.set); 425 426 if (ln_get_solar_rst_horizon(JD()-1.5, const_cast<Nova::LnLatPosn*>(&posn), horizon, &sun_day)==1) 427 return Time(floor(Mjd())); 428 429 return Time(sun_day.set); 430 #else 431 return Time(floor(Mjd()-0.5)+0.5); 432 #endif 433 } 434 435 // -------------------------------------------------------------------------- 436 // 437 //! @returns 438 //! The time of the next sun-set, relative to given horizon in degree, 439 //! for the observatory location given (see nova.h). 440 //! If the sun is circumpolar, it simply return the intgeral fraction of 441 //! the current MJD+1. 442 //! If libnova was not compiled in, it will return the next noon. 443 //! 444 //! @throws 445 //! A runtime_error exception is thrown if the observatory location 446 //! is not defined (see nova.h) 447 // 448 Time Time::GetNextSunSet(double horizon, const string &obs) const 449 { 450 #ifdef HAVE_NOVA 451 const Nova::LnLatPosn posn(obs); 452 if (!posn.isValid()) 453 throw runtime_error("Observatory location '"+obs+"' unknown."); 454 455 ln_rst_time sun_day; 456 if (ln_get_solar_rst_horizon(JD()-0.5, const_cast<Nova::LnLatPosn*>(&posn), horizon, &sun_day)==1) 457 return Time(floor(Mjd())+1); 458 459 if (Time(sun_day.set)>=*this) 460 return Time(sun_day.set); 461 462 if (ln_get_solar_rst_horizon(JD()+0.5, const_cast<Nova::LnLatPosn*>(&posn), horizon, &sun_day)==1) 463 return Time(floor(Mjd())+1); 464 465 return Time(sun_day.set); 466 #else 467 return Time(floor(Mjd()+0.5)+0.5); 468 #endif 469 } 470 471 // -------------------------------------------------------------------------- 472 // 473 //! Calls GetPrevSunSet(LN_SOLAR_STANDART_HORIZON) 474 // 475 Time Time::GetPrevSunSet(const string &obs) const 476 { 477 #ifdef HAVE_NOVA 478 return GetPrevSunSet(LN_SOLAR_STANDART_HORIZON, obs); 479 #else 480 return GetPrevSunSet(-0.8333, obs); 481 #endif 482 } 483 484 // -------------------------------------------------------------------------- 485 // 486 //! Calls GetNextSunSet(LN_SOLAR_STANDART_HORIZON) 487 // 488 Time Time::GetNextSunSet(const string &obs) const 489 { 490 #ifdef HAVE_NOVA 491 return GetNextSunSet(LN_SOLAR_STANDART_HORIZON, obs); 492 #else 493 return GetNextSunSet(-0.8333, obs); 494 #endif 495 } 496 497 // -------------------------------------------------------------------------- 498 // 499 //! @returns 402 500 //! Returns an int corresponding to the current sun-cycle, that means 403 501 //! the day of the last sun-rise w.r.t. this Time. -
trunk/FACT++/src/Time.h
r19390 r19430 120 120 Time GetNextSunRise(const std::string &obs="") const; 121 121 122 Time GetPrevSunSet(double horizon, const std::string &obs="") const; 123 Time GetNextSunSet(double horizon, const std::string &obs="") const; 124 125 Time GetPrevSunSet(const std::string &obs="") const; 126 Time GetNextSunSet(const std::string &obs="") const; 127 122 128 uint32_t NightAsInt(const std::string &obs="") const; 123 129 };
Note:
See TracChangeset
for help on using the changeset viewer.