radarlib  1.4.6
odimh5v20_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_ODIMH5V20_SUPPORT_HPP__
28 #define __RADAR_ODIMH5V20_SUPPORT_HPP__
29 
30 /*===========================================================================*/
31 
32 #include <string>
33 #include <vector>
34 
35 #include <radarlib/defs.h>
37 
38 namespace OdimH5v20 {
39 
40 /*===========================================================================*/
41 /* ODIM OBJECT MODEL VERSION NUMBERS */
42 /*===========================================================================*/
43 
53 class RADAR_API ModelVersion
54 {
55 public:
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 
110 class RADAR_API SourceInfo
111 {
112 public:
116  std::string WMO;
120  std::string OperaRadarSite;
128  std::string Place;
132  int Country;
136  std::string Comment;
137 
142  SourceInfo();
151  SourceInfo(const std::string& value);
160  void parse(const std::string value);
166  std::string toString() const;
167 
172  inline SourceInfo& setWMO(const std::string& value)
173  {
174  WMO = value;
175  return *this;
176  }
181  inline SourceInfo& setOperaRadarSite(const std::string& value)
182  {
183  OperaRadarSite = value;
184  return *this;
185  }
190  inline SourceInfo& setOriginatingCenter(int value)
191  {
192  OriginatingCenter = value;
193  return *this;
194  }
199  inline SourceInfo& setPlace(const std::string& value)
200  {
201  Place = value;
202  return *this;
203  }
208  inline SourceInfo& setCountry(int value)
209  {
210  Country = value;
211  return *this;
212  }
217  inline SourceInfo& setComment(const std::string& value)
218  {
219  Comment = value;
220  return *this;
221  }
222 };
223 
224 /*===========================================================================*/
225 /* AZIMUTH ANGLES PAIR */
226 /*===========================================================================*/
227 
235 class RADAR_API AZAngles
236 {
237 public:
243  double start;
249  double stop;
250 
255  AZAngles();
263  AZAngles(double start, double stop);
272  AZAngles(const std::string& value);
280  void set(double start, double stop);
289  void parse(const std::string& str);
294  std::string toString() const;
302  std::string toString(int precision) const;
309  static std::vector<AZAngles> parseSequence(const std::string& str);
315  static std::string toString(const std::vector<AZAngles>& right);
323  static std::string toString(const std::vector<AZAngles>& right, int precision);
324 };
325 
326 /*===========================================================================*/
327 /* AZIMUTH TIMES PAIR */
328 /*===========================================================================*/
329 
337 class RADAR_API AZTimes
338 {
339 public:
345  double start;
351  double stop;
352 
357  AZTimes();
364  AZTimes(double start, double stop);
371  AZTimes(const std::string& str);
379  void set(double start, double stop);
387  void parse(const std::string& str);
392  std::string toString() const;
399  static std::vector<AZTimes> parseSequence(const std::string& str);
404  static std::string toString(const std::vector<AZTimes>& right);
405 };
406 
407 /*===========================================================================*/
408 /* VIL HEIGHTS PAIR */
409 /*===========================================================================*/
410 
417 class RADAR_API VILHeights
418 {
419 public:
423  double bottom;
427  double top;
428 
432  VILHeights();
436  VILHeights(double bottom, double top);
441  VILHeights(const std::string& str);
442 
446  void set(double bottom, double top);
450  void parse(const std::string& str);
454  std::string toString() const;
455 };
456 
457 /*===========================================================================*/
458 /* DATA MATRIX */
459 /*===========================================================================*/
460 
471 template <class T> class DataMatrix
472 {
473 public:
481  :fillvalue(0)
482  ,rows(0)
483  ,cols(0)
484  ,cells()
485  {
486  }
495  DataMatrix(int rows, int cols)
496  :fillvalue(0)
497  ,rows(0)
498  ,cols(0)
499  ,cells()
500  {
501  resize(rows, cols);
502  }
510  DataMatrix(int rows, int cols, T value)
511  :fillvalue(value)
512  ,rows(0)
513  ,cols(0)
514  ,cells()
515  {
516  resize(rows, cols);
517  }
518  virtual ~DataMatrix()
519  {
520  }
529  inline void resize(const int rows, const int cols)
530  {
531  resize(rows, cols, fillvalue);
532  }
542  inline void resize(const int rows, const int cols, const T fillvalue)
543  {
544  this->rows = rows;
545  this->cols = cols;
546  cells.resize(rows * cols * sizeof(T));
547  fill(fillvalue);
548  }
552  inline void erase()
553  {
554  fill(this->fillvalue);
555  }
559  inline void fill(T value)
560  {
561  int total = rows * cols;
562  for (int i=0; i<total; i++)
563  cells[i] = value;
564  this->fillvalue = value;
565  }
566 
573  inline T& elem(const int r, const int b)
574  {
575  return cells[r * cols + b];
576  }
580  inline const T* get() const
581  {
582  return &(cells[0]);
583  }
587  inline int getRowCount() const { return rows; }
591  inline int getColCount() const { return cols; }
592 
593 protected:
594  T fillvalue;
595  int rows;
596  int cols;
597  std::vector<T> cells;
598 };
599 
600 /*===========================================================================*/
601 /* RAY MATRIX */
602 /*===========================================================================*/
603 
615 template <class T> class RayMatrix: public DataMatrix<T>
616 {
617 public:
625  :DataMatrix<T>()
626  {
627  }
637  RayMatrix(int rays, int bins)
638  :DataMatrix<T>(rays, bins)
639  {
640  }
651  RayMatrix(int rays, int bins, T fillvalue)
652  :DataMatrix<T>(rays, bins, fillvalue)
653  {
654  }
655  virtual ~RayMatrix()
656  {
657  }
666  inline void resize(const int rays, const int bins)
667  {
668  DataMatrix<T>::resize(rays, bins);
669  }
679  inline void resize(const int rays, const int bins, const T fillvalue)
680  {
681  DataMatrix<T>::resize(rays, bins, fillvalue);
682  }
686  inline int getRayCount() const { return this->rows; }
690  inline int getBinCount() const { return this->cols; }
691 };
692 
693 /*===========================================================================*/
694 /* ELEVATION ANGLES */
695 /*===========================================================================*/
696 
704 class RADAR_API Angles
705 {
706 public:
711  double value;
715  Angles();
720  Angles(double value);
725  Angles(const std::string& value);
732  void set(double value);
741  void parse(const std::string& str);
746  std::string toString() const;
754  std::string toString(int precision) const;
761  static std::vector<Angles> parseSequence(const std::string& str);
767  static std::string toString(const std::vector<Angles>& right);
774  static std::string toString(const std::vector<Angles>& right, int precision);
775 };
776 
777 /*===========================================================================*/
778 /* AROTATION */
779 /*===========================================================================*/
780 
788 class RADAR_API Arotation
789 {
790 public:
794  double value;
798  Arotation();
803  Arotation(double value);
808  Arotation(const std::string& value);
815  void set(double value);
824  void parse(const std::string& str);
829  std::string toString() const;
837  std::string toString(int precision) const;
844  static std::vector<Arotation> parseSequence(const std::string& str);
850  static std::string toString(const std::vector<Arotation>& right);
857  static std::string toString(const std::vector<Arotation>& right, int precision);
858 };
859 
860 /*===========================================================================*/
861 /* NODES */
862 /*===========================================================================*/
863 
871 class RADAR_API Nodes
872 {
873 private:
877  std::string radar;
878 public:
882  Nodes();
887  Nodes(const std::string & radar);
892  Nodes(const char * radar);
893 
894  std::string get() const;
901  void set(const std::string & radar);
908  void set(const char * radar);
915  static std::vector<Nodes> parseSequence(const std::string& str);
921  static std::string toString(const std::vector<Nodes>& radars);
922 };
923 
924 
925 }
926 
927 #endif
double top
Upper value in meters.
Definition: odimh5v20_support.hpp:427
SourceInfo & setPlace(const std::string &value)
Set Place value and return a reference to this object.
Definition: odimh5v20_support.hpp:199
OdimH5 object source informations.
Definition: odimh5v20_support.hpp:110
SourceInfo & setOperaRadarSite(const std::string &value)
Set OperaRadarSite value and return a reference to this object.
Definition: odimh5v20_support.hpp:181
DataMatrix()
Create an empty 0x0 matrix.
Definition: odimh5v20_support.hpp:480
void resize(const int rows, const int cols)
Resize the matrix.
Definition: odimh5v20_support.hpp:529
SourceInfo & setOriginatingCenter(int value)
Set OriginatingCenter value and return a reference to this object.
Definition: odimh5v20_support.hpp:190
int getBinCount() const
Get the number of bins that can be store in a single ray (matrix cols num)
Definition: odimh5v20_support.hpp:690
double stop
Stop azimuth angle.
Definition: odimh5v20_support.hpp:249
DataMatrix(int rows, int cols)
Create an empty rows x cols matrix.
Definition: odimh5v20_support.hpp:495
Bottom and top heights (m) of the integration layer.
Definition: odimh5v20_support.hpp:417
double stop
Start azimuth time (seconds.milliseconds)
Definition: odimh5v20_support.hpp:351
Arotation - Antenna Rotation Speed.
Definition: odimh5v20_support.hpp:788
Internal library macros.
std::string Place
Place according to Table 9 of OdimH5 standard.
Definition: odimh5v20_support.hpp:128
DataMatrix(int rows, int cols, T value)
Create an empty rows x cols matrix, setting elements to 0.
Definition: odimh5v20_support.hpp:510
std::string Comment
Free comment.
Definition: odimh5v20_support.hpp:136
std::string OperaRadarSite
Radar site as indexed in the OPERA database.
Definition: odimh5v20_support.hpp:120
int Country
Country according to BUFR tables 14 0 1 101.
Definition: odimh5v20_support.hpp:132
double bottom
Lower value in meters.
Definition: odimh5v20_support.hpp:423
void erase()
Set all matrix values to the current fill value.
Definition: odimh5v20_support.hpp:552
Matrix of data values.
Definition: odimh5v20_support.hpp:471
SourceInfo & setWMO(const std::string &value)
Set WMO value and return a reference to this object.
Definition: odimh5v20_support.hpp:172
std::string toString(const T &value)
Convert a value to its string rapresentation.
Definition: string.hpp:139
void resize(const int rays, const int bins, const T fillvalue)
Resize the matrix.
Definition: odimh5v20_support.hpp:679
static T parse(const std::string &str, const std::string &typestr)
Parse a std::string to a given type value.
Definition: string.hpp:308
Azimuth angles pair.
Definition: odimh5v20_support.hpp:337
void resize(const int rays, const int bins)
Resize the matrix.
Definition: odimh5v20_support.hpp:666
std::string WMO
Combined WMO block and station number in the form A1bwnnnnn, or 0 if none assigned.
Definition: odimh5v20_support.hpp:116
void resize(const int rows, const int cols, const T fillvalue)
Resize the matrix.
Definition: odimh5v20_support.hpp:542
SourceInfo & setComment(const std::string &value)
Set Comment value and return a reference to this object.
Definition: odimh5v20_support.hpp:217
int getRayCount() const
Get the number of rays that can be store in the matrix (matrix rows num)
Definition: odimh5v20_support.hpp:686
OdimH5 rays matrix.
Definition: odimh5v20_support.hpp:615
int OriginatingCenter
Originating centre.
Definition: odimh5v20_support.hpp:124
Nodes - Radar nodes which have crontributed data to composit.
Definition: odimh5v20_support.hpp:871
OdimH5 model version informations.
Definition: odimh5v20_support.hpp:53
double value
Elevation angle Elevation angles are ordered from lower to upper values.
Definition: odimh5v20_support.hpp:711
SourceInfo & setCountry(int value)
Set Country value and return a reference to this object.
Definition: odimh5v20_support.hpp:208
OdimH5 exceptions.
Azimuth angles pair.
Definition: odimh5v20_support.hpp:235
int getColCount() const
Return the number of cols.
Definition: odimh5v20_support.hpp:591
RayMatrix(int rays, int bins)
Create a matrix to store a ray collection.
Definition: odimh5v20_support.hpp:637
double start
Start azimuth angle.
Definition: odimh5v20_support.hpp:243
void fill(T value)
Set all matrix values to the given value.
Definition: odimh5v20_support.hpp:559
double start
Start azimuth time (seconds.milliseconds)
Definition: odimh5v20_support.hpp:345
Elevation angle.
Definition: odimh5v20_support.hpp:704
int getRowCount() const
Return the number of rows.
Definition: odimh5v20_support.hpp:587
T & elem(const int r, const int b)
Reference to the element (r,b)
Definition: odimh5v20_support.hpp:573
RayMatrix()
Create a matrix with no rays.
Definition: odimh5v20_support.hpp:624
RayMatrix(int rays, int bins, T fillvalue)
Create a matrix to store a ray collection.
Definition: odimh5v20_support.hpp:651
double value
Antenna rotation speed.
Definition: odimh5v20_support.hpp:794