${iServer2_ProximityParam_Title}

${iServer2_ProximityParam_Description}

        internal static string ToJson(ProximityParam proximityParam)
        {
            if (proximityParam == null)
            {
                return null;
            }
            string json = "{";
            List<string> list = new List<string>();
            StringBuilder stringBuilder = new StringBuilder();

            if (NetworkAnalystParam.ToJson(proximityParam.NetworkAnalystParam) != null)
            {
                stringBuilder.Append("\"networkAnalystParam\"");
                stringBuilder.Append(":");
                stringBuilder.Append(NetworkAnalystParam.ToJson(proximityParam.NetworkAnalystParam));
                list.Add(stringBuilder.ToString());
            }

            list.Add(string.Format("\"isFromEvent\":{0}", proximityParam.IsFromEvent));
            list.Add(string.Format("\"maxImpedance\":{0}", proximityParam.MaxImpedance));
            list.Add(string.Format("\"facilityCount\":{0}", proximityParam.FacilityCount));

            json += string.Join(",", list.ToArray());
            json += "}";
            return json;
        }
        //最近设施查找
        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);
        }