21 #include <grass/gjson.h>
30 static void close_file(FILE *fp)
57 static int r0 = -1, g0 = -1, b0 = -1;
60 if (v0 == *val && r0 ==
r && g0 ==
g && b0 ==
b)
63 v0 = *val, r0 =
r, g0 =
g, b0 =
b;
66 if (color_value ==
NULL) {
69 G_fatal_error(
_(
"Failed to initialize JSON object. Out of memory?"));
101 if (root_value ==
NULL) {
103 G_fatal_error(
_(
"Failed to initialize JSON array. Out of memory?"));
116 for (
int i = lo; i <= hi; i++) {
117 unsigned char r,
g,
b, set;
122 write_json_rule(&val, &
min, &
max,
r,
g,
b, root_array, perc,
123 clr_frmt, fp, root_value);
130 for (
int i = 0; i <
count; i++) {
132 unsigned char r1, g1, b1, r2, g2, b2;
136 colors,
count - 1 - i);
139 write_json_rule(&val1, &
min, &
max, r1, g1, b1, root_array, perc,
140 clr_frmt, fp, root_value);
141 write_json_rule(&val2, &
min, &
max, r2, g2, b2, root_array, perc,
142 clr_frmt, fp, root_value);
153 if (nv_value ==
NULL) {
157 _(
"Failed to initialize JSON object. Out of memory?"));
168 if (default_value ==
NULL) {
172 _(
"Failed to initialize JSON object. Out of memory?"));
ColorFormat
Color format identifiers (enum)
#define COLOR_STRING_LENGTH
void G_color_to_str(int, int, int, ColorFormat, char *)
Parse red,green,blue and set color string.
void void void void G_fatal_error(const char *,...) __attribute__((format(printf
int Rast_colors_count(const struct Colors *)
Get both modular and fixed rules count.
void Rast_get_c_color_range(CELL *, CELL *, const struct Colors *)
Get color range values (CELL)
int Rast_get_fp_color_rule(DCELL *, unsigned char *, unsigned char *, unsigned char *, DCELL *, unsigned char *, unsigned char *, unsigned char *, const struct Colors *, int)
Get color rule from both modular and fixed rules.
void Rast_get_null_value_color(int *, int *, int *, const struct Colors *)
Gets color for null value.
void Rast_lookup_c_colors(const CELL *, unsigned char *, unsigned char *, unsigned char *, unsigned char *, int, struct Colors *)
Lookup an array of colors.
void Rast_get_default_color(int *, int *, int *, const struct Colors *)
Gets default color.
char * G_json_serialize_to_string_pretty(const JSON_Value *value)
void G_json_value_free(JSON_Value *value)
void G_json_free_serialized_string(char *string)
JSON_Status G_json_object_set_number(JSON_Object *object, const char *name, double number)
JSON_Array * G_json_array(const JSON_Value *value)
JSON_Value * G_json_value_init_object(void)
JSON_Value * G_json_value_init_array(void)
JSON_Status G_json_object_set_string(JSON_Object *object, const char *name, const char *string)
JSON_Status G_json_array_append_value(JSON_Array *array, JSON_Value *value)
JSON_Object * G_json_object(const JSON_Value *value)
GRASS_INTERPFL_EXPORT int count
void Rast_print_json_colors(struct Colors *colors, DCELL min, DCELL max, FILE *fp, int perc, ColorFormat clr_frmt)
Print color table in JSON format.
const char * json_string(const JSON_Value *value)
struct json_array_t JSON_Array
struct json_value_t JSON_Value
struct json_object_t JSON_Object