Ejemplo n.º 1
0
        private void CreateDrawLines(string type, bool isCasing)
        {
            AppendLine("draw:");
            _indent++;



            if (Color != null)
            {
                int  colorStringLength = 0;
                bool forceBlended      = LayerUtils.IsBlendedLayer(LayerWithSource.Id);
                if (!forceBlended)
                {
                    if (!Color.Contains(","))
                    {
                        colorStringLength = Color.Length;
                    }
                    else
                    {
                        // todo split this kind of thing to get the length of the color strings inside.  "[[5,'#F2934A'],[6,'#fc8']]"
                    }
                }

                if (forceBlended || colorStringLength > 7)             // i.e. longer than #FFFFFF so it has an A component.
                {
                    if (type == "polygons")
                    {
                        type = "polys-blended";
                    }
                    else if (type == "lines")
                    {
                        type = "lines-blended";
                    }
                }
            }

            AppendLine(type + ":");
            _indent++;

            if (type != TangramText)
            {
                AppendLine("order: " + LayerUtils.GetLayerOrder(LayerWithSource, isCasing || Outline != null));
            }
            else
            {
                AppendLine("priority: " + LayerUtils.GetTextLayerPriority(LayerWithSource));
            }

            //if (LayerWithSource.Id.StartsWith("road"))
            // AppendLine("collide: false");

            if (Outline != null)
            {
                AppendLine("outline:");
                _indent++;
                if (Outline.Width != null)
                {
                    AppendLine("width: " + Outline.Width);
                }
                if (Outline.Color != null)
                {
                    AppendLine("color: " + Outline.Color);
                }
                _indent--;
            }

            if (Color != null)
            {
                AppendLine("color: " + Color);
            }
            //AppendLine("color: " + (!isCasing ? Color : "'#FF0000'"));
            if (Width != null)
            {
                AppendLine("width: " + Width);
            }

            if (!isCasing)
            {
                if (Join != null)
                {
                    AppendLine("join: " + Join);
                }
                if (Cap != null && !LayerWithSource.Id.StartsWith("bridge"))
                {
                    AppendLine("cap: " + Cap);
                }
            }

            if (Font != null && type != TangramIcons)
            {
                AppendFont();
            }

            if (Sprite != null && !Sprite.Contains("motorway-exit"))
            {
                AppendLine("sprite: " + Sprite);

                //AppendLine("blend_order: 1");
                //AppendLine("priority: 21");
                //AppendLine("order: 100");
                //AppendLine("size: 24px");

                bool preciseIcon = Sprite.Contains("dot");

                AppendLine("collide: false");
                if (!preciseIcon)
                {
                    AppendLine("anchor: top");
                }

                _indent--;

                if (type == TangramIcons && Sprite != null)
                {
                    DrawIconText(preciseIcon);
                }
            }
            else if (type == TangramIcons && Font != null)
            {
                _indent--;
                DrawIconText(false);
                _indent++;
            }


            _indent--;
        }