private void Button_Click_1(object sender, RoutedEventArgs e) { if (_routeLayer.Features.Count > 1) { _routeLayer.Features.RemoveAt(1); } if (string.IsNullOrEmpty(StartValue.Text) || string.IsNullOrEmpty(EndValue.Text)) { MessageBox.Show("请输入里程值!"); return; } Route route = new Route(); if (_routeLayer.Features.Count > 0) { Feature f = _routeLayer.Features[0]; route = f.Geometry as Route; } double sValue = 0; double.TryParse(StartValue.Text, out sValue); double eValue = 0; double.TryParse(EndValue.Text, out eValue); if (_routeLayer.Features.Count > 0) { Feature f = _routeLayer.Features[0]; route = f.Geometry as Route; } RouteLocatorParameters param = new RouteLocatorParameters(); param.SourceRoute = route; param.Type = LocateType.LINE; param.StartMeasure = sValue; param.EndMeasure = eValue; param.IsIgnoreGap = false; RouteLocatorService service = new RouteLocatorService(_serviceUrl); service.ProcessAsync(param); service.ProcessCompleted += new EventHandler<RouteLocatorEventArgs>(service_ProcessCompleted); service.Failed += new EventHandler<ServiceFailedEventArgs>(service_Failed); }
internal static Dictionary<string, string> ToDictionary(RouteLocatorParameters param) { Dictionary<string, string> dic = new Dictionary<string, string>(); dic.Add("sourceRoute",ServerGeometry.ToJson(param.SourceRoute.ToServerGeometry())); dic.Add("type", param.Type.ToString()); if (param.Type == LocateType.POINT) { dic.Add("measure", param.Measure.ToString(CultureInfo.InvariantCulture)); } if(param.Type==LocateType.POINT) { dic.Add("offset", param.Offset.ToString(CultureInfo.InvariantCulture)); dic.Add("isIgnoreGap", param.IsIgnoreGap.ToString(System.Globalization.CultureInfo.InvariantCulture).ToLower()); } if(param.Type==LocateType.LINE||param.Type==LocateType.LINEM) { dic.Add("startMeasure", param.StartMeasure.ToString(CultureInfo.InvariantCulture)); dic.Add("endMeasure", param.EndMeasure.ToString(CultureInfo.InvariantCulture)); } return dic; }
private void GenerateAbsoluteUrl(RouteLocatorParameters RouteLocatorPostParameter) { if ( RouteLocatorPostParameter== null) { throw new ArgumentNullException("请求服务参数为空!"); } if (this.Url.EndsWith("/")) { this.Url += "geometry/routelocator.json?debug=true&returnContent=true"; } else { this.Url += "/geometry/routelocator.json?debug=true&returnContent=true"; } //http://localhost:8090/iserver/services/spatialanalyst-changchun/restjsr/spatialanalyst/geometry/routelocator }
/// <summary>${iServerJava6R_RouteLocatorService_method_ProcessAsync_D}</summary> /// <param name="param">${iServerJava6R_RouteLocatorService_method_ProcessAsync_param_param}</param> /// <param name="state">${iServerJava6R_RouteLocatorService_method_ProcessAsync_param_state}</param> public void ProcessAsync(RouteLocatorParameters RouteLocatorPostParameter, object state) { GenerateAbsoluteUrl(RouteLocatorPostParameter); base.SubmitRequest(this.Url, GetDictionaryParameter(RouteLocatorPostParameter), new EventHandler<RequestEventArgs>(RouteLocatorService_Complated), state, true, false, false); }
/// <summary>${iServerJava6R_RouteLocatorService_method_ProcessAsync_D}</summary> /// <overloads>${iServerJava6R_RouteLocatorService_method_ProcessAsync_overloads_D}</overloads> public void ProcessAsync(RouteLocatorParameters RouteLocatorPostParameter) { ProcessAsync(RouteLocatorPostParameter,null); }
private System.Collections.Generic.Dictionary<string, string> GetDictionaryParameter(RouteLocatorParameters parameters) { return RouteLocatorParameters.ToDictionary(parameters); }
private void Button_Click_1(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(MValue.Text)) { MessageBox.Show("请输入里程值!"); return; } Route route = new Route(); if (_routeLayer.Features.Count > 0) { Feature f = _routeLayer.Features[0]; route = f.Geometry as Route; } else { MessageBox.Show("请先获取路由对象!"); return; } double mValue=0; double.TryParse(MValue.Text, out mValue); if (_routeLayer.Features.Count > 0) { Feature f = _routeLayer.Features[0]; route = f.Geometry as Route; } RouteLocatorParameters param = new RouteLocatorParameters(); param.SourceRoute = route; param.Type = LocateType.POINT; param.Measure = mValue; param.Offset = 0; param.IsIgnoreGap = false; RouteLocatorService service = new RouteLocatorService(_serviceUrl); service.ProcessAsync(param); service.ProcessCompleted += new EventHandler<RouteLocatorEventArgs>(service_ProcessCompleted); service.Failed += new EventHandler<ServiceFailedEventArgs>(service_Failed); }