/// <summary>
        /// 渲染解析
        /// </summary>
        /// <returns></returns>
        public ptLayer GetRenderLayer()
        {
            ptLayer pLayer = new ptLayer();

            if (m_FeatureRender == null && m_FeatureLayer == null)
            {
                return(pLayer);
            }
            //初始化图层基本信息
            pLayer.InitailGeneralInfo(m_FeatureLayer);
            //解析渲染方式
            ptRender pLayerRender = null;

            if (m_FeatureRender is IUniqueValueRenderer)
            {
                pLayerRender = new ptUniqueValueRendererClass(m_FeatureRender, m_FeatureLayer as IFeatureLayer);
            }
            else if (m_FeatureRender is ISimpleRenderer)
            {
                pLayerRender = new ptSimpleRendererClass(m_FeatureRender, m_FeatureLayer as IFeatureLayer);
            }
            else if (m_FeatureRender is IClassBreaksRenderer)
            {
                pLayerRender = new ptClassBreaksRendererCalss(m_FeatureRender, m_FeatureLayer as IFeatureLayer);
            }
            pLayer.m_LayerRender = pLayerRender;
            return(pLayer);
        }
Exemplo n.º 2
0
 public ptRender(IFeatureRenderer pFeatureRender, ILayer pLayer)
 {
     if (pLayer != null)
     {
         IFeatureLayer pFeatureLayer = pLayer as IFeatureLayer;
         m_FeatureClass = pFeatureLayer.FeatureClass;
         m_LayerName    = pFeatureLayer.Name;
         IDataset pds = pFeatureLayer.FeatureClass as IDataset;
         m_DatasetName   = pds.Name;
         AnnotationClass = new AnnotationClass(pFeatureLayer);
         SymbolList      = new List <ptSymbolClass>();
         m_ptLayer       = new ptLayer();
         m_ptLayer.InitailGeneralInfo(pFeatureLayer);
         m_ptLayer.m_LayerRender = this;
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 将分析的符号信息写入SLD
        /// </summary>
        /// <returns></returns>
        public bool WriteToSLD(bool SepFiles, bool IncludeLayerNames)
        {
            string         cLayerName     = "";                  //图层名称
            IList <string> objFieldValues = new List <string>(); //字段值列表
            bool           bDoOneLayer    = false;
            double         dummy          = 0;
            string         sldFileName    = "";

            if (SepFiles)
            {
                bDoOneLayer = false;
            }
            else
            {
                bDoOneLayer = true;
                sldFileName = m_cFilename;
                if (!CreateSLD(sldFileName, IncludeLayerNames))
                {
                    ptLogManager.WriteMessage(string.Format("创建SLD文件失败:{0}", sldFileName));
                    return(false);
                }
            }
            try
            {
                XmlElement pRootElment = null;
                foreach (string key in m_strDataSavings.m_LayerRender.Keys)
                {
                    #region 获取图层名称
                    string strDatasetName            = "";                         //数据集名称
                    IList <ptSymbolClass> objSymbols = new List <ptSymbolClass>(); //符号列表
                    ptLayer pLayer = m_strDataSavings.m_LayerRender[key];
                    strDatasetName = pLayer.m_LayerRender.m_DatasetName;
                    cLayerName     = pLayer.m_LayerRender.m_LayerName;
                    objSymbols     = pLayer.m_LayerRender.SymbolList;
                    ptRender pRender = pLayer.m_LayerRender;
                    #endregion
                    m_WriteLog(string.Format("正在处理图层【{0}】...", cLayerName));
                    //是否每个图层都要新建一个SLD文件
                    if (!bDoOneLayer)
                    {
                        sldFileName = m_cPath + "\\" + cLayerName + ".sld";
                        if (!CreateSLD(sldFileName, IncludeLayerNames))
                        {
                            m_WriteLog(string.Format("创建SLD文件失败:{0}", sldFileName));
                            break;
                        }
                    }
                    #region 创建基础节点
                    if (IncludeLayerNames)
                    {
                        XmlElement NameLayerelment = m_newXmlDoc.DocumentElement.AppendChild(CommXmlHandle.CreateElement("NamedLayer", m_newXmlDoc)) as XmlElement;
                        NameLayerelment.AppendChild(CommXmlHandle.CreateElementAndSetElemnetText("LayerName", m_newXmlDoc, strDatasetName));
                        XmlElement UserStyleElment = CommXmlHandle.CreateElement("UserStyle", m_newXmlDoc);
                        UserStyleElment.AppendChild(CommXmlHandle.CreateElementAndSetElemnetText("StyleName", m_newXmlDoc, "Style1"));
                        NameLayerelment.AppendChild(UserStyleElment);
                        XmlElement TypeStyleElement = CommXmlHandle.CreateElement("FeatureTypeStyle", m_newXmlDoc);
                        TypeStyleElement.AppendChild(CommXmlHandle.CreateElementAndSetElemnetText("FeatureTypeName", m_newXmlDoc, strDatasetName));
                        UserStyleElment.AppendChild(TypeStyleElement);
                        pRender.GetRendXmlNode(m_newXmlDoc, TypeStyleElement);
                    }
                    else
                    {
                        if (pRootElment == null)
                        {
                            pRootElment = m_newXmlDoc.DocumentElement.AppendChild(CommXmlHandle.CreateElement("FeatureTypeStyle", m_newXmlDoc)) as XmlElement;
                            pRootElment = pRootElment.AppendChild(CommXmlHandle.CreateElementAndSetElemnetText("FeatureTypeName", m_newXmlDoc, strDatasetName)) as XmlElement;
                            pRootElment = pRootElment.AppendChild(CommXmlHandle.CreateElementAndSetElemnetText("FeatureTypeTitle", m_newXmlDoc, strDatasetName)) as XmlElement;
                        }
                        pRender.GetRendXmlNode(m_newXmlDoc, pRootElment);
                    }
                    #endregion
                    if (bDoOneLayer == false)
                    {
                        CommXmlHandle.SaveDoc(m_newXmlDoc, sldFileName);
                    }
                }
                if (bDoOneLayer == true)
                {
                    CommXmlHandle.SaveDoc(m_newXmlDoc, sldFileName);
                }
                return(true);
            }
            catch (Exception ex)
            {
                m_WriteLog(string.Format("SLD文件写入错误:方法名称【{0}】{1}{2}{3}{4}", "WriteToSLD", Environment.NewLine, ex.Message, Environment.NewLine, ex.StackTrace));
                return(false);
            }
        }