Skip to content
This repository was archived by the owner on Aug 2, 2022. It is now read-only.

Commit 866912a

Browse files
comments (#37)
Add doc comments to lots of files
1 parent f1edc94 commit 866912a

File tree

7 files changed

+376
-146
lines changed

7 files changed

+376
-146
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2018 Database Research Group of the University of Marburg
3+
Copyright (c) 2014-2020 Database Research Group of the University of Marburg
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

src/datatypes/colorizer.h

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,19 @@
1010

1111
using color_t = uint32_t;
1212

13+
/// Create a color from rgba bytes
1314
auto color_from_rgba(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) noexcept -> color_t;
15+
16+
/// Extracts the red portion (byte) of a color
1417
auto r_from_color(color_t color) -> uint8_t;
18+
19+
/// Extracts the green portion (byte) of a color
1520
auto g_from_color(color_t color) -> uint8_t;
21+
22+
/// Extracts the blue portion (byte) of a color
1623
auto b_from_color(color_t color) -> uint8_t;
24+
25+
/// Extracts the alpha portion (byte) of a color
1726
auto a_from_color(color_t color) -> uint8_t;
1827

1928
class Unit;
@@ -27,13 +36,19 @@ static color_t defaultDefaultColor = color_from_rgba(255, 0, 255, 0);
2736
*/
2837
class Colorizer {
2938
public:
39+
/**
40+
* A breakpoint that maps a value to a color
41+
*/
3042
struct Breakpoint {
3143
Breakpoint(double v, color_t c) : value(v), color(c) {}
3244

3345
double value;
3446
color_t color;
3547
};
3648

49+
/**
50+
* An interpolation method between break points
51+
*/
3752
enum class Interpolation {
3853
NEAREST,
3954
LINEAR,
@@ -42,15 +57,27 @@ class Colorizer {
4257
};
4358
using ColorTable = std::vector<Breakpoint>;
4459

60+
/**
61+
* Create a new colorizer by specifying a color breakpoint table, an interpolation method, a no data color and a default color
62+
*/
4563
explicit Colorizer(ColorTable table, Interpolation interpolation = Interpolation::LINEAR,
4664
color_t nodataColor = defaultNoDataColor, color_t defaultColor = defaultDefaultColor);
4765

4866
virtual ~Colorizer();
4967

68+
/**
69+
* Fill a palette of `num_colors` colors by using the colorizer's breakpoints
70+
*/
5071
void fillPalette(color_t *colors, unsigned int num_colors, double min, double max) const;
5172

73+
/**
74+
* Serialize this colorizer to a JSON string
75+
*/
5276
std::string toJson() const;
5377

78+
/**
79+
* Retrieve the interpolation enum variant
80+
*/
5481
auto getInterpolation() const -> Interpolation { return this->interpolation; }
5582

5683
/**
@@ -73,18 +100,30 @@ class Colorizer {
73100
*/
74101
static const Colorizer &error();
75102

103+
/**
104+
* Retrieve the minimum value of the color breakpoint table
105+
*/
76106
double minValue() const {
77107
return table.front().value;
78108
}
79109

110+
/**
111+
* Retrieve the maximum value of the color breakpoint table
112+
*/
80113
double maxValue() const {
81114
return table.back().value;
82115
}
83116

117+
/**
118+
* Retrieve no data color
119+
*/
84120
color_t getNoDataColor() const {
85121
return nodataColor;
86122
}
87123

124+
/**
125+
* Retrieve the default color
126+
*/
88127
color_t getDefaultColor() const {
89128
return defaultColor;
90129
}

src/datatypes/plots/histogram.h

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,42 +8,85 @@
88
#include <datatypes/plot.h>
99

1010
/**
11-
* This class models a one dimensional histograms with variable number of buckets
11+
* This class models a one dimensional histogram with a variable number of buckets
1212
*/
1313
class Histogram : public GenericPlot {
1414
public:
15+
/**
16+
* Construct a histogram by specifying the number of buckets and its range.
17+
*/
1518
Histogram(unsigned long number_of_buckets, double min, double max);
19+
20+
/**
21+
* Construct a histogram by specifying the number of buckets and its range.
22+
* Furthermore, specify a unit for the X axis
23+
*/
1624
Histogram(unsigned long number_of_buckets, double min, double max, const Unit &unit);
25+
26+
/**
27+
* Construct a histogram by specifying the number of buckets and its range.
28+
* Furthermore, specify the unit string for the X axis
29+
*/
1730
Histogram(unsigned long number_of_buckets, double min, double max, std::string unit_string);
1831

32+
/**
33+
* Deserialize a histogram from a binary buffer
34+
*/
1935
explicit Histogram(BinaryReadBuffer &buffer);
2036

2137
~Histogram() override;
2238

39+
/**
40+
* Compute a display X axis unit string from a unit
41+
*/
2342
static auto compute_unit_string(const Unit &unit) -> std::string;
2443

44+
/**
45+
* Increase a histogram bucket by a value in which it fits
46+
*/
2547
void inc(double value);
2648

49+
/**
50+
* Increase the histogram's no data counter
51+
*/
2752
void incNoData();
2853

54+
/**
55+
* Serialize the histogram to a JSON string
56+
*/
2957
const std::string toJSON() const override;
3058

59+
/**
60+
* Retrieve the number of values for one bucket
61+
*/
3162
int getCountForBucket(unsigned long bucket) {
3263
return counts.at(bucket);
3364
}
3465

66+
/**
67+
* Retrieve the number of no data values
68+
*/
3569
int getNoDataCount() {
3670
return nodata_count;
3771
}
3872

73+
/**
74+
* Retrieve the minimum value of the histogram's range
75+
*/
3976
double getMin() {
4077
return min;
4178
}
4279

80+
/**
81+
* Retrieve the maximum value of the histogram's range
82+
*/
4383
double getMax() {
4484
return max;
4585
}
4686

87+
/**
88+
* Retrieve the number of buckets
89+
*/
4790
unsigned long getNumberOfBuckets() {
4891
return counts.size();
4992
}
@@ -68,8 +111,14 @@ class Histogram : public GenericPlot {
68111
*/
69112
void addMarker(double bucket, const std::string &label);
70113

114+
/**
115+
* Clone the histogram by copying its internals
116+
*/
71117
std::unique_ptr<GenericPlot> clone() const override;
72118

119+
/**
120+
* Serialize the histogram into a binary buffer
121+
*/
73122
void serialize(BinaryWriteBuffer &buffer, bool is_persistent_memory) const override;
74123

75124
private:

src/datatypes/raster/raster_priv.h

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,61 @@
99
template<typename T, int dimensions>
1010
class Raster : public GenericRaster {
1111
public:
12+
/**
13+
* Create a raster using a `DataDescription`, a `SpatioTemporalReference` as well as its `width`, `height` and `depth`
14+
*/
1215
Raster(const DataDescription &datadescription, const SpatioTemporalReference &stref, uint32_t width,
1316
uint32_t height, uint32_t depth);
1417

18+
/**
19+
* Destructor for the raster
20+
*/
1521
virtual ~Raster();
1622

23+
/**
24+
* Retrieve the byte size of the raster's pixels
25+
*/
1726
virtual size_t getDataSize() const { return sizeof(T) * getPixelCount(); };
1827

28+
/**
29+
* Retrieve the byte size of
30+
*/
1931
virtual int getBPP() { return sizeof(T); }
2032

33+
/**
34+
* Change representation to CPU or GPU
35+
*/
2136
virtual void setRepresentation(Representation);
2237

38+
/**
39+
* Access the data as a const void pointer
40+
*/
2341
virtual const void *getData() {
2442
setRepresentation(GenericRaster::Representation::CPU);
2543
return (void *) data;
2644
};
2745

46+
/**
47+
* Access the data as a void pointer
48+
*/
2849
virtual void *getDataForWriting() {
2950
setRepresentation(GenericRaster::Representation::CPU);
3051
return (void *) data;
3152
};
3253

54+
/**
55+
* Retrieve the underlying OpenCL Buffer if it exists
56+
*/
3357
virtual cl::Buffer *getCLBuffer() { return clbuffer; };
3458

59+
/**
60+
* Retrieve the underlying OpenCL Info Buffer if it exists
61+
*/
3562
virtual cl::Buffer *getCLInfoBuffer() { return clbuffer_info; };
3663

64+
/**
65+
* Return the total byte size of this raster
66+
*/
3767
virtual size_t get_byte_size() const {
3868
return GenericRaster::get_byte_size() + getDataSize() + sizeof(T *) + sizeof(void *) +
3969
2 * sizeof(cl::Buffer *);
@@ -54,52 +84,115 @@ class RasterOperator;
5484
template<typename T>
5585
class Raster2D : public Raster<T, 2> {
5686
public:
87+
/**
88+
* Create a raster using a `DataDescription`, a `SpatioTemporalReference` as well as its `width` and `height`
89+
*/
5790
Raster2D(const DataDescription &datadescription, const SpatioTemporalReference &stref, uint32_t width,
5891
uint32_t height, uint32_t depth = 0);
5992

93+
/**
94+
* Destructor of `Raster2D`
95+
*/
6096
virtual ~Raster2D();
6197

98+
/**
99+
* Create a Netpbm grayscale image file
100+
*/
62101
virtual void toPGM(const char *filename, bool avg);
63102

103+
/**
104+
* Create a YUV video file
105+
*/
64106
virtual void toYUV(const char *filename);
65107

108+
/**
109+
* Create a Portable Network Graphics byte stream
110+
*/
66111
virtual void toPNG(std::ostream &output, const Colorizer &colorizer, bool flipx = false, bool flipy = false,
67112
Raster2D<uint8_t> *overlay = nullptr);
68113

114+
/**
115+
* Create a JPEG file
116+
*/
69117
virtual void toJPEG(const char *filename, const Colorizer &colorizer, bool flipx = false, bool flipy = false);
70118

119+
/**
120+
* Create a GDAL file based on a driver
121+
*/
71122
virtual void toGDAL(const char *filename, const char *driver, bool flipx = false, bool flipy = false);
72123

124+
/**
125+
* Clears all pixels and sets a value
126+
*/
73127
virtual void clear(double value);
74128

129+
/**
130+
* Copies this raster's values to an offset of a destination raster
131+
*/
75132
virtual void blit(const GenericRaster *raster, int x, int y = 0, int z = 0);
76133

134+
/**
135+
* Modifies this raster by cutting out a rectangular portion
136+
*/
77137
virtual std::unique_ptr<GenericRaster> cut(int x, int y, int z, int width, int height, int depths);
78138

139+
/**
140+
* Resizes this raster with scale parameters
141+
*/
79142
virtual std::unique_ptr<GenericRaster> scale(int width, int height = 0, int depth = 0);
80143

144+
/**
145+
* Flips the current raster along axes
146+
*/
81147
virtual std::unique_ptr<GenericRaster> flip(bool flipx, bool flipy);
82148

149+
/**
150+
* Modifies this raster by cutting out the rectangular region of the query rectangle `qrect`
151+
*/
83152
virtual std::unique_ptr<GenericRaster> fitToQueryRectangle(const QueryRectangle &qrect);
84153

154+
/**
155+
* Prints a series of chars to a region of this raster
156+
*/
85157
virtual void print(int x, int y, double value, const char *text, int maxlen = -1);
86158

159+
/**
160+
* Retrieves a pixel values as a double
161+
*/
87162
virtual double getAsDouble(int x, int y = 0, int z = 0) const;
88163

164+
/**
165+
* Retrieves a pixel value
166+
*
167+
* Performs no out of bounds check
168+
*/
89169
T get(int x, int y) const {
90170
return data[(size_t) y * width + x];
91171
}
92172

173+
/**
174+
* Retrieves a pixel value and returns the default value `def` if the call is out of bounds
175+
*/
93176
T getSafe(int x, int y, T def = 0) const {
94177
if (x >= 0 && y >= 0 && (uint32_t) x < width && (uint32_t) y < height)
95178
return data[(size_t) y * width + x];
96179
return def;
97180
}
98181

182+
/**
183+
* Writes a value to a pixel position
184+
*
185+
* Performs no out of bounds check
186+
*/
99187
void set(int x, int y, T value) {
100188
data[(size_t) y * width + x] = value;
101189
}
102190

191+
/**
192+
* Writes a value to a pixel position
193+
*
194+
* Performs no action if the position is out of bounds
195+
*/
103196
void setSafe(int x, int y, T value) {
104197
if (x >= 0 && y >= 0 && (uint32_t) x < width && (uint32_t) y < height)
105198
data[(size_t) y * width + x] = value;

0 commit comments

Comments
 (0)