GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 68.6% 181 / 0 / 264
Functions: 70.0% 7 / 0 / 10
Branches: 51.4% 73 / 0 / 142

shumate/vector/shumate-vector-render-scope.c
Line Branch Exec Source
1 /*
2 * Copyright (C) 2021 James Westman <james@jwestman.net>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
16 */
17
18 #include "shumate-vector-render-scope-private.h"
19
20 enum {
21 MOVE_TO = 1,
22 LINE_TO = 2,
23 CLOSE_PATH = 7,
24 };
25
26 static int
27 46 zigzag (guint value)
28 {
29 46 return (value >> 1) ^ (-(value & 1));
30 }
31
32 static void
33 10 apply_transforms (ShumateVectorRenderScope *self,
34 float extent,
35 float *x,
36 float *y)
37 {
38 10 *x = ((*x / extent) - self->overzoom_x) * self->overzoom_scale;
39 10 *y = ((*y / extent) - self->overzoom_y) * self->overzoom_scale;
40 }
41
42 /* Draws the current feature as a path onto the scope's cairo context. */
43 void
44 8 shumate_vector_render_scope_exec_geometry (ShumateVectorRenderScope *self)
45 {
46 8 VectorTile__Tile__Feature *feature = shumate_vector_reader_iter_get_feature_struct (self->reader);
47
48
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 8 times.
8 g_return_if_fail (feature != NULL);
49
50 8 cairo_new_path (self->cr);
51 8 cairo_move_to (self->cr, 0, 0);
52
53
2/2
✓ Branch 27 → 7 taken 20 times.
✓ Branch 27 → 28 taken 8 times.
36 for (int i = 0; i < feature->n_geometry; i ++)
54 {
55 20 int cmd = feature->geometry[i];
56 20 double dx, dy;
57
58 /* See https://github.com/mapbox/vector-tile-spec/tree/master/2.1#43-geometry-encoding */
59 20 int op = cmd & 0x7;
60 20 int repeat = cmd >> 3;
61
62
2/2
✓ Branch 23 → 8 taken 40 times.
✓ Branch 23 → 24 taken 20 times.
60 for (int j = 0; j < repeat; j ++)
63 {
64
3/4
✓ Branch 8 → 9 taken 8 times.
✓ Branch 8 → 12 taken 28 times.
✓ Branch 8 → 16 taken 4 times.
✗ Branch 8 → 20 not taken.
40 switch (op) {
65 8 case MOVE_TO:
66
1/2
✓ Branch 9 → 10 taken 8 times.
✗ Branch 9 → 11 not taken.
8 g_return_if_fail (i + 2 < feature->n_geometry);
67 8 dx = zigzag (feature->geometry[++i]);
68 8 dy = zigzag (feature->geometry[++i]);
69 8 cairo_rel_move_to (self->cr, dx, dy);
70 8 break;
71 28 case LINE_TO:
72
1/2
✓ Branch 12 → 13 taken 28 times.
✗ Branch 12 → 15 not taken.
28 g_return_if_fail (i + 2 < feature->n_geometry);
73 28 dx = zigzag (feature->geometry[++i]);
74 28 dy = zigzag (feature->geometry[++i]);
75 28 cairo_rel_line_to (self->cr, dx, dy);
76 28 break;
77 4 case CLOSE_PATH:
78 4 cairo_get_current_point (self->cr, &dx, &dy);
79 4 cairo_close_path (self->cr);
80 4 cairo_move_to (self->cr, dx, dy);
81 4 break;
82 ✗ default:
83 40 g_assert_not_reached ();
84 }
85 }
86 }
87 }
88
89
90 GPtrArray *
91 10 shumate_vector_render_scope_get_geometry (ShumateVectorRenderScope *self)
92 {
93 10 GPtrArray *lines = g_ptr_array_new_with_free_func ((GDestroyNotify)shumate_vector_line_string_free);
94 10 ShumateVectorLineString *current_line = NULL;
95 10 VectorTile__Tile__Feature *feature = shumate_vector_reader_iter_get_feature_struct (self->reader);
96 10 VectorTile__Tile__Layer *layer = shumate_vector_reader_iter_get_layer_struct (self->reader);
97 10 float x = 0, y = 0;
98 10 float x_tf, y_tf;
99
100
1/2
✗ Branch 5 → 6 not taken.
✓ Branch 5 → 31 taken 10 times.
10 g_return_val_if_fail (feature != NULL, NULL);
101
102
2/2
✓ Branch 31 → 7 taken 10 times.
✓ Branch 31 → 32 taken 10 times.
20 for (int i = 0; i < feature->n_geometry; i ++)
103 {
104 10 int cmd = feature->geometry[i];
105 10 double start_x = 0, start_y = 0;
106
107 10 int op = cmd & 0x7;
108 10 int repeat = cmd >> 3;
109
110
1/2
✗ Branch 7 → 8 not taken.
✓ Branch 7 → 10 taken 10 times.
10 if (current_line != NULL)
111 ✗ current_line->points = g_realloc (current_line->points, (repeat + current_line->n_points) * sizeof (ShumateVectorPoint));
112
113
2/2
✓ Branch 29 → 11 taken 10 times.
✓ Branch 29 → 30 taken 10 times.
20 for (int j = 0; j < repeat; j ++)
114 {
115
1/4
✓ Branch 11 → 12 taken 10 times.
✗ Branch 11 → 19 not taken.
✗ Branch 11 → 24 not taken.
✗ Branch 11 → 27 not taken.
10 switch (op) {
116 10 case MOVE_TO:
117
1/2
✓ Branch 12 → 13 taken 10 times.
✗ Branch 12 → 14 not taken.
10 g_return_val_if_fail (i + 2 < feature->n_geometry, NULL);
118
119
1/2
✗ Branch 13 → 15 not taken.
✓ Branch 13 → 16 taken 10 times.
10 if (current_line != NULL)
120 ✗ g_ptr_array_add (lines, current_line);
121
122 10 current_line = g_new (ShumateVectorLineString, 1);
123 10 current_line->points = g_new (ShumateVectorPoint, 1);
124 10 current_line->n_points = 1;
125
126 10 x += zigzag (feature->geometry[++i]);
127 10 y += zigzag (feature->geometry[++i]);
128
129 10 x_tf = x;
130 10 y_tf = y;
131 10 apply_transforms (self, layer->extent, &x_tf, &y_tf);
132
133 10 start_x = x_tf;
134 10 start_y = y_tf;
135
136 10 current_line->points[0] = (ShumateVectorPoint) {
137 .x = x_tf,
138 .y = y_tf,
139 };
140 10 break;
141 ✗ case LINE_TO:
142 ✗ g_return_val_if_fail (i + 2 < feature->n_geometry, NULL);
143 ✗ g_return_val_if_fail (current_line != NULL, NULL);
144
145 ✗ x += zigzag (feature->geometry[++i]);
146 ✗ y += zigzag (feature->geometry[++i]);
147
148 ✗ x_tf = x;
149 ✗ y_tf = y;
150 ✗ apply_transforms (self, layer->extent, &x_tf, &y_tf);
151
152 ✗ current_line->points[current_line->n_points++] = (ShumateVectorPoint) {
153 .x = x_tf,
154 .y = y_tf,
155 };
156 ✗ break;
157 ✗ case CLOSE_PATH:
158 ✗ g_return_val_if_fail (current_line != NULL, NULL);
159
160 ✗ current_line->points[current_line->n_points++] = (ShumateVectorPoint) {
161 .x = start_x,
162 .y = start_y,
163 };
164 ✗ break;
165 ✗ default:
166 ✗ g_assert_not_reached ();
167 }
168 }
169 }
170
171
1/2
✓ Branch 32 → 33 taken 10 times.
✗ Branch 32 → 34 not taken.
10 if (current_line != NULL)
172 10 g_ptr_array_add (lines, current_line);
173
174 return lines;
175 }
176
177
178 void
179 ✗ shumate_vector_render_scope_get_bounds (ShumateVectorRenderScope *self,
180 float *min_x,
181 float *min_y,
182 float *max_x,
183 float *max_y)
184 {
185 ✗ VectorTile__Tile__Layer *layer = shumate_vector_reader_iter_get_layer_struct (self->reader);
186 ✗ VectorTile__Tile__Feature *feature = shumate_vector_reader_iter_get_feature_struct (self->reader);
187 ✗ double x = 0, y = 0;
188
189 ✗ *min_x = G_MAXFLOAT;
190 ✗ *min_y = G_MAXFLOAT;
191 ✗ *max_x = G_MINFLOAT;
192 ✗ *max_y = G_MINFLOAT;
193
194 ✗ g_return_if_fail (feature != NULL);
195
196 ✗ for (int i = 0; i < feature->n_geometry; i ++)
197 {
198 ✗ int cmd = feature->geometry[i];
199
200 /* See https://github.com/mapbox/vector-tile-spec/tree/master/2.1#43-geometry-encoding */
201 ✗ int op = cmd & 0x7;
202 ✗ int repeat = cmd >> 3;
203
204 ✗ for (int j = 0; j < repeat; j ++)
205 {
206 ✗ switch (op) {
207 ✗ case 1:
208 ✗ g_return_if_fail (i + 2 < feature->n_geometry);
209 ✗ x += zigzag (feature->geometry[++i]);
210 ✗ y += zigzag (feature->geometry[++i]);
211 ✗ break;
212 ✗ case 2:
213 ✗ g_return_if_fail (i + 2 < feature->n_geometry);
214 ✗ x += zigzag (feature->geometry[++i]);
215 ✗ y += zigzag (feature->geometry[++i]);
216 ✗ break;
217 case 7:
218 break;
219 ✗ default:
220 ✗ g_assert_not_reached ();
221 }
222
223 ✗ *min_x = MIN (*min_x, x);
224 ✗ *min_y = MIN (*min_y, y);
225 ✗ *max_x = MAX (*max_x, x);
226 ✗ *max_y = MAX (*max_y, y);
227 }
228 }
229
230 ✗ apply_transforms (self, layer->extent, min_x, min_y);
231 ✗ apply_transforms (self, layer->extent, max_x, max_y);
232 }
233
234
235 ShumateVectorGeometryType
236 20 shumate_vector_render_scope_get_geometry_type (ShumateVectorRenderScope *self)
237 {
238 20 VectorTile__Tile__Feature *feature = shumate_vector_reader_iter_get_feature_struct (self->reader);
239
1/2
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 20 times.
20 g_return_val_if_fail (feature != NULL, 0);
240 20 return (ShumateVectorGeometryType) feature->type;
241 }
242
243 void
244 ✗ shumate_vector_render_scope_get_geometry_center (ShumateVectorRenderScope *self,
245 double *x,
246 double *y)
247 {
248 ✗ float min_x, min_y, max_x, max_y;
249 ✗ shumate_vector_render_scope_get_bounds (self, &min_x, &min_y, &max_x, &max_y);
250 ✗ *x = (min_x + max_x) / 2.0;
251 ✗ *y = (min_y + max_y) / 2.0;
252 ✗ }
253
254 static void
255 32 convert_vector_value (VectorTile__Tile__Value *v, ShumateVectorValue *value)
256 {
257
2/2
✓ Branch 2 → 3 taken 2 times.
✓ Branch 2 → 4 taken 30 times.
32 if (v->has_int_value)
258 2 shumate_vector_value_set_number (value, v->int_value);
259
1/2
✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 30 times.
30 else if (v->has_uint_value)
260 ✗ shumate_vector_value_set_number (value, v->uint_value);
261
1/2
✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 30 times.
30 else if (v->has_sint_value)
262 ✗ shumate_vector_value_set_number (value, v->sint_value);
263
1/2
✗ Branch 8 → 9 not taken.
✓ Branch 8 → 10 taken 30 times.
30 else if (v->has_float_value)
264 ✗ shumate_vector_value_set_number (value, v->float_value);
265
1/2
✗ Branch 10 → 11 not taken.
✓ Branch 10 → 12 taken 30 times.
30 else if (v->has_double_value)
266 ✗ shumate_vector_value_set_number (value, v->double_value);
267
1/2
✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 30 times.
30 else if (v->has_bool_value)
268 ✗ shumate_vector_value_set_boolean (value, v->bool_value);
269
1/2
✓ Branch 14 → 15 taken 30 times.
✗ Branch 14 → 16 not taken.
30 else if (v->string_value != NULL)
270 30 shumate_vector_value_set_string (value, v->string_value);
271 else
272 ✗ shumate_vector_value_unset (value);
273 32 }
274
275 void
276 36 shumate_vector_render_scope_get_variable (ShumateVectorRenderScope *self, const char *variable, ShumateVectorValue *value)
277 {
278 36 VectorTile__Tile__Layer *layer = shumate_vector_reader_iter_get_layer_struct (self->reader);
279 36 VectorTile__Tile__Feature *feature = shumate_vector_reader_iter_get_feature_struct (self->reader);
280
281
2/2
✓ Branch 9 → 5 taken 36 times.
✓ Branch 9 → 10 taken 10 times.
82 for (int i = 0; i + 1 < feature->n_tags; i += 2)
282 {
283
2/2
✓ Branch 5 → 6 taken 26 times.
✓ Branch 5 → 8 taken 10 times.
36 if (strcmp (layer->keys[feature->tags[i]], variable) == 0)
284 {
285 26 convert_vector_value (layer->values[feature->tags[i + 1]], value);
286 26 return;
287 }
288 }
289
290 10 shumate_vector_value_unset (value);
291 }
292
293
294 GHashTable *
295 10 shumate_vector_render_scope_create_tag_table (ShumateVectorRenderScope *self)
296 {
297 10 g_autoptr(GHashTable) tags = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
298 20 g_auto(ShumateVectorValue) value = SHUMATE_VECTOR_VALUE_INIT;
299 10 VectorTile__Tile__Layer *layer = shumate_vector_reader_iter_get_layer_struct (self->reader);
300 10 VectorTile__Tile__Feature *feature = shumate_vector_reader_iter_get_feature_struct (self->reader);
301
302
1/2
✗ Branch 24 → 6 not taken.
✓ Branch 24 → 25 taken 10 times.
20 for (int i = 1; i < feature->n_tags; i += 2)
303 {
304 ✗ g_auto(ShumateVectorValue) value = SHUMATE_VECTOR_VALUE_INIT;
305 ✗ int key = feature->tags[i - 1];
306 ✗ int val = feature->tags[i];
307
308 ✗ if (key >= layer->n_keys || val >= layer->n_values)
309 ✗ continue;
310
311 ✗ convert_vector_value (layer->values[val], &value);
312 ✗ g_hash_table_insert (tags, g_strdup (layer->keys[key]), shumate_vector_value_as_string (&value));
313 }
314
315 10 return g_steal_pointer (&tags);
316 }
317
318 ShumateVectorIndexBitset *
319 ✗ shumate_vector_render_scope_get_bitset (ShumateVectorRenderScope *self,
320 const char *field,
321 ShumateVectorValue *value)
322 {
323 ✗ return shumate_vector_index_get_bitset (self->index, self->layer_idx, field, value);
324 }
325
326 /* Temporary data for shumate_vector_render_scope_index_layer */
327 typedef struct {
328 ShumateVectorIndexBitset *used_values;
329 ShumateVectorIndexBitset *unused_values;
330 GHashTable *indexes;
331 ShumateVectorIndexBitset *has_index;
332 guint8 is_unused;
333 } FieldIndexingData;
334
335 void
336 14 shumate_vector_render_scope_index_layer (ShumateVectorRenderScope *self)
337 {
338 14 const char *layer_name = shumate_vector_reader_iter_get_layer_name (self->reader);
339 14 VectorTile__Tile__Layer *layer;
340 14 FieldIndexingData *fields;
341 14 int feature_idx = 0;
342 14 ShumateVectorIndexBitset *broad_geometry_indexes[3] = { NULL, NULL, NULL };
343
344
1/2
✓ Branch 3 → 4 taken 14 times.
✗ Branch 3 → 6 not taken.
14 if (self->index == NULL)
345 14 self->index = shumate_vector_index_new ();
346
347
1/2
✓ Branch 7 → 8 taken 14 times.
✗ Branch 7 → 97 not taken.
14 if (shumate_vector_index_has_layer (self->index, self->source_layer_idx))
348 6 return;
349
350
2/2
✓ Branch 9 → 10 taken 8 times.
✓ Branch 9 → 97 taken 6 times.
14 if (!shumate_vector_index_description_has_layer (self->index_description, layer_name))
351 return;
352
353 8 layer = shumate_vector_reader_iter_get_layer_struct (self->reader);
354
1/4
✗ Branch 11 → 12 not taken.
✓ Branch 11 → 14 taken 8 times.
✗ Branch 12 → 13 not taken.
✗ Branch 12 → 14 not taken.
8 fields = g_new0 (FieldIndexingData, layer->n_keys);
355
356
2/2
✓ Branch 16 → 19 taken 4 times.
✓ Branch 16 → 23 taken 4 times.
8 if (shumate_vector_index_description_has_broad_geometry_type (self->index_description, layer_name))
357 {
358
2/2
✓ Branch 19 → 17 taken 12 times.
✓ Branch 19 → 20 taken 4 times.
16 for (int i = 0; i < 3; i ++)
359 12 broad_geometry_indexes[i] = shumate_vector_index_bitset_new (layer->n_features);
360
361 4 shumate_vector_index_add_bitset_broad_geometry_type (self->index, self->source_layer_idx, SHUMATE_GEOMETRY_TYPE_POINT, broad_geometry_indexes[0]);
362 4 shumate_vector_index_add_bitset_broad_geometry_type (self->index, self->source_layer_idx, SHUMATE_GEOMETRY_TYPE_LINESTRING, broad_geometry_indexes[1]);
363 4 shumate_vector_index_add_bitset_broad_geometry_type (self->index, self->source_layer_idx, SHUMATE_GEOMETRY_TYPE_POLYGON, broad_geometry_indexes[2]);
364 }
365
366 /* Read all of the features and build every requested index */
367 8 shumate_vector_reader_iter_read_feature (self->reader, 0);
368 24 while (TRUE)
369 8 {
370 16 VectorTile__Tile__Feature *feature = shumate_vector_reader_iter_get_feature_struct (self->reader);
371
372
2/2
✓ Branch 25 → 26 taken 8 times.
✓ Branch 25 → 33 taken 8 times.
16 if (broad_geometry_indexes[0] != NULL)
373 {
374
1/4
✗ Branch 26 → 27 not taken.
✓ Branch 26 → 29 taken 8 times.
✗ Branch 26 → 31 not taken.
✗ Branch 26 → 33 not taken.
8 switch (feature->type)
375 {
376 ✗ case VECTOR_TILE__TILE__GEOM_TYPE__POINT:
377 ✗ shumate_vector_index_bitset_set (broad_geometry_indexes[0], feature_idx);
378 ✗ break;
379 8 case VECTOR_TILE__TILE__GEOM_TYPE__LINESTRING:
380 8 shumate_vector_index_bitset_set (broad_geometry_indexes[1], feature_idx);
381 8 break;
382 ✗ case VECTOR_TILE__TILE__GEOM_TYPE__POLYGON:
383 ✗ shumate_vector_index_bitset_set (broad_geometry_indexes[2], feature_idx);
384 ✗ break;
385 default:
386 break;
387 }
388 }
389
390
2/2
✓ Branch 71 → 34 taken 8 times.
✓ Branch 71 → 72 taken 16 times.
24 for (int i = 1; i < feature->n_tags; i += 2)
391 {
392 8 ShumateVectorIndexBitset *bitset;
393 8 int key = feature->tags[i - 1];
394 8 int val = feature->tags[i];
395
396
2/4
✓ Branch 34 → 35 taken 8 times.
✗ Branch 34 → 36 not taken.
✗ Branch 35 → 36 not taken.
✓ Branch 35 → 37 taken 8 times.
8 if (key >= layer->n_keys || val >= layer->n_values)
397 ✗ continue;
398
399
1/2
✓ Branch 37 → 38 taken 8 times.
✗ Branch 37 → 50 not taken.
8 if (fields[key].indexes == NULL)
400 {
401
1/2
✗ Branch 38 → 39 not taken.
✓ Branch 38 → 40 taken 8 times.
8 if (fields[key].is_unused)
402 /* We have already looked up this field, and it is not in the description */
403 ✗ continue;
404
405
2/2
✓ Branch 41 → 42 taken 4 times.
✓ Branch 41 → 49 taken 4 times.
8 if (shumate_vector_index_description_has_field (self->index_description, layer_name, layer->keys[key]))
406 {
407 4 fields[key].indexes = g_hash_table_new (g_direct_hash, g_direct_equal);
408 4 fields[key].used_values = shumate_vector_index_bitset_new (layer->n_values);
409 4 fields[key].unused_values = shumate_vector_index_bitset_new (layer->n_values);
410
2/2
✓ Branch 46 → 47 taken 2 times.
✓ Branch 46 → 50 taken 2 times.
4 if (shumate_vector_index_description_has_field_has_index (self->index_description, layer_name, layer->keys[key]))
411 2 fields[key].has_index = shumate_vector_index_bitset_new (layer->n_features);
412 }
413 else
414 {
415 4 fields[key].is_unused = TRUE;
416 4 continue;
417 }
418 }
419
420
2/2
✓ Branch 50 → 51 taken 2 times.
✓ Branch 50 → 52 taken 2 times.
4 if (fields[key].has_index != NULL)
421 2 shumate_vector_index_bitset_set (fields[key].has_index, feature_idx);
422
423
1/2
✗ Branch 53 → 54 not taken.
✓ Branch 53 → 55 taken 4 times.
4 if (shumate_vector_index_bitset_get (fields[key].unused_values, val))
424 ✗ continue;
425
426
1/2
✗ Branch 56 → 57 not taken.
✓ Branch 56 → 58 taken 4 times.
4 if (shumate_vector_index_bitset_get (fields[key].used_values, val))
427 ✗ bitset = g_hash_table_lookup (fields[key].indexes, GINT_TO_POINTER (val));
428 else
429 {
430 4 g_auto(ShumateVectorValue) value = SHUMATE_VECTOR_VALUE_INIT;
431 4 VectorTile__Tile__Value *v = layer->values[val];
432 4 const char *field_name = layer->keys[key];
433
434 4 convert_vector_value (v, &value);
435
436
2/2
✓ Branch 60 → 61 taken 2 times.
✓ Branch 60 → 66 taken 2 times.
4 if (shumate_vector_index_description_has_value (self->index_description, layer_name, field_name, &value))
437 2 bitset = shumate_vector_index_bitset_new (layer->n_features);
438 else
439 {
440 2 shumate_vector_index_bitset_set (fields[key].unused_values, val);
441 2 continue;
442 }
443
444 2 g_hash_table_insert (fields[key].indexes, GINT_TO_POINTER (val), bitset);
445 2 shumate_vector_index_bitset_set (fields[key].used_values, val);
446 }
447
448 2 shumate_vector_index_bitset_set (bitset, feature_idx);
449 }
450
451
2/2
✓ Branch 73 → 74 taken 8 times.
✓ Branch 73 → 92 taken 8 times.
16 if (!shumate_vector_reader_iter_next_feature (self->reader))
452 break;
453 8 feature_idx ++;
454 }
455
456
2/2
✓ Branch 92 → 75 taken 8 times.
✓ Branch 92 → 93 taken 8 times.
16 for (int key = 0; key < layer->n_keys; key ++)
457 {
458 8 gpointer valp;
459 8 const char *field_name;
460 8 GHashTableIter field_iter;
461 8 ShumateVectorIndexBitset *bitset;
462 8 FieldIndexingData *field = &fields[key];
463
464
2/2
✓ Branch 75 → 76 taken 4 times.
✓ Branch 75 → 77 taken 4 times.
8 if (field->indexes == NULL)
465 4 continue;
466
467 4 field_name = layer->keys[key];
468
469 4 g_hash_table_iter_init (&field_iter, field->indexes);
470
2/2
✓ Branch 84 → 79 taken 2 times.
✓ Branch 84 → 85 taken 4 times.
6 while (g_hash_table_iter_next (&field_iter, &valp, (gpointer *)&bitset))
471 {
472 2 int val = GPOINTER_TO_INT(valp);
473 2 g_auto(ShumateVectorValue) value = SHUMATE_VECTOR_VALUE_INIT;
474 2 VectorTile__Tile__Value *v;
475
476 2 v = layer->values[val];
477 2 convert_vector_value (v, &value);
478
479 2 shumate_vector_index_add_bitset (self->index, self->source_layer_idx, field_name, &value, bitset);
480 }
481
482 4 g_hash_table_destroy (field->indexes);
483 4 shumate_vector_index_bitset_free (field->used_values);
484 4 shumate_vector_index_bitset_free (field->unused_values);
485
486
2/2
✓ Branch 88 → 89 taken 2 times.
✓ Branch 88 → 90 taken 2 times.
4 if (field->has_index != NULL)
487 2 shumate_vector_index_add_bitset_has (self->index, self->source_layer_idx, field_name, field->has_index);
488 }
489
490
1/2
✗ Branch 93 → 94 not taken.
✓ Branch 93 → 95 taken 8 times.
8 g_free (fields);
491 }
492