libdballe  6.8
wr_exporters/common.h
1 /*
2  * dballe/wr_exporter/common - Common infrastructure for wreport exporters
3  *
4  * Copyright (C) 2013 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.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * Author: Enrico Zini <enrico@enricozini.com>
20  */
21 
22 #ifndef DBALLE_MSG_WREXPORTER_BASE_H
23 #define DBALLE_MSG_WREXPORTER_BASE_H
24 
25 #include <dballe/msg/msg.h>
26 
27 namespace wreport {
28 struct Subset;
29 struct Bulletin;
30 struct Var;
31 }
32 
33 namespace dballe {
34 namespace msg {
35 namespace wr {
36 
38 {
39 protected:
40  // Subset being written
41  wreport::Subset* subset;
42  const msg::Context* c_ana;
43  const msg::Context* c_surface_instant;
44 
45  void add(wreport::Varcode code, const msg::Context* ctx, int shortcut) const;
46  void add(wreport::Varcode code, const msg::Context* ctx, wreport::Varcode srccode) const;
47  void add(wreport::Varcode code, const msg::Context* ctx) const;
48  void add(wreport::Varcode code, const wreport::Var* var) const;
49 
50 public:
51  void init(wreport::Subset& subset);
52  void scan_context(const msg::Context& c);
53 
54  int get_hour();
55 
56  void add_year_to_minute();
57  void add_latlon_coarse();
58  void add_latlon_high();
59  void add_station_name(wreport::Varcode code);
60  void add_station_height();
61  void add_ecmwf_synop_head();
62  void add_ship_head();
63  // SYNOP Fixed surface station identification, time, horizontal and
64  // vertical coordinates
65  void add_D01090();
66  void add_D01093();
67 };
68 
70 {
71 protected:
72  const msg::Context* c_geopotential;
73  const msg::Context* c_thermo;
74  const msg::Context* c_tmax;
75  const msg::Context* c_tmin;
76  const msg::Context* c_prec1;
77  const msg::Context* c_prec2;
78  const msg::Context* c_prec24;
79  const msg::Context* c_cloud_cover;
80  const msg::Context* c_cloud_data[4];
81  const msg::Context* c_cloud_group[4];
82  const msg::Context* c_wind;
83  const msg::Context* c_gust1;
84  const msg::Context* c_gust2;
85  const msg::Context* c_visib;
86  const msg::Context* c_past_wtr;
87  const msg::Context* c_depth;
88  const msg::Context* c_swell_waves[2];
89 
90 public:
91  const wreport::Var* v_press;
92  const wreport::Var* v_pressmsl;
93  const wreport::Var* v_pchange3;
94  const wreport::Var* v_pchange24;
95  const wreport::Var* v_ptend;
96  const wreport::Var* v_geopotential;
97 
98  void init(wreport::Subset& subset);
99  void scan_context(const msg::Context& c);
100 
101  // Pressure data
102  void add_D02001();
103  // synop: pressure data
104  void add_D02031();
105  // synop: temperature and humidity
106  void add_D02032();
107  // ship: temperature and humidity
108  void add_D02052();
109  // synop: extreme temperature data
110  void add_D02041();
111  // ship: extreme temperature data
112  void add_D02058();
113  void add_pressure();
114  void add_geopotential(wreport::Varcode code);
115  // Precipitation past 24 hours
116  void add_D02034();
117  // Precipitation measurement
118  void add_D02040();
119  // synop: wind data
120  void add_D02042();
121  // ship: wind data
122  void add_D02059();
123  // Present and past weather
124  void add_D02038();
125  void add_ecmwf_synop_weather();
126  // Basic synoptic "instantaneous" data
127  void add_D02035();
128  // Icing and ice
129  void add_D02055();
130  void add_ecmwf_ice();
131  // ship: visibility data
132  void add_D02053();
133  // Ship marine data
134  void add_D02056();
135  // Sea waves
136  void add_plain_waves();
137  // Ship waves (wind and swell)
138  void add_D02024();
139 
144  void add_sensor_height(const msg::Context& c, const wreport::Var* sample_var=NULL);
145 
150  void add_marine_sensor_height(const msg::Context& c, const wreport::Var* sample_var=NULL);
151 
156  void add_xtemp_group(wreport::Varcode code, const msg::Context* c);
157 
161  void add_prec_group(const msg::Context* c);
162 
166  void add_cloud_data();
167 
169  void add_wind_gust(const msg::Context* c);
170 
175  void add_time_period(wreport::Varcode code, const msg::Context& c, const wreport::Var* sample_var, const Trange& tr_std);
176 };
177 
178 }
179 }
180 }
181 
182 #endif
Store an array of physical data all on the same level.
Definition: msg/context.h:44
Definition: wr_exporters/common.h:37
Definition: defs.h:113
void add_marine_sensor_height(const msg::Context &c, const wreport::Var *sample_var=NULL)
Add B07032 and B07033 sensor heights, taking the value from the var attributes or the context...
void add_xtemp_group(wreport::Varcode code, const msg::Context *c)
Add an extreme temperature group, with the measured value added with the given code, from temperature data found on the given context.
Definition: cmdline.h:34
void add_time_period(wreport::Varcode code, const msg::Context &c, const wreport::Var *sample_var, const Trange &tr_std)
Add a B04025 or B04025 time period variable, with data taken from its parameters as needed...
void add_prec_group(const msg::Context *c)
Add time period and total precipitation from the given context.
Abstraction for a weather report message which is independent from the encoding, used to make sense o...
void add_wind_gust(const msg::Context *c)
Add a wind gust block with info from the given context.
Definition: wr_exporters/common.h:69
void add_sensor_height(const msg::Context &c, const wreport::Var *sample_var=NULL)
Add B07032 sensor height, taking the value from the var attributes or the context, as appropriate.
Definition: conversion.h:31
void add_cloud_data()
Add cloud data, as D02004 and a delayed replication of D02005.