${iServer2_queryByGeometryParameters_Title}
${iServer2_queryByGeometryParameters_Description}
Inheritance: QueryParametersBase
        /// <summary>${iServer2_Query_QueryByGeometryService_method_ProcessAsync_D}</summary>
        /// <param name="parameters">${iServer2_Query_QueryByGeometryService_method_ProcessAsync_param_parameters}</param>
        /// <param name="state">${iServer2_Query_QueryByGeometryService_method_ProcessAsync_param_state}</param>
        public void ProcessAsync(QueryByGeometryParameters parameters, object state)
        {
            if (parameters == null)
            {
                //TODO:资源
                //throw new ArgumentNullException("QueryByGeometryParamters is Null");
                throw new ArgumentNullException(ExceptionStrings.ArgumentIsNull);
            }
            if (parameters.Geometry == null)
            {
                //TODO:资源
                //throw new InvalidOperationException("The geometry is null");
                throw new InvalidOperationException(ExceptionStrings.GeometryIsNull);
            }
            if (string.IsNullOrEmpty(base.Url))
            {
                //TODO:资源
                //throw new InvalidOperationException("Url is not set");
                throw new InvalidOperationException(ExceptionStrings.InvalidUrl);
            }

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

            base.SubmitRequest(base.Url + "commonhandler?", GetParameters(parameters),
                new EventHandler<RequestEventArgs>(request_Completed), state, false);
        }
        //设置几何查询参数类
        private void LoadParam(Geometry geo)
        {
            List<QueryLayerParam> queryLayerParams = new List<QueryLayerParam>();
            if (comboBox.SelectedIndex != 3)
            {
                //在一个图层中查询,获取要查询的图层名
                QueryLayerParam queryLayerParam = new QueryLayerParam();
                queryLayerParam.Name = comboBox.SelectionBoxItem.ToString();

                //查询图层参数列表
                queryLayerParams = new List<QueryLayerParam>() { queryLayerParam };
            }
            else
            {
                //在三个图层中查询,获取要查询的图层名
                QueryLayerParam queryLayerParamLine = new QueryLayerParam();
                queryLayerParamLine.Name = LineLayerName;
                QueryLayerParam queryLayerParamPolygon = new QueryLayerParam();
                queryLayerParamPolygon.Name = AreaLayerName;
                QueryLayerParam queryLayerParamPoint = new QueryLayerParam();
                queryLayerParamPoint.Name = PointLayerName;

                //查询图层参数列表
                queryLayerParams = new List<QueryLayerParam>()
                {   queryLayerParamPoint,
                    queryLayerParamLine,
                    queryLayerParamPolygon
                };
            }

            //设置几何查询参数类,以下属性为必设属性
            QueryByGeometryParameters parameters = new QueryByGeometryParameters
            {
                MapName = "Changchun",
                QueryParam = new QueryParam() { QueryLayerParams = queryLayerParams, ExpectCount = 0 },
                Geometry = geo
            };

            //与指定服务器交互
            QueryByGeometryService query = new QueryByGeometryService("http://localhost:7080/demo/");
            query.ProcessAsync(parameters);
            query.ProcessCompleted += new EventHandler<QueryEventArgs>(ProcessCompleted);
            query.Failed += new EventHandler<ServiceFailedEventArgs>(queryFailedMessages);
        }
 /// <overloads>${iServer2_Query_QueryByGeometryService_method_ProcessAsync_overloads_D}</overloads>
 /// <summary>${iServer2_Query_QueryByGeometryService_method_ProcessAsync_D}</summary>
 /// <param name="parameters">${iServer2_Query_QueryByGeometryService_method_ProcessAsync_param_parameters}</param>
 public void ProcessAsync(QueryByGeometryParameters parameters)
 {
     this.ProcessAsync(parameters, null);
 }
        private Dictionary<string, string> GetParameters(QueryByGeometryParameters parameters)
        {
            Dictionary<string, string> dictionary = new Dictionary<string, string>();
            Point2DCollection gps = new Point2DCollection();

            if (parameters.Geometry is GeoRegion)
            {
                string method = "QueryByPolygon";

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

                Dictionary<string, string> dict = new Dictionary<string, string>();
                dict.Add("mapName", parameters.MapName);
                dict.Add("queryParam", QueryParam.ToJson(parameters.QueryParam));

                foreach (Point2DCollection g in (parameters.Geometry as GeoRegion).Parts)
                {
                    for (int i = 0; i < g.Count; i++)
                    {
                        gps.Add(g[i]);
                    }
                }//服务端其实不支持复杂几何体的
                dict.Add("points", JsonHelper.FromPoint2DCollection(gps));

                dictionary.Add("params", Bridge.CreateParams(method, dict));

            }
            else if (parameters.Geometry is GeoCircle)
            {
                string method = "QueryByPolygon";

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

                Dictionary<string, string> dict = new Dictionary<string, string>();
                dict.Add("mapName", parameters.MapName);
                dict.Add("queryParam", QueryParam.ToJson(parameters.QueryParam));

                foreach (Point2DCollection g in (parameters.Geometry as GeoCircle).Parts)
                {
                    for (int i = 0; i < g.Count; i++)
                    {
                        gps.Add(g[i]);
                    }
                }//服务端其实不支持复杂几何体的
                dict.Add("points", JsonHelper.FromPoint2DCollection(gps));

                dictionary.Add("params", Bridge.CreateParams(method, dict));

            }
            else if (parameters.Geometry is GeoLine)
            {
                string method = "QueryByLine";

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

                Dictionary<string, string> dict = new Dictionary<string, string>();
                dict.Add("mapName", parameters.MapName);
                dict.Add("queryParam", QueryParam.ToJson(parameters.QueryParam));
                foreach (Point2DCollection g in (parameters.Geometry as GeoLine).Parts)
                {
                    for (int i = 0; i < g.Count; i++)
                    {
                        gps.Add(g[i]);
                    }
                }
                dict.Add("points", JsonHelper.FromPoint2DCollection(gps));

                dictionary.Add("params", Bridge.CreateParams(method, dict));
            }
            else if (parameters.Geometry is GeoPoint)
            {
                string method = "QueryByPoint";
                dictionary.Add("method", method);
                dictionary.Add("mapName", parameters.MapName);
                Dictionary<string, string> dict = new Dictionary<string, string>();
                dict.Add("mapName", parameters.MapName);
                dict.Add("queryParam", QueryParam.ToJson(parameters.QueryParam));
                dict.Add("point", JsonHelper.FromPoint2D((parameters.Geometry as GeoPoint).Bounds.Center));
                dict.Add("tolerance", "0");
                dictionary.Add("params", Bridge.CreateParams(method, dict));
            }

            return dictionary;
        }