PostGIS 3.0.6dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ encode_properties()

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

Definition at line 97 of file geobuf.c.

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

References geobuf_agg_context::geom_index, get_tuple_desc(), geobuf_agg_context::row, and set_int_value().

Referenced by encode_feature().

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