${IS6_BufferParam_Title}

${IS6_BufferParam_Description}

        internal static string ToJson(BufferParam param)
        {
            if (param == null)
            {
                return null;
            }
            string json = "{";
            List<string> list = new List<string>();

            list.Add(string.Format("\"distance\":{0}", param.Distance));

            list.Add(string.Format("\"fromCustomGeo\":{0}", param.FromCustomGeo.ToString().ToLower()));

            if (param.FromLayer != null)
            {
                list.Add(string.Format("\"fromLayer\":{0}", QueryLayer.ToJson(param.FromLayer)));
            }
            else
            {
                list.Add(string.Format("\"fromLayer\":null"));
            }

            //外边让用户设置Geometry,但在内部要将其转为ServerGeometry
            if (param.Geometries != null && param.Geometries.Count > 0)
            {
                List<string> temp = new List<string>();

                for (int i = 0; i < param.Geometries.Count; i++)
                {
                    temp.Add(ServerGeometry.ToJson(param.Geometries[i].ToServerGeometry()));
                }

                list.Add(string.Format("\"geometries\":[{0}]", string.Join(",", temp.ToArray())));
            }
            else
            {
                list.Add("\"geometries\":null");
            }

            list.Add(string.Format("\"queryMode\":{0}", (int)param.QueryMode));
            list.Add(string.Format("\"smoothness\":{0}", param.Smoothness));

            json += string.Join(",", list.ToArray());
            json += "}";
            return json;
        }
        //设置缓冲区查询参数
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            BufferQueryParameters parameters = new BufferQueryParameters();

            //几何对象缓冲区查询
            if (BufferQuery.IsChecked == true)
            {
                BufferParam bufferParam = new BufferParam()
                {
                    Distance = 500,
                    FromCustomGeo = true,
                    Geometries = geometries,
                    Smoothness = 12,
                    QueryMode = SpatialQueryMode.AreaIntersect,
                    ReturnBufferResult = true
                };

                QueryLayer queriedLayer = new QueryLayer();
                queriedLayer.LayerName = QueriedComboBox.SelectionBoxItem.ToString();
                QueryParam queryParam = new QueryParam() { QueryLayers = new List<QueryLayer> { queriedLayer } };
                parameters = new BufferQueryParameters() { MapName = "changchun", QueryParam = queryParam, BufferParam = bufferParam };
            }

            //地物缓冲区查询
            else
            {
                QueryLayer queryLayer = new QueryLayer();
                queryLayer.LayerName = QueryComboBox.SelectionBoxItem.ToString();
                queryLayer.WhereClause = queryText.Text;

                BufferParam bufferParam = new BufferParam()
                {
                    FromLayer = queryLayer,
                    Distance = 500,
                    FromCustomGeo = false,
                    Smoothness = 12,
                    QueryMode = SpatialQueryMode.AreaIntersect,
                    ReturnBufferResult = true
                };

                QueryLayer queriedLayer = new QueryLayer();
                queriedLayer.LayerName = QueriedComboBox.SelectionBoxItem.ToString();
                QueryParam queryParam = new QueryParam() { QueryLayers = new List<QueryLayer> { queriedLayer } };
                parameters = new BufferQueryParameters() { MapName = "changchun", QueryParam = queryParam, BufferParam = bufferParam };
            }
            BufferQueryService bufferQueryService = new BufferQueryService("http://localhost/IS/AjaxDemo");
            bufferQueryService.ProcessAsync(parameters);
            bufferQueryService.Failed += new EventHandler<ServiceFailedEventArgs>(Service_Failed);
            bufferQueryService.ProcessCompleted += new EventHandler<BufferQueryEventArgs>(bufferQueryService_ProcessCompleted);

            resultLayer.MouseLeftButtonDown += new EventHandler<FeatureMouseButtonEventArgs>(resultLayer_MouseLeftButtonDown);
        }
        private string GetQueryStr(BufferParam bufferParam, QueryParam queryParam)
        {
            if (bufferParam != null && queryParam != null)
            {
                List<string> temp = new List<string>();
                temp.Add("\"bufferDistance\":" + bufferParam.Distance.ToString(CultureInfo.InvariantCulture));
                temp.Add("\"bufferSmoothness\":" + bufferParam.Smoothness.ToString(CultureInfo.InvariantCulture));
                //temp.Add("\bufferSourceHighlight\":"+queryParam.he)
                temp.Add("\"queryMode\":" + ((int)bufferParam.QueryMode).ToString(CultureInfo.InvariantCulture));
                temp.Add("\"queryParam\":" + QueryParam.ToJson(queryParam));
                temp.Add("\"returnBufferResult\":" + bufferParam.ReturnBufferResult.ToString(CultureInfo.InvariantCulture).ToLower(CultureInfo.InvariantCulture));
                string str = "{" + string.Format("{0}", string.Join(",", temp.ToArray())) + "}";

                return str;
            }
            else
            {
                return string.Empty;
            }
        }