10 #include "Utilities.h" 21 static constexpr std::chrono::milliseconds LunarMonthMilliseconds{2551442125};
22 static constexpr std::time_t LunarNewMoonEpoch{1618194720};
29 std::chrono::system_clock::time_point newEpoch = std::chrono::system_clock::from_time_t(LunarNewMoonEpoch);
30 std::chrono::system_clock::time_point epoch = std::chrono::system_clock::now();
31 auto moonAge = std::chrono::duration_cast<std::chrono::milliseconds>(epoch - newEpoch);
32 auto phase =
static_cast<double>((moonAge % LunarMonthMilliseconds).count()) /
33 static_cast<double>(LunarMonthMilliseconds.count()) * 2. * M_PI;
50 ClearSkyEphemeris(
const std::string &rootUri,
const path &xdgDir,
const std::string &storeRoot,
51 std::chrono::system_clock::duration duration) :
52 WebCache(rootUri, xdgDir, storeRoot, duration) {}
55 ClearSkyEphemeris(
const std::string &rootUri,
const path &xdgDir,
const std::string &storeRoot,
56 std::chrono::system_clock::duration duration, It first, It last)
57 :
WebCache(rootUri, xdgDir, storeRoot, duration) {
62 if (localId ==
"Amateur")
63 return mRootURI +
"esats.pl?getall=";
64 else if (localId ==
"Moon")
65 return mRootURI +
"esats.pl?tlename=Moon";
70 static constexpr std::array<WebCacheItem,2> CS_Ephem{
79 class Ephemeris :
public std::map<std::string_view, std::array<std::string_view,3>> {
81 std::string mEphemerisSet{};
84 using iterator = std::map<std::string_view, std::array<std::string_view,3>>::iterator;
88 explicit Ephemeris(
const std::filesystem::path& filePath);
90 void readFile(
const std::filesystem::path &filePath);
100 std::unique_ptr<ClearSkyEphemeris> mEphemerisCache{};
123 return mEphemeris.begin();
127 return mEphemeris.end();
130 [[nodiscard]]
auto begin()
const {
131 return mEphemeris.cbegin();
134 [[nodiscard]]
auto end()
const {
135 return mEphemeris.cend();
143 std::vector<Satellite> mConstellation{};
152 void predict(
const DateTime &dateTime);
154 void passPrediction(uint maxCount,
const std::string &favorite);
156 [[nodiscard]]
const Observer& observer()
const {
160 [[nodiscard]]
auto empty()
const noexcept {
161 return mConstellation.empty();
164 [[nodiscard]]
auto size()
const noexcept {
165 return mConstellation.size();
168 [[nodiscard]]
auto front()
const noexcept {
169 return mConstellation.front();
173 static constexpr
long COARSE_DT = 90L;
174 static constexpr
long FINE_DT = (-2L);
175 static constexpr
double SAT_MIN_EL = 1.;
179 bool riseOk{
false}, setOk{
false}, everUp{
false}, everDown{
false};
180 long deltaTime{COARSE_DT};
181 double altitude{}, azimuth{}, range{}, rangeRate{}, latRad{}, lonRad{}, periodDays{},
182 maxAltitude{}, prevAltitude{0}, setAz{0}, riseAz{0};
184 DateTime srchTime{}, riseTime{}, setTime{};
199 [[nodiscard]] std::string passTimeString(time_t relative = 0)
const;
203 return (!setOk || !riseOk) && srchTime < now + 2.0F && (srchTime > now || altitude > -1.);
206 [[nodiscard]]
bool goodPass(
double minAltitude)
const noexcept {
207 return riseOk && setOk && maxAltitude >= minAltitude;
210 void setTopo(
const Observer& observer) {
211 auto topo = satellite.topo(observer);
212 altitude = std::get<0>(topo);
213 azimuth = std::get<1>(topo);
214 range = std::get<2>(topo);
215 rangeRate = std::get<3>(topo);
219 auto geo = satellite.geo();
220 latRad = std::get<0>(geo);
221 lonRad = std::get<1>(geo);
Encapsulate the day-in-space for orbital mechanics computations.
Definition: Plan13.h:141
Definition: SatelliteModel.h:37
Definition: SatelliteModel.h:139
std::shared_ptr< Slot< Args... > > slot_type
Composed Slot type.
Definition: Signals.h:123
Fetch web resources caching them in the local filesystem following XDG specifications.
Definition: WebCache.h:40
ClearSkyEphemeris(const std::string &rootUri, const path &xdgDir, const std::string &storeRoot, std::chrono::system_clock::duration duration)
Constructor.
Definition: SatelliteModel.h:50
Definition: SatelliteModel.h:79
std::string constructUrl(const local_id_t &localId) override
Construct the appropriate URL for the item.
Definition: SatelliteModel.h:61
std::string mRootURI
The root URI for items in the cache.
Definition: WebCache.h:81
void setCacheItem(key_t key, local_id_t localId)
Add or change a cache item.
Definition: WebCache.h:141
double MoonPhase()
Calculate the current phase of the moon in days between [0..2*M_PI].
Definition: SatelliteModel.h:28
bool search(DateTime &now) const noexcept
Return true if pass not found and search time not exceeded.
Definition: SatelliteModel.h:202
Fetching and caching web resources.
Data specifying an observer for computing relative visibility data.
Definition: Plan13.h:254
Definition: WebCache.h:27
Satellite orbital mechanics.
Definition: Plan13.h:294
Definition: SatelliteModel.h:98
ToDo: There is an issue that the initial scroll interaction is lost if the click/press lands on a Wid...
Definition: CelestialOverlay.cpp:13
Definition: SatelliteModel.h:177