PostGIS 3.7.0dev-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 96 of file geobuf.c.

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