bufr2synop 0.24.0
bufr2tac_print.c
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2013-2018 by Guillermo Ballester Valor *
3 * gbv@ogimet.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
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 *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20/*!
21 \file bufr2tac_print.c
22 \brief file with the code to print the results
23 */
24#include "bufr2tac.h"
25
26/*!
27 \fn int print_plain ( FILE *f, struct metreport *m )
28 \brief Print in a file the report decoded to Traditional Alphanumeric Code in plain text format. A line per report
29 \param f pointer to file where to write to
30 \param m pointer to struct \ref metreport where the decoded report is stored
31*/
32int print_plain ( FILE *f, struct metreport *m )
33{
34 if ( m->alphanum[0] )
35 fprintf ( f, "%s\n", m->alphanum );
36 if ( m->alphanum2[0] )
37 fprintf ( f, "%s\n", m->alphanum2 );
38 if ( m->alphanum3[0] )
39 fprintf ( f, "%s\n", m->alphanum3 );
40 if ( m->alphanum4[0] )
41 fprintf ( f, "%s\n", m->alphanum4 );
42 return 0;
43}
44
45/*!
46 \fn int print_html ( FILE *f, struct metreport *m )
47 \brief Print in a file the report decoded to Traditional Alphanumeric Code in plain html format. A line per report
48 \param f pointer to file where to write to
49 \param m pointer to struct \ref metreport where the decoded report is stored
50*/
51int print_html ( FILE *f, struct metreport *m )
52{
53 fprintf(f, "<pre>");
54 if ( m->alphanum[0] )
55 fprintf ( f, "%s\n", m->alphanum );
56 if ( m->alphanum2[0] )
57 fprintf ( f, "%s\n", m->alphanum2 );
58 if ( m->alphanum3[0] )
59 fprintf ( f, "%s\n", m->alphanum3 );
60 if ( m->alphanum4[0] )
61 fprintf ( f, "%s\n", m->alphanum4 );
62 fprintf(f, "</pre>");
63 return 0;
64}
65
66/*!
67 * \fn size_t print_geo ( char **geo, size_t lmax, struct metrepor *m )
68 * \brief Prints a WIGOS identifier in a TAC output report
69 * \param m pointer to struct \ref metreport where are both target and source
70 */
71size_t print_geo ( char **geo, size_t lmax, struct metreport *m )
72{
73 size_t used;
74 char sep = '|';
75
76 used = snprintf(*geo, lmax, "%8.4lf %9.4lf %6.1lf%c", m->g.lat, m->g.lon, m->g.alt, sep);
77 *geo += used;
78 return used;
79}
80
81/*!
82 * \fn size_t print_wigos_id ( char **wid, size_t lmax, struct metrepor *m )
83 * \brief Prints a WIGOS identifier in a TAC output report
84 * \param m pointer to struct \ref metreport where are both target and source
85 */
86 size_t print_wigos_id ( char **wid, size_t lmax, struct metreport *m )
87{
88 char aux[40];
89 size_t used;
90 char sep = '|';
91
92 if (m->g.wid.series == 0 && m->g.wid.issuer == 0 && m->g.wid.issue == 0 && m->g.wid.local_id[0] == '\0')
93 sprintf (aux,"0-0-0-MISSING");
94 else
95 sprintf (aux,"%d-%d-%d-%s", m->g.wid.series, m->g.wid.issuer, m->g.wid.issue, m->g.wid.local_id );
96
97 used = snprintf (*wid, lmax, "%-32s%c", aux, sep);
98 *wid += used;
99 return used;
100}
Include header file for binary bufr2tac.
size_t print_wigos_id(char **wid, size_t lmax, struct metreport *m)
size_t print_geo(char **geo, size_t lmax, struct metreport *m)
int print_plain(FILE *f, struct metreport *m)
Print in a file the report decoded to Traditional Alphanumeric Code in plain text format....
int print_html(FILE *f, struct metreport *m)
Print in a file the report decoded to Traditional Alphanumeric Code in plain html format....
double lat
Definition: bufr2tac.h:299
double lon
Definition: bufr2tac.h:300
double alt
Definition: bufr2tac.h:301
struct wigos_id wid
Definition: bufr2tac.h:295
all the information for a meteorological report in WMO text format from a BUFR file
Definition: bufr2tac.h:309
char alphanum[REPORT_LENGTH]
Definition: bufr2tac.h:321
char alphanum3[REPORT_LENGTH]
Definition: bufr2tac.h:325
struct met_geo g
Definition: bufr2tac.h:315
char alphanum2[REPORT_LENGTH]
Definition: bufr2tac.h:323
char alphanum4[REPORT_LENGTH]
Definition: bufr2tac.h:327
uint16_t issue
Definition: metcommon.h:49
uint16_t issuer
Definition: metcommon.h:48
uint8_t series
Definition: metcommon.h:47
char local_id[24]
Definition: metcommon.h:50