GRIB-392: grib_dump for JSON: print all data values and use null for missing values

This commit is contained in:
Shahram Najm 2013-06-24 16:26:44 +01:00
parent ec72a662fc
commit 25be970213
2 changed files with 12 additions and 3 deletions

View File

@ -116,6 +116,7 @@ static void dump_values(grib_dumper* d,grib_accessor* a)
long more=0;
long count=0;
int mydepth=depth+2;
double missing_value = 9999;
count=grib_value_count(a);
size=count;
@ -145,12 +146,20 @@ static void dump_values(grib_dumper* d,grib_accessor* a)
fprintf(self->dumper.out,"%-*s",mydepth," ");
fprintf(self->dumper.out,"\"%s\" : [ ",a->name);
tab=lens+mydepth+7;
for (i=0;i<size-1;i++) {
err = grib_get_double(a->parent->h, "missingValue", &missing_value);
for (i=0; i<size-1; ++i) {
if (count>cols || i==0) {fprintf(self->dumper.out,"\n%-*s",tab," ");count=0;}
if (values[i] == missing_value)
fprintf(self->dumper.out, "%s, ", "null");
else
fprintf(self->dumper.out,"%g, ",values[i]);
count++;
}
if (count>cols) fprintf(self->dumper.out,"\n%-*s",tab," ");
if (values[i] == missing_value)
fprintf(self->dumper.out, "%s ","null");
else
fprintf(self->dumper.out,"%g ",values[i]);
if (more)
fprintf(self->dumper.out,"\n%-*s... %ld more values",tab," ",more);
@ -316,4 +325,3 @@ static void dump_section(grib_dumper* d,grib_accessor* a,grib_block_of_accessors
grib_dump_accessors_block(d,block);
}
}

View File

@ -102,7 +102,8 @@ int grib_tool_init(grib_runtime_options* options) {
if (grib_options_on("H"))
options->dump_flags |= GRIB_DUMP_FLAG_HEXADECIMAL;
if (grib_options_on("d"))
/* In JSON mode we want to print all data values */
if ( grib_options_on("d") || grib_options_on("j") )
options->dump_flags |= GRIB_DUMP_FLAG_ALL_DATA;
return 0;