GCC Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 95.8% 23 / 0 / 24
Functions: 100.0% 7 / 0 / 7
Branches: 62.5% 5 / 0 / 8

shumate/shumate-vector-reader.c
Line Branch Exec Source
1 /*
2 * Copyright (C) 2023 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-reader-private.h"
19 #include "vector/vector_tile.pb-c.h"
20
21 /**
22 * ShumateVectorReader:
23 *
24 * Provides low-level access to the contents of a vector tile.
25 *
26 * To create a new [class@VectorReader], use [ctor@VectorReader.new] and pass
27 * the bytes of a vector tile, which you might get from a [class@DataSource].
28 * Then, use [method@VectorReader.iterate] to get a [class@VectorReaderIter]
29 * and iterate over the features in the tile. You can create multiple
30 * [class@VectorReaderIter]s from the same [class@VectorReader].
31 *
32 * Since: 1.2
33 */
34
35
4/6
shumate_vector_reader_class_intern_init:
✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 9 times.
shumate_vector_reader_get_type:
✓ Branch 2 → 3 taken 9 times.
✓ Branch 2 → 7 taken 41 times.
✓ Branch 4 → 5 taken 9 times.
✗ Branch 4 → 7 not taken.
68 G_DEFINE_TYPE (ShumateVectorReader, shumate_vector_reader, G_TYPE_OBJECT)
36
37 static void
38 14 shumate_vector_reader_finalize (GObject *object)
39 {
40 14 ShumateVectorReader *self = SHUMATE_VECTOR_READER (object);
41
42 14 vector_tile__tile__free_unpacked (self->tile, NULL);
43 14 self->tile = NULL;
44
45 14 G_OBJECT_CLASS (shumate_vector_reader_parent_class)->finalize (object);
46 14 }
47
48 static void
49 9 shumate_vector_reader_class_init (ShumateVectorReaderClass *klass)
50 {
51 9 GObjectClass *object_class = G_OBJECT_CLASS (klass);
52
53 9 object_class->finalize = shumate_vector_reader_finalize;
54 }
55
56 static void
57 14 shumate_vector_reader_init (ShumateVectorReader *self)
58 {
59 14 }
60
61 /**
62 * shumate_vector_reader_new:
63 * @bytes: (transfer none): A tile in Mapbox Vector Tile format
64 *
65 * Creates a new [class@VectorReader] from @bytes.
66 *
67 * Returns: (transfer full): A new [class@VectorReader]
68 *
69 * Since: 1.2
70 */
71 ShumateVectorReader *
72 14 shumate_vector_reader_new (GBytes *bytes)
73 {
74 14 g_autoptr(ShumateVectorReader) self = g_object_new(SHUMATE_TYPE_VECTOR_READER, NULL);
75 14 gconstpointer data;
76 14 gsize len;
77
78 14 data = g_bytes_get_data (bytes, &len);
79 14 self->tile = vector_tile__tile__unpack (NULL, len, data);
80
81
1/2
✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 14 times.
14 if (self->tile == NULL)
82 ✗ return NULL;
83
84 return g_steal_pointer (&self);
85 }
86
87 /**
88 * shumate_vector_reader_iterate:
89 * @self: A [class@VectorReader]
90 *
91 * Creates a new [class@VectorReaderIter] for @self.
92 *
93 * Returns: (transfer full): A new [class@VectorReaderIter]
94 *
95 * Since: 1.2
96 */
97 ShumateVectorReaderIter *
98 26 shumate_vector_reader_iterate (ShumateVectorReader *self)
99 {
100 26 return shumate_vector_reader_iter_new (self);
101 }
102