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