File indexing completed on 2024-04-28 15:11:24

0001 /*
0002     SPDX-FileCopyrightText: 2012 Samikshan Bairagya <samikshan@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "kstarsdata.h"
0010 
0011 /**
0012  * @class ObsConditions
0013  *
0014  * This class deals with the observing conditions of the night sky.
0015  * The limiting magnitude is calculated depending on the equipment
0016  * available to the user and the amount of light-pollution in the
0017  * user's current observing location.
0018  *
0019  * @author Samikshan  Bairagya
0020  */
0021 class ObsConditions
0022 {
0023   public:
0024     /**
0025      * @enum Equipment
0026      *
0027      * Equipment available to the user.
0028      */
0029     enum Equipment
0030     {
0031         Telescope,
0032         Binoculars,
0033         Both,
0034         None
0035     };
0036 
0037     /**
0038      * @enum TelescopeType
0039      *
0040      * Telescope Type (Reflector/Refractor)
0041      */
0042     enum TelescopeType
0043     {
0044         Reflector = 0,
0045         Refractor,
0046         Invalid
0047     };
0048 
0049     /**
0050      * @brief Constructor
0051      *
0052      * @param bortle          Rating of light pollution based on the bortle dark-sky scale.
0053      * @param aperture        Aperture of equipment.
0054      * @param equip           Equipment available to the user.
0055      * @param telType         Reflector/Refractor type of telescope (if available)
0056      */
0057     ObsConditions(int bortle, double aperture, Equipment equip, TelescopeType telType);
0058 
0059     ~ObsConditions() = default;
0060 
0061     /** Inline method to set available equipment */
0062     inline void setEquipment(Equipment equip) { m_Equip = equip; }
0063 
0064     /** Inline method to set reflector/refractor type for telescope. */
0065     inline void setTelescopeType(TelescopeType telType) { m_TelType = telType; }
0066 
0067     /** Set limiting magnitude depending on Bortle dark-sky rating. */
0068     void setLimMagnitude();
0069 
0070     /** Set new observing conditions. */
0071     void setObsConditions(int bortle, double aperture, Equipment equip, TelescopeType telType);
0072 
0073     /**
0074      * @brief Get optimum magnification under current observing conditions.
0075      *
0076      * @return Get optimum magnification under current observing conditions
0077      */
0078     double getOptimumMAG();
0079 
0080     /**
0081      * @brief Get true limiting magnitude after taking equipment specifications into consideration.
0082      *
0083      * @return True limiting magnitude after taking equipment specifications into consideration.
0084      */
0085     double getTrueMagLim();
0086 
0087     /**
0088      * @brief Evaluate visibility of sky-object based on current observing conditions.
0089      *
0090      * @param geo       Geographic location of user.
0091      * @param lst       Local standard time expressed as a dms object.
0092      * @param so        SkyObject for which visibility is to be evaluated.
0093      * @return Visibility of sky-object based on current observing conditions as a boolean.
0094      */
0095     bool isVisible(GeoLocation *geo, dms *lst, SkyObject *so);
0096 
0097     /**
0098      * @brief Create QMap<int, double> to be initialised to static member variable m_LMMap
0099      *
0100      * @return QMap<int, double> to be initialised to static member variable m_LMMap
0101      */
0102     static QMap<int, double> setLMMap();
0103 
0104   private:
0105     /// Bortle dark-sky rating (from 1-9)
0106     int m_BortleClass { 0 };
0107     /// Equipment type
0108     Equipment m_Equip;
0109     /// Telescope type
0110     TelescopeType m_TelType;
0111     /// Aperture of equipment
0112     double m_Aperture { 0 };
0113     /// t-parameter corresponding to telescope type
0114     double m_tParam { 0 };
0115     /// Naked-eye limiting magnitude depending on m_BortleClass
0116     double m_LM { 0 };
0117     /// Lookup table mapping Bortle Scale values to corresponding limiting magnitudes
0118     static const QMap<int, double> m_LMMap;
0119 };