FireSTARR
Loading...
Searching...
No Matches
stdafx.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, 2021-2025. */
3
4/* SPDX-License-Identifier: AGPL-3.0-or-later */
5
6#pragma once
7#include "debug_settings.h"
8
9// #define VLD_FORCE_ENABLE
10// #include "vld.h"
11#define _USE_MATH_DEFINES
12#define NOMINMAX
13#include <algorithm>
14#include <array>
15#include <atomic>
16#include <cassert>
17#include <cerrno>
18#include <chrono>
19#include <cmath>
20#include <cstdarg>
21#include <cstdint>
22#include <cstdio>
23#include <cstring>
24#include <ctime>
25#include <execution>
26#include <fstream>
27#include <functional>
28#include <future>
29#include <iomanip>
30#include <iostream>
31#include <iterator>
32#include <limits>
33#include <list>
34#include <locale>
35#include <map>
36#include <memory>
37#include <random>
38#include <ranges>
39#include <set>
40#include <sstream>
41#include <string_view>
42#include <string>
43#include <unordered_map>
44#include <utility>
45#include <vector>
46#include <geo_normalize.h>
47#include <geotiff.h>
48#include <geovalues.h>
49#include <xtiffio.h>
50#include "tiff.h"
51#include <tiffio.h>
52#include <sys/stat.h>
53#include "unstable.h"
54// unreferenced inline function has been removed
55// Informational: catch(...) semantics changed since Visual C++ 7.1; structured exceptions (SEH) are no longer caught
56// function 'X' selected for automatic inline expansion
57// function not inlined
58// selected for automatic inline expansion
59// Do not assign the result of an allocation or a function call with an owner<T> return value to a raw pointer, use owner<T> instead
60// Do not delete a raw pointer that is not an owner<T>
61// Return a scoped object instead of a heap-allocated if it has a move constructor
62// Reset or explicitly delete an owner<T> pointer
63// Do not assign to an owner<T> which may be in valid state
64// Do not assign a raw pointer to an owner<T>
65// Prefer scoped objects, don't heap-allocate unnecessarily
66// Avoid calling new and delete explicitly, use std::make_unique<T> instead
67// Global initializer calls a non-constexpr function
68// Symbol is never tested for nullness, it can be marked as not_null
69// Function hides a non-virtual function
70// prefer to use gsl::at()
71// Don't use a static_cast for arithmetic conversions. Use brace initialization, gsl::narrow_cast or gsl::narrow
72// Don't use pointer arithmetic. Use span instead
73// Only index into arrays using constant expressions
74// No array to pointer decay
75using std::abs;
76using std::array;
77using std::async;
78using std::atomic;
79using std::endl;
80using std::fixed;
81using std::function;
82using std::future;
83using std::get;
84using std::getline;
85using std::hash;
86using std::ifstream;
87using std::istringstream;
88using std::launch;
89using std::list;
90using std::lock_guard;
91using std::make_shared;
92using std::make_tuple;
93using std::make_unique;
94using std::map;
95using std::max;
96using std::min;
97using std::mt19937;
98using std::mutex;
99using std::numeric_limits;
100using std::ofstream;
101using std::ostream;
102using std::ostringstream;
103using std::pair;
104using std::put_time;
105using std::runtime_error;
106using std::set;
107using std::setprecision;
108using std::shared_ptr;
109using std::stod;
110using std::stoi;
111using std::stol;
112using std::string;
113using std::string_view;
114using std::stringstream;
115using std::to_string;
116using std::to_wstring;
117using std::tuple;
118using std::uniform_real_distribution;
119using std::unique_ptr;
120using std::unordered_map;
121using std::vector;
122using std::wstring;
123namespace fs
124{
128using HashSize = uint32_t;
132using CellIndex = uint8_t;
133// want to be able to make a bitmask of all directions it came from
134// 064 008 032
135// 001 000 002
136// 016 004 128
137static constexpr CellIndex DIRECTION_NONE = 0b00000000;
138static constexpr CellIndex DIRECTION_W = 0b00000001;
139static constexpr CellIndex DIRECTION_E = 0b00000010;
140static constexpr CellIndex DIRECTION_S = 0b00000100;
141static constexpr CellIndex DIRECTION_N = 0b00001000;
142static constexpr CellIndex DIRECTION_SW = 0b00010000;
143static constexpr CellIndex DIRECTION_NE = 0b00100000;
144static constexpr CellIndex DIRECTION_NW = 0b01000000;
145static constexpr CellIndex DIRECTION_SE = 0b10000000;
149using Idx = int16_t;
153using FullIdx = int64_t;
157// FIX: could try to get really fancy and use number of bits per pixel options
158using PerimSize = uint8_t;
159// using PerimSize = uint16_t;
163// FIX: seriously does not like uint for some reason
164using FuelSize = uint16_t;
165// using FuelSize = int16_t;
166using DirectionSize = uint16_t;
167constexpr auto INVALID_DIRECTION = std::numeric_limits<DirectionSize>::max();
171using AspectSize = DirectionSize;
175using ElevationSize = int16_t;
179using SlopeSize = uint16_t;
183using IntensitySize = uint32_t;
187// using DistanceSize = _Float16;
188using DistanceSize = double;
192// FIX: results in "Invalid fuel type in fuel map"
193// using InnerSize = _Float16;
194// using InnerSize = float;
195using InnerSize = double;
199using XYSize = double;
200// using InnerSize = float;
201// using InnerSize = double;
205using ThresholdSize = double;
209using DurationSize = double;
210constexpr DurationSize INVALID_TIME = -1;
211constexpr auto NO_INTENSITY = static_cast<IntensitySize>(0);
212using ROSSize = MathSize;
213constexpr auto NO_ROS = static_cast<ROSSize>(0.0);
217using Day = uint16_t;
218static constexpr Day MAX_DAYS = 366;
222static constexpr Idx MAX_COLUMNS = 4096;
226static constexpr Idx MAX_ROWS = MAX_COLUMNS;
227// static_assert(static_cast<size_t>(MAX_ROWS) * (MAX_COLUMNS - 1) <= std::numeric_limits<Idx>::max());
228static constexpr Idx PREFERRED_TILE_WIDTH = 256;
229static constexpr Idx TILE_WIDTH = min(MAX_COLUMNS, static_cast<Idx>(PREFERRED_TILE_WIDTH));
233static constexpr auto MAX_ASPECT = 359;
237static constexpr auto MAX_SLOPE_FOR_DISTANCE = 500;
241static constexpr auto INVALID_ANGLE = 361;
245static constexpr auto INVALID_ASPECT = INVALID_ANGLE;
249static constexpr MathSize INVALID_CURING = -1;
253static constexpr auto INVALID_SLOPE = 511;
257static constexpr auto NUMBER_OF_FUELS = 141;
261static constexpr auto M_2_X_PI = 2.0 * M_PI;
265static constexpr auto M_3_X_PI_2 = 3.0 * M_PI_2;
269static constexpr auto M_RADIANS_TO_DEGREES = 180.0 / M_PI;
273static constexpr int DAY_HOURS = 24;
277static constexpr int HOUR_MINUTES = 60;
281static constexpr int MINUTE_SECONDS = 60;
285static constexpr int HOUR_SECONDS = HOUR_MINUTES * MINUTE_SECONDS;
289static constexpr int DAY_MINUTES = DAY_HOURS * HOUR_MINUTES;
293static constexpr int DAY_SECONDS = DAY_MINUTES * MINUTE_SECONDS;
297static constexpr int YEAR_HOURS = MAX_DAYS * DAY_HOURS;
301using SlopeTableArray = array<double, MAX_SLOPE_FOR_DISTANCE + 1>;
305using DegreesSize = uint16_t;
309using AngleTableArray = array<double, 361>;
313using FuelCodeSize = uint8_t;
317using Topo = uint64_t;
321using SubSize = uint16_t;
325using Coordinates = tuple<Idx, Idx, SubSize, SubSize>;
329using FullCoordinates = tuple<FullIdx, FullIdx, SubSize, SubSize>;
333using Clock = std::chrono::steady_clock;
334}