public override bool Exexute()
        {
            ServerLayer server    = new ServerLayer(serverUrl);
            IWorkspace  workspace = GisDataHelper.OpenWorkspace(dataSourceId);

            Output = server.SaveToFeatureClass(workspace, layerName, deleteOld, clearRecord);
            return(Output != null);
        }
Example #2
0
        public void List(WebLegend tree, ServerLayer l = null, TreeNode parent = null)
        {
            if (l == null)
            {
                TreeNode tn = new TreeNode(_layer.Title);
                tn.ShowCheckBox = true;
                tn.Checked = _layer.visible;
                tn.Expand();

                if (_layer.Style != null)
                {
                    if (_layer.Style.Count() > 0)
                    {
                        if (_layer.Style[0].LegendUrl.OnlineResource.OnlineResource != "")
                        {
                            tn.ImageUrl = _layer.Style[0].LegendUrl.OnlineResource.OnlineResource;
                        }
                    }
                

                    List(tree, _layer, tn);
                }

                tree.Nodes.Add(tn);
            }
            else
            {
                //foreach (WmsServerLayer cl in l.ChildLayers)
                for (int i = l.ChildLayers.Count() - 1; i >= 0; i--)
                {
                    ServerLayer cl = l.ChildLayers[i];

                    TreeNode tn = new TreeNode(cl.Title);// + " " + cl.Name);
                    tn.ShowCheckBox = true;
                    tn.Checked = cl.visible;

                    List(tree, cl, tn);

                    tn.Expand();

                    parent.ChildNodes.Add(tn);

                }
            }
        }
Example #3
0
        public void CheckLayer(string[] keys, bool check, ServerLayer l = null)
        {
            if (keys.Count() == 0) return;

            if (l == null)
            {
                if (_layer.Title == keys[0])
                {
                    if (keys.Count() == 1)
                    {
                        if (_layer.Title == keys[0])
                        {
                            _layer.visible = check;
                            return;
                        }
                    }
                    else
                    {
                        string[] k = keysPop(keys);
                        CheckLayer(k, check, _layer);
                    }
                }
            }
            else
            {
                foreach (ServerLayer cl in l.ChildLayers)
                {

                    if (keys.Count() == 1)
                    {
                        if (cl.Title == keys[0])
                        {
                            cl.visible = check;
                            return;
                        }
                    }
                    else
                    {
                        if (cl.Title == keys[0])
                        {
                            string[] k = keysPop(keys);
                            CheckLayer(k, check, cl);
                        }
                    }
                }
            }

        }
Example #4
0
        private List<ServerLayer> GetVisibleLayer(ServerLayer layer=null,List<ServerLayer> list = null)
        {
            if (list == null)
            {
                list = new List<ServerLayer>();
            }

            if (layer == null) layer = _layer;
            
            if (layer.visible == true)
            {
                    if (layer.Name != null) list.Add(layer);

                    if (layer.ChildLayers != null)
                    {
                        foreach (ServerLayer l in layer.ChildLayers)
                        {
                            GetVisibleLayer(l, list);
                        }
                    }

            }


            return list;
        }
Example #5
0
        /// <summary>
        /// Iterates through the layer nodes recursively
        /// </summary>
        /// <param name="xmlLayer"></param>
        /// <returns></returns>
        private ServerLayer ParseLayer(XmlNode xmlLayer)
        {
            var layer = new ServerLayer();
            XmlNode node = xmlLayer.SelectSingleNode("sm:Name", _nsmgr);
            layer.Name = (node != null ? node.InnerText : null);
            node = xmlLayer.SelectSingleNode("sm:Title", _nsmgr);
            layer.Title = (node != null ? node.InnerText : null);
            node = xmlLayer.SelectSingleNode("sm:Abstract", _nsmgr);
            layer.Abstract = (node != null ? node.InnerText : null);
            XmlAttribute attr = xmlLayer.Attributes["queryable"];
            layer.Queryable = (attr != null && attr.InnerText == "1");


            XmlNodeList xnlKeywords = xmlLayer.SelectNodes("sm:KeywordList/sm:Keyword", _nsmgr);
            if (xnlKeywords != null)
            {
                layer.Keywords = new string[xnlKeywords.Count];
                for (int i = 0; i < xnlKeywords.Count; i++)
                    layer.Keywords[i] = xnlKeywords[i].InnerText;
            }

            if (Version == "1.3.0")
            {
                XmlNodeList xnlCrs = xmlLayer.SelectNodes("sm:CRS", _nsmgr);
                if (xnlCrs != null)
                {
                    layer.Crs = new string[xnlCrs.Count];
                    for (int i = 0; i < xnlCrs.Count; i++)
                        layer.Crs[i] = xnlCrs[i].InnerText;
                }
            }
            else
            {
                XmlNodeList xnlCrs = xmlLayer.SelectNodes("sm:SRS", _nsmgr);
                if (xnlCrs != null)
                {
                    layer.Crs = new string[xnlCrs.Count];
                    for (int i = 0; i < xnlCrs.Count; i++)
                        layer.Crs[i] = xnlCrs[i].InnerText;
                }
            }


            XmlNodeList xnlStyle = xmlLayer.SelectNodes("sm:Style", _nsmgr);
            if (xnlStyle != null)
            {
                layer.Style = new LayerStyle[xnlStyle.Count];
                for (int i = 0; i < xnlStyle.Count; i++)
                {
                    node = xnlStyle[i].SelectSingleNode("sm:Name", _nsmgr);
                    layer.Style[i].Name = (node != null ? node.InnerText : null);
                    node = xnlStyle[i].SelectSingleNode("sm:Title", _nsmgr);
                    layer.Style[i].Title = (node != null ? node.InnerText : null);
                    node = xnlStyle[i].SelectSingleNode("sm:Abstract", _nsmgr);
                    layer.Style[i].Abstract = (node != null ? node.InnerText : null);
                    node = xnlStyle[i].SelectSingleNode("sm:LegendUrl", _nsmgr);
                    if (node != null)
                    {
                        layer.Style[i].LegendUrl = new WmsStyleLegend();
                        layer.Style[i].LegendUrl.Width = int.Parse(node.Attributes["width"].InnerText);
                        layer.Style[i].LegendUrl.Width = int.Parse(node.Attributes["height"].InnerText);
                        layer.Style[i].LegendUrl.OnlineResource.OnlineResource =
                            node.SelectSingleNode("sm:OnlineResource", _nsmgr).Attributes["xlink:href"].InnerText;
                        layer.Style[i].LegendUrl.OnlineResource.Type =
                            node.SelectSingleNode("sm:Format", _nsmgr).InnerText;
                    }
                    node = xnlStyle[i].SelectSingleNode("sm:StyleSheetURL", _nsmgr);
                    if (node != null)
                    {
                        layer.Style[i].StyleSheetUrl = new WmsOnlineResource();
                        layer.Style[i].StyleSheetUrl.OnlineResource =
                            node.SelectSingleNode("sm:OnlineResource", _nsmgr).Attributes["xlink:href"].InnerText;
                        //layer.Style[i].StyleSheetUrl.OnlineResource = node.SelectSingleNode("sm:Format", nsmgr).InnerText;
                    }
                }
            }

            XmlNodeList xnlLayers = xmlLayer.SelectNodes("sm:Layer", _nsmgr);
            if (xnlLayers != null)
            {
                //layer.ChildLayers = new WmsServerLayer[xnlLayers.Count];

                for (int i = 0; i < xnlLayers.Count; i++)
                    layer.ChildLayers.Add(ParseLayer(xnlLayers[i]));
            }

            if (Version == "1.3.0")
            {
                XmlNode GeographicBoundingBox = xmlLayer.SelectSingleNode("sm:EX_GeographicBoundingBox", _nsmgr);
                if (GeographicBoundingBox != null)
                {
                    double minx, miny, maxx, maxy;

                    XmlNode w = GeographicBoundingBox.SelectSingleNode("sm:westBoundLongitude", _nsmgr);
                    XmlNode e = GeographicBoundingBox.SelectSingleNode("sm:eastBoundLongitude", _nsmgr);
                    XmlNode s = GeographicBoundingBox.SelectSingleNode("sm:southBoundLatitude", _nsmgr);
                    XmlNode n = GeographicBoundingBox.SelectSingleNode("sm:northBoundLatitude", _nsmgr);

                    if (!double.TryParse(w.InnerText, NumberStyles.Any, CultureInfo.InvariantCulture, out minx) &
                        !double.TryParse(s.InnerText, NumberStyles.Any, CultureInfo.InvariantCulture, out miny) &
                        !double.TryParse(e.InnerText, NumberStyles.Any, CultureInfo.InvariantCulture, out maxx) &
                        !double.TryParse(n.InnerText, NumberStyles.Any, CultureInfo.InvariantCulture, out maxy))
                        throw new ArgumentException("Invalid LatLonBoundingBox on layer '" + layer.Name + "'");

                    layer.LatLonBoundingBox = new Extent(minx, miny, maxx, maxy);
                }
            }
            else
            {
                XmlNode GeographicBoundingBox = xmlLayer.SelectSingleNode("sm:LatLonBoundingBox", _nsmgr);
                if (GeographicBoundingBox != null)
                {
                    double minx, miny, maxx, maxy;

                    if (!double.TryParse(GeographicBoundingBox.Attributes["minx"].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out minx) &
                        !double.TryParse(GeographicBoundingBox.Attributes["miny"].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out miny) &
                        !double.TryParse(GeographicBoundingBox.Attributes["maxx"].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out maxx) &
                        !double.TryParse(GeographicBoundingBox.Attributes["maxy"].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out maxy))
                        throw new ArgumentException("Invalid LatLonBoundingBox on layer '" + layer.Name + "'");

                    layer.LatLonBoundingBox = new Extent(minx, miny, maxx, maxy);
                }

            }

            if (Version == "1.3.0")
            {
                XmlNodeList CrsExtent = xmlLayer.SelectNodes("sm:BoundingBox", _nsmgr);

                if (CrsExtent != null)
                {
                    layer.CrsExtent = new Extent[layer.Crs.Count()];

                    foreach (XmlNode nd in CrsExtent)
                    {
                        string CRS = nd.Attributes["CRS"].Value;

                        double minx, miny, maxx, maxy;

                        int i = Array.IndexOf(layer.Crs, CRS);

                        if (!double.TryParse(nd.Attributes["minx"].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out minx) &
                            !double.TryParse(nd.Attributes["miny"].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out miny) &
                            !double.TryParse(nd.Attributes["maxx"].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out maxx) &
                            !double.TryParse(nd.Attributes["maxy"].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out maxy))
                            throw new ArgumentException("Invalid BoundingBox on CRS on layer '" + layer.Name + "'");

                        layer.CrsExtent[i] = new Extent(minx, miny, maxx, maxy);
                    }

                }



                XmlNode xmlMaxScaleDenominator = xmlLayer.SelectSingleNode("sm:MaxScaleDenominator", _nsmgr);
                if (xmlMaxScaleDenominator != null)
                {
                    double.TryParse(xmlMaxScaleDenominator.InnerText, out layer.MaxScaleDenominator);
                }
                else
                {
                    layer.MaxScaleDenominator = 0;
                }

                XmlNode xmlMinScaleDenominator = xmlLayer.SelectSingleNode("sm:MinScaleDenominator", _nsmgr);
                if (xmlMinScaleDenominator != null)
                {
                    double.TryParse(xmlMinScaleDenominator.InnerText, out layer.MinScaleDenominator);
                }
                else
                {
                    layer.MinScaleDenominator = 0;
                }

            }
            else
            {

                XmlNodeList CrsExtent = xmlLayer.SelectNodes("sm:BoundingBox", _nsmgr);

                if (CrsExtent != null)
                {

                    int n = layer.Crs.Count();

                    if (n <= 0) n = 1;

                    layer.CrsExtent = new Extent[n];

                    foreach (XmlNode nd in CrsExtent)
                    {
                        string CRS = nd.Attributes["SRS"].Value;

                        double minx, miny, maxx, maxy;

                        int i = Array.IndexOf(layer.Crs, CRS);

                        if (i < 0) i = 0;

                        if (!double.TryParse(nd.Attributes["minx"].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out minx) &
                            !double.TryParse(nd.Attributes["miny"].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out miny) &
                            !double.TryParse(nd.Attributes["maxx"].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out maxx) &
                            !double.TryParse(nd.Attributes["maxy"].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out maxy))
                            throw new ArgumentException("Invalid BoundingBox on CRS on layer '" + layer.Name + "'");

                        layer.CrsExtent[i] = new Extent(minx, miny, maxx, maxy);
                    }

                }

                XmlNode ScaleHint = xmlLayer.SelectSingleNode("sm:ScaleHint", _nsmgr);

                if (ScaleHint != null)
                {
                    double min, max;

                    if (!double.TryParse(ScaleHint.Attributes["min"].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out min) ||
                        !double.TryParse(ScaleHint.Attributes["max"].Value, NumberStyles.Any, CultureInfo.InvariantCulture, out max))
                    {
                        throw new ArgumentException("No hint scale on layer '" + layer.Name + "'");
                    }

                    layer.MinScaleHint = min;
                    layer.MaxScaleHint = max;
                }
            }


            return layer;
        }
Example #6
0
        /// <summary>
        /// Parses capability node
        /// </summary>
        /// <param name="xnCapability"></param>
        private void ParseCapability(XmlNode xnCapability)
        {
            XmlNode xnRequest = xnCapability.SelectSingleNode("sm:Request", _nsmgr);
            if (xnRequest == null)
                throw (new Exception("Request parameter not specified in Service Description"));
            ParseRequest(xnRequest);
            XmlNode xnLayer = xnCapability.SelectSingleNode("sm:Layer", _nsmgr);
            if (xnLayer == null)
                throw (new Exception("No layer tag found in Service Description"));
            _layer = ParseLayer(xnLayer);

            XmlNode xnException = xnCapability.SelectSingleNode("sm:Exception", _nsmgr);
            if (xnException != null)
                ParseExceptions(xnException);

            _vendorSpecificCapabilities = xnCapability.SelectSingleNode("sm:VendorSpecificCapabilities", _nsmgr);
        }
Example #7
0
        public WMSClient()
        {
            Opacity = 100;
            _layer = new ServerLayer();

        }