${iServer2_measure_MeasureParameter_Title}

${iServer2_measure_MeasureParameter_Description}

Inheritance: ParametersBase
        /// <overloads>${iServer2_measure_MeasureService_method_processAsync_overloads}</overloads>
        /// <summary>${iServer2_measure_MeasureService_method_processAsync_object_D}</summary>
        /// <param name="parameters">${iServer2_measure_MeasureService_method_processAsync_param_parameters}</param>
        /// <param name="state">${iServer2_measure_MeasureService_method_processAsync_param_state}</param>
        public void ProcessAsync(MeasureParameters parameters, object state)
        {
            if (parameters == null)
            {
                throw new ArgumentNullException(ExceptionStrings.ArgumentIsNull);
            }
            if (string.IsNullOrEmpty(this.Url))
            {
                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 line_DrawCompleted(object sender, DrawEventArgs e)
        {
            //将线标绘在客户端要素图层
            PredefinedLineStyle lineStyle = new PredefinedLineStyle { Stroke = new SolidColorBrush(Colors.Red), StrokeThickness = 3 };
            Feature feature = new Feature
                {
                    Geometry = e.Geometry,
                    Style = lineStyle
                };
            featuresLayer.Features.Add(feature);

            MeasureParameters parameters = new MeasureParameters
            {
                Geometry = e.Geometry,
                MapName = "Changchun"
            };
            MeasureService measureDistance = new MeasureService("http://localhost:7080/demo/");
            measureDistance.ProcessAsync(parameters);
            measureDistance.ProcessCompleted += new EventHandler<MeasureEventArgs>(measureDistance_ProcessCompleted);
            measureDistance.Failed += new EventHandler<ServiceFailedEventArgs>(measure_Failed);
        }
 /// <overloads>${iServer2_measure_MeasureService_method_processAsync_overloads}</overloads>
 /// <summary>${iServer2_measure_MeasureService_method_processAsync_D}</summary>
 /// <param name="parameters">${iServer2_measure_MeasureService_method_processAsync_param_parameters}</param>
 public void ProcessAsync(MeasureParameters parameters)
 {
     ProcessAsync(parameters, null);
 }
        private Dictionary<string, string> GetParameters(MeasureParameters parameters)
        {
            Dictionary<string, string> dictionary = new Dictionary<string, string>();
            Point2DCollection gps = new Point2DCollection();

            if (parameters.Geometry is GeoLine)
            {
                string method = "MeasureDistance";

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

                Dictionary<string, string> dict = new Dictionary<string, string>();
                dict.Add("mapName", parameters.MapName);
                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 GeoRegion)
            {
                string method = "MeasureArea";

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

                Dictionary<string, string> dict = new Dictionary<string, string>();
                dict.Add("mapName", parameters.MapName);
                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));

            }
            return dictionary;
        }
        //面积量算
        private void polygon_DrawCompleted(object sender, DrawEventArgs e)
        {
            //将面标绘在客户端任意图层
            PolygonElement polygon = e.Element as PolygonElement;
            polygon.Opacity = 0.618;
            polygon.StrokeThickness = 1;
            polygon.Fill = new SolidColorBrush(Colors.LightGray);
            this.elementsLayer.Children.Add(polygon);

            MeasureParameters parameters = new MeasureParameters
            {
                Geometry = e.Geometry,
                MapName = "Changchun"
            };

            //与服务器交互
            MeasureService measureRegion = new MeasureService("http://localhost:7080/demo/");
            measureRegion.ProcessAsync(parameters);
            measureRegion.ProcessCompleted += new EventHandler<MeasureEventArgs>(measureRegion_ProcessCompleted);
            measureRegion.Failed += new EventHandler<ServiceFailedEventArgs>(measure_Failed);
        }