bufr2synop 0.24.0
Functions
bufr2tac_json.c File Reference

Output a struct metreport in json form. More...

#include "bufr2tac.h"
Include dependency graph for bufr2tac_json.c:

Go to the source code of this file.

Functions

int print_json_alphanum (FILE *f, char *type, char *alphanum, struct metreport *m)
 
int print_json (FILE *f, struct metreport *m)
 prints a struct metreport in json format More...
 

Detailed Description

Output a struct metreport in json form.

Definition in file bufr2tac_json.c.

Function Documentation

◆ print_json()

int print_json ( FILE *  f,
struct metreport m 
)

prints a struct metreport in json format

Parameters
fpointer to a file already open by caller routine
mpointer to a struct metreport containing the data to print

Definition at line 62 of file bufr2tac_json.c.

63{
64 fprintf ( f, "{\"metreport\" :" );
65 if ( m->alphanum[0] )
66 {
67 print_json_alphanum ( f, m->type, m->alphanum, m );
68 }
69
70 if ( m->alphanum2[0] ) //TTBB
71 {
72 fprintf ( f, "," );
73 print_json_alphanum ( f, m->type2, m->alphanum2, m );
74 }
75
76 if ( m->alphanum3[0] ) //TTCC
77 {
78 fprintf ( f, "," );
79 print_json_alphanum ( f, m->type3, m->alphanum3, m );
80 }
81 if ( m->alphanum4[0] ) //TTDD
82 {
83 fprintf ( f, "," );
84 print_json_alphanum ( f, m->type4, m->alphanum4, m );
85 }
86
87 fprintf ( f, "\n}\n" );
88 return 0;
89}
int print_json_alphanum(FILE *f, char *type, char *alphanum, struct metreport *m)
Definition: bufr2tac_json.c:26
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
char type2[8]
Definition: bufr2tac.h:322
char alphanum3[REPORT_LENGTH]
Definition: bufr2tac.h:325
char alphanum2[REPORT_LENGTH]
Definition: bufr2tac.h:323
char alphanum4[REPORT_LENGTH]
Definition: bufr2tac.h:327

References metreport::alphanum, metreport::alphanum2, metreport::alphanum3, metreport::alphanum4, print_json_alphanum(), metreport::type, metreport::type2, metreport::type3, and metreport::type4.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ print_json_alphanum()

int print_json_alphanum ( FILE *  f,
char *  type,
char *  alphanum,
struct metreport m 
)

Definition at line 26 of file bufr2tac_json.c.

27{
28 fprintf ( f, " { \n \"type\": \"%s\",\n", type );
29 if ( m->h != NULL )
30 {
31 fprintf ( f, " \"bufrfile\": \"%s\",\n", m->h->filename );
32 fprintf ( f, " \"gts_header\": \"%s %s %s %s\",\n", m->h->bname, m->h->center, m->h->dtrel, m->h->order );
33 }
34 fprintf ( f, " \"observation_datetime\": \"%s\",\n", m->t.datime );
35 fprintf ( f, " \"geo\": { \n" );
36 if ( strlen ( m->g.index ) )
37 {
38 fprintf ( f, " \"index\": \"%s\",\n", m->g.index );
39 }
40 if ( strlen ( m->g.name ) )
41 {
42 fprintf ( f, " \"name\": \"%s\",\n", m->g.name );
43 }
44 if ( strlen ( m->g.country ) )
45 {
46 fprintf ( f, " \"country\": \"%s\",\n", m->g.country );
47 }
48 fprintf ( f, " \"latitude\": %.6lf,\n", m->g.lat );
49 fprintf ( f, " \"longitude\": %.6lf,\n", m->g.lon );
50 fprintf ( f, " \"altitude\": %.1lf\n", m->g.alt );
51 fprintf ( f, " },\n" );
52 fprintf ( f, " \"report\": \"%s\"\n", alphanum );
53 fprintf ( f, " }" );
54 return 0;
55}
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
struct gts_header * h
Definition: bufr2tac.h:313
struct met_datetime t
Definition: bufr2tac.h:314
struct met_geo g
Definition: bufr2tac.h:315

References met_geo::alt, gts_header::bname, gts_header::center, met_geo::country, met_datetime::datime, gts_header::dtrel, gts_header::filename, metreport::g, metreport::h, met_geo::index, met_geo::lat, met_geo::lon, met_geo::name, gts_header::order, and metreport::t.

Referenced by print_json().

Here is the caller graph for this function: