PostGIS  2.5.0dev-r@@SVN_REVISION@@
static void encode_properties ( struct geobuf_agg_context ctx,
Data__Feature *  feature 
)
static

Definition at line 101 of file geobuf.c.

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

Referenced by encode_feature().

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

Here is the call graph for this function:

Here is the caller graph for this function: