Exemplo n.º 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));
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// 深圳市道路编码
 /// </summary>
 /// <param name="pRoadLayer"></param>
 public void Coding(IFeatureLayer pRoadLayer)
 {
     try
     {
         if (pRoadLayer == null)
         {
             return;
         }
         //获取配置信息
         ptDataPool pDataPool = new ptDataPool();
         DataTable  ModelDt   = pDataPool.ModelDt;
         //根据配置信息来获取图层要素进行编码
         DataView dv = ModelDt.DefaultView;
         dv.RowFilter = string.Format("{0}='{1}'", ptColumnName.ModelType, "道路等级");
         DataTable pRoadLevel = dv.ToTable(true, new string[] { ptColumnName.ModelCode, ptColumnName.StartCode });
         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}'", ptColumnName.ModelCode, RoadLevelId));
             if (pRoadRows.Length == 0)
             {
                 continue;
             }
             //构造条件选择所有的道路
             string StrWhere = "";
             foreach (DataRow pRow in pRoadRows)
             {
                 StrWhere = StrWhere + string.Format("{0}='{1}' or ", ptColumnName.Shape_RoadLevel_SZ, pRow[ptColumnName.ModelName]);
             }
             //去掉最后的OR
             StrWhere = StrWhere.Substring(0, StrWhere.LastIndexOf("or"));
             //获取所有符合条件的要素
             //获取起点在该行政区内的所有道路线
             IList <IFeature> AllRoadLine = ptGeoFeatureBase.GetFeatures(pRoadLayer.FeatureClass, StrWhere);
             //根据排序规则,多该行政区内的所有道路线进行排序
             SortFeature SortRoad = new SortFeature(AllRoadLine);
             SortRoad.Sort();
             IList <RoadFeature> SortedRoadLine = SortRoad.m_SortedRoad;
             //根据编码规则进行编码
             RoadLineCode(SortedRoadLine, pRoadLevel.Rows[i]);
         }
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// 佛山道路编码
        /// </summary>
        /// <param name="pRoadLayer"></param>
        /// <param name="pRegionLayer"></param>
        public void Coding(IFeatureLayer pRoadLayer, IFeatureLayer pRegionLayer)
        {
            if (pRoadLayer == null || pRegionLayer == null)
            {
                return;
            }
            IFeatureClass pRoadFc   = pRoadLayer.FeatureClass;
            IFeatureClass pRegionFc = pRegionLayer.FeatureClass;
            //获取所有行政区面
            IList <IFeature> AllRegionFeatures = ptGeoFeatureBase.GetFeatures(pRegionFc);

            if (AllRegionFeatures.Count == 0)
            {
                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, "道路等级");
                    DataTable pRoadModelDt = dv.ToTable();
                    foreach (DataRow pRow in pRoadModelDt.Rows)
                    {
                        string   StrWhere       = string.Format("{0}='{1}'", ptColumnName.Shape_RoadLevel, pRow[ptColumnName.ModelName].ToString());
                        IFeature pRegionFeature = AllRegionFeatures[regionIndex];
                        //获取起点在该行政区内的所有道路线
                        IList <IFeature> AllRoadLine = ptGeoFeatureBase.GetFeatures(pRoadFc, pRegionFeature, StrWhere);
                        //根据排序规则,多该行政区内的所有道路线进行排序
                        SortFeature SortRoad = new SortFeature(AllRoadLine);
                        SortRoad.Sort();
                        IList <RoadFeature> SortedRoadLine = SortRoad.m_SortedRoad;
                        //根据编码规则进行编码
                        RoadLineCode(SortedRoadLine, pRegionFeature, pRow);
                    }
                }
            }
        }
Exemplo n.º 4
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;
            }
        }