Ejemplo n.º 1
0
        private string GetTextField(object source, Layer layer)
        {
            string textSource = Helper.ProcessStoppable(source);

            if (layer.Id == "road_label" && layer.SourceLayer == "transportation_name")
            {
                return("global.ref_source");
            }

            if (textSource == "{name_en}" || textSource == "{name}")
            {
                return("global.name_source");
            }

            if (textSource.Contains("{"))
            {
                var split = textSource.Split(new[] { '{', '}' });
                if (split.Length == 1)
                {
                    return($"function() {{ return feature.{split[0]}; }}");
                }
                if (split.Length == 3)
                {
                    return($"function() {{ return \"{split[0]}\" + feature.{split[1]} + \"{split[2]}\"; }}");
                }
                if (split.Length == 5)
                {
                    return($"function() {{ return \"{split[0]}\" + feature.{split[1]} + \"{split[2]}\" + feature.{split[3]} + \"{split[4]}\"; }}");
                }

                return("?");
            }

            Converter.AppendDebug("Default TextField ignored", textSource);

            return(LayerUtils.IsRefTextLayer(layer) ? "global.ref_source" : "global.default_text_source");
        }