FireSTARR
Loading...
Searching...
No Matches
Weather.h
1/* Copyright (c) Queen's Printer for Ontario, 2020. */
2/* Copyright (c) His Majesty the King in Right of Canada as represented by the Minister of Natural Resources, 2025. */
3
4/* SPDX-License-Identifier: AGPL-3.0-or-later */
5
6#pragma once
7#include "Index.h"
8#include "Util.h"
9#include "unstable.h"
10namespace fs
11{
12using data::Index;
13namespace wx
14{
18class Temperature : public Index<Temperature>
19{
20public:
22 using Index::Index;
24
27 static const Temperature Zero;
28 static const Temperature Invalid;
29};
33class RelativeHumidity : public Index<RelativeHumidity>
34{
35public:
37 using Index::Index;
39
42 static const RelativeHumidity Zero;
43 static const RelativeHumidity Invalid;
44};
48class Speed : public Index<Speed>
49{
50public:
52 using Index::Index;
54
57 static const Speed Zero;
58 static const Speed Invalid;
59};
63class Direction : public Index<Direction>
64{
65public:
69 ~Direction() = default;
73 constexpr Direction() noexcept = default;
79 constexpr Direction(const MathSize value, const bool is_radians) noexcept
80 : Index(is_radians ? util::to_degrees(value) : value)
81 {
82 }
87 constexpr Direction(const Direction& rhs) noexcept = default;
92 constexpr Direction(Direction&& rhs) noexcept = default;
98 Direction& operator=(const Direction& rhs) noexcept = default;
104 Direction& operator=(Direction&& rhs) noexcept = default;
109 [[nodiscard]] constexpr MathSize asRadians() const
110 {
111 return util::to_radians(asDegrees());
112 }
117 [[nodiscard]] constexpr MathSize asDegrees() const
118 {
119 return asValue();
120 }
125 [[nodiscard]] constexpr MathSize heading() const
126 {
127 return util::to_heading(asRadians());
128 }
132 static const Direction Zero;
133 static const Direction Invalid;
134};
138class Wind
139{
140public:
144 ~Wind() = default;
148 constexpr Wind() noexcept
149 : wsv_x_(0),
150 wsv_y_(0),
151 direction_(0.0, false),
152 speed_(0)
153 {
154 }
160 Wind(const Direction& direction, const Speed speed) noexcept
161 : wsv_x_(speed.asValue() * _sin(direction.heading())),
162 wsv_y_(speed.asValue() * _cos(direction.heading())),
165 {
166 }
171 constexpr Wind(const Wind& rhs) noexcept = default;
176 constexpr Wind(Wind&& rhs) noexcept = default;
182 Wind& operator=(const Wind& rhs) noexcept = default;
188 Wind& operator=(Wind&& rhs) noexcept = default;
193 [[nodiscard]] constexpr const Speed& speed() const noexcept
194 {
195 return speed_;
196 }
201 [[nodiscard]] constexpr const Direction& direction() const noexcept
202 {
203 return direction_;
204 }
209 [[nodiscard]] constexpr MathSize heading() const noexcept
210 {
211 return direction_.heading();
212 }
217 [[nodiscard]] constexpr MathSize wsvX() const noexcept
218 {
219 return wsv_x_;
220 }
225 [[nodiscard]] constexpr MathSize wsvY() const noexcept
226 {
227 return wsv_y_;
228 }
234 [[nodiscard]] constexpr bool operator!=(const Wind& rhs) const noexcept
235 {
236 return direction_ != rhs.direction_ || speed_ != rhs.speed_;
237 }
243 [[nodiscard]] constexpr bool operator==(const Wind& rhs) const noexcept
244 {
245 return direction_ == rhs.direction_ && speed_ == rhs.speed_;
246 }
252 [[nodiscard]] constexpr bool operator<(const Wind& rhs) const noexcept
253 {
254 if (direction_ == rhs.direction_)
255 {
256 return speed_ < rhs.speed_;
257 }
258 return direction_ < rhs.direction_;
259 }
263 [[maybe_unused]] static const Wind Zero;
264 static const Wind Invalid;
265private:
269 MathSize wsv_x_;
273 MathSize wsv_y_;
282};
286class Precipitation : public Index<Precipitation>
287{
288public:
290 using Index::Index;
292
295 static const Precipitation Zero;
296 static const Precipitation Invalid;
297};
302{
303public:
307 virtual ~Weather() = default;
311 constexpr Weather() noexcept = default;
319 constexpr Weather(const Temperature& temp,
320 const RelativeHumidity& rh,
321 const Wind& wind,
322 const Precipitation& prec) noexcept
324 {
325 }
330 constexpr Weather(Weather&& rhs) noexcept = default;
335 constexpr Weather(const Weather& rhs) noexcept = default;
341 Weather& operator=(Weather&& rhs) noexcept = default;
347 Weather& operator=(const Weather& rhs) = default;
352 [[nodiscard]] constexpr const Temperature& temp() const noexcept
353 {
354 return temp_;
355 }
360 [[nodiscard]] constexpr const RelativeHumidity& rh() const noexcept
361 {
362 return rh_;
363 }
368 [[nodiscard]] constexpr const Wind& wind() const noexcept
369 {
370 return wind_;
371 }
376 [[nodiscard]] constexpr const Precipitation& prec() const noexcept
377 {
378 return prec_;
379 }
380private:
397};
398}
399}
A wrapper around a MathSize to ensure correct types are used.
Definition Index.h:15
constexpr MathSize asValue() const noexcept
Returns value as a MathSize.
Definition Index.h:84
constexpr Index() noexcept
Construct with a value of 0.
Definition Index.h:28
Direction with access to degrees or radians.
Definition Weather.h:64
constexpr MathSize heading() const
Heading (opposite of this direction)
Definition Weather.h:125
constexpr Direction(Direction &&rhs) noexcept=default
Move constructor.
Direction & operator=(const Direction &rhs) noexcept=default
Copy assignment.
~Direction()=default
Destructor.
Direction & operator=(Direction &&rhs) noexcept=default
Move assignment.
constexpr Direction() noexcept=default
Construct with Direction of 0 (North)
constexpr Direction(const Direction &rhs) noexcept=default
Copy constructor.
static const Direction Zero
Direction of 0 (North)
Definition Weather.h:132
constexpr MathSize asDegrees() const
Direction as degrees, where 0 is North and values increase clockwise.
Definition Weather.h:117
constexpr MathSize asRadians() const
Direction as radians, where 0 is North and values increase clockwise.
Definition Weather.h:109
Precipitation (1hr accumulation) (mm)
Definition Weather.h:287
static const Precipitation Zero
Accumulated Precipitation of 0 mm.
Definition Weather.h:295
Relative humidity as a percentage.
Definition Weather.h:34
static const RelativeHumidity Zero
0% Relative Humidity
Definition Weather.h:42
Speed in kilometers per hour.
Definition Weather.h:49
static const Speed Zero
0 km/h
Definition Weather.h:57
Temperature in degrees Celsius.
Definition Weather.h:19
static const Temperature Zero
0 degrees Celsius
Definition Weather.h:27
Collection of weather indices used for calculating FwiWeather.
Definition Weather.h:302
constexpr Weather(const Weather &rhs) noexcept=default
Copy constructor.
constexpr const Temperature & temp() const noexcept
Temperature (Celsius)
Definition Weather.h:352
constexpr Weather() noexcept=default
Constructor with no initialization.
virtual ~Weather()=default
Destructor.
Weather & operator=(const Weather &rhs)=default
Move assignment.
constexpr const Wind & wind() const noexcept
Wind (km/h)
Definition Weather.h:368
constexpr const RelativeHumidity & rh() const noexcept
Relative Humidity (%)
Definition Weather.h:360
Temperature temp_
Temperature (Celsius)
Definition Weather.h:384
constexpr Weather(Weather &&rhs) noexcept=default
Move constructor.
RelativeHumidity rh_
Relative Humidity (%)
Definition Weather.h:388
Wind wind_
Wind (km/h)
Definition Weather.h:392
constexpr const Precipitation & prec() const noexcept
Precipitation (1hr accumulation) (mm)
Definition Weather.h:376
Precipitation prec_
Precipitation (1hr accumulation) (mm)
Definition Weather.h:396
Weather & operator=(Weather &&rhs) noexcept=default
Move assignment.
Wind with a Speed and Direction.
Definition Weather.h:139
Direction direction_
Direction (degrees or radians, N is 0)
Definition Weather.h:277
MathSize wsv_y_
Wind speed vector in Y direction (North is positive)
Definition Weather.h:273
constexpr const Direction & direction() const noexcept
Direction wind is coming from.
Definition Weather.h:201
~Wind()=default
Destructor.
constexpr const Speed & speed() const noexcept
Speed of wind (km/h)
Definition Weather.h:193
static const Wind Zero
Wind with 0 Speed from Direction 0.
Definition Weather.h:263
constexpr bool operator==(const Wind &rhs) const noexcept
Equals to operator.
Definition Weather.h:243
Wind & operator=(const Wind &rhs) noexcept=default
Copy assignment.
constexpr Wind(Wind &&rhs) noexcept=default
Move constructor.
constexpr MathSize wsvY() const noexcept
Y component of wind vector (km/h)
Definition Weather.h:225
constexpr MathSize heading() const noexcept
Direction wind is going towards.
Definition Weather.h:209
Wind(const Direction &direction, const Speed speed) noexcept
Constructor.
Definition Weather.h:160
constexpr MathSize wsvX() const noexcept
X component of wind vector (km/h)
Definition Weather.h:217
Wind & operator=(Wind &&rhs) noexcept=default
Move assignment.
constexpr bool operator<(const Wind &rhs) const noexcept
Less than operator.
Definition Weather.h:252
Speed speed_
Speed (km/h)
Definition Weather.h:281
constexpr Wind() noexcept
Construct with 0 values.
Definition Weather.h:148
MathSize wsv_x_
Wind speed vector in X direction (East is positive)
Definition Weather.h:269
constexpr Wind(const Wind &rhs) noexcept=default
Copy constructor.
constexpr bool operator!=(const Wind &rhs) const noexcept
Not equal to operator.
Definition Weather.h:234
Definition util.py:1