Exemplo n.º 1
0
        public override XmlElement GetRendXmlNode(XmlDocument xmlDoc, XmlElement RootXmlElement)
        {
            try
            {
                //如果有标注,则添加标注信息
                XmlElement pAnnotationElment = null;
                if (AnnotationClass.IsSingleProperty && !string.IsNullOrEmpty(AnnotationClass.PropertyName))
                {
                    pAnnotationElment = AnnotationClass.GetSymbolNode(xmlDoc);
                }
                //开始解析渲染符号信息
                for (int i = 0; i < SymbolList.Count; i++)
                {
                    XmlElement    pRuleElement = default(XmlElement);
                    ptSymbolClass pSymbolClass = SymbolList[i];
                    //生成Rule节点信息
                    pRuleElement = CommXmlHandle.CreateElement("Rule", xmlDoc);
                    pRuleElement.AppendChild(CommXmlHandle.CreateElementAndSetElemnetText("RuleName", xmlDoc, pSymbolClass.Label));
                    pRuleElement.AppendChild(CommXmlHandle.CreateElementAndSetElemnetText("Title", xmlDoc, pSymbolClass.Label));
                    if (pSymbolClass.LowerLimit != 0.00 && pSymbolClass.UpperLimit != 0.00)
                    {
                        //写条件节点
                        XmlElement pFilterElement  = CommXmlHandle.CreateElement("Filter", xmlDoc);
                        XmlElement pBetweenElement = CommXmlHandle.CreateElement("PropertyIsBetween", xmlDoc);
                        pFilterElement.AppendChild(pBetweenElement);
                        XmlElement pPropertyNameElement = CommXmlHandle.CreateElementAndSetElemnetText("PropertyName", xmlDoc, this.FieldName);
                        pBetweenElement.AppendChild(pPropertyNameElement);
                        XmlElement pLowerBoundaryElement = CommXmlHandle.CreateElement("LowerBoundary", xmlDoc);
                        pBetweenElement.AppendChild(pLowerBoundaryElement);
                        XmlElement pLowerValue = CommXmlHandle.CreateElementAndSetElemnetText("", xmlDoc, CommStaticClass.CommaToPoint(pSymbolClass.LowerLimit));
                        pLowerBoundaryElement.AppendChild(pLowerValue);

                        XmlElement pUpperElement = CommXmlHandle.CreateElement("UpperBoundary", xmlDoc);
                        pBetweenElement.AppendChild(pUpperElement);
                        XmlElement pUpperValueElement = CommXmlHandle.CreateElementAndSetElemnetText("Fieldvalue", xmlDoc, CommStaticClass.CommaToPoint(pSymbolClass.UpperLimit));
                        pUpperElement.AppendChild(pUpperValueElement);

                        pRuleElement.AppendChild(pFilterElement);
                    }
                    //设置显示比例尺
                    if (!double.IsNaN(m_ptLayer.m_MaxScale) && !double.IsNaN(m_ptLayer.m_MinScale))
                    {
                        pRuleElement.AppendChild(CommXmlHandle.CreateElementAndSetElemnetText("MinScale", xmlDoc, m_ptLayer.m_MaxScale.ToString()));
                        pRuleElement.AppendChild(CommXmlHandle.CreateElementAndSetElemnetText("MaxScale", xmlDoc, m_ptLayer.m_MinScale.ToString()));
                    }
                    //获取符号节点
                    IList <XmlElement> pSymbolizedNode = pSymbolClass.GetSymbolNode(xmlDoc);
                    foreach (XmlElement pElement in pSymbolizedNode)
                    {
                        pRuleElement.AppendChild(pElement);
                    }
                    if (pAnnotationElment != null)
                    {
                        pRuleElement.AppendChild(pAnnotationElment.CloneNode(true));
                    }
                    RootXmlElement.AppendChild(pRuleElement);
                }
            }
            catch (Exception ex)
            {
                ptLogManager.WriteMessage(string.Format("解析符号信息失败:{0}{1}{2}{3}", Environment.NewLine, ex.Message, Environment.NewLine, ex.StackTrace));
            }
            return(RootXmlElement);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 初始化符号信息
        /// </summary>
        protected override void InitialSymbol()
        {
            base.InitialSymbol();

            if (m_pUniqueRender == null || m_pFeatureLayer == null)
            {
                return;
            }
            //是否是多个字段
            bool bNoSepFieldVal = false;
            //是否是连接表
            bool bIsJoined = false;

            try
            {
                IDisplayTable pDisplayTable = m_pFeatureLayer as IDisplayTable;
                ITable        pTable        = pDisplayTable.DisplayTable;
                IDataset      objDataset    = m_FeatureClass as IDataset;
                //是否是关系表
                if (pTable is IRelQueryTable)
                {
                    bIsJoined = true;
                }

                if (FieldCount > 1)
                {
                    bNoSepFieldVal = true;
                }
                //唯一值字段有多个
                if (bNoSepFieldVal)
                {
                    //数据源为SHAPE文件
                    if (objDataset.Workspace.Type == esriWorkspaceType.esriFileSystemWorkspace)
                    {
                        for (int i = 1; i <= FieldCount; i++)
                        {
                            FieldNames.Add(m_pUniqueRender.Field[i - 1].ToLower());
                        }

                        CommStaticClass.GimmeUniqueValuesFromShape(m_FeatureClass as ITable, FieldNames);
                    }
                    //数据源为其他
                    else
                    {
                        for (int i = 1; i <= FieldCount; i++)
                        {
                            FieldNames.Add(m_pUniqueRender.Field[i - 1].ToLower());
                            //属性表有连接表
                            if (pTable is IRelQueryTable)
                            {
                                IRelQueryTable pRelQueryTable     = default(IRelQueryTable);
                                ITable         pDestTable         = default(ITable);
                                IDataset       pDataSet           = default(IDataset);
                                IList <string> alJoinedTableNames = new List <string>();
                                while (pTable is IRelQueryTable)
                                {
                                    pRelQueryTable = pTable as IRelQueryTable;
                                    pDestTable     = pRelQueryTable.DestinationTable;
                                    pDataSet       = pDestTable as IDataset;

                                    pTable = pRelQueryTable.SourceTable;
                                    alJoinedTableNames.Add(pDataSet.Name);
                                }
                                CommStaticClass.GimmeUniqeValuesForFieldname(m_FeatureClass as ITable, m_pUniqueRender.Field[i - 1], alJoinedTableNames);
                                pTable = pDisplayTable.DisplayTable;
                            }
                            //属性表没有连接表
                            else
                            {
                                CommStaticClass.GimmeUniqeValuesForFieldname(m_FeatureClass as ITable, m_pUniqueRender.Field[i - 1]);
                            }
                        }
                    }
                }
                //唯一值字段只有一个
                else
                {
                    FieldNames.Add(m_pUniqueRender.Field[FieldCount - 1].ToLower());
                }

                //开始解析符号
                for (int j = 0; j <= ValueCount - 1; j++)
                {
                    ISymbol         pSymbol      = m_pUniqueRender.get_Symbol(m_pUniqueRender.get_Value(j));
                    ptSymbolFactory pSymbolFac   = new ptSymbolFactory(pSymbol);
                    ptSymbolClass   pSymbolClass = pSymbolFac.GetSymbolClass(m_pUniqueRender.Label[m_pUniqueRender.get_Value(j)], CommStaticClass.getUVFieldValues(m_pUniqueRender, j)
                                                                             , 0, 0);
                    SymbolList.Add(pSymbolClass);
                }
            }
            catch (Exception ex)
            {
                ptLogManager.WriteMessage(string.Format("方法名称:{0}{1}{2}{3}{4}", "InitialSymbol", Environment.NewLine, ex.Message, Environment.NewLine, ex.StackTrace));
            }
        }