PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ parse_jsonb()

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

Definition at line 556 of file mvt.c.

557 {
558  JsonbIterator *it;
559  JsonbValue v;
560  bool skipNested = false;
561  JsonbIteratorToken r;
562  uint32_t k;
563 
564  if (!JB_ROOT_IS_OBJECT(jb))
565  return;
566 
567  it = JsonbIteratorInit(&jb->root);
568 
569  while ((r = JsonbIteratorNext(&it, &v, skipNested)) != WJB_DONE)
570  {
571  skipNested = true;
572 
573  if (r == WJB_KEY && v.type != jbvNull)
574  {
575 
576  k = get_key_index_with_size(ctx, v.val.string.val, v.val.string.len);
577  if (k == UINT32_MAX)
578  {
579  char *key = palloc(v.val.string.len + 1);
580  memcpy(key, v.val.string.val, v.val.string.len);
581  key[v.val.string.len] = '\0';
582  k = add_key(ctx, key);
583  }
584 
585  r = JsonbIteratorNext(&it, &v, skipNested);
586 
587  if (v.type == jbvString)
588  {
589  char *value = palloc(v.val.string.len + 1);
590  memcpy(value, v.val.string.val, v.val.string.len);
591  value[v.val.string.len] = '\0';
592  add_value_as_string(ctx, feature, value, k);
593  }
594  else if (v.type == jbvBool)
595  {
596  MVT_PARSE_VALUE(bool_values_hash,
597  v.val.boolean,
598  sizeof(protobuf_c_boolean),
599  bool_value,
600  VECTOR_TILE__TILE__VALUE__TEST_ONEOF_BOOL_VALUE);
601  }
602  else if (v.type == jbvNumeric)
603  {
604  char *str;
605  double d;
606  long l;
607  str = DatumGetCString(DirectFunctionCall1(numeric_out,
608  PointerGetDatum(v.val.numeric)));
609  d = strtod(str, NULL);
610  l = strtol(str, NULL, 10);
611 
612  if (fabs(d - (double)l) > FLT_EPSILON)
613  {
614  MVT_PARSE_VALUE(double_values_hash,
615  d,
616  sizeof(double),
617  double_value,
618  VECTOR_TILE__TILE__VALUE__TEST_ONEOF_DOUBLE_VALUE);
619  }
620  else
621  {
623  }
624  }
625  }
626  }
627 }
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:316
#define MVT_PARSE_INT_VALUE(value)
Definition: mvt.c:472
static uint32_t add_key(mvt_agg_context *ctx, char *name)
Definition: mvt.c:325
#define MVT_PARSE_VALUE(hash, newvalue, size, pfvaluefield, pftype)
Definition: mvt.c:449
static void add_value_as_string(mvt_agg_context *ctx, struct feature_builder *feature, char *value, uint32_t k)
Definition: mvt.c:535
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: