#include #include #ifdef VTZERO_TEST_WITH_VARIANT # include using variant_type = boost::variant; #endif #include #include #include TEST_CASE("property map") { vtzero::tile_builder tile; vtzero::layer_builder layer_points{tile, "points"}; { vtzero::point_feature_builder fbuilder{layer_points}; fbuilder.set_id(1); fbuilder.add_points(1); fbuilder.set_point(10, 10); fbuilder.add_property("foo", "bar"); fbuilder.add_property("x", "y"); fbuilder.add_property("abc", "def"); fbuilder.commit(); } std::string data = tile.serialize(); vtzero::vector_tile vt{data}; REQUIRE(vt.count_layers() == 1); auto layer = vt.next_layer(); REQUIRE(layer.valid()); REQUIRE(layer.num_features() == 1); const auto feature = layer.next_feature(); REQUIRE(feature.valid()); REQUIRE(feature.num_properties() == 3); #ifdef VTZERO_TEST_WITH_VARIANT SECTION("std::map") { using prop_map_type = std::map; auto map = vtzero::create_properties_map(feature); REQUIRE(map.size() == 3); REQUIRE(boost::get(map["foo"]) == "bar"); REQUIRE(boost::get(map["x"]) == "y"); REQUIRE(boost::get(map["abc"]) == "def"); } SECTION("std::unordered_map") { using prop_map_type = std::unordered_map; auto map = vtzero::create_properties_map(feature); REQUIRE(map.size() == 3); REQUIRE(boost::get(map["foo"]) == "bar"); REQUIRE(boost::get(map["x"]) == "y"); REQUIRE(boost::get(map["abc"]) == "def"); } #endif }