public OsmRelationLayer(OsmTree gt, Relation selectedRelation) : base(gt, string.Empty) { relation = selectedRelation; description = GetDesc(relation); }
public OsmLayer(OsmTree gt, string desc ) { osmTree = gt; description = "osm objects: " + desc; }
public static OsmTree ApplyFilter(OsmObjectFilter ft, OsmTree origObjects) { if (ft != null) { OsmTree newOsmTree = new OsmTree(); List<Node> nodeList = new List<Node>(); foreach (FilterRule rule in ft.Rules) { if (rule.Target == "node") { string key = rule.Selector.Substring(0, rule.Selector.IndexOf("=")); string value = rule.Selector.Substring(rule.Selector.IndexOf("=") + 1); foreach (Node node in origObjects.Nodes) { bool showNode = false; if (node.Tags != null) { foreach (Tag tag in node.Tags) { if (tag.Key == key) { if (value == "*") { showNode = true; } else if (value == tag.Value) { showNode = true; } } } } if (showNode) { Node newNode = (Node) node.Clone(); foreach (FilterTemplate template in rule.Templates) { if (template.FilterType == "dot") { // nothing to do } else if (template.FilterType == "text") { string text = string.Empty; foreach (Tag tag in node.Tags) { if (tag.Key == template.Tag) { text = tag.Value; } } newNode.DrawText += text + "\n"; } else if (template.FilterType == "icon") { newNode.DrawIcon = template.Name; } } nodeList.Add(newNode); } } } } newOsmTree.Nodes = nodeList.ToArray(); return newOsmTree; } else { return origObjects; } }
/// <summary> /// /// </summary> public void ThreadGetDataFinishedCallback() { if (this.InvokeRequired) { // Execute the same method, but this time on the GUI thread this.BeginInvoke(new Invoker(ThreadGetDataFinishedCallback) ); // we return immediately return; } if ((getDataThread.ErrorMessage != null) && (getDataThread.ErrorMessage.Length > 0)) { MessageBox.Show(getDataThread.ErrorMessage, "Scout", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (( getDataThread.Message != null) && (getDataThread.Message.Length > 0)) { MessageBox.Show(getDataThread.Message, "Scout", MessageBoxButtons.OK, MessageBoxIcon.Information); } if (getDataThread.Method == ThreadGetData.METHOD.LoadDump) { osmDumpObjects = getDataThread.OsmDumpData; } else { if (getDataThread.Layer != null) { layers.Add(getDataThread.Layer); } } } DownloadInProgress = false; Invalidate(); }