PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ parse_jsonb()

static void parse_jsonb ( mvt_agg_context ctx,
struct feature_builder feature,
Jsonb *  jb 
)
static

Definition at line 557 of file mvt.c.

558 {
559  JsonbIterator *it;
560  JsonbValue v;
561  bool skipNested = false;
562  JsonbIteratorToken r;
563  uint32_t k;
564 
565  if (!JB_ROOT_IS_OBJECT(jb))
566  return;
567 
568  it = JsonbIteratorInit(&jb->root);
569 
570  while ((r = JsonbIteratorNext(&it, &v, skipNested)) != WJB_DONE)
571  {
572  skipNested = true;
573 
574  if (r == WJB_KEY && v.type != jbvNull)
575  {
576 
577  k = get_key_index_with_size(ctx, v.val.string.val, v.val.string.len);
578  if (k == UINT32_MAX)
579  {
580  char *key = palloc(v.val.string.len + 1);
581  memcpy(key, v.val.string.val, v.val.string.len);
582  key[v.val.string.len] = '\0';
583  k = add_key(ctx, key);
584  }
585 
586  r = JsonbIteratorNext(&it, &v, skipNested);
587 
588  if (v.type == jbvString)
589  {
590  char *value = palloc(v.val.string.len + 1);
591  memcpy(value, v.val.string.val, v.val.string.len);
592  value[v.val.string.len] = '\0';
593  add_value_as_string(ctx, feature, value, k);
594  }
595  else if (v.type == jbvBool)
596  {
597  MVT_PARSE_VALUE(bool_values_hash,
598  v.val.boolean,
599  sizeof(protobuf_c_boolean),
600  bool_value,
601  VECTOR_TILE__TILE__VALUE__TEST_ONEOF_BOOL_VALUE);
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 
613  if (fabs(d - (double)l) > FLT_EPSILON)
614  {
615  MVT_PARSE_VALUE(double_values_hash,
616  d,
617  sizeof(double),
618  double_value,
619  VECTOR_TILE__TILE__VALUE__TEST_ONEOF_DOUBLE_VALUE);
620  }
621  else
622  {
624  }
625  }
626  }
627  }
628 }
char * r
Definition: cu_in_wkt.c:24
#define str(s)
#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:317
#define MVT_PARSE_INT_VALUE(value)
Definition: mvt.c:473
static uint32_t add_key(mvt_agg_context *ctx, char *name)
Definition: mvt.c:326
#define MVT_PARSE_VALUE(hash, newvalue, size, pfvaluefield, pftype)
Definition: mvt.c:450
static void add_value_as_string(mvt_agg_context *ctx, struct feature_builder *feature, char *value, uint32_t k)
Definition: mvt.c:536
int value
Definition: genraster.py:62

References add_key(), add_value_as_string(), get_key_index_with_size(), MVT_PARSE_INT_VALUE, MVT_PARSE_VALUE, r, str, 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: