Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Place label parsing is broken

Aperta
#47 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
45/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
csharp
Ambito
backend

Direzione di ricerca

Inizia in VectorTileFeatures.cs, in GetProperties(), e riproduci il caso di chiavi duplicate con il tileset mapbox-streets-v7 o mapbox-streets-v8. Assicurati che le proprietà duplicate non causino più il lancio di un'eccezione durante il parsing, mentre un numero non uniforme di tag continui a segnalare un errore; adatta opportunamente il comportamento degli avvisi a questo progetto invece di affidarti al logging di Unity.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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;
}
Lingua principale
C#
Stelle
64
Fork
38
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di mapbox/vector-tile-cs

Tutte le issue di mapbox/vector-tile-cs

Issue simili

Altre issue su C#

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.