public RenderingRulesMother AddSelectors(string expression) { OsmElementSelectorParser parser = new OsmElementSelectorParser(); IOsmElementSelector selector = parser.Parse(expression); currentRule.Selector = selector; return(this); }
public RenderingRule(string ruleName, RenderingRuleTargets targets, IOsmElementSelector selector, IOsmObjectRenderingTemplate template) { this.ruleName = ruleName; this.targets = targets; this.selector = selector; this.template = template; }
private IOsmElementSelector ParseRuleSelector(string selectorText) { try { OsmElementSelectorParser parser = new OsmElementSelectorParser(); IOsmElementSelector selector = parser.Parse(selectorText); return(selector); } catch (Exception ex) { ThrowParseError("Could not parse the selector: '{0}'", ex.Message); return(null); // dummy } }
private void ParseAreaRule(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, "Area colors value missing"); string patternText = GetTableRowCell(tableRowCells, 7, true, null); IOsmElementSelector osmElementSelector = ParseRuleSelector(tableRowCells[1]); IList <string> colors = ParseColors(colorsText); PolygonTemplate template = new PolygonTemplate(); 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", colors); if (false == string.IsNullOrEmpty(typeName)) { template.Style.SetParameter("typename", typeName); } if (false == String.IsNullOrEmpty(label)) { template.Style.SetParameter("label", label); } if (false == String.IsNullOrEmpty(patternText)) { template.Style.SetParameter("pattern", ParseAreaPattern(patternText)); } RenderingRule rule = new RenderingRule(ruleName, RenderingRuleTargets.Areas, osmElementSelector, template); rules.AddRule(rule); }
private void ParsePointRule(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 iconText = GetTableRowCell(tableRowCells, 6, true, null); IOsmElementSelector osmElementSelector = ParseRuleSelector(tableRowCells[1]); IconTemplate template = new IconTemplate(); 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); } if (false == string.IsNullOrEmpty(typeName)) { template.Style.SetParameter("typename", typeName); } if (false == String.IsNullOrEmpty(label)) { template.Style.SetParameter("label", label); } if (false == String.IsNullOrEmpty(iconText)) { // first check if it is a Wiki link Match match = regexWikiLink.Match(iconText); if (match.Success) { string wikiLink = match.Groups["link"].Value.Trim(); // now check that the link is a local one (we are currently not supporting remote links) if (false == wikiLink.StartsWith("#", StringComparison.OrdinalIgnoreCase)) { ThrowParseError( "Currently only local links (to the same page) are supported for point patterns: '{0}'", wikiLink); } template.Style.SetParameter("patternurl", wikiLink); } else { template.Style.SetParameter("iconurl", iconText); } } // NOTE: the rule will target both OSM nodes and areas // this way we can put an icon on the conter of an area (example: place=locality) RenderingRule rule = new RenderingRule(ruleName, RenderingRuleTargets.Nodes | RenderingRuleTargets.Areas, osmElementSelector, template); rules.AddRule(rule); }
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); }
public OsmFeature(IOsmElementSelector selector) { this.selector = selector; }