예제 #1
0
        /// <summary>
        /// 佛山道路编码
        /// </summary>
        /// <param name="pRoadLayer"></param>
        /// <param name="pRegionLayer"></param>
        private void DoCoding(ptCodeFeautreLayer pRoadLayer, ptCodeFeautreLayer pRegionLayer)
        {
            if (pRoadLayer == null || pRegionLayer == null)
            {
                return;
            }
            IFeatureClass pRoadFc   = pRoadLayer.CodeLayer.FeatureClass;
            IFeatureClass pRegionFc = pRegionLayer.CodeLayer.FeatureClass;

            try
            {
                m_RefreshLog(string.Format("获取行政区信息"));
                //获取所有行政区面
                IList <IFeature> AllRegionFeatures = ptGeoFeatureBase.GetFeatures(pRegionFc);
                if (AllRegionFeatures.Count == 0)
                {
                    m_RefreshLog(string.Format("行政区信息获取失败"));
                    return;
                }
                ptDataPool pDataPool = new ptDataPool();
                DataTable  ModelDt   = pDataPool.ModelDt;
                for (int regionIndex = 0; regionIndex < AllRegionFeatures.Count; regionIndex++)
                {
                    if (ModelDt != null && ModelDt.Rows.Count > 0)
                    {
                        DataView dv = ModelDt.DefaultView;
                        //获取道路分级配置信息
                        dv.RowFilter = string.Format("{0}='{1}'", ptColumnName.ModelType, Enum.GetName(typeof(ModelType), ModelType.RoadLevel));
                        DataTable pRoadModelDt = dv.ToTable();
                        foreach (DataRow pRow in pRoadModelDt.Rows)
                        {
                            string StrWhere = string.Format("{0}='{1}'", pRoadLayer.LayerConfigRow[ptColumnName.LevelField], pRow[ptColumnName.ModelName].ToString());

                            IFeature pRegionFeature = AllRegionFeatures[regionIndex];
                            //获取起点在该行政区内的所有道路线
                            IList <IFeature> AllRoadLine    = ptGeoFeatureBase.GetFeatures(pRoadFc, pRegionFeature, StrWhere);
                            string           tempRegionCode = pRegionFeature.get_Value(pRegionFeature.Fields.FindField(pRegionLayer.CodeField)).ToString();
                            m_RefreshLog(string.Format("获取区域【{0}】中类型为【{1}】的要素:【{2}】", tempRegionCode,
                                                       pRow[ptColumnName.ModelName], AllRoadLine.Count));
                            //根据排序规则,多该行政区内的所有道路线进行排序
                            SortFeature SortRoad = new SortFeature(AllRoadLine);
                            SortRoad.Sort();
                            IList <RoadFeature> SortedRoadLine = SortRoad.m_SortedRoad;
                            m_RefreshLog(string.Format("完成对区域【{0}】中类型为【{1}】的要素排序", tempRegionCode, pRow[ptColumnName.ModelName]));
                            //根据编码规则进行编码
                            RoadLineCode(SortedRoadLine, pRegionFeature, pRow);
                            m_RefreshLog(string.Format("完成对区域【{0}】中类型为【{1}】的要素编码", tempRegionCode, pRow[ptColumnName.ModelName]));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                m_RefreshLog(string.Format("编码失败:{0}", ex.Message));
            }
        }
예제 #2
0
        /// <summary>
        /// 获取行政区图层
        /// </summary>
        /// <param name="dicCodeLayer"></param>
        /// <returns></returns>
        private ptCodeFeautreLayer GetLayerByRoadType(Dictionary <string, ptCodeFeautreLayer> dicCodeLayer, RoadeType sType)
        {
            ptCodeFeautreLayer pRegionLayer = null;

            foreach (string key in dicCodeLayer.Keys)
            {
                pRegionLayer = dicCodeLayer[key];
                DataRow pLayerRow    = pRegionLayer.LayerConfigRow;
                string  StrLayerType = pLayerRow[ptColumnName.RoadType].ToString();
                if (StrLayerType == Enum.GetName(typeof(RoadeType), sType))
                {
                    return(pRegionLayer);
                }
            }
            return(pRegionLayer);
        }
예제 #3
0
        /// <summary>
        /// 佛山道路编码
        /// </summary>
        /// <param name="dicCodeLayer"></param>
        public void Coding(Dictionary <string, ptCodeFeautreLayer> dicCodeLayer)
        {
            if (dicCodeLayer.Count <= 0)
            {
                m_RefreshLog(string.Format("未配置任何编码图层"));
                return;
            }
            //获取区域图层
            ptCodeFeautreLayer ptRegionLayer = GetLayerByRoadType(dicCodeLayer, RoadeType.district);

            if (ptRegionLayer == null)
            {
                m_RefreshLog(string.Format("当前未配置区域图层"));
                return;
            }
            //获取道路中心线图层
            ptCodeFeautreLayer ptRoadLineLayer = GetLayerByRoadType(dicCodeLayer, RoadeType.roadline);

            if (ptRoadLineLayer == null)
            {
                m_RefreshLog(string.Format("当前未配置道路中心线图层"));
                return;
            }
            //判断是否有道路面图层,如果有,则需要对道路面进行编码
            //暂不判断
            ptCodeFeautreLayer ptRoadPolygonLayer = GetLayerByRoadType(dicCodeLayer, RoadeType.roadformation);

            m_RefreshLog(string.Empty);
            //进行道路编码
            m_RefreshLog(string.Format("开始对图层:【{0}】进行编码", ptRoadLineLayer.LayerName));
            DoCoding(ptRoadLineLayer, ptRegionLayer);
            m_RefreshLog(string.Format("图层:【{0}】编码完成", ptRoadLineLayer.LayerName));
            m_RefreshLog(string.Empty);
            //道路面进行编码
            if (ptRoadPolygonLayer != null)
            {
            }
        }
예제 #4
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));
            }
        }
예제 #5
0
        public void Coding(Dictionary <string, ptCodeFeautreLayer> dicCodeLayer)
        {
            if (dicCodeLayer.Count <= 0)
            {
                m_RefreshLog(string.Format("未加载任何道路图层配置"));
            }
            try
            {
                //获取配置信息
                ptDataPool pDataPool = new ptDataPool();
                DataTable  ModelDt   = pDataPool.ModelDt;
                foreach (string layername in dicCodeLayer.Keys)
                {
                    m_RefreshLog(string.Empty);

                    m_RefreshLog(string.Format("开始对图层【{0}】进行编码", layername));

                    ptCodeFeautreLayer ptCodeRoadLayer = dicCodeLayer[layername];
                    IFeatureLayer      pRoadLayer      = ptCodeRoadLayer.CodeLayer;
                    //根据配置信息来获取图层要素进行编码
                    //根据道路等级进行编码
                    DataView dv = ModelDt.DefaultView;
                    dv.RowFilter = string.Format("{0}='{1}'", ptColumnName.ModelType, Enum.GetName(typeof(ModelType), ModelType.RoadLevel));
                    DataTable pRoadLevel = dv.ToTable(true, new string[] { ptColumnName.ModelCode, ptColumnName.StartCode });
                    //数据中道路等级字段,通过配置获取
                    string DataRoadLevel = ptCodeRoadLayer.LayerConfigRow[ptColumnName.LevelField].ToString();
                    if (string.IsNullOrEmpty(DataRoadLevel))
                    {
                        m_RefreshLog(string.Format("未配置图层【{0}】的道路分级字段", layername));
                        continue;
                    }

                    for (int i = 0; i < pRoadLevel.Rows.Count; i++)
                    {
                        string    RoadLevelId = pRoadLevel.Rows[i][ptColumnName.ModelCode].ToString();
                        DataRow[] pRoadRows   = ModelDt.Select(string.Format("{0}='{1}' and {2}='{3}'", ptColumnName.ModelCode, RoadLevelId,
                                                                             ptColumnName.ModelType, Enum.GetName(typeof(ModelType), ModelType.RoadLevel)));
                        if (pRoadRows.Length == 0)
                        {
                            continue;
                        }
                        //构造条件选择所有的道路
                        string StrWhere = "";
                        //日志显示信息
                        string LogStr = "";
                        foreach (DataRow pRow in pRoadRows)
                        {
                            StrWhere = StrWhere + string.Format("{0}='{1}' or ", DataRoadLevel, pRow[ptColumnName.ModelName]);
                            LogStr   = LogStr + string.Format("{0},", pRow[ptColumnName.ModelName]);
                        }
                        //去掉最后的OR
                        StrWhere = StrWhere.Substring(0, StrWhere.LastIndexOf("or"));
                        LogStr   = LogStr.Substring(0, LogStr.LastIndexOf(","));
                        //写日志
                        m_RefreshLog(string.Format("开始对图层【{0}】中类型为【{1}】的数据进行编码", layername, LogStr));
                        //获取所有符合条件的要素
                        //获取起点在该行政区内的所有道路线
                        IList <IFeature> AllRoadLine = ptGeoFeatureBase.GetFeatures(pRoadLayer.FeatureClass, StrWhere);
                        m_RefreshLog(string.Format("完成对图层【{0}】中类型为【{1}】的数据获取", layername, LogStr));
                        //根据排序规则,多该行政区内的所有道路线进行排序
                        SortFeature SortRoad = new SortFeature(AllRoadLine);
                        SortRoad.Sort();
                        m_RefreshLog(string.Format("完成对图层【{0}】中类型为【{1}】的数据排序", layername, LogStr));
                        IList <RoadFeature> SortedRoadLine = SortRoad.m_SortedRoad;
                        //根据编码规则进行编码
                        RoadLineCode(SortedRoadLine, pRoadLevel.Rows[i], ptCodeRoadLayer.CodeField);
                        m_RefreshLog(string.Format("完成对图层【{0}】中类型为【{1}】的数据编码", layername, LogStr));

                        m_RefreshLog(string.Empty);
                    }
                    m_RefreshLog(string.Format("图层【{0}】道路编码完成编码", layername));
                }
            }
            catch (Exception ex)
            {
                m_RefreshLog(string.Format("编码失败: {0}", ex.Message));
                return;
            }
        }