${iServer2_ClosestFacilityParameters_Title}

${iServer2_ClosestFacilityParameters_Description}

${iServer2_ClosestFacilityParameters_Remarks}
Inheritance: ParametersBase
        /// <summary>${iServer2_ClosestFacilityService_method_ProcessAsync_D}</summary>
        /// <param name="parameters">${iServer2_ClosestFacilityService_method_ProcessAsync_param_parameters}</param>
        /// <param name="state">${iServer2_ClosestFacilityService_method_ProcessAsync_param_state}</param>
        public void ProcessAsync(ClosestFacilityParameters parameters, object state)
        {
            if (parameters == null)
            {
                //TODO:资源
                //throw new ArgumentNullException("NetworkAnalystParameters is Null");
                throw new ArgumentNullException(SuperMap.Web.iServerJava2.Resources.ExceptionStrings.ArgumentIsNull);
            }
            if (string.IsNullOrEmpty(this.Url))
            {
                //TODO:资源
                // throw new InvalidOperationException("Url is not set");
                throw new InvalidOperationException(SuperMap.Web.iServerJava2.Resources.ExceptionStrings.InvalidUrl);
            }

            if (!base.Url.EndsWith("/"))
            {
                base.Url += '/';
            }

            base.SubmitRequest(base.Url + "commonhandler?", GetParameters(parameters),
                new EventHandler<RequestEventArgs>(request_Completed), state, false);
        }
        private System.Collections.Generic.Dictionary<string, string> GetParameters(ClosestFacilityParameters parameters)
        {
            Dictionary<string, string> dictionary = new Dictionary<string, string>();

            string method = "ClosestFacility";

            dictionary.Add("method", method);
            dictionary.Add("mapName", parameters.MapName);

            Dictionary<string, string> dict = new Dictionary<string, string>();

            dict.Add("mapName", parameters.MapName);
            dict.Add("networkSetting", NetworkModelSetting.ToJson(parameters.NetworkSetting));
            dict.Add("eventPoint", JsonHelper.FromPoint2D(parameters.EventPoint));
            dict.Add("proximityParam", ProximityParam.ToJson(parameters.ProximityParam));

            dictionary.Add("params", Bridge.CreateParams(method, dict));
            return dictionary;
        }
 /// <summary>${iServer2_ClosestFacilityService_method_ProcessAsync_D}</summary>
 /// <overloads>${iServer2_ClosestFacilityService_method_ProcessAsync_overloads_D}</overloads>
 /// <param name="parameters">${iServer2_ClosestFacilityService_method_ProcessAsync_param_parameters}</param>
 public void ProcessAsync(ClosestFacilityParameters parameters)
 {
     ProcessAsync(parameters, null);
 }
        //最近设施查找
        private void FindClosestFacility_Click(object sender, RoutedEventArgs e)
        {
            //设置权重字段列表
            WeightFieldInfo weightFieldInfo = new WeightFieldInfo { Name = "length", TFWeightField = "SmLength", FTWeightField = "SmLength" };
            List<WeightFieldInfo> list = new List<WeightFieldInfo>();
            list.Add(weightFieldInfo);

            //设置网络分析模型
            NetworkModelSetting networkModelSetting = new NetworkModelSetting
            {
                NetworkDatasetName = "RoadNet",
                NetworkDataSourceName = "changchun",
                Tolerance = 30,
                NodeIDField = "SMNODEID",
                EdgeIDField = "SmID",
                WeightFieldInfos = list,
                TNodeIDField = "SMTNODE",
                FNodeIDField = "SMFNODE",

            };

            //设置网络分析参数
            NetworkAnalystParam networkAnalystParam = new NetworkAnalystParam
            {
                Point2Ds = points,
                IsPathsReturn = true,
                WeightName = "length"
            };

            //设置最近设施查找参数
            ProximityParam proximityParam = new ProximityParam
            {
                FacilityCount = 1,
                MaxImpedance = 100000,
                NetworkAnalystParam = networkAnalystParam
            };

            //设置最近设施分析参数
            ClosestFacilityParameters paramters = new ClosestFacilityParameters
            {
                MapName = "Changchun",
                EventPoint = eventp,
                NetworkSetting = networkModelSetting,
                ProximityParam = proximityParam
            };

            //与服务器交换
            ClosestFacilityService service = new ClosestFacilityService("http://localhost:7080/demo");
            service.ProcessAsync(paramters);
            service.Failed += new EventHandler<ServiceFailedEventArgs>(service_Failed);
            service.ProcessCompleted += new EventHandler<NetworkAnalystEventArgs>(service_ProcessCompleted);
        }