public void UpdateRoads()
        {
            string           filePath   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config/mapbar.xml");
            List <CityModel> cityModels = CityURLConfig.GetInstance(filePath).cityURLConfig.cityModels;

            filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config/mapbarCityRoadConfig.xml");
            List <CityRoad> cityRoads = CityRoadConfig.GetInstance(filePath).cityRoadConfig.cityRoadList;

            cityRoads.Clear();
            k     = 0;
            count = cityModels.Count;
            foreach (CityModel mode in cityModels)
            {
                k++;
                string   url  = mode.URL;
                CityRoad road = GetRoadsByCityName(url, mode.name, cityModels.Count);
                road.cityName = mode.name.TrimEnd(new char[] { '地', '图' });
                cityRoads.Add(road);
                CityRoadConfig.GetInstance().SaveConfig();
            }
            if (this.cityRoadLoadLog != null)
            {
                string log     = "下载完成";
                int    process = 100;
                this.cityRoadLoadLog(log, process);
            }
        }
Esempio n. 2
0
        public void UpdateRoads()
        {
            List <CityModel> cityModels = CityURLConfig.GetInstance().cityURLConfig.cityModels;
            List <CityRoad>  cityRoads  = CityRoadConfig.GetInstance().cityRoadConfig.cityRoadList;

            cityRoads.Clear();
            k     = 0;
            count = cityModels.Count;
            foreach (CityModel mode in cityModels)
            {
                k++;
                string   url  = mode.URL;
                CityRoad road = GetRoadsByCityName(url, mode.name, cityModels.Count);
                road.cityName = mode.name.TrimEnd(new char[] { '地', '图' });
                cityRoads.Add(road);
                //CityURLConfig.GetInstance().saveConfig();
                CityRoadConfig.GetInstance().SaveConfig();
            }
            if (this.cityRoadLoadLog != null)
            {
                string log     = "下载完成";
                int    process = 100;
                this.cityRoadLoadLog(log, process);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 根据城市名称下载道路
        /// </summary>
        /// <param name="cityName">城市名称</param>
        public void downLoadRoadsByCityName(string cityName)
        {
            string        code      = this.getCodeByCityName(cityName);
            List <string> roadNames = CityRoadConfig.GetInstance().GetRoadNamesByCityName(cityName);

            if (roadNames.Count == 0)
            {
                System.Windows.Forms.MessageBox.Show("没有" + cityName + "的道路信息,等待后续路网库更新");
            }
            this.DownLoadRoads(code, roadNames);
        }
Esempio n. 4
0
        public List <string> getCityRoads(string cityName)
        {
            List <CityRoad> cityRoads = CityRoadConfig.GetInstance().cityRoadConfig.cityRoadList;

            foreach (CityRoad road in cityRoads)
            {
                if (road.cityName == cityName)
                {
                    return(road.Roads);
                }
            }
            return(new List <string>());
        }
        public List <string> getCityRoads(string cityName)
        {
            string          filePath  = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config/mapbarCityRoadConfig.xml");
            List <CityRoad> cityRoads = CityRoadConfig.GetInstance(filePath).cityRoadConfig.cityRoadList;

            foreach (CityRoad road in cityRoads)
            {
                if (road.cityName == cityName)
                {
                    return(road.Roads);
                }
            }
            return(new List <string>());
        }
Esempio n. 6
0
 /// <summary>
 /// 获取配置信息(单例模式)
 /// </summary>
 /// <returns></returns>
 public static CityRoadConfig GetInstance(string configPath = "")
 {
     return(instance ?? (instance = new CityRoadConfig(configPath)));
 }
Esempio n. 7
0
        public void downLoadRoadCrossByCityName(string cityName)
        {
            string        code      = this.getCodeByCityName(cityName);
            List <string> roadNames = CityRoadConfig.GetInstance().GetRoadNamesByCityName(cityName);

            if (roadNames.Count == 0)
            {
                System.Windows.Forms.MessageBox.Show("没有" + cityName + "的道路信息,等待后续路网库更新");
            }
            int i = 0;

            foreach (string name in roadNames)
            {
                i++;
                int    index    = i % this.keys.Length;
                string realName = name;
                if (name.Contains("-"))
                {
                    realName = realName.Split('-')[1];
                }
                string tempUrl = string.Format(urlCross, code, keys[index], realName);
                string context = HttpHelper.GetRequestContent(tempUrl);
                if (string.IsNullOrEmpty(context))
                {
                    continue;
                }
                object t = JsonHelper.JsonDeserialize <object>(context);
                Dictionary <string, object> dicRoot = t as Dictionary <string, object>;
                if (dicRoot != null && dicRoot["status"].ToString() == "1")
                {
                    object[] roadsObjs = dicRoot["roadinters"] as object[];
                    if (roadsObjs != null && roadsObjs.Length > 0)
                    {
                        for (int j = 0; j < roadsObjs.Length; j++)
                        {
                            Dictionary <string, object> dicRoadCross = roadsObjs[j] as Dictionary <string, object>;
                            if (dicRoadCross != null)
                            {
                                RoadCrossModel roadCrossModel = new RoadCrossModel();
                                roadCrossModel.id = dicRoadCross["id"] != null ? dicRoadCross["id"].ToString() : "";
                                //roadCrossModel.first_id = dicRoadCross["first_id"] != null
                                //                              ? dicRoadCross["first_id"].ToString()
                                //                              : "";
                                roadCrossModel.first_name = dicRoadCross["first_name"] != null
                                                                ? dicRoadCross["first_name"].ToString()
                                                                : "";
                                //roadCrossModel.second_id = dicRoadCross["second_id"] != null
                                //                               ? dicRoadCross["second_id"].ToString()
                                //                               : "";
                                roadCrossModel.second_name = dicRoadCross["second_name"] != null
                                                                 ? dicRoadCross["second_name"].ToString()
                                                                 : "";
                                string localtionXY = dicRoadCross["location"] != null
                                                         ? dicRoadCross["location"].ToString()
                                                         : "";
                                string[] xy = localtionXY.Split(',');
                                if (xy.Length == 2)
                                {
                                    double.TryParse(xy[0], out roadCrossModel.x);
                                    double.TryParse(xy[1], out roadCrossModel.y);

                                    var coor = CoordHelper.Gcj2Wgs(roadCrossModel.x, roadCrossModel.y);
                                    roadCrossModel.wgs_x = coor.lon;
                                    roadCrossModel.wgs_y = coor.lat;
                                }
                                if (roadCrossModel.x > 0 && roadCrossModel.y > 0)
                                {
                                    if (this.roadCrossDowningHandler != null)
                                    {
                                        this.roadCrossDowningHandler(roadCrossModel, i, roadNames.Count);
                                    }
                                }
                            }
                        }
                    }
                }
                System.Threading.Thread.Sleep(50);
            }
            if (this.downOverHandler != null)
            {
                this.downOverHandler();
            }
        }