PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ parse_jsonb()

static uint32_t* parse_jsonb ( mvt_agg_context ctx,
Jsonb *  jb,
uint32_t tags 
)
static

Definition at line 551 of file mvt.c.

553 {
554  JsonbIterator *it;
555  JsonbValue v;
556  bool skipNested = false;
557  JsonbIteratorToken r;
558  uint32_t k;
559 
560  if (!JB_ROOT_IS_OBJECT(jb))
561  return tags;
562 
563  it = JsonbIteratorInit(&jb->root);
564 
565  while ((r = JsonbIteratorNext(&it, &v, skipNested)) != WJB_DONE)
566  {
567  skipNested = true;
568 
569  if (r == WJB_KEY && v.type != jbvNull)
570  {
571 
572  k = get_key_index_with_size(ctx, v.val.string.val, v.val.string.len);
573  if (k == UINT32_MAX)
574  {
575  char *key;
576  uint32_t newSize = ctx->keys_hash_i + 1;
577 
578  key = palloc(v.val.string.len + 1);
579  memcpy(key, v.val.string.val, v.val.string.len);
580  key[v.val.string.len] = '\0';
581 
582  tags = repalloc(tags, newSize * 2 * sizeof(*tags));
583  k = add_key(ctx, key);
584  }
585 
586  r = JsonbIteratorNext(&it, &v, skipNested);
587 
588  if (v.type == jbvString)
589  {
590  char *value;
591  value = palloc(v.val.string.len + 1);
592  memcpy(value, v.val.string.val, v.val.string.len);
593  value[v.val.string.len] = '\0';
594  add_value_as_string(ctx, value, tags, k);
595  ctx->row_columns++;
596  }
597  else if (v.type == jbvBool)
598  {
599  MVT_PARSE_VALUE(v.val.boolean, mvt_kv_bool_value,
600  bool_values_hash, bool_value, sizeof(protobuf_c_boolean));
601  ctx->row_columns++;
602  }
603  else if (v.type == jbvNumeric)
604  {
605  char *str;
606  double d;
607  long l;
608  str = DatumGetCString(DirectFunctionCall1(numeric_out,
609  PointerGetDatum(v.val.numeric)));
610  d = strtod(str, NULL);
611  l = strtol(str, NULL, 10);
612  if (FP_NEQUALS(d, (double)l))
613  {
614  MVT_PARSE_VALUE(d, mvt_kv_double_value, double_values_hash,
615  double_value, sizeof(double));
616  }
617  else
618  {
620  }
621  ctx->row_columns++;
622  }
623  }
624  }
625 
626  return tags;
627 }
char * r
Definition: cu_in_wkt.c:24
#define FP_NEQUALS(A, B)
#define UINT32_MAX
Definition: lwin_wkt_lex.c:343
static uint32_t get_key_index_with_size(mvt_agg_context *ctx, const char *name, size_t size)
Definition: mvt.c:299
#define MVT_PARSE_INT_VALUE(value)
Definition: mvt.c:480
static uint32_t add_key(mvt_agg_context *ctx, char *name)
Definition: mvt.c:308
static void add_value_as_string(mvt_agg_context *ctx, char *value, uint32_t *tags, uint32_t k)
Definition: mvt.c:531
#define MVT_PARSE_VALUE(value, kvtype, hash, valuefield, size)
Definition: mvt.c:459
int value
Definition: genraster.py:61
uint32_t keys_hash_i
Definition: mvt.h:77
uint32_t row_columns
Definition: mvt.h:78
unsigned int uint32_t
Definition: uthash.h:78

References add_key(), add_value_as_string(), FP_NEQUALS, get_key_index_with_size(), mvt_agg_context::keys_hash_i, MVT_PARSE_INT_VALUE, MVT_PARSE_VALUE, r, mvt_agg_context::row_columns, UINT32_MAX, and genraster::value.

Referenced by parse_values().

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