PostGIS  2.4.9dev-r@@SVN_REVISION@@

◆ encode_properties()

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

Definition at line 102 of file geobuf.c.

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().

104 {
105  uint32_t *properties;
106  Data__Value **values;
107  uint32_t i, k = 0, c = 0;
108  TupleDesc tupdesc = get_tuple_desc(ctx);
109  int natts = tupdesc->natts;
110  properties = palloc(sizeof (*properties) * (natts - 1) * 2);
111  values = palloc (sizeof (*values) * (natts - 1));
112 
113  for (i = 0; i < natts; i++) {
114  Data__Value *value;
115  char *type, *string_value;
116  Datum datum;
117  bool isnull;
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  Oid typoid = getBaseType(tupdesc->attrs[i]->atttypid);
132 #else
133  Oid 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 }
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
type
Definition: ovdump.py:41
static void set_int_value(Data__Value *value, int64 intval)
Definition: geobuf.c:92
int value
Definition: genraster.py:61
Here is the call graph for this function:
Here is the caller graph for this function: