radarlib 1.4.6
odimh5v21_dump.hpp
Go to the documentation of this file.
1/*
2 * Radar Library
3 *
4 * Copyright (C) 2009-2010 ARPA-SIM <urpsim@smr.arpa.emr.it>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Author: Guido Billi <guidobilli@gmail.com>
21 */
22
27#ifndef __RADAR_ODIMH5V21_DUMP_HPP__
28#define __RADAR_ODIMH5V21_DUMP_HPP__
29
30#include <string>
31#include <sstream>
32#include <iostream>
33#include <iomanip>
34
35#include <radarlib/math.hpp>
37
38namespace OdimH5v21 {
39
40/*===========================================================================*/
41/* DUMPER */
42/*===========================================================================*/
43
51class RADAR_API OdimObjectDumper
52{
53public:
54 virtual ~OdimObjectDumper();
55
64 virtual void dump(OdimObject* object);
65
75 virtual void dump(OdimObject* object, std::ostream& out);
76
86 virtual void dump(OdimObject* object, std::ostream* out);
87
88protected:
89 int level; /* current indendation level for output formatting */
90 std::ostream* out; /* current output stream */
91
92 virtual void dumpMetadata(int level, MetadataGroup* metadata, const std::string& name);
93 virtual void dumpDataset(int level, OdimData* data);
94 std::ostream& prefix(int level);
95
96 template <class T> void dumpIntBuffer(int level, const T* values, const T undetect, const T nodata, int rows, int cols)
97 {
98 for (int y=0; y<rows; y++)
99 {
100 prefix(level) << std::setw(3) << y << ": ";
101 for (int x=0; x<cols; x++)
102 {
103 T value = values[y * cols + x];
104 if (value == undetect) *out << "_ ";
105 else if (value == nodata) *out << ". ";
106 else *out << value << " ";
107 }
108 *out << std::endl;
109 }
110 }
111
112 template <class T> void dumpFloatBuffer(int level, const T* values, const T undetect, const T nodata, int rows, int cols)
113 {
114 for (int y=0; y<rows; y++)
115 {
116 prefix(level) << std::setw(3) << y << ": ";
117 for (int x=0; x<cols; x++)
118 {
119 T value = values[y * cols + x];
120 if (value == undetect) *out << "_ ";
121 else if (value == nodata) *out << ". ";
122 else if (Radar::math::isnan(value)) *out << "N " << " ";
123 else *out << value << " ";
124 }
125 *out << std::endl;
126 }
127 }
128
129protected:
130
131
132 /* default constructor is not public in order to deny users from directly creating dumpers */
133 /* only class factories are allowed to create instances */
135 friend class OdimFactory;
136
137};
138
139/*===========================================================================*/
140
141}
142
143#endif
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196// virtual void dumpFileConventions (OdimObject* object);
197// virtual void dumpPolarVolume (PolarVolume* volume);
198// virtual void dumpPolarVolumeWhat (PolarVolume* volume);
199// virtual void dumpPolarVolumeWhere (PolarVolume* volume);
200// virtual void dumpPolarVolumeHow (PolarVolume* volume);
201// virtual void dumpPolarVolumeScans (PolarVolume* volume);
202//
203// virtual void dumpPolarScan (PolarScan* scan);
204// virtual void dumpPolarScanWhat (PolarScan* scan);
205// virtual void dumpPolarScanWhere (PolarScan* scan);
206// virtual void dumpPolarScanHow (PolarScan* scan);
207// virtual void dumpPolarScanDatas (PolarScan* scan);
208//
209// virtual void dumpPolarScanData (PolarScan* scan, PolarScanData* scanData);
210// virtual void dumpPolarScanDataWhat (PolarScan* scan, PolarScanData* scanData);
211// virtual void dumpPolarScanDataWhere (PolarScan* scan, PolarScanData* scanData);
212// virtual void dumpPolarScanDataHow (PolarScan* scan, PolarScanData* scanData);
213// virtual void dumpPolarScanDataMatrix (PolarScan* scan, PolarScanData* scanData);
214//
215// virtual void dumpGroupName(int level, const char* name);
216// virtual void dumpAttribute(int level, const char* name, bool value);
217// virtual void dumpAttribute(int level, const char* name, int value);
218// virtual void dumpAttribute(int level, const char* name, int64_t value);
219// virtual void dumpAttribute(int level, const char* name, double value);
220// virtual void dumpAttribute(int level, const char* name, const std::string& value);
221// virtual void dumpAttribute(int level, const char* name, const char* value);
222// virtual void dumpAttribute(int level, const char* name, const std::vector<int64_t>& value);
223// virtual void dumpAttribute(int level, const char* name, const std::vector<double>& value);
224// virtual void dumpAttribute(int level, const char* name, const std::vector<std::string>& value);
Attribute (odim metadata) group.
Definition odimh5v21_metadata.hpp:54
Generic OdimH5 v2.1 data group.
Definition odimh5v21_classes.hpp:415
Definition odimh5v21_factory.hpp:52
OdimH5 object dumper.
Definition odimh5v21_dump.hpp:52
Generic OdimH5 v2.1 object.
Definition odimh5v21_classes.hpp:96
Macros, functions and constants about mathematic values.
Namespace related to ODIMH5 version 2.1.
Definition odimh5v21.hpp:46
Main library classes (generic objects, polar volumes etc.)