radarlib 1.4.6
odimh5v21_support.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_SUPPORT_HPP__
28#define __RADAR_ODIMH5V21_SUPPORT_HPP__
29
30/*===========================================================================*/
31
32#include <string>
33#include <vector>
34
35#include <radarlib/defs.h>
37
38namespace OdimH5v21 {
39
40/*===========================================================================*/
41/* ODIM OBJECT MODEL VERSION NUMBERS */
42/*===========================================================================*/
43
53class RADAR_API ModelVersion
54{
55public:
56 int Major;
57 int Minor;
58
66 ModelVersion(int maj, int min);
67
76 ModelVersion(const std::string& value);
85 void parse(const std::string& val);
86
91 std::string toString() const;
92};
93
94
95/*===========================================================================*/
96/* ODIM OBJECT SOURCE INFORMATIONS */
97/*===========================================================================*/
98
110class RADAR_API SourceInfo
111{
112public:
116 std::string WMO;
120 std::string OperaRadarNode;
124 std::string OperaRadarSite;
132 std::string Place;
140 std::string Comment;
141
146 SourceInfo();
155 SourceInfo(const std::string& value);
164 void parse(const std::string value);
170 std::string toString() const;
171
176 inline SourceInfo& setWMO(const std::string& value)
177 {
178 WMO = value;
179 return *this;
180 }
185 inline SourceInfo& setOperaRadarNode(const std::string& value)
186 {
187 OperaRadarNode = value;
188 return *this;
189 }
194 inline SourceInfo& setOperaRadarSite(const std::string& value)
195 {
196 OperaRadarSite = value;
197 return *this;
198 }
204 {
205 OriginatingCenter = value;
206 return *this;
207 }
212 inline SourceInfo& setPlace(const std::string& value)
213 {
214 Place = value;
215 return *this;
216 }
221 inline SourceInfo& setCountry(int value)
222 {
223 Country = value;
224 return *this;
225 }
230 inline SourceInfo& setComment(const std::string& value)
231 {
232 Comment = value;
233 return *this;
234 }
235};
236
237/*===========================================================================*/
238/* AZIMUTH ANGLES PAIR */
239/*===========================================================================*/
240
248class RADAR_API AZAngles
249{
250public:
256 double start;
262 double stop;
263
268 AZAngles();
276 AZAngles(double start, double stop);
285 AZAngles(const std::string& value);
293 void set(double start, double stop);
302 void parse(const std::string& str);
307 std::string toString() const;
315 std::string toString(int precision) const;
322 static std::vector<AZAngles> parseSequence(const std::string& str);
330 static std::vector<AZAngles> parseSimpleArrays(const std::vector<double>& first, const std::vector<double>& second);
336 static std::string toString(const std::vector<AZAngles>& right);
344 static std::string toString(const std::vector<AZAngles>& right, int precision);
350 double averagedAngle(int direction = 0);
351};
352
353/*===========================================================================*/
354/* AZIMUTH TIMES PAIR */
355/*===========================================================================*/
356
364class RADAR_API AZTimes
365{
366public:
372 double start;
378 double stop;
379
384 AZTimes();
391 AZTimes(double start, double stop);
398 AZTimes(const std::string& str);
406 void set(double start, double stop);
414 void parse(const std::string& str);
419 std::string toString() const;
426 static std::vector<AZTimes> parseSequence(const std::string& str);
434 static std::vector<AZTimes> parseSimpleArrays(const std::vector<double>& first, const std::vector<double>& second);
439 static std::string toString(const std::vector<AZTimes>& right);
440};
441
442/*===========================================================================*/
443/* VIL HEIGHTS PAIR */
444/*===========================================================================*/
445
452class RADAR_API VILHeights
453{
454public:
458 double bottom;
462 double top;
463
467 VILHeights();
471 VILHeights(double bottom, double top);
476 VILHeights(const std::string& str);
477
481 void set(double bottom, double top);
485 void parse(const std::string& str);
489 std::string toString() const;
490};
491
492/*===========================================================================*/
493/* DATA MATRIX */
494/*===========================================================================*/
495
506template <class T> class DataMatrix
507{
508public:
516 :fillvalue(0)
517 ,rows(0)
518 ,cols(0)
519 ,cells()
520 {
521 }
530 DataMatrix(int rows, int cols)
531 :fillvalue(0)
532 ,rows(0)
533 ,cols(0)
534 ,cells()
535 {
536 resize(rows, cols);
537 }
545 DataMatrix(int rows, int cols, T value)
546 :fillvalue(value)
547 ,rows(0)
548 ,cols(0)
549 ,cells()
550 {
551 resize(rows, cols);
552 }
553 virtual ~DataMatrix()
554 {
555 }
564 inline void resize(const int rows, const int cols)
565 {
566 resize(rows, cols, fillvalue);
567 }
577 inline void resize(const int rows, const int cols, const T fillvalue)
578 {
579 this->rows = rows;
580 this->cols = cols;
581 cells.resize(rows * cols * sizeof(T));
582 fill(fillvalue);
583 }
587 inline void erase()
588 {
589 fill(this->fillvalue);
590 }
594 inline void fill(T value)
595 {
596 int total = rows * cols;
597 for (int i=0; i<total; i++)
598 cells[i] = value;
599 this->fillvalue = value;
600 }
601
608 inline T& elem(const int r, const int b)
609 {
610 return cells[r * cols + b];
611 }
615 inline const T* get() const
616 {
617 return &(cells[0]);
618 }
622 inline int getRowCount() const { return rows; }
626 inline int getColCount() const { return cols; }
627
628protected:
629 T fillvalue;
630 int rows;
631 int cols;
632 std::vector<T> cells;
633};
634
635/*===========================================================================*/
636/* RAY MATRIX */
637/*===========================================================================*/
638
650template <class T> class RayMatrix: public DataMatrix<T>
651{
652public:
660 :DataMatrix<T>()
661 {
662 }
672 RayMatrix(int rays, int bins)
673 :DataMatrix<T>(rays, bins)
674 {
675 }
686 RayMatrix(int rays, int bins, T fillvalue)
687 :DataMatrix<T>(rays, bins, fillvalue)
688 {
689 }
690 virtual ~RayMatrix()
691 {
692 }
701 inline void resize(const int rays, const int bins)
702 {
703 DataMatrix<T>::resize(rays, bins);
704 }
714 inline void resize(const int rays, const int bins, const T fillvalue)
715 {
716 DataMatrix<T>::resize(rays, bins, fillvalue);
717 }
721 inline int getRayCount() const { return this->rows; }
725 inline int getBinCount() const { return this->cols; }
726};
727
728/*===========================================================================*/
729/* ELEVATION ANGLES */
730/*===========================================================================*/
731
739class RADAR_API Angles
740{
741public:
746 double value;
750 Angles();
755 Angles(double value);
760 Angles(const std::string& value);
767 void set(double value);
776 void parse(const std::string& str);
781 std::string toString() const;
789 std::string toString(int precision) const;
796 static std::vector<Angles> parseSimpleArray(const std::vector <double> & value);
803 static std::vector<Angles> parseSequence(const std::string& str);
809 static std::string toString(const std::vector<Angles>& right);
816 static std::string toString(const std::vector<Angles>& right, int precision);
817};
818
819/*===========================================================================*/
820/* AROTATION */
821/*===========================================================================*/
822
830class RADAR_API Arotation
831{
832public:
836 double value;
840 Arotation();
845 Arotation(double value);
850 Arotation(const std::string& value);
857 void set(double value);
866 void parse(const std::string& str);
871 std::string toString() const;
879 std::string toString(int precision) const;
886 static std::vector<Arotation> parseSequence(const std::string& str);
893 static std::vector<Arotation> parseSimpleArray(const std::vector <double> & value);
899 static std::string toString(const std::vector<Arotation>& right);
906 static std::string toString(const std::vector<Arotation>& right, int precision);
907};
908
909/*===========================================================================*/
910/* TXPower */
911/*===========================================================================*/
912
920class RADAR_API TXpower
921{
922public:
926 double value;
930 TXpower();
935 TXpower(double value);
940 TXpower(const std::string& value);
947 void set(double value);
956 void parse(const std::string& str);
961 std::string toString() const;
969 std::string toString(int precision) const;
976 static std::vector<TXpower> parseSequence(const std::string& str);
983 static std::vector<TXpower> parseSimpleArray(const std::vector <double> & value);
989 static std::string toString(const std::vector<TXpower>& right);
996 static std::string toString(const std::vector<TXpower>& right, int precision);
997};
998
999/*===========================================================================*/
1000/* NODES */
1001/*===========================================================================*/
1002
1010class RADAR_API Nodes
1011{
1012private:
1016 std::string radar;
1017public:
1021 Nodes();
1026 Nodes(const std::string & radar);
1031 Nodes(const char * radar);
1032
1033 std::string get() const;
1040 void set(const std::string & radar);
1047 void set(const char * radar);
1054 static std::vector<Nodes> parseSequence(const std::string& str);
1060 static std::string toString(const std::vector<Nodes>& radars);
1061};
1062
1063
1064}
1065
1066#endif
Azimuth angles pair.
Definition: odimh5v21_support.hpp:249
double start
Start azimuth angle.
Definition: odimh5v21_support.hpp:256
double stop
Stop azimuth angle.
Definition: odimh5v21_support.hpp:262
Azimuth angles pair.
Definition: odimh5v21_support.hpp:365
double start
Start azimuth time (seconds.milliseconds)
Definition: odimh5v21_support.hpp:372
double stop
Start azimuth time (seconds.milliseconds)
Definition: odimh5v21_support.hpp:378
Elevation angle.
Definition: odimh5v21_support.hpp:740
double value
Elevation angle Elevation angles are ordered from lower to upper values.
Definition: odimh5v21_support.hpp:746
Arotation - Antenna Rotation Speed.
Definition: odimh5v21_support.hpp:831
double value
Antenna rotation speed.
Definition: odimh5v21_support.hpp:836
Matrix of data values.
Definition: odimh5v21_support.hpp:507
void fill(T value)
Set all matrix values to the given value.
Definition: odimh5v21_support.hpp:594
DataMatrix(int rows, int cols)
Create an empty rows x cols matrix.
Definition: odimh5v21_support.hpp:530
void erase()
Set all matrix values to the current fill value.
Definition: odimh5v21_support.hpp:587
void resize(const int rows, const int cols, const T fillvalue)
Resize the matrix.
Definition: odimh5v21_support.hpp:577
int getColCount() const
Return the number of cols.
Definition: odimh5v21_support.hpp:626
T & elem(const int r, const int b)
Reference to the element (r,b)
Definition: odimh5v21_support.hpp:608
const T * get() const
Return the pointer to the underneath data buffer.
Definition: odimh5v21_support.hpp:615
int getRowCount() const
Return the number of rows.
Definition: odimh5v21_support.hpp:622
DataMatrix(int rows, int cols, T value)
Create an empty rows x cols matrix, setting elements to 0.
Definition: odimh5v21_support.hpp:545
DataMatrix()
Create an empty 0x0 matrix.
Definition: odimh5v21_support.hpp:515
void resize(const int rows, const int cols)
Resize the matrix.
Definition: odimh5v21_support.hpp:564
OdimH5 model version informations.
Definition: odimh5v21_support.hpp:54
Nodes - Radar nodes which have crontributed data to composit.
Definition: odimh5v21_support.hpp:1011
OdimH5 rays matrix.
Definition: odimh5v21_support.hpp:651
int getRayCount() const
Get the number of rays that can be store in the matrix (matrix rows num)
Definition: odimh5v21_support.hpp:721
void resize(const int rays, const int bins)
Resize the matrix.
Definition: odimh5v21_support.hpp:701
RayMatrix(int rays, int bins, T fillvalue)
Definition: odimh5v21_support.hpp:686
RayMatrix()
Definition: odimh5v21_support.hpp:659
int getBinCount() const
Get the number of bins that can be store in a single ray (matrix cols num)
Definition: odimh5v21_support.hpp:725
void resize(const int rays, const int bins, const T fillvalue)
Resize the matrix.
Definition: odimh5v21_support.hpp:714
RayMatrix(int rays, int bins)
Definition: odimh5v21_support.hpp:672
OdimH5 object source informations.
Definition: odimh5v21_support.hpp:111
int Country
Country according to BUFR tables 14 0 1 101.
Definition: odimh5v21_support.hpp:136
SourceInfo & setPlace(const std::string &value)
Set Place value and return a reference to this object.
Definition: odimh5v21_support.hpp:212
SourceInfo & setOperaRadarSite(const std::string &value)
Set OperaRadarSite value and return a reference to this object.
Definition: odimh5v21_support.hpp:194
int OriginatingCenter
Originating centre.
Definition: odimh5v21_support.hpp:128
std::string OperaRadarSite
Radar site as indexed in the OPERA database.
Definition: odimh5v21_support.hpp:124
std::string Comment
Free comment.
Definition: odimh5v21_support.hpp:140
SourceInfo & setWMO(const std::string &value)
Set WMO value and return a reference to this object.
Definition: odimh5v21_support.hpp:176
SourceInfo & setComment(const std::string &value)
Set Comment value and return a reference to this object.
Definition: odimh5v21_support.hpp:230
SourceInfo & setOriginatingCenter(int value)
Set OriginatingCenter value and return a reference to this object.
Definition: odimh5v21_support.hpp:203
std::string WMO
Combined WMO block and station number in the form A1bwnnnnn, or 0 if none assigned.
Definition: odimh5v21_support.hpp:116
std::string Place
Place according to Table 9 of OdimH5 standard.
Definition: odimh5v21_support.hpp:132
SourceInfo & setOperaRadarNode(const std::string &value)
Set OperaRadarNode value and return a reference to this object.
Definition: odimh5v21_support.hpp:185
std::string OperaRadarNode
Radar node according to OPERA name table (see right column of Table 9 in OPERA v2....
Definition: odimh5v21_support.hpp:120
SourceInfo & setCountry(int value)
Set Country value and return a reference to this object.
Definition: odimh5v21_support.hpp:221
TXpower - TX Power.
Definition: odimh5v21_support.hpp:921
double value
TX Power.
Definition: odimh5v21_support.hpp:926
Bottom and top heights (m) of the integration layer.
Definition: odimh5v21_support.hpp:453
double bottom
Lower value in meters.
Definition: odimh5v21_support.hpp:458
double top
Upper value in meters.
Definition: odimh5v21_support.hpp:462
Internal library macros.
Namespace related to ODIMH5 version 2.1.
Definition: odimh5v21.hpp:46
OdimH5 exceptions.