diff --git a/include/attribute_store.h b/include/attribute_store.h index dc210b96..498c6c6c 100644 --- a/include/attribute_store.h +++ b/include/attribute_store.h @@ -42,13 +42,13 @@ class AttributeKeyStore { std::map keys2index; }; -enum class AttributePairType: char { Bool = 0, Float = 1, String = 2 }; +enum class AttributePairType: uint8_t { Bool = 0, Float = 1, String = 2 }; // AttributePair is a key/value pair (with minzoom) #pragma pack(push, 1) struct AttributePair { short keyIndex : 9; - AttributePairType valueType : 3; - char minzoom : 4; + AttributePairType valueType : 2; + uint8_t minzoom : 5; // Support zooms from 0..31. In practice, we expect z16 to be the biggest minzoom. union { float floatValue_; PooledString stringValue_; diff --git a/test/attribute_store.test.cpp b/test/attribute_store.test.cpp index db104a14..aa721787 100644 --- a/test/attribute_store.test.cpp +++ b/test/attribute_store.test.cpp @@ -11,10 +11,10 @@ MU_TEST(test_attribute_store) { AttributeSet s1; store.addAttribute(s1, "str1", std::string("someval"), 0); - store.addAttribute(s1, "str2", std::string("a very long string"), 0); + store.addAttribute(s1, "str2", std::string("a very long string"), 14); store.addAttribute(s1, "bool1", false, 0); store.addAttribute(s1, "bool2", true, 0); - store.addAttribute(s1, "float1", (float)42.0, 0); + store.addAttribute(s1, "float1", (float)42.0, 4); const auto s1Index = store.add(s1); @@ -35,6 +35,7 @@ MU_TEST(test_attribute_store) { mu_check(str2 != s1Pairs.end()); mu_check((*str2)->hasStringValue()); mu_check((*str2)->stringValue() == "a very long string"); + mu_check((*str2)->minzoom == 14); const auto bool1 = std::find_if(s1Pairs.begin(), s1Pairs.end(), [&store](auto ap) { return ap->keyIndex == store.keyStore.key2index("bool1"); @@ -56,6 +57,7 @@ MU_TEST(test_attribute_store) { mu_check(float1 != s1Pairs.end()); mu_check((*float1)->hasFloatValue()); mu_check((*float1)->floatValue() == 42); + mu_check((*float1)->minzoom == 4); } MU_TEST(test_attribute_store_reuses) {