TerrainGen coverage


terraingen/
Coverage:
low: ≥ 0%
medium: ≥ 75.0%
high: ≥ 90.0%
Lines:
3 / 5
60.0%
Branches:
-
-%
Functions:
2 / 3
66.7%

sources/source.h
Line Branch Exec Source
1 /// @file
2 /// @brief The source interface: where a terrain's heights come from.
3 #pragma once
4
5 #include "terraingen/raster/geotiff/geotiff.h"
6 #include "terraingen/raster/grid.h"
7 #include "terraingen/raster/raster.h"
8 #include "terraingen/util/geometry.h"
9
10 namespace terraingen {
11
12 /// Where a terrain's heights come from: a flat datum, a DEM, or a source of your own. Layers
13 /// add relief to what the source gives, then filters transform the result.
14 ///
15 /// Sources must be deterministic and thread safe: a terrain may be evaluated tile by tile, in
16 /// parallel, and the tiles must agree with the whole.
17 class Source {
18 public:
19 263 virtual ~Source() = default;
20
21 /// The grid the source covers, which a terrain is evaluated over unless another is given.
22 virtual RasterGrid Grid() const = 0;
23
24 /// A point near the source's data, in world units, that noise layers measure positions from,
25 /// keeping single-precision noise accurate where coordinates are large; the origin by default.
26 2 virtual Vec2d ReferencePoint() const {
27 2 return {};
28 }
29
30 /// The projection outputs over the source's grid are written with; none by default.
31 ✗ virtual GeoKeys Keys() const {
32 ✗ return {};
33 }
34
35 /// Overwrites every cell of `heights`, placed by its transform, with the source's height
36 /// there, or with `heights`' no-data value where the source has none.
37 virtual void Fill(Raster<float>& heights) const = 0;
38
39 /// The height in metres at world point (`x`, `y`), or NaN where the source has no data: what
40 /// `Fill` gives a cell centred there, to the same bits.
41 virtual float HeightAt(double x, double y) const = 0;
42 };
43
44 } // namespace terraingen
45