예제 #1
0
        private static BoundingBox ChooseBoundingBox(this Layer layer, ISpatialReference mapProjection)
        {
            // can be used to double check, but there is little use of it we don't have bounds in particular projection
            //foreach (var crs in layer.SRS)
            //{
            //    if (ParseEpsg(crs, ref epsg))
            //    {
            //        yield return epsg;
            //    }
            //}

            if (mapProjection == null)
            {
                return(layer.BoundingBox.FirstOrDefault());
            }

            foreach (var box in layer.BoundingBox)
            {
                if (IsSameProjection(box, mapProjection))
                {
                    return(box);
                }
            }

            return(layer.BoundingBox.FirstOrDefault());
        }
예제 #2
0
 private static TreeNode FindNodeByLayer(IEnumerable nodes, Layer layer)
 {
     foreach (TreeNode node in nodes)
     {
         if (node.Tag == layer) return node;
         var ch = FindNodeByLayer(node.Nodes, layer);
         if (ch != null) return ch;
     }
     return null;
 }
예제 #3
0
 public WmsInfo(string serverUrl, WmsCapabilities wmsCapabilities, Layer layer, Dictionary<string, string> customParameters,
     string crs, ProjectionInfo projectionInfo, string style, NetworkCredential credentials)
 {
     Credentials = credentials;
     CustomParameters = customParameters;
     CRS = crs;
     CrsProjectionInfo = projectionInfo;
     Style = style;
     Layer = layer;
     WmsCapabilities = wmsCapabilities;
     ServerUrl = serverUrl;
 }
예제 #4
0
파일: Capability.cs 프로젝트: bertt/BruTile
        public Capability(XElement node, string @namespace)
        {
            var element = node.Element(XName.Get("Request", @namespace));
            if (element == null)
                throw WmsParsingException.ElementNotFound("Request");
            Request = new Request(element, @namespace);

            foreach (var el in node.Elements())
            {
                if (el.Name.LocalName == "Request" || el.Name.LocalName == "Layer")
                    continue;

                if (el.Name.LocalName == "Exception")
                {
                    Exception.Add(el.Value);
                    continue;
                }

                ExtendedCapabilities.Add(el.Name, el);
            }

            if (Exception.Count == 0)
                throw WmsParsingException.ElementNotFound("Exception");

            bool baseNodeCreated = false;
            foreach (var layerNode in node.Elements(XName.Get("Layer", @namespace)))
            {
                var layer = new Layer(layerNode, @namespace);
                if (_layerField == null)
                {
                    _layerField = layer;
                }

                else if (_layerField != null && !baseNodeCreated)
                {
                    var tmpLayer = new Layer { Title = "Root Layer" };
                    tmpLayer.ChildLayers.Add(Layer);
                    tmpLayer.ChildLayers.Add(layer);
                    Layer = tmpLayer;
                    baseNodeCreated = true;
                }
                else
                {
                    _layerField.ChildLayers.Add(layer);
                }
            }
        }
예제 #5
0
 private static void FillTree(TreeNodeCollection collection, Layer root)
 {
     var node = new TreeNode(root.Title) { Tag = root };
     collection.Add(node);
     foreach (var childLayer in root.ChildLayers)
     {
         FillTree(node.Nodes, childLayer);
     }
 }
예제 #6
0
파일: Capability.cs 프로젝트: bertt/BruTile
        public override void ReadXml(XmlReader reader)
        {
            if (CheckEmptyNode(reader, "Capability", string.Empty, true))
                throw WmsParsingException.ElementNotFound("Capability");

            bool baseLayerCreated = false;

            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    switch (reader.LocalName)
                    {
                        case "Request":
                            _requestField = new Request();
                            _requestField.ReadXml(reader.ReadSubtree());
                            break;

                        case "Exception":
                            if (_exceptionField == null)
                                _exceptionField = new List<string>();
                            var subReader = reader.ReadSubtree();
                            while (!subReader.EOF)
                            {
                                reader.ReadStartElement("Format");
                                var format = reader.ReadContentAsString();
                                reader.ReadEndElement();
                                _exceptionField.Add(format);
                            }
                            break;
                        case "Layer":
                            if (_layerField == null)
                            {
                                _layerField = new Layer();
                                _layerField.ReadXml(reader);
                            }
                            else
                            {
                                if (!baseLayerCreated)
                                {
                                    var tmp = _layerField;
                                    _layerField = new Layer();
                                    _layerField.Name = _layerField.Title = "Created base layer";
                                    _layerField.ChildLayers.Add(tmp);
                                    baseLayerCreated = true;
                                }
                                var layer = new Layer();
                                layer.ReadXml(reader);
                                _layerField.ChildLayers.Add(layer);
                            }
                            break;

                        default:
                            ExtendedCapabilities.Add(XName.Get(reader.LocalName, reader.NamespaceURI), XNode.ReadFrom(reader));
                            break;
                    }
                }
                else
                {
                    reader.Read();
                }
            }
        }