Right now using the mapbox-streets-v7 and mapbox-streets-v8 tile-sets querying place labels throws excpetions when parsing properties. The exception happens when the API returns duplicated keys. For example for the class property it returns both country and disputed_country.
The problematic code is in VectorTileFeatures.cs GetProperties() method
public Dictionary<string, object> GetProperties()
{
if (0 != Tags.Count % 2)
{
throw new Exception(string.Format("Layer [{0}]: uneven number of feature tag ids", _layer.Name));
}
Dictionary<string, object> properties = new Dictionary<string, object>();
int tagCount = Tags.Count;
for (int i = 0; i < tagCount; i += 2)
{
properties.Add(_layer.Keys[Tags[i]], _layer.Values[Tags[i + 1]]);
}
return properties;
}
Suggested fix:
public Dictionary<string, object> GetProperties()
{
if (Tags.Count % 2 != 0) throw new InvalidOperationException($"Layer [{_layer.Name}]: uneven number of feature tag ids");
var properties = new Dictionary<string, object>();
var tagCount = Tags.Count;
for (var i = 0; i < tagCount; i += 2)
{
var key = _layer.Keys[Tags[i]];
var value = _layer.Values[Tags[i + 1]];
if (properties.TryGetValue(key, out var oldValue))
{
if (Equals(value, oldValue))
{
continue;
}
else
{
// To work around the issue we started using this projects source directly in Unity. This logging should be different in the actual fix
UnityEngine.Debug.LogWarning($"Overriding tile property. Key: {key}, Old value: {properties[key]}, New value: {value}");
}
}
properties[key] = value;
}
return properties;
}
Right now using the
mapbox-streets-v7andmapbox-streets-v8tile-sets querying place labels throws excpetions when parsing properties. The exception happens when the API returns duplicated keys. For example for theclassproperty it returns bothcountryanddisputed_country.The problematic code is in
VectorTileFeatures.csGetProperties()methodSuggested fix: