1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-22 16:08:39 -05:00
sdrangel/sdrbase/util/weather.h
Jon Beniston cddc8c9b83 Star Tracker updates.
Plot Sun and Moon on sky temperature chart.
Plot markers on Galactic line-of-sight chart.
Create animations from Galactic line-of-sight chart.
Allow weather at antenna location to be downloaded from openweathermap.org
Allow target to be entered as Galactic longitude / latitude.
Add azimuth and elevation offsets to support scans around targets.
Add S7, S8 and S9 targets.
Refactor some code from GUI to main plugin, so computed values can be used in other plugins.
2021-10-12 11:07:56 +01:00

77 lines
2.7 KiB
C++

///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2021 Jon Beniston, M7RCE //
// //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation as version 3 of the License, or //
// (at your option) any later version. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License V3 for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#ifndef INCLUDE_WEATHER_H
#define INCLUDE_WEATHER_H
#include <QtCore>
#include <QTimer>
#include "export.h"
class QNetworkAccessManager;
class QNetworkReply;
// Weather API wrapper
// Allows temperature, pressure and humidity to be obtained for a given latitude and longitude
// Currently supports openweathermap.org
class SDRBASE_API Weather : public QObject
{
Q_OBJECT
protected:
Weather();
public:
static Weather* create(const QString& apiKey, const QString& service="openweathermap.org");
virtual void getWeather(float latitude, float longitude) = 0;
void getWeatherPeriodically(float latitude, float longitude, int periodInMins);
public slots:
void update();
signals:
void weatherUpdated(float temperature, float pressure, float humidity); // Called when new data available. If no value is available, parameter will be NAN
private:
QTimer m_timer; // Timer for periodic updates
float m_latitude; // Saved latitude for periodic updates
float m_longitude; // Saved longitude for periodic updates
};
class SDRBASE_API OpenWeatherMap : public Weather {
Q_OBJECT
public:
OpenWeatherMap(const QString& apiKey);
~OpenWeatherMap();
virtual void getWeather(float latitude, float longitude) override;
private:
QString m_apiKey;
QNetworkAccessManager *m_networkManager;
public slots:
void handleReply(QNetworkReply* reply);
};
#endif /* INCLUDE_WEATHER_H */