Place label parsing is broken
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 45/100
Research direction
Start in VectorTileFeatures.cs at GetProperties() and reproduce the duplicate-key case with the mapbox-streets-v7 or mapbox-streets-v8 tileset. Ensure duplicate properties no longer cause parsing to throw, while uneven tag counts still report an error; adapt the warning behavior appropriately for this project rather than relying on Unity logging.
Written by the indexing model from the issue text.
Description
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;
}
- Dominant language
- C#
- Stars
- 64
- Forks
- 38
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from mapbox/vector-tile-cs
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
mapbox/vector-tile-cs#45 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
mapbox/vector-tile-cs#43 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 35/100
mapbox/vector-tile-cs#39 · 1 comment ·
-
Remove bench fixtures (have been deprecated)May be free again @wilhelmberg claimed this 3198 days ago, and no pull request is open. Open
mapbox/vector-tile-cs#38 · 1 assignee ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
mapbox/vector-tile-cs#29 · 4 comments ·
All issues in mapbox/vector-tile-cs
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
stryker-mutator/stryker-net#3892 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
MobiFlight/MobiFlight-Connector#3419 ·
Maintainers usually reply within 1 day
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Kryptos-FR/MarkView.Avalonia#105 ·
Maintainers usually reply within 1 day
-
[辞書]Open提案 辞書
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day