/// <summary> /// Add a node to the layer tree /// </summary> /// <param name="nodes">The collection of the tree nodes to which the node should be added</param> /// <param name="layerDesc">The XML data for the layer node</param> private void AddLayerNode(TreeNodeCollection nodes, XmlNode layerDesc) { var layerNode = new TreeNodeView(layerDesc); nodes.Add(layerNode); // add sublayers (if any) foreach (XmlNode node in layerNode.ViewModel.LayerNodes) { AddLayerNode(layerNode.Nodes, node); } }
/// <summary> /// Get the property of the layer in the hierarchy /// </summary> /// <param name="node">The tree node that represents the layer</param> /// <param name="prop">The property name</param> /// <param name="inherit">The type of the inheritance (see WMS specification)</param> /// <returns></returns> private List <XmlNode> GetLayerProp(TreeNodeView node, string xpath, LayerInheritConstants inherit) { XmlNode layerDesc = (XmlNode)node.Tag; XmlNodeList propNodes = layerDesc.SelectNodes(xpath); List <XmlNode> retNodes = new List <XmlNode>(); foreach (XmlNode n in propNodes) { retNodes.Add(n); } if (inherit != LayerInheritConstants.No && node.Parent != null) { // trying to find the property from the parent layer if (propNodes.Count == 0 || inherit == LayerInheritConstants.Add) { retNodes.AddRange(GetLayerProp((TreeNodeView)node.Parent, xpath, inherit)); } } return(retNodes); }
private void GetLayerAttributes(TreeNodeView node) { XmlNode minx = null; XmlNode miny = null; XmlNode maxx = null; XmlNode maxy = null; NumberFormatInfo ni = new NumberFormatInfo(); ni.NumberDecimalSeparator = "."; // minscale - maxscale List <XmlNode> props = GetLayerProp(node, "MaxScaleDenominator", LayerInheritConstants.Replace); if (props.Count > 0) { wms_maxscaledenom = Convert.ToDouble(props[0].InnerText, ni); } props = GetLayerProp(node, "MinScaleDenominator", LayerInheritConstants.Replace); if (props.Count > 0) { wms_minscaledenom = Convert.ToDouble(props[0].InnerText, ni); } // Title props = GetLayerProp(node, "Title", LayerInheritConstants.No); if (props.Count > 0) { wms_title = props[0].InnerText.Trim(); } // Name props = GetLayerProp(node, "Name", LayerInheritConstants.No); if (props.Count > 0) { if (wms_name == "") { wms_name = props[0].InnerText.Trim(); } else { wms_name += "," + props[0].InnerText.Trim(); } } // queryable XmlAttribute att = ((XmlNode)node.Tag).Attributes["queryable"]; if (att != null && att.Value.Trim() == "1") { wms_queryable = "1"; } // bbox props = GetLayerProp(node, "BoundingBox|EX_GeographicBoundingBox|LatLonBoundingBox", LayerInheritConstants.Replace); if (props.Count > 0) { if (props[0].Name == "BoundingBox" || props[0].Name == "LatLonBoundingBox") { minx = props[0].Attributes["minx"]; miny = props[0].Attributes["miny"]; maxx = props[0].Attributes["maxx"]; maxy = props[0].Attributes["maxy"]; } else { minx = props[0].SelectSingleNode("westBoundLongitude"); miny = props[0].SelectSingleNode("southBoundLatitude"); maxx = props[0].SelectSingleNode("eastBoundLongitude"); maxy = props[0].SelectSingleNode("northBoundLatitude"); } } if (minx != null && miny != null && maxx != null && maxy != null) { double fminx = Convert.ToDouble(minx.InnerText, ni); double fminy = Convert.ToDouble(miny.InnerText, ni); double fmaxx = Convert.ToDouble(maxx.InnerText, ni); double fmaxy = Convert.ToDouble(maxy.InnerText, ni); if (wms_bbox == null) { wms_bbox = new rectObj(fminx, fminy, fmaxx, fmaxy, 0); } else { if (wms_bbox.minx > fminx) { wms_bbox.minx = fminx; } if (wms_bbox.miny > fminy) { wms_bbox.miny = fminy; } if (wms_bbox.maxx < fmaxx) { wms_bbox.maxx = fmaxx; } if (wms_bbox.maxy < fmaxy) { wms_bbox.maxy = fmaxy; } } } }