bufr2synop 0.24.0
bufr2tac_xml.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_xml.c
22 \brief Output a struct \ref metreport in xml form
23*/
24#include "bufr2tac.h"
25
26
27
28int print_xml_alphanum ( FILE *f, char *type, char *alphanum, struct metreport *m )
29{
30 // prints header
31 fprintf ( f, "<metreport type=%s>\n", type );
32 // print GTS_HEADER
33 if ( m->h != NULL )
34 {
35 fprintf ( f, "<bufrfile>%s</bufrfile>\n",m->h->filename );
36 fprintf ( f, " <gts_header>%s %s %s %s</gts_header>\n",m->h->bname, m->h->center, m->h->dtrel, m->h->order );
37 }
38 // print DATE AND TIME
39 fprintf ( f, " <observation_datetime>%s</observation_datetime>\n",m->t.datime );
40
41 // Geo data
42 fprintf ( f, " <geo>\n" );
43 if ( strlen ( m->g.index ) )
44 {
45 fprintf ( f, " <index>%s</index>\n", m->g.index );
46 }
47 if ( strlen ( m->g.name ) )
48 {
49 fprintf ( f, " <name>%s</name>\n", m->g.name );
50 }
51 if ( strlen ( m->g.country ) )
52 {
53 fprintf ( f, " <country>%s</country>\n", m->g.country );
54 }
55 fprintf ( f, " <latitude>%.6lf</latitude>\n", m->g.lat );
56 fprintf ( f, " <longitude>%.6lf</longitude>\n", m->g.lon );
57 fprintf ( f, " <altitude>%.1lf</altitude>\n", m->g.alt );
58 fprintf ( f, " </geo>\n" );
59 fprintf ( f, " <report>%s=</report>\n", alphanum );
60 fprintf ( f, "</metreport>\n" );
61 return 0;
62}
63
64
65/*!
66 \fn int print_xml(FILE *f, struct metreport *m)
67 \brief prints a struct \ref metreport in xml format
68 \param f pointer to a file already open by caller routine
69 \param m pointer to a struct \ref metreport containing the data to print
70*/
71int print_xml ( FILE *f, struct metreport *m )
72{
73 // Single report
74 if ( m->alphanum[0] )
75 {
76 print_xml_alphanum ( f, m->type, m->alphanum, m );
77 }
78
79 if ( m->alphanum2[0] ) //TTBB
80 {
81 print_xml_alphanum ( f, m->type2, m->alphanum2, m );
82 }
83
84 if ( m->alphanum3[0] ) //TTCC
85 {
86 print_xml_alphanum ( f, m->type3, m->alphanum3, m );
87 }
88
89 if ( m->alphanum4[0] ) //TTDD
90 {
91 print_xml_alphanum ( f, m->type4, m->alphanum4, m );
92 }
93
94 return 0;
95}
Include header file for binary bufr2tac.
int print_xml(FILE *f, struct metreport *m)
prints a struct metreport in xml format
Definition: bufr2tac_xml.c:71
int print_xml_alphanum(FILE *f, char *type, char *alphanum, struct metreport *m)
Definition: bufr2tac_xml.c:28
char center[8]
Definition: bufrdeco.h:709
char dtrel[16]
Definition: bufrdeco.h:710
char order[8]
Definition: bufrdeco.h:711
char bname[16]
Definition: bufrdeco.h:708
char filename[BUFRDECO_PATH_LENGTH]
Definition: bufrdeco.h:712
char datime[16]
Definition: metcommon.h:63
double lat
Definition: bufr2tac.h:299
double lon
Definition: bufr2tac.h:300
double alt
Definition: bufr2tac.h:301
char index[16]
Definition: bufr2tac.h:296
char name[80]
Definition: bufr2tac.h:297
char country[80]
Definition: bufr2tac.h:298
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 type4[8]
Definition: bufr2tac.h:326
char type[8]
Definition: bufr2tac.h:320
char type3[8]
Definition: bufr2tac.h:324
struct gts_header * h
Definition: bufr2tac.h:313
char type2[8]
Definition: bufr2tac.h:322
char alphanum3[REPORT_LENGTH]
Definition: bufr2tac.h:325
struct met_datetime t
Definition: bufr2tac.h:314
struct met_geo g
Definition: bufr2tac.h:315
char alphanum2[REPORT_LENGTH]
Definition: bufr2tac.h:323
char alphanum4[REPORT_LENGTH]
Definition: bufr2tac.h:327