示例#1
0
        public RenderingRulesMother AddLineRule()
        {
            string ruleName = counter.ToString(CultureInfo.InvariantCulture);

            PolylineTemplate template = new PolylineTemplate();

            template.Style.SetParameter("rulename", ruleName);

            List <string> colors = new List <string> ();

            colors.Add("ffffff");
            template.Style.SetParameter("colors", colors);

            currentRule = new RenderingRule(
                ruleName,
                RenderingRuleTargets.Ways,
                new OsmElementSelectorContainer(OsmElementSelectorContainerOperation.And),
                template);
            rules.AddRule(currentRule);

            counter++;
            return(this);
        }
示例#2
0
        private void ParseLineRule(IList <string> tableRowCells)
        {
            string ruleName        = GetTableRowCell(tableRowCells, 0, false, "Rule name missing");
            string selectorText    = GetTableRowCell(tableRowCells, 1, false, "Rule selector missing");
            string minLevelText    = GetTableRowCell(tableRowCells, 2, true, null);
            string maxLevelText    = GetTableRowCell(tableRowCells, 3, true, null);
            string typeName        = GetTableRowCell(tableRowCells, 4, true, null);
            string label           = GetTableRowCell(tableRowCells, 5, true, null);
            string colorsText      = GetTableRowCell(tableRowCells, 6, false, "Line colors value missing");
            string widthText       = GetTableRowCell(tableRowCells, 7, true, null);
            string borderWidthText = GetTableRowCell(tableRowCells, 8, true, null);
            string patternText     = GetTableRowCell(tableRowCells, 9, true, null);

            IOsmElementSelector osmElementSelector = ParseRuleSelector(tableRowCells[1]);

            bool lineWidthsSpecified = false;

            PolylineTemplate template = new PolylineTemplate();

            template.Style.SetParameter("rulename", ruleName);
            if (false == string.IsNullOrEmpty(minLevelText))
            {
                template.Style.MinZoomFactor = ParseLevel(minLevelText);
            }
            if (false == string.IsNullOrEmpty(maxLevelText))
            {
                template.Style.MaxZoomFactor = ParseLevel(maxLevelText);
            }
            template.Style.SetParameter("colors", ParseColors(colorsText));
            if (false == string.IsNullOrEmpty(typeName))
            {
                template.Style.SetParameter("typename", typeName);
            }
            if (false == String.IsNullOrEmpty(label))
            {
                template.Style.SetParameter("label", label);
            }
            if (false == String.IsNullOrEmpty(widthText))
            {
                lineWidthsSpecified = true;
                template.Style.SetParameter("width", ParseLineWidth(widthText));
            }
            if (false == String.IsNullOrEmpty(borderWidthText))
            {
                lineWidthsSpecified = true;
                template.Style.SetParameter("borderwidth", ParseLineWidth(borderWidthText));
            }
            if (false == String.IsNullOrEmpty(patternText))
            {
                if (lineWidthsSpecified)
                {
                    ThrowParseError("Both line widths and the line pattern are specified. These are mutually exclusive - choose one or the other");
                }

                template.Style.SetParameter("pattern", ParseLinePattern(patternText));
            }

            RenderingRule rule = new RenderingRule(ruleName, RenderingRuleTargets.Ways, osmElementSelector, template);

            rules.AddRule(rule);
        }