tests/vector-reader.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #undef G_DISABLE_ASSERT | ||
| 2 | |||
| 3 | #include <shumate/shumate.h> | ||
| 4 | #include "shumate/vector/vector_tile.pb-c.h" | ||
| 5 | |||
| 6 | #define MOVE_TO 1 | ||
| 7 | #define LINE_TO 2 | ||
| 8 | #define CLOSE_PATH 7 | ||
| 9 | #define CMD(op, rep) ((op & 7) | ((rep) << 3)) | ||
| 10 | #define POINT(x, y) unzigzag (x), unzigzag (y) | ||
| 11 | |||
| 12 | static uint32_t | ||
| 13 | unzigzag (int value) | ||
| 14 | { | ||
| 15 | return (value << 1) ^ (value >> 31); | ||
| 16 | } | ||
| 17 | |||
| 18 | static VectorTile__Tile__Value * | ||
| 19 | 6 | new_string_value (const char *value) | |
| 20 | { | ||
| 21 | 6 | VectorTile__Tile__Value *v = g_new0 (VectorTile__Tile__Value, 1); | |
| 22 | 6 | vector_tile__tile__value__init (v); | |
| 23 |
1/2✓ Branch 4 → 5 taken 6 times.
✗ Branch 4 → 6 not taken.
|
6 | v->string_value = g_strdup (value); |
| 24 | 6 | return v; | |
| 25 | } | ||
| 26 | |||
| 27 | static void | ||
| 28 | 36 | set_feature_geometry (VectorTile__Tile__Feature *feature, VectorTile__Tile__GeomType geom_type, const uint32_t *geometry) | |
| 29 | { | ||
| 30 | 36 | feature->type = geom_type; | |
| 31 | 36 | feature->has_type = TRUE; | |
| 32 |
2/2✓ Branch 4 → 3 taken 522 times.
✓ Branch 4 → 5 taken 36 times.
|
558 | for (int i = 0; geometry[i] != G_MAXUINT32; i++) |
| 33 | 522 | feature->n_geometry++; | |
| 34 |
1/4✗ Branch 5 → 6 not taken.
✓ Branch 5 → 8 taken 36 times.
✗ Branch 6 → 7 not taken.
✗ Branch 6 → 8 not taken.
|
36 | feature->geometry = g_new0 (uint32_t, feature->n_geometry); |
| 35 |
2/2✓ Branch 11 → 10 taken 522 times.
✓ Branch 11 → 12 taken 36 times.
|
558 | for (int i = 0; i < feature->n_geometry; i++) |
| 36 | 522 | feature->geometry[i] = geometry[i]; | |
| 37 | 36 | } | |
| 38 | |||
| 39 | static VectorTile__Tile__Feature * | ||
| 40 | 36 | add_feature (VectorTile__Tile__Layer *layer, uint32_t id, uint32_t *tags, uint32_t n_tags) | |
| 41 | { | ||
| 42 | 36 | VectorTile__Tile__Feature *feature = g_new0 (VectorTile__Tile__Feature, 1); | |
| 43 | 36 | vector_tile__tile__feature__init (feature); | |
| 44 | 36 | feature->id = id; | |
| 45 | 36 | feature->has_id = TRUE; | |
| 46 | 36 | feature->n_tags = n_tags; | |
| 47 |
1/2✗ Branch 4 → 5 not taken.
✓ Branch 4 → 6 taken 36 times.
|
36 | feature->tags = g_new0 (uint32_t, n_tags); |
| 48 |
2/2✓ Branch 9 → 8 taken 12 times.
✓ Branch 9 → 10 taken 36 times.
|
48 | for (int i = 0; i < n_tags; i++) |
| 49 | 12 | feature->tags[i] = tags[i]; | |
| 50 | 36 | layer->n_features++; | |
| 51 |
1/4✗ Branch 10 → 11 not taken.
✓ Branch 10 → 13 taken 36 times.
✗ Branch 11 → 12 not taken.
✗ Branch 11 → 13 not taken.
|
36 | layer->features = g_renew (VectorTile__Tile__Feature *, layer->features, layer->n_features); |
| 52 | 36 | layer->features[layer->n_features - 1] = feature; | |
| 53 | 36 | return feature; | |
| 54 | } | ||
| 55 | |||
| 56 | static VectorTile__Tile__Layer * | ||
| 57 | 12 | add_layer (VectorTile__Tile *tile, char *name, int extent, char **keys, VectorTile__Tile__Value **values) | |
| 58 | { | ||
| 59 | 12 | VectorTile__Tile__Layer *layer = g_new0 (VectorTile__Tile__Layer, 1); | |
| 60 | 12 | vector_tile__tile__layer__init (layer); | |
| 61 |
1/2✓ Branch 4 → 5 taken 12 times.
✗ Branch 4 → 6 not taken.
|
12 | layer->name = g_strdup (name); |
| 62 | 12 | layer->extent = extent; | |
| 63 | 12 | layer->has_extent = TRUE; | |
| 64 | 12 | layer->version = 2; | |
| 65 | 12 | layer->n_keys = g_strv_length (keys); | |
| 66 |
1/2✗ Branch 13 → 14 not taken.
✓ Branch 13 → 15 taken 12 times.
|
12 | layer->keys = g_new0 (char *, layer->n_keys); |
| 67 |
2/2✓ Branch 26 → 17 taken 6 times.
✓ Branch 26 → 27 taken 12 times.
|
18 | for (int i = 0; i < layer->n_keys; i++) |
| 68 |
1/2✗ Branch 17 → 18 not taken.
✓ Branch 17 → 19 taken 6 times.
|
12 | layer->keys[i] = g_strdup (keys[i]); |
| 69 | 12 | layer->n_values = g_strv_length ((char **)values); | |
| 70 |
1/2✗ Branch 28 → 29 not taken.
✓ Branch 28 → 30 taken 12 times.
|
12 | layer->values = g_new0 (VectorTile__Tile__Value *, layer->n_values); |
| 71 |
2/2✓ Branch 33 → 32 taken 6 times.
✓ Branch 33 → 34 taken 12 times.
|
18 | for (int i = 0; i < layer->n_values; i++) |
| 72 | 6 | layer->values[i] = values[i]; | |
| 73 | 12 | tile->n_layers++; | |
| 74 |
1/4✗ Branch 34 → 35 not taken.
✓ Branch 34 → 37 taken 12 times.
✗ Branch 35 → 36 not taken.
✗ Branch 35 → 37 not taken.
|
12 | tile->layers = g_renew (VectorTile__Tile__Layer *, tile->layers, tile->n_layers); |
| 75 | 12 | tile->layers[tile->n_layers - 1] = layer; | |
| 76 | 12 | return layer; | |
| 77 | } | ||
| 78 | |||
| 79 | static GBytes * | ||
| 80 | 6 | create_test_tile (void) | |
| 81 | { | ||
| 82 | 6 | VectorTile__Tile *tile; | |
| 83 | 6 | VectorTile__Tile__Layer *layer; | |
| 84 | 6 | VectorTile__Tile__Feature *feature; | |
| 85 | 6 | uint8_t *out; | |
| 86 | 6 | size_t out_len; | |
| 87 | |||
| 88 | 6 | tile = g_new0 (VectorTile__Tile, 1); | |
| 89 | 6 | vector_tile__tile__init (tile); | |
| 90 | |||
| 91 | 18 | layer = add_layer (tile, "helloworld", 4096, | |
| 92 | 6 | (char*[]){"hello", NULL}, | |
| 93 | 6 | (VectorTile__Tile__Value*[]){new_string_value ("world"), NULL} | |
| 94 | ); | ||
| 95 | |||
| 96 | /* Point feature*/ | ||
| 97 | 6 | feature = add_feature (layer, 1, (uint32_t[]){0, 0}, 2); | |
| 98 | 6 | set_feature_geometry (feature, VECTOR_TILE__TILE__GEOM_TYPE__POINT, (uint32_t[]){CMD (MOVE_TO, 1), POINT (1, 2), G_MAXUINT32}); | |
| 99 | |||
| 100 | /* MultiPoint feature */ | ||
| 101 | 6 | feature = add_feature (layer, 2, (uint32_t[]){}, 0); | |
| 102 | 6 | set_feature_geometry (feature, VECTOR_TILE__TILE__GEOM_TYPE__POINT, (uint32_t[]){ | |
| 103 | CMD (MOVE_TO, 2), | ||
| 104 | 6 | POINT (100, 200), | |
| 105 | 6 | POINT (300, 400), | |
| 106 | G_MAXUINT32, | ||
| 107 | }); | ||
| 108 | |||
| 109 | /* LineString feature */ | ||
| 110 | 6 | feature = add_feature (layer, 3, (uint32_t[]){}, 0); | |
| 111 | 6 | set_feature_geometry (feature, VECTOR_TILE__TILE__GEOM_TYPE__LINESTRING, (uint32_t[]){ | |
| 112 | CMD (MOVE_TO, 1), | ||
| 113 | 6 | POINT (100, 200), | |
| 114 | CMD (LINE_TO, 2), | ||
| 115 | 6 | POINT (300, 400), | |
| 116 | 6 | POINT (500, 600), | |
| 117 | G_MAXUINT32, | ||
| 118 | }); | ||
| 119 | |||
| 120 | /* MultiLineString feature */ | ||
| 121 | 6 | feature = add_feature (layer, 4, (uint32_t[]){}, 0); | |
| 122 | 6 | set_feature_geometry (feature, VECTOR_TILE__TILE__GEOM_TYPE__LINESTRING, (uint32_t[]){ | |
| 123 | CMD (MOVE_TO, 1), | ||
| 124 | 6 | POINT (100, 200), | |
| 125 | CMD (LINE_TO, 2), | ||
| 126 | 6 | POINT (300, 400), | |
| 127 | 6 | POINT (500, 600), | |
| 128 | CMD (MOVE_TO, 1), | ||
| 129 | 6 | POINT (100, 200), | |
| 130 | CMD (LINE_TO, 2), | ||
| 131 | 6 | POINT (300, 400), | |
| 132 | 6 | POINT (500, 600), | |
| 133 | G_MAXUINT32, | ||
| 134 | }); | ||
| 135 | |||
| 136 | /* Polygon feature */ | ||
| 137 | 6 | feature = add_feature (layer, 5, (uint32_t[]){}, 0); | |
| 138 | 6 | set_feature_geometry (feature, VECTOR_TILE__TILE__GEOM_TYPE__POLYGON, (uint32_t[]){ | |
| 139 | /* Exterior ring */ | ||
| 140 | CMD (MOVE_TO, 1), | ||
| 141 | 6 | POINT (100, 200), | |
| 142 | CMD (LINE_TO, 3), | ||
| 143 | 6 | POINT (200, 0), | |
| 144 | 6 | POINT (0, 200), | |
| 145 | 6 | POINT (-200, 0), | |
| 146 | CMD (CLOSE_PATH, 1), | ||
| 147 | /* Interior ring */ | ||
| 148 | CMD (MOVE_TO, 1), | ||
| 149 | 6 | POINT (50, -50), | |
| 150 | CMD (LINE_TO, 3), | ||
| 151 | 6 | POINT (100, 0), | |
| 152 | 6 | POINT (0, -100), | |
| 153 | 6 | POINT (-100, 0), | |
| 154 | CMD (CLOSE_PATH, 1), | ||
| 155 | G_MAXUINT32, | ||
| 156 | }); | ||
| 157 | |||
| 158 | /* MultiPolygon feature */ | ||
| 159 | 6 | feature = add_feature (layer, 6, (uint32_t[]){}, 0); | |
| 160 | 6 | set_feature_geometry (feature, VECTOR_TILE__TILE__GEOM_TYPE__POLYGON, (uint32_t[]){ | |
| 161 | /* Exterior ring 1 (a square) */ | ||
| 162 | CMD (MOVE_TO, 1), | ||
| 163 | 6 | POINT (100, 200), | |
| 164 | CMD (LINE_TO, 3), | ||
| 165 | 6 | POINT (200, 0), | |
| 166 | 6 | POINT (0, 200), | |
| 167 | 6 | POINT (-200, 0), | |
| 168 | CMD (CLOSE_PATH, 1), | ||
| 169 | /* Interior ring (another square)*/ | ||
| 170 | CMD (MOVE_TO, 1), | ||
| 171 | 6 | POINT (50, -50), | |
| 172 | CMD (LINE_TO, 3), | ||
| 173 | 6 | POINT (100, 0), | |
| 174 | 6 | POINT (0, -100), | |
| 175 | 6 | POINT (-100, 0), | |
| 176 | CMD (CLOSE_PATH, 1), | ||
| 177 | /* Exterior ring 2 (square rotated 45 degrees, overlapping ring 1) */ | ||
| 178 | CMD (MOVE_TO, 1), | ||
| 179 | 6 | POINT (51, 51), | |
| 180 | CMD (LINE_TO, 3), | ||
| 181 | 6 | POINT (49, -51), | |
| 182 | 6 | POINT (100, 50), | |
| 183 | 6 | POINT (-100, 50), | |
| 184 | CMD (CLOSE_PATH, 1), | ||
| 185 | G_MAXUINT32, | ||
| 186 | }); | ||
| 187 | |||
| 188 | |||
| 189 | 12 | layer = add_layer (tile, "helloworld2", 100, | |
| 190 | 6 | (char*[]){NULL}, | |
| 191 | 6 | (VectorTile__Tile__Value*[]){NULL} | |
| 192 | ); | ||
| 193 | |||
| 194 | 6 | out_len = vector_tile__tile__get_packed_size (tile); | |
| 195 | 6 | out = g_new0 (uint8_t, out_len); | |
| 196 | 6 | vector_tile__tile__pack (tile, out); | |
| 197 | |||
| 198 | 6 | vector_tile__tile__free_unpacked (tile, NULL); | |
| 199 | |||
| 200 | 6 | return g_bytes_new_take (out, out_len); | |
| 201 | } | ||
| 202 | |||
| 203 | static void | ||
| 204 | 2 | test_vector_reader_layers (void) | |
| 205 | { | ||
| 206 | 4 | g_autoptr(ShumateVectorReader) reader = NULL; | |
| 207 |
1/2✓ Branch 41 → 42 taken 2 times.
✗ Branch 41 → 43 not taken.
|
2 | g_autoptr(ShumateVectorReaderIter) iter = NULL; |
| 208 |
1/2✓ Branch 39 → 40 taken 2 times.
✗ Branch 39 → 41 not taken.
|
4 | g_autoptr(GBytes) tile_data = create_test_tile (); |
| 209 |
1/2✓ Branch 37 → 38 taken 2 times.
✗ Branch 37 → 39 not taken.
|
2 | g_auto(GValue) value = G_VALUE_INIT; |
| 210 | |||
| 211 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 2 times.
|
2 | g_assert_nonnull (tile_data); |
| 212 | |||
| 213 | 2 | reader = shumate_vector_reader_new (tile_data); | |
| 214 |
1/2✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 2 times.
|
2 | g_assert_nonnull (reader); |
| 215 | |||
| 216 | 2 | iter = shumate_vector_reader_iterate (reader); | |
| 217 |
1/2✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 2 times.
|
2 | g_assert_nonnull (iter); |
| 218 | |||
| 219 |
1/2✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 2 times.
|
2 | g_assert_cmpint (shumate_vector_reader_iter_get_layer_count (iter), ==, 2); |
| 220 | |||
| 221 | 2 | shumate_vector_reader_iter_read_layer (iter, 0); | |
| 222 |
1/2✗ Branch 17 → 18 not taken.
✓ Branch 17 → 19 taken 2 times.
|
2 | g_assert_cmpstr (shumate_vector_reader_iter_get_layer_name (iter), ==, "helloworld"); |
| 223 |
1/2✗ Branch 20 → 21 not taken.
✓ Branch 20 → 22 taken 2 times.
|
2 | g_assert_cmpint (shumate_vector_reader_iter_get_layer_extent (iter), ==, 4096); |
| 224 |
1/2✗ Branch 23 → 24 not taken.
✓ Branch 23 → 25 taken 2 times.
|
2 | g_assert_cmpint (shumate_vector_reader_iter_get_layer_feature_count (iter), ==, 6); |
| 225 | |||
| 226 | 2 | shumate_vector_reader_iter_read_layer (iter, 1); | |
| 227 |
1/2✗ Branch 28 → 29 not taken.
✓ Branch 28 → 30 taken 2 times.
|
2 | g_assert_cmpstr (shumate_vector_reader_iter_get_layer_name (iter), ==, "helloworld2"); |
| 228 |
1/2✗ Branch 31 → 32 not taken.
✓ Branch 31 → 33 taken 2 times.
|
2 | g_assert_cmpint (shumate_vector_reader_iter_get_layer_extent (iter), ==, 100); |
| 229 |
1/2✗ Branch 34 → 35 not taken.
✓ Branch 34 → 36 taken 2 times.
|
2 | g_assert_cmpint (shumate_vector_reader_iter_get_layer_feature_count (iter), ==, 0); |
| 230 | 2 | } | |
| 231 | |||
| 232 | static void | ||
| 233 | 2 | test_vector_reader_tags (void) | |
| 234 | { | ||
| 235 | 4 | g_autoptr(ShumateVectorReader) reader = NULL; | |
| 236 |
1/2✓ Branch 42 → 43 taken 2 times.
✗ Branch 42 → 44 not taken.
|
2 | g_autoptr(ShumateVectorReaderIter) iter = NULL; |
| 237 |
1/2✓ Branch 40 → 41 taken 2 times.
✗ Branch 40 → 42 not taken.
|
4 | g_autoptr(GBytes) tile_data = create_test_tile (); |
| 238 |
1/2✓ Branch 38 → 39 taken 2 times.
✗ Branch 38 → 40 not taken.
|
2 | g_auto(GValue) value = G_VALUE_INIT; |
| 239 | 2 | g_autofree const char **keys; | |
| 240 | |||
| 241 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 2 times.
|
2 | g_assert_nonnull (tile_data); |
| 242 | |||
| 243 | 2 | reader = shumate_vector_reader_new (tile_data); | |
| 244 |
1/2✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 2 times.
|
2 | g_assert_nonnull (reader); |
| 245 | |||
| 246 | 2 | iter = shumate_vector_reader_iterate (reader); | |
| 247 |
1/2✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 2 times.
|
2 | g_assert_nonnull (iter); |
| 248 | |||
| 249 |
1/2✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_read_layer_by_name (iter, "helloworld")); |
| 250 |
1/2✗ Branch 15 → 16 not taken.
✓ Branch 15 → 17 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_next_feature (iter)); |
| 251 |
1/2✗ Branch 18 → 19 not taken.
✓ Branch 18 → 20 taken 2 times.
|
2 | g_assert_cmpint (shumate_vector_reader_iter_get_feature_id (iter), ==, 1); |
| 252 |
1/2✗ Branch 21 → 22 not taken.
✓ Branch 21 → 23 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_get_feature_tag (iter, "hello", &value)); |
| 253 | |||
| 254 | 2 | keys = shumate_vector_reader_iter_get_feature_keys (iter); | |
| 255 |
1/2✗ Branch 25 → 26 not taken.
✓ Branch 25 → 27 taken 2 times.
|
2 | g_assert_cmpint (g_strv_length ((char **)keys), ==, 1); |
| 256 |
1/2✗ Branch 28 → 29 not taken.
✓ Branch 28 → 30 taken 2 times.
|
2 | g_assert_cmpstr (keys[0], ==, "hello"); |
| 257 |
1/2✗ Branch 30 → 31 not taken.
✓ Branch 30 → 32 taken 2 times.
|
2 | g_assert_null (keys[1]); |
| 258 | |||
| 259 |
1/2✗ Branch 34 → 35 not taken.
✓ Branch 34 → 36 taken 2 times.
|
2 | g_assert_cmpstr (g_value_get_string (&value), ==, "world"); |
| 260 | 2 | } | |
| 261 | |||
| 262 | static void | ||
| 263 | 2 | test_vector_reader_geometry (void) | |
| 264 | { | ||
| 265 | 4 | g_autoptr(ShumateVectorReader) reader = NULL; | |
| 266 |
1/2✓ Branch 110 → 111 taken 2 times.
✗ Branch 110 → 112 not taken.
|
2 | g_autoptr(ShumateVectorReaderIter) iter = NULL; |
| 267 |
1/2✓ Branch 108 → 109 taken 2 times.
✗ Branch 108 → 110 not taken.
|
4 | g_autoptr(GBytes) tile_data = create_test_tile (); |
| 268 |
1/2✓ Branch 106 → 107 taken 2 times.
✗ Branch 106 → 108 not taken.
|
2 | g_auto(GValue) value = G_VALUE_INIT; |
| 269 | 2 | double x, y; | |
| 270 | |||
| 271 |
1/2✗ Branch 3 → 4 not taken.
✓ Branch 3 → 5 taken 2 times.
|
2 | g_assert_nonnull (tile_data); |
| 272 | |||
| 273 | 2 | reader = shumate_vector_reader_new (tile_data); | |
| 274 |
1/2✗ Branch 6 → 7 not taken.
✓ Branch 6 → 8 taken 2 times.
|
2 | g_assert_nonnull (reader); |
| 275 | |||
| 276 | 2 | iter = shumate_vector_reader_iterate (reader); | |
| 277 |
1/2✗ Branch 9 → 10 not taken.
✓ Branch 9 → 11 taken 2 times.
|
2 | g_assert_nonnull (iter); |
| 278 | |||
| 279 |
1/2✗ Branch 12 → 13 not taken.
✓ Branch 12 → 14 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_read_layer_by_name (iter, "helloworld")); |
| 280 | |||
| 281 | /* Point */ | ||
| 282 |
1/2✗ Branch 15 → 16 not taken.
✓ Branch 15 → 17 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_next_feature (iter)); |
| 283 |
1/2✗ Branch 18 → 19 not taken.
✓ Branch 18 → 20 taken 2 times.
|
2 | g_assert_cmpint (shumate_vector_reader_iter_get_feature_geometry_type (iter), ==, SHUMATE_GEOMETRY_TYPE_POINT); |
| 284 |
1/2✗ Branch 21 → 22 not taken.
✓ Branch 21 → 23 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_get_feature_point (iter, &x, &y)); |
| 285 |
1/2✗ Branch 23 → 24 not taken.
✓ Branch 23 → 25 taken 2 times.
|
2 | g_assert_cmpfloat (x, ==, 1.0); |
| 286 |
1/2✗ Branch 25 → 26 not taken.
✓ Branch 25 → 27 taken 2 times.
|
2 | g_assert_cmpfloat (y, ==, 2.0); |
| 287 | |||
| 288 | /* MultiPoint */ | ||
| 289 |
1/2✗ Branch 28 → 29 not taken.
✓ Branch 28 → 30 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_next_feature (iter)); |
| 290 |
1/2✗ Branch 31 → 32 not taken.
✓ Branch 31 → 33 taken 2 times.
|
2 | g_assert_cmpint (shumate_vector_reader_iter_get_feature_geometry_type (iter), ==, SHUMATE_GEOMETRY_TYPE_MULTIPOINT); |
| 291 | |||
| 292 | /* LineString */ | ||
| 293 |
1/2✗ Branch 34 → 35 not taken.
✓ Branch 34 → 36 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_next_feature (iter)); |
| 294 |
1/2✗ Branch 37 → 38 not taken.
✓ Branch 37 → 39 taken 2 times.
|
2 | g_assert_cmpint (shumate_vector_reader_iter_get_feature_geometry_type (iter), ==, SHUMATE_GEOMETRY_TYPE_LINESTRING); |
| 295 | |||
| 296 | /* MultiLineString */ | ||
| 297 |
1/2✗ Branch 40 → 41 not taken.
✓ Branch 40 → 42 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_next_feature (iter)); |
| 298 |
1/2✗ Branch 43 → 44 not taken.
✓ Branch 43 → 45 taken 2 times.
|
2 | g_assert_cmpint (shumate_vector_reader_iter_get_feature_geometry_type (iter), ==, SHUMATE_GEOMETRY_TYPE_MULTILINESTRING); |
| 299 | |||
| 300 | /* Polygon */ | ||
| 301 |
1/2✗ Branch 46 → 47 not taken.
✓ Branch 46 → 48 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_next_feature (iter)); |
| 302 |
1/2✗ Branch 49 → 50 not taken.
✓ Branch 49 → 51 taken 2 times.
|
2 | g_assert_cmpint (shumate_vector_reader_iter_get_feature_geometry_type (iter), ==, SHUMATE_GEOMETRY_TYPE_POLYGON); |
| 303 |
1/2✗ Branch 52 → 53 not taken.
✓ Branch 52 → 54 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_feature_contains_point (iter, 105, 205)); |
| 304 |
1/2✗ Branch 55 → 56 not taken.
✓ Branch 55 → 57 taken 2 times.
|
2 | g_assert_false (shumate_vector_reader_iter_feature_contains_point (iter, 175, 300)); |
| 305 |
1/2✗ Branch 58 → 59 not taken.
✓ Branch 58 → 60 taken 2 times.
|
2 | g_assert_false (shumate_vector_reader_iter_feature_contains_point (iter, 0, 0)); |
| 306 | |||
| 307 | /* Multipolygon */ | ||
| 308 |
1/2✗ Branch 61 → 62 not taken.
✓ Branch 61 → 63 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_next_feature (iter)); |
| 309 |
1/2✗ Branch 64 → 65 not taken.
✓ Branch 64 → 66 taken 2 times.
|
2 | g_assert_cmpint (shumate_vector_reader_iter_get_feature_geometry_type (iter), ==, SHUMATE_GEOMETRY_TYPE_MULTIPOLYGON); |
| 310 | /* Simple case */ | ||
| 311 |
1/2✗ Branch 67 → 68 not taken.
✓ Branch 67 → 69 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_feature_contains_point (iter, 105, 205)); |
| 312 | /* Overlap */ | ||
| 313 |
1/2✗ Branch 70 → 71 not taken.
✓ Branch 70 → 72 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_feature_contains_point (iter, 275, 300)); |
| 314 | /* Interior ring + overlap*/ | ||
| 315 |
1/2✗ Branch 73 → 74 not taken.
✓ Branch 73 → 75 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_feature_contains_point (iter, 225, 300)); |
| 316 | /* Interior ring */ | ||
| 317 |
1/2✗ Branch 76 → 77 not taken.
✓ Branch 76 → 78 taken 2 times.
|
2 | g_assert_false (shumate_vector_reader_iter_feature_contains_point (iter, 175, 300)); |
| 318 | /* Outside */ | ||
| 319 |
1/2✗ Branch 79 → 80 not taken.
✓ Branch 79 → 81 taken 2 times.
|
2 | g_assert_false (shumate_vector_reader_iter_feature_contains_point (iter, 0, 0)); |
| 320 | /* Ray might pass through a corner */ | ||
| 321 |
1/2✗ Branch 82 → 83 not taken.
✓ Branch 82 → 84 taken 2 times.
|
2 | g_assert_false (shumate_vector_reader_iter_feature_contains_point (iter, 350, 299)); |
| 322 |
1/2✗ Branch 85 → 86 not taken.
✓ Branch 85 → 87 taken 2 times.
|
2 | g_assert_false (shumate_vector_reader_iter_feature_contains_point (iter, 350, 301)); |
| 323 |
1/2✗ Branch 88 → 89 not taken.
✓ Branch 88 → 90 taken 2 times.
|
2 | g_assert_false (shumate_vector_reader_iter_feature_contains_point (iter, 351, 300)); |
| 324 |
1/2✗ Branch 91 → 92 not taken.
✓ Branch 91 → 93 taken 2 times.
|
2 | g_assert_true (shumate_vector_reader_iter_feature_contains_point (iter, 349, 300)); |
| 325 | /* Horizontal/vertical edges */ | ||
| 326 |
1/2✗ Branch 94 → 95 not taken.
✓ Branch 94 → 96 taken 2 times.
|
2 | g_assert_false (shumate_vector_reader_iter_feature_contains_point (iter, 99, 200)); |
| 327 |
1/2✗ Branch 97 → 98 not taken.
✓ Branch 97 → 99 taken 2 times.
|
2 | g_assert_false (shumate_vector_reader_iter_feature_contains_point (iter, 301, 200)); |
| 328 |
1/2✗ Branch 100 → 101 not taken.
✓ Branch 100 → 102 taken 2 times.
|
2 | g_assert_false (shumate_vector_reader_iter_feature_contains_point (iter, 100, 199)); |
| 329 |
1/2✗ Branch 103 → 104 not taken.
✓ Branch 103 → 105 taken 2 times.
|
2 | g_assert_false (shumate_vector_reader_iter_feature_contains_point (iter, 100, 401)); |
| 330 | 2 | } | |
| 331 | |||
| 332 | int | ||
| 333 | 2 | main (int argc, char *argv[]) | |
| 334 | { | ||
| 335 | 2 | g_test_init (&argc, &argv, NULL); | |
| 336 | |||
| 337 | 2 | g_test_add_func ("/vector-reader/layers", test_vector_reader_layers); | |
| 338 | 2 | g_test_add_func ("/vector-reader/tags", test_vector_reader_tags); | |
| 339 | 2 | g_test_add_func ("/vector-reader/geometry", test_vector_reader_geometry); | |
| 340 | |||
| 341 | 2 | return g_test_run (); | |
| 342 | } | ||
| 343 |