PostGIS  2.5.7dev-r@@SVN_REVISION@@

◆ encode_properties()

static void encode_properties ( struct geobuf_agg_context ctx,
Data__Feature *  feature 
)
static

Definition at line 101 of file geobuf.c.

103 {
104  uint32_t *properties;
105  Data__Value **values;
106  uint32_t i, k = 0, c = 0;
107  TupleDesc tupdesc = get_tuple_desc(ctx);
108  uint32_t natts = (uint32_t) tupdesc->natts;
109  properties = palloc(sizeof (*properties) * (natts - 1) * 2);
110  values = palloc (sizeof (*values) * (natts - 1));
111 
112  for (i = 0; i < natts; i++) {
113  Data__Value *value;
114  char *type, *string_value;
115  Datum datum;
116  bool isnull;
117  Oid typoid;
118 
119  if (i == ctx->geom_index)
120  continue;
121  k++;
122 
123  value = palloc (sizeof (*value));
124  data__value__init(value);
125 
126  type = SPI_gettype(tupdesc, i + 1);
127  datum = GetAttributeByNum(ctx->row, i + 1, &isnull);
128  if (isnull)
129  continue;
130 #if POSTGIS_PGSQL_VERSION < 110
131  typoid = getBaseType(tupdesc->attrs[i]->atttypid);
132 #else
133  typoid = getBaseType(tupdesc->attrs[i].atttypid);
134 #endif
135  if (strcmp(type, "int2") == 0) {
136  set_int_value(value, DatumGetInt16(datum));
137  } else if (strcmp(type, "int4") == 0) {
138  set_int_value(value, DatumGetInt32(datum));
139  } else if (strcmp(type, "int8") == 0) {
140  set_int_value(value, DatumGetInt64(datum));
141  } else if (strcmp(type, "float4") == 0) {
142  value->value_type_case = DATA__VALUE__VALUE_TYPE_DOUBLE_VALUE;
143  value->double_value = DatumGetFloat4(datum);
144  } else if (strcmp(type, "float8") == 0) {
145  value->value_type_case = DATA__VALUE__VALUE_TYPE_DOUBLE_VALUE;
146  value->double_value = DatumGetFloat8(datum);
147  } else {
148  Oid foutoid;
149  bool typisvarlena;
150  getTypeOutputInfo(typoid, &foutoid, &typisvarlena);
151  string_value = OidOutputFunctionCall(foutoid, datum);
152  value->value_type_case = DATA__VALUE__VALUE_TYPE_STRING_VALUE;
153  value->string_value = string_value;
154  }
155  properties[c * 2] = k - 1;
156  properties[c * 2 + 1] = c;
157  values[c++] = value;
158  }
159 
160  ReleaseTupleDesc(tupdesc);
161 
162  feature->n_values = c;
163  feature->values = values;
164  feature->n_properties = c * 2;
165  feature->properties = properties;
166 }
static TupleDesc get_tuple_desc(struct geobuf_agg_context *ctx)
Definition: geobuf.c:44
static void set_int_value(Data__Value *value, int64 intval)
Definition: geobuf.c:91
int value
Definition: genraster.py:61
type
Definition: ovdump.py:41
HeapTupleHeader row
Definition: geobuf.h:52
uint32_t geom_index
Definition: geobuf.h:51
unsigned int uint32_t
Definition: uthash.h:78

References geobuf_agg_context::geom_index, get_tuple_desc(), geobuf_agg_context::row, set_int_value(), ovdump::type, and genraster::value.

Referenced by encode_feature().

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