Closed Algunenano closed 6 years ago
This definitely seems like a bug -- if you create a PR please make a unit test to show that it is fixed.
@Algunenano - storing Value_Encoding
looks like a good approach here as mapnik::value is not the same as protozero value.
/cc @flippmoke
I tried the approach that I was talking about (using a std::pair<Value_Encoding, mapnik::value>
) but the code ended up being overcomplicated with multiple visitors. I decided instead to go for just declaring custom hash and compare functions instead taking into account the associated Value_Encoding
type.
Ey, do you need anything apart from https://github.com/mapbox/mapnik-vector-tile/pull/281 for this issue? Let me know if you need any change to the PR to get this fixed.
If I try to add 2 key-value pairs in a layer and both values have different types but same value (for example
3
and3.0
) bothkeys
are added but only the first of the values is added, and the second key will point to the first one index.This is an problem as, when storing the values in protozero, we store not only the value but the type (
Value_Encoding
) too, so when extracting the data instead of getting 'int(3)' and 'float(3.0)' we'll get have 'int(3)' for both. It's even more troublesome with bools as storing 'boolean(false)' and 'int(0)' will lead to both values becoming 'false' when extracting.The issue is that the 'mapnik::value' comparison is done purely by value (references here and here so
0.0
is equal to0
and equal tofalse
. Small sample with the comparison:2 questions:
std::unordered_map<std::pair<Value_Encoding, mapnik::value>, unsigned>
as container instead ofstd::unordered_map<mapnik::value, unsigned>
so I will create a PR if this behaviour isn't intended and should be fixed here.