// antenna.hxx -- FGRadioAntenna: class to represent antenna properties
//
// Written by Adrian Musceac YO8RZZ, started December 2011.
//
// SPDX-FileCopyrightText: 2011 Adrian Musceac YO8RZZ
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <simgear/compiler.h>
#include <simgear/structure/subsystem_mgr.hxx>
#include <Main/fg_props.hxx>

#include <simgear/math/sg_geodesy.hxx>
#include <simgear/debug/logstream.hxx>


class FGRadioAntenna
{
private:
    /*** load external plot file generated by NEC2. needs to have a txt extension
*	when naming plots, use the following scheme: type_frequencyMHz.txt
*	eg: yagi_110.txt or LPDA_333.txt
*	@param: name of file
*	@return: none
***/
    void load_NEC_antenna_pattern(std::string type);

    int _mirror_y;
    int _mirror_z;
    int _invert_ground;
    double _heading_deg;
    double _elevation_angle_deg;
    struct AntennaGain {
        double azimuth;
        double elevation;
        double gain;
    };
    SGPath _pattern_file;
    typedef std::vector<AntennaGain*> AntennaPattern;
    AntennaPattern _pattern;

public:
    FGRadioAntenna(std::string type);
    ~FGRadioAntenna();

/*** calculate far-field antenna gain on a 3D volume around it
*	@param: bearing to the other station, vertical angle (some call it theta)
*	@return: gain relative to maximum normalized gain. will be negative in all cases
***/
	double calculate_gain(double bearing, double angle);

    /// some convenience setters and getters (unused for now)
    inline void set_heading(double heading_deg) { _heading_deg = heading_deg; };
    inline void set_elevation_angle(double elevation_angle_deg) { _elevation_angle_deg = elevation_angle_deg; };
};
