Ejemplo n.º 1
0
        //区分行政区
        public static void AddMapOfByXZQ(IMap inMap, string inType, string ZTMC, IMap inSourceMap, string inXZQMC)
        {
            IMapLayers inMapLayers = inMap as IMapLayers;

            if (!File.Exists(LayerXMLpath))
            {
                return;
            }
            XmlDocument cXmlDoc = new XmlDocument();

            cXmlDoc.Load(LayerXMLpath);
            if (cXmlDoc == null)
            {
                return;
            }
            string xpath = "";

            if (ZTMC == "")//规划不分年度
            {
                xpath = "//DIR[@DIRType='" + inType + "']";
            }
            else//现状分年度专题
            {
                xpath = "//DIR[@DIRType='" + inType + "' and @NodeText='" + ZTMC + "']";
            }
            XmlNode xn = cXmlDoc.SelectSingleNode(xpath);

            if (xn == null)
            {
                return;
            }
            inMap.Name = xn.Attributes["NodeText"].Value; //设置地图名称
            string xzqmc = getXIAN(inXZQMC);              //从不同级别的行政区获得县名称,以获得数据

            if (xzqmc == null)
            {
                return;
            }
            if (ZTMC != "")//区分现状和规划
            {
                string nxzq = ModGetData.AttrValueByXpath("//SpecialXZQ[@ZTMC='" + ZTMC + "']", "New");
                if (nxzq != "")
                {
                    if (nxzq.Contains(xzqmc))
                    {
                        xzqmc = ModGetData.AttrValueByXpath("//SpecialXZQ[@ZTMC='" + ZTMC + "']", "Old");
                    }

                    if (xzqmc == "")
                    {
                        return;
                    }
                }
            }
            XmlNode xnXZQ = xn.SelectSingleNode(".//DataDIR[contains(@NodeText,'" + xzqmc + "')]");

            if (xnXZQ == null)
            {
                return;
            }
            IGroupLayer gLayer = new GroupLayerClass();

            gLayer.Name = xnXZQ.Attributes["NodeText"].Value;
            XmlNodeList xnl = xnXZQ.SelectNodes(".//Layer");

            foreach (XmlNode pxn in xnl)
            {
                string nodeKey = pxn.Attributes["NodeKey"].Value;
                ILayer pLayer  = GetLayerByNodeKey(inSourceMap, nodeKey);
                if (pLayer != null)
                {
                    gLayer.Add(pLayer);
                }
            }
            if ((gLayer as ICompositeLayer).Count != 0)
            {
                if (!isExistGpLyr(inMap, gLayer.Name))
                {
                    inMapLayers.InsertLayer(gLayer as ILayer, false, inMapLayers.LayerCount);
                }
            }
            cXmlDoc = null;
        }