示例#1
0
        public IRoadCode GetRoadCodeClass(CodeType pCodeType)
        {
            IRoadCode pRoadCode = null;

            switch (pCodeType)
            {
            case CodeType.SzRoadCode:
                pRoadCode = new szRoadCode(m_RefreshLog);
                break;

            case CodeType.FsRoadCode:
                pRoadCode = new FsRoadCode(m_RefreshLog);
                break;

            case CodeType.FsFacilityCode:
                pRoadCode = new FsFacilityCode(m_RefreshLog);
                break;
            }
            return(pRoadCode);
        }
示例#2
0
        /// <summary>
        /// 开始编码
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDoCoding_Click(object sender, EventArgs e)
        {
            //清空日志信息
            txtLog.Text = string.Empty;

            if (m_MainMap == null)
            {
                RefreshLog(string.Format("无法获取地图文档"));
                return;
            }
            else if (m_MainMap.LayerCount <= 0)
            {
                RefreshLog(string.Format("当前地图未加载任何图层"));
                return;
            }
            try
            {
                //读取配置信息
                ReadDbConfig();
                //根据编码类型获取相应的配置信息,并进行编码
                if (m_DtCodeRule == null || m_DtLayerConfig == null)
                {
                    return;
                }
                string RowFilter = "";
                switch (m_RoadCodeType)
                {
                case CodeType.SzRoadCode:
                    RowFilter = string.Format("{0}='{1}'", ptColumnName.CodeType, Enum.GetName(typeof(CodeType), CodeType.SzRoadCode));
                    break;

                case CodeType.FsRoadCode:
                    RowFilter = string.Format("{0}='{1}'", ptColumnName.CodeType, Enum.GetName(typeof(CodeType), CodeType.FsRoadCode));
                    break;

                case CodeType.FsFacilityCode:
                    RowFilter = string.Format("{0}='{1}'", ptColumnName.CodeType, Enum.GetName(typeof(CodeType), CodeType.FsRoadCode));
                    break;
                }
                DataRow[] CodeLayers = m_DtCodeRule.Select(RowFilter);
                if (CodeLayers.Length <= 0)
                {
                    RefreshLog(string.Format("当前未配置编码图层"));
                    return;
                }
                Dictionary <string, ptCodeFeautreLayer> pCodeLayers = new Dictionary <string, ptCodeFeautreLayer>();
                //查找编码图层
                for (int i = 0; i < CodeLayers.Length; i++)
                {
                    string        StrLayerName = CodeLayers[i][ptColumnName.CodeLayer].ToString();
                    IFeatureLayer pTempLayer   = GetLayerByName(StrLayerName);
                    if (pTempLayer != null)
                    {
                        DataRow[] pTempRows = m_DtLayerConfig.Select(string.Format("{0}='{1}'", ptColumnName.LayerName, StrLayerName));
                        if (pTempRows.Length <= 0)
                        {
                            RefreshLog(string.Format("未能加载图层:【{0}】相关配置信息", StrLayerName));
                            return;
                        }
                        //判断配置的编码字段,是否存在于数据中
                        if (pTempLayer.FeatureClass.FindField(pTempRows[0][ptColumnName.CodeField].ToString()) < 0)
                        {
                            RefreshLog(string.Format("未能在加载图层:【{0}】中找到配置的编码字段【{1}】", StrLayerName, pTempRows[0][ptColumnName.CodeField]));
                            continue;
                        }
                        ptCodeFeautreLayer pptLayer = new ptCodeFeautreLayer();
                        pptLayer.CodeLayer      = pTempLayer;
                        pptLayer.LayerName      = StrLayerName;
                        pptLayer.RoadType       = pTempRows[0][ptColumnName.RoadType].ToString();
                        pptLayer.CodeField      = pTempRows[0][ptColumnName.CodeField].ToString();
                        pptLayer.LayerConfigRow = pTempRows[0];
                        pCodeLayers.Add(StrLayerName, pptLayer);
                    }
                    else
                    {
                        RefreshLog(string.Format("当前地图未加载图层:{0}", StrLayerName));
                        return;
                    }
                }
                if (RoadCodeLog == null)
                {
                    RoadCodeLog = RefreshLog;
                }

                ptRoadCodeFactory RoadCodeFac = new ptRoadCodeFactory(RoadCodeLog);
                IRoadCode         pRoadCode   = RoadCodeFac.GetRoadCodeClass(m_RoadCodeType);
                if (pRoadCode != null)
                {
                    pRoadCode.Coding(pCodeLayers);
                }
            }
            catch (Exception ex)
            {
                RefreshLog(string.Format("编码失败:{0}", ex.Message));
            }
        }