KWeatherCore

caparea.h
1/*
2 * SPDX-FileCopyrightText: 2021 Han Young <hanyoung@protonmail.com>
3 * SPDX-FileCopyrightText: 2021 Anjani Kumar <anjanik012@gmail.com>
4 * SPDX-FileCopyrightText: 2022 Volker Krause <vkrause@kde.org>
5 * SPDX-License-Identifier: LGPL-2.0-or-later
6 */
7
8#ifndef KWEATHERCORE_CAPAREA_H
9#define KWEATHERCORE_CAPAREA_H
10
11#include "capnamedvalue.h"
12#include <kweathercore/kweathercore_export.h>
13
14#include <QMetaType>
15#include <QSharedDataPointer>
16
17#include <cmath>
18
19namespace KWeatherCore
20{
21
22/** A geographic coordinate as part of a polygon. */
24{
25public:
26 float latitude = NAN;
27 float longitude = NAN;
28};
29
30/** Geographic polygon describing the target area of a CAP alert message. */
31using CAPPolygon = std::vector<CAPCoordinate>;
32
33/** Geographic circle describing the target area of a CAP alert message. */
34class KWEATHERCORE_EXPORT CAPCircle
35{
36 Q_GADGET
37 Q_PROPERTY(float latitude MEMBER latitude)
38 Q_PROPERTY(float longitude MEMBER longitude)
39 Q_PROPERTY(float radius MEMBER radius)
40
41public:
42 float latitude = NAN;
43 float longitude = NAN;
44 float radius = NAN;
45};
46
47class CAPAreaPrivate;
48
49/** Affected area of a CAP alert message.
50 * @see https://docs.oasis-open.org/emergency/cap/v1.2/CAP-v1.2.html ยง3.2.4
51 */
52class KWEATHERCORE_EXPORT CAPArea
53{
54 Q_GADGET
55 Q_PROPERTY(QString description READ description)
56 Q_PROPERTY(float altitude READ altitude)
57 Q_PROPERTY(float ceiling READ ceiling)
58public:
59 CAPArea();
60 CAPArea(const CAPArea &other);
61 CAPArea(CAPArea &&other);
62 ~CAPArea();
63 CAPArea &operator=(const CAPArea &other);
64 CAPArea &operator=(CAPArea &&other);
65
66 /** A text description of the message target area. */
67 QString description() const;
68 void setDescription(const QString &areaDesc);
69
70 /** Geographic polygon(s) enclosing the message target area. */
71 const std::vector<CAPPolygon> &polygons() const;
72 void addPolygon(CAPPolygon &&polygon);
73
74 /** Geographic circles(s) enclosing the message target area. */
75 const std::vector<CAPCircle> &circles() const;
76 void addCircle(CAPCircle &&circle);
77
78 /** Any geographically-based code to describe a message target area, as key/value pair. */
79 const std::vector<CAPNamedValue> &geoCodes() const;
80 void addGeoCode(CAPNamedValue &&geoCode);
81
82 /** The specific or minimum altitude of the affected area of the alert message.
83 * The altitude measure is in feet above mean sea level.
84 * If not set, NAN is returned.
85 */
86 float altitude() const;
87 void setAltitude(float altitude);
88
89 /** The maximum altitude of the affected area of the alert message.
90 * The altitude measure is in feet above mean sea level.
91 * If not set, NAN is returned.
92 */
93 float ceiling() const;
94 void setCeiling(float ceiling);
95
96private:
98};
99
100}
101
102Q_DECLARE_METATYPE(KWeatherCore::CAPCircle)
103Q_DECLARE_METATYPE(KWeatherCore::CAPArea)
104
105#endif // KWEATHERCORE_CAPAREA_H
Affected area of a CAP alert message.
Definition caparea.h:53
Geographic circle describing the target area of a CAP alert message.
Definition caparea.h:35
A geographic coordinate as part of a polygon.
Definition caparea.h:24
CAP key/value pairs as found in area geo codes, alert event codes or alert parameters.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:42 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.