1 /*
2     SPDX-FileCopyrightText: 2012 Samikshan Bairagya <samikshan@gmail.com>
3 
4     SPDX-License-Identifier: GPL-2.0-or-later
5 */
6 
7 #pragma once
8 
9 #include "kstarsdata.h"
10 
11 /**
12  * @class ObsConditions
13  *
14  * This class deals with the observing conditions of the night sky.
15  * The limiting magnitude is calculated depending on the equipment
16  * available to the user and the amount of light-pollution in the
17  * user's current observing location.
18  *
19  * @author Samikshan  Bairagya
20  */
21 class ObsConditions
22 {
23   public:
24     /**
25      * @enum Equipment
26      *
27      * Equipment available to the user.
28      */
29     enum Equipment
30     {
31         Telescope,
32         Binoculars,
33         Both,
34         None
35     };
36 
37     /**
38      * @enum TelescopeType
39      *
40      * Telescope Type (Reflector/Refractor)
41      */
42     enum TelescopeType
43     {
44         Reflector = 0,
45         Refractor,
46         Invalid
47     };
48 
49     /**
50      * @brief Constructor
51      *
52      * @param bortle          Rating of light pollution based on the bortle dark-sky scale.
53      * @param aperture        Aperture of equipment.
54      * @param equip           Equipment available to the user.
55      * @param telType         Reflector/Refractor type of telescope (if available)
56      */
57     ObsConditions(int bortle, double aperture, Equipment equip, TelescopeType telType);
58 
59     ~ObsConditions() = default;
60 
61     /** Inline method to set available equipment */
setEquipment(Equipment equip)62     inline void setEquipment(Equipment equip) { m_Equip = equip; }
63 
64     /** Inline method to set reflector/refractor type for telescope. */
setTelescopeType(TelescopeType telType)65     inline void setTelescopeType(TelescopeType telType) { m_TelType = telType; }
66 
67     /** Set limiting magnitude depending on Bortle dark-sky rating. */
68     void setLimMagnitude();
69 
70     /** Set new observing conditions. */
71     void setObsConditions(int bortle, double aperture, Equipment equip, TelescopeType telType);
72 
73     /**
74      * @brief Get optimum magnification under current observing conditions.
75      *
76      * @return Get optimum magnification under current observing conditions
77      */
78     double getOptimumMAG();
79 
80     /**
81      * @brief Get true limiting magnitude after taking equipment specifications into consideration.
82      *
83      * @return True limiting magnitude after taking equipment specifications into consideration.
84      */
85     double getTrueMagLim();
86 
87     /**
88      * @brief Evaluate visibility of sky-object based on current observing conditions.
89      *
90      * @param geo       Geographic location of user.
91      * @param lst       Local standard time expressed as a dms object.
92      * @param so        SkyObject for which visibility is to be evaluated.
93      * @return Visibility of sky-object based on current observing conditions as a boolean.
94      */
95     bool isVisible(GeoLocation *geo, dms *lst, SkyObject *so);
96 
97     /**
98      * @brief Create QMap<int, double> to be initialised to static member variable m_LMMap
99      *
100      * @return QMap<int, double> to be initialised to static member variable m_LMMap
101      */
102     static QMap<int, double> setLMMap();
103 
104   private:
105     /// Bortle dark-sky rating (from 1-9)
106     int m_BortleClass { 0 };
107     /// Equipment type
108     Equipment m_Equip;
109     /// Telescope type
110     TelescopeType m_TelType;
111     /// Aperture of equipment
112     double m_Aperture { 0 };
113     /// t-parameter corresponding to telescope type
114     double m_tParam { 0 };
115     /// Naked-eye limiting magnitude depending on m_BortleClass
116     double m_LM { 0 };
117     /// Lookup table mapping Bortle Scale values to corresponding limiting magnitudes
118     static const QMap<int, double> m_LMMap;
119 };
120