private void PathAnalyst_Click(object sender, RoutedEventArgs e) { if (points.Count == 0) { MessageBox.Show("请指定服务点"); return; } //定义 Point2D 类型的参数 FindServiceAreasParameters<Point2D> paramPoint2D = new FindServiceAreasParameters<Point2D> { Centers = points, Weights = listweights, Parameter = new TransportationAnalystParameter { ResultSetting = new TransportationAnalystResultSetting { ReturnEdgeFeatures = true, ReturnEdgeGeometry = true, ReturnEdgeIDs = true, ReturnPathGuides = true, ReturnRoutes = true, }, WeightFieldName = "length", TurnWeightField = "TurnCost", } }; //与服务器交互 FindServiceAreasService findServiceAreaService = new FindServiceAreasService("http://*****:*****@Changchun"); findServiceAreaService.ProcessAsync(paramPoint2D); findServiceAreaService.ProcessCompleted += new EventHandler<FindServiceAreasEventArgs>(findServiceAreaService_ProcessCompleted); findServiceAreaService.Failed += new EventHandler<ServiceFailedEventArgs>(findServiceAreaService_Failed); }
async private void PathAnalyst_Click(object sender, RoutedEventArgs e) { if (points.Count == 0) { await MessageBox.Show("请指定服务点"); return; } if (string.IsNullOrEmpty(MyTextBox.Text)) { await MessageBox.Show("请填写服务半径"); return; } double radius; if (double.TryParse(MyTextBox.Text, out radius)) { if (radius <= 0) { await MessageBox.Show("服务半径必须大于0"); return; } } else { await MessageBox.Show("服务半径必须为数值"); return; } //listweights用来添加服务半径,list记录点,点与半径一一对应 //每次新添加的点用新添加的服务半径进行分析,以前的几个点的服务半径不变 List<double> listweights = new List<double>(); List<Point2D> list = new List<Point2D>(); for(int count=i;count<points.Count;count++) { list.Add(points[count]); listweights.Add(radius); } //记录点的个数,下次分析从此点开始进行分析,之前的点仍用原服务半径 i=points.Count; //定义 Point2D 类型的参数 FindServiceAreasParameters<Point2D> paramPoint2D = new FindServiceAreasParameters<Point2D> { Centers = list, Weights = listweights, Parameter = new TransportationAnalystParameter { ResultSetting = new TransportationAnalystResultSetting { ReturnEdgeFeatures = true, ReturnEdgeGeometry = true, ReturnEdgeIDs = true, ReturnPathGuides = true, ReturnRoutes = true, }, WeightFieldName = "length", TurnWeightField = "TurnCost", } }; //与服务器交互 try { FindServiceAreasService findServiceAreaService = new FindServiceAreasService("http://support.supermap.com.cn:8090/iserver/services/components-rest/rest/networkanalyst/RoadNet@Changchun"); var result = await findServiceAreaService.ProcessAsync(paramPoint2D); foreach (SuperMap.WinRT.REST.NetworkAnalyst.ServiceArea p in result.ServiceAreaList) { //将要素添加到图层 PredefinedFillStyle style = new PredefinedFillStyle(); style.Fill = new SolidColorBrush(Color.FromArgb(120, 179, 235, 246)); Feature area = new Feature(); area.Geometry = p.ServiceRegion; area.Style = style; featuresLayer.AddFeature(area); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void ServiceAreas_Click(object sender, RoutedEventArgs e) { FindServiceAreasParameters<int> param = new FindServiceAreasParameters<int> { Centers = new List<int> { 2, 4 }, Weights = new List<double> { 500, 1000 }, IsCenterMutuallyExclusive = false, IsFromCenter = true, Parameter = new TransportationAnalystParameter { ResultSetting = new TransportationAnalystResultSetting { ReturnEdgeFeatures = true, ReturnEdgeGeometry = true, ReturnEdgeIDs = true, //ReturnImage = false, ReturnNodeFeatures = true, ReturnNodeGeometry = true, ReturnNodeIDs = true, ReturnPathGuides = true, ReturnRoutes = true }, //MapParameter = new NAResultMapParameter //{ // Viewer = new Rect(0, 0, 256, 256), // Format = OutputFormat.PNG //}, WeightFieldName = "length", TurnWeightField = "TurnCost" } }; FindServiceAreasService serviceAreasService = new FindServiceAreasService(networkUrl); serviceAreasService.ProcessAsync(param); serviceAreasService.ProcessCompleted += new EventHandler<FindServiceAreasEventArgs>(serviceAreasService_ProcessCompleted); serviceAreasService.Failed += Failed; }