Rise
The Vieneo Province
Toggle main menu visibility
Loading...
Searching...
No Matches
WeatherRadarSource.h
Go to the documentation of this file.
1
#pragma once
2
#include "
WeatherRadarModel.h
"
3
#include "
../Protocol/TerrainWeather.h
"
4
#include <type_traits>
5
6
namespace
WeatherRadarModel
7
{
8
struct
GridFootprint
9
{
10
unsigned
face
;
11
VECTOR2SHORT
center
;
12
bool
Contains
(
double
u,
double
v)
const
13
{
14
return
std::isfinite(u) && std::isfinite(v) &&
15
u>=
center
.
u
-31 && u<=
center
.
u
+32 && v>=
center
.
v
-31 && v<=
center
.
v
+32;
16
}
17
bool
Contains
(
Point
position)
const
18
{
19
double
u,v;
20
const
RiseMath::Vector3
point(
float
(position.
x
),
float
(position.
y
),
float
(position.
z
));
21
return
PlotWeather::Coordinates
(point,
face
,u,v) &&
Contains
(u,v);
22
}
23
};
24
25
template
<
class
Elevation>
Sample
SampleGrid
(
const
PlotWeather::Store
& source,
Point
position,
26
double
topKm,Elevation elevation,
const
GridFootprint
* terrainFootprint=
nullptr
)
27
{
28
Sample
result;
29
if
(!source.
Ready
())
return
result;
30
const
RiseMath::Vector3
point(
float
(position.
x
),
float
(position.
y
),
float
(position.
z
));
31
const
auto
& header=source.
Header
();
32
double
u,v;
PlotWeather::LocalSample
cell;
float
surfaceMeters;
33
if
(!
PlotWeather::Coordinates
(point,header.cube,u,v))
return
result;
34
// A finite source footprint is a normal operating limit. Keep holes,
35
// invalid samples and pending terrain rows inside it as missing data.
36
// Each stream has its own face/center; never join by array index.
37
const
GridFootprint
weatherFootprint{header.cube,header.tcp};
38
if
(!weatherFootprint.
Contains
(u,v) || (terrainFootprint && !terrainFootprint->Contains(position)))
39
{ result.
outsideCoverage
=
true
;
return
result; }
40
if
(!source.
Interpolate
(header.cube,u,v,header.requestToken,cell))
return
result;
41
// Existing elevation-only callers remain valid. Production supplies
42
// the independent landform water fraction with the same coordinate join.
43
if
constexpr
(std::is_invocable_r_v<bool,Elevation,unsigned,double,double,float&,float&>)
44
{
45
float
waterFraction;
46
if
(!elevation(header.cube,u,v,surfaceMeters,waterFraction))
return
result;
47
result.
waterFraction
=waterFraction;
48
}
49
else
if
(!elevation(header.cube,u,v,surfaceMeters))
return
result;
50
result.
available
=
true
; result.
level
=cell.
precipitation
;
51
result.
surfaceKm
=surfaceMeters*.001; result.
topKm
=topKm;
52
return
result;
53
}
54
}
TerrainWeather.h
WeatherRadarModel.h
PlotWeather::Store
Definition
TerrainWeather.h:123
PlotWeather::Store::Interpolate
bool Interpolate(unsigned cube, double u, double v, uint16_t token, LocalSample &result) const
Definition
TerrainWeather.h:139
PlotWeather::Store::Ready
bool Ready() const
Definition
TerrainWeather.h:129
PlotWeather::Store::Header
const SPlotWeatherHeader & Header() const
Definition
TerrainWeather.h:130
PlotWeather::Coordinates
bool Coordinates(const RiseMath::Vector3 &position, unsigned cube, double &u, double &v)
Definition
TerrainWeather.h:100
WeatherRadarModel
Definition
WeatherRadarDisplay.h:10
WeatherRadarModel::SampleGrid
Sample SampleGrid(const PlotWeather::Store &source, Point position, double topKm, Elevation elevation, const GridFootprint *terrainFootprint=nullptr)
Definition
WeatherRadarSource.h:25
PlotWeather::LocalSample
Definition
TerrainWeather.h:91
PlotWeather::LocalSample::precipitation
float precipitation
Definition
TerrainWeather.h:92
RiseMath::Vector3
Definition
ClientMath.h:38
VECTOR2SHORT
Definition
ServerTypes.h:173
VECTOR2SHORT::v
short v
Definition
ServerTypes.h:174
VECTOR2SHORT::u
short u
Definition
ServerTypes.h:174
WeatherRadarModel::GridFootprint
Definition
WeatherRadarSource.h:9
WeatherRadarModel::GridFootprint::Contains
bool Contains(Point position) const
Definition
WeatherRadarSource.h:17
WeatherRadarModel::GridFootprint::face
unsigned face
Definition
WeatherRadarSource.h:10
WeatherRadarModel::GridFootprint::center
VECTOR2SHORT center
Definition
WeatherRadarSource.h:11
WeatherRadarModel::GridFootprint::Contains
bool Contains(double u, double v) const
Definition
WeatherRadarSource.h:12
WeatherRadarModel::Point
Definition
WeatherRadarDisplay.h:12
WeatherRadarModel::Point::z
double z
Definition
WeatherRadarDisplay.h:13
WeatherRadarModel::Point::x
double x
Definition
WeatherRadarDisplay.h:13
WeatherRadarModel::Point::y
double y
Definition
WeatherRadarDisplay.h:13
WeatherRadarModel::Sample
Definition
WeatherRadarModel.h:101
WeatherRadarModel::Sample::level
double level
Definition
WeatherRadarModel.h:103
WeatherRadarModel::Sample::waterFraction
double waterFraction
Definition
WeatherRadarModel.h:105
WeatherRadarModel::Sample::topKm
double topKm
Definition
WeatherRadarModel.h:103
WeatherRadarModel::Sample::surfaceKm
double surfaceKm
Definition
WeatherRadarModel.h:103
WeatherRadarModel::Sample::outsideCoverage
bool outsideCoverage
Definition
WeatherRadarModel.h:104
WeatherRadarModel::Sample::available
bool available
Definition
WeatherRadarModel.h:102
Modules
WeatherRadarSource.h
Generated on
for Rise by
1.18.0