/// <summary>${iServer2_Query_QueryByCenterService_method_ProcessAsync_D}</summary> /// <param name="parameters">${iServer2_Query_QueryByCenterService_method_ProcessAsync_param_parameters}</param> /// <param name="state">${iServer2_Query_QueryByCenterService_method_ProcessAsync_param_state}</param> public void ProcessAsync(QueryByCenterParameters parameters, object state) { if (parameters == null) { //TODO:资源 //throw new ArgumentNullException("QueryByCenterParameters"); throw new ArgumentNullException(ExceptionStrings.ArgumentIsNull); } if (parameters.CenterPoint.IsEmpty) { //TODO:资源 //throw new InvalidOperationException("CenterPoint is Empty"); throw new InvalidOperationException(ExceptionStrings.CenterPointIsEmpty); } 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 point_DrawCompleted(object sender, DrawEventArgs e) { QueryByCenterParameters parameters = new QueryByCenterParameters { CenterPoint = e.Geometry.Bounds.Center, Tolerance = 5, MapName = "Changchun", QueryParam = new QueryParam { QueryLayerParams = new List<QueryLayerParam>() { qlpVegetable } } }; QueryByCenterService query = new QueryByCenterService("http://localhost:7080/demo"); query.ProcessAsync(parameters); query.Failed += (s, args) => { MessageBox.Show(args.Error.ToString()); }; query.ProcessCompleted += new EventHandler<QueryEventArgs>(query_ProcessCompleted); }
private void selectEntity_DrawCompleted(object sender, DrawEventArgs e) { //如果存在编辑过的地物,则不显示编辑过的地物 if (Editflag == true) { drawLayer.ClearFeatures(); dgVegetable.Visibility = Visibility.Collapsed; Editflag = false; } //查询鼠标点击处地物 QueryByCenterParameters parameters = new QueryByCenterParameters { CenterPoint = e.Geometry.Bounds.Center, Tolerance = 5, MapName = "Changchun", IsNearest = true, QueryParam = new QueryParam { QueryLayerParams = new List<QueryLayerParam>() { qureyLayerParam } } }; QueryByCenterService selectQuery = new QueryByCenterService("http://localhost:7080/demo"); selectQuery.ProcessAsync(parameters); selectQuery.Failed += (s, args) => { MessageBox.Show(args.Error.ToString()); }; selectQuery.ProcessCompleted += new EventHandler<QueryEventArgs>(selectQuery_ProcessCompleted); }
//中心点查询功能查询地物 private void queryEntity(SuperMap.Web.Core.Geometry entity) { QueryByCenterParameters parameters = new QueryByCenterParameters { CenterPoint = entity.Bounds.Center, Tolerance = 5, MapName = "Changchun", IsNearest = true, QueryParam = new QueryParam { QueryLayerParams = new List<QueryLayerParam>() { qureyLayerParam } } }; QueryByCenterService query = new QueryByCenterService("http://localhost:7080/demo"); query.ProcessAsync(parameters); query.Failed += (s, args) => { MessageBox.Show(args.Error.ToString()); }; query.ProcessCompleted += new EventHandler<QueryEventArgs>(query_ProcessCompleted); }
private void residential_Click(object sender, RoutedEventArgs e) { DrawPoint point = new DrawPoint(MyMap); MyMap.Action = point; point.DrawCompleted += (s2, e2) => { QueryByCenterParameters parameters = new QueryByCenterParameters { CenterPoint = e2.Geometry.Bounds.Center, Tolerance = 5, MapName = "Changchun", QueryParam = new QueryParam { QueryLayerParams = new List<QueryLayerParam>() { qlpResidentialArea } } }; QueryByCenterService query = new QueryByCenterService("http://localhost:7080/demo"); query.ProcessAsync(parameters); query.Failed += (s, args) => { MessageBox.Show(args.Error.ToString()); }; query.ProcessCompleted += (s3, e3) => { if (e3.ResultSet == null) { MessageBox.Show("No Result!"); return; } sgResidentialArea = e3.ResultSet.RecordSets[0].Records[0].Shape; FeatureCollection fc = e3.ResultSet.RecordSets[0].ToFeatureSet(); Feature f = new Feature { Geometry = fc[0].Geometry, Style = this.RedFillStyle }; paramLayer.Features.Add(f); }; }; }
/// <overloads>${iServer2_Query_QueryByCenterService_method_ProcessAsync_overloads_D}</overloads> /// <summary>${iServer2_Query_QueryByCenterService_method_ProcessAsync_D}</summary> /// <param name="parameters">${iServer2_Query_QueryByCenterService_method_ProcessAsync_param_parameters}</param> public void ProcessAsync(QueryByCenterParameters parameters) { ProcessAsync(parameters, null); }
private Dictionary<string, string> GetParameters(QueryByCenterParameters parameters) { Dictionary<string, string> dictionary = new Dictionary<string, string>(); string method = parameters.IsNearest ? "FindNearest" : "QueryByPoint";// queryByCircle 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.CenterPoint)); dict.Add("tolerance", parameters.Tolerance.ToString()); dictionary.Add("params", Bridge.CreateParams(method, dict)); return dictionary; }
//中心点查询 private void point_DrawCompleted(object sender, DrawEventArgs e) { 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 queryLayerParamPoint = new QueryLayerParam(); queryLayerParamPoint.Name = PointLayerName; QueryLayerParam queryLayerParamLine = new QueryLayerParam(); queryLayerParamLine.Name = LineLayerName; QueryLayerParam queryLayerParamPolygon = new QueryLayerParam(); queryLayerParamPolygon.Name = AreaLayerName; //查询图层参数列表 queryLayerParams = new List<QueryLayerParam>() { queryLayerParamPoint, queryLayerParamLine, queryLayerParamPolygon }; } //将文本中读取的容限值转换为Double类型,如果值为0则将其设为100 double tolerance; if (!double.TryParse(MyTextBox.Text, out tolerance)) { tolerance = 100; } //设置中心点查询参数,其中四个属性都为必设属性 QueryByCenterParameters parameters = new QueryByCenterParameters { CenterPoint = e.Geometry.Bounds.Center, Tolerance = tolerance, MapName = "Changchun", // ExceptCount属性小于等于0时表示返回全部查询结果 QueryParam = new QueryParam { QueryLayerParams = queryLayerParams, ExpectCount =1000 } }; //是否查找最近地物 if (FindNearest.IsChecked == true) { parameters.IsNearest = true; } //与指定服务器交互 QueryByCenterService queryByCenterService = new QueryByCenterService("http://localhost:7080/demo"); queryByCenterService.ProcessAsync(parameters); queryByCenterService.Failed += new System.EventHandler<ServiceFailedEventArgs>(queryByCenterService_Failed); queryByCenterService.ProcessCompleted += new System.EventHandler<QueryEventArgs>(queryByCenterService_ProcessCompleted); }