private void ExecuteRelationButton_Click(object sender, System.Windows.RoutedEventArgs e) { MyDrawObject.IsEnabled = false; ExecuteRelationButton.Visibility = Visibility.Collapsed; geometryService = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); geometryService.RelationCompleted += GeometryService_RelationCompleted; geometryService.SimplifyCompleted += GeometryService_SimplifyCompleted; geometryService.Failed += GeometryService_Failed; if (pointLayer.Graphics.Count < 1) { MessageBox.Show("No points available"); ExecuteRelationButton.Visibility = Visibility.Visible; return; } foreach (Graphic graphic in pointLayer.Graphics) { graphic.Attributes["Relation"] = null; } foreach (Graphic graphic in polygonLayer.Graphics) { graphic.Attributes["Relation"] = null; } // Call simplify operation to correct orientation of rings in a polygon (clockwise = ring, counterclockwise = hole) geometryService.SimplifyAsync(polygonLayer.Graphics); }
private void ExecuteRelationButton_Click(object sender, System.Windows.RoutedEventArgs e) { MyDrawObject.IsEnabled = false; ExecuteRelationButton.Visibility = Visibility.Collapsed; geometryService = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); geometryService.RelationCompleted += GeometryService_RelationCompleted; geometryService.SimplifyCompleted += GeometryService_SimplifyCompleted; geometryService.Failed += GeometryService_Failed; if (pointLayer.Graphics.Count < 1) { MessageBox.Show("No points available"); ExecuteRelationButton.Visibility = Visibility.Visible; return; } foreach (Graphic graphic in pointLayer.Graphics) graphic.Attributes["Relation"] = null; foreach (Graphic graphic in polygonLayer.Graphics) graphic.Attributes["Relation"] = null; // Call simplify operation to correct orientation of rings in a polygon (clockwise = ring, counterclockwise = hole) geometryService.SimplifyAsync(polygonLayer.Graphics); }
private void SimplifyAndQueryButton_Click(object sender, RoutedEventArgs e) { GeometryService geometryService = new GeometryService("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); geometryService.SimplifyCompleted += GeometryService_SimplifyCompleted; geometryService.Failed += GeometryService_Failed; List <Graphic> graphicList = new List <Graphic>(); graphicList.Add(_unsimplifiedGraphic); geometryService.SimplifyAsync(graphicList); }
private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args) { MyDrawObject.IsEnabled = false; ESRI.ArcGIS.Client.Geometry.Polygon intersectPolygon = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polygon; intersectPolygon.SpatialReference = MyMap.SpatialReference; List <Graphic> graphicList = new List <Graphic>(); graphicList.Add(new Graphic() { Geometry = intersectPolygon }); geometryService.SimplifyAsync(graphicList); }
private void MyDrawObject_DrawComplete(object sender, DrawEventArgs args) { MyDrawObject.IsEnabled = false; ESRI.ArcGIS.Client.Geometry.Polygon polygon = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polygon; polygon.SpatialReference = MyMap.SpatialReference; geometryService.SimplifyAsync(new List <Graphic>() { new Graphic() { Geometry = polygon } }); }
private void MyDrawObject_DrawComplete(object sender, ESRI.ArcGIS.Client.DrawEventArgs args) { MyDrawObject.IsEnabled = false; ESRI.ArcGIS.Client.Geometry.Polygon polygon = args.Geometry as ESRI.ArcGIS.Client.Geometry.Polygon; polygon.SpatialReference = new SpatialReference(4326); Graphic graphic = new Graphic() { Symbol = LayoutRoot.Resources["DefaultPolygonSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol, Geometry = polygon }; graphic.Attributes.Add("X", "Label Point Polygon"); graphicsLayer.Graphics.Add(graphic); List <Graphic> graphicsList = new List <Graphic>(); graphicsList.Add(graphic); geometryService.SimplifyAsync(graphicsList); }
protected override void Invoke(object parameter) { // Clear error Error = null; try { if (Target != null && !string.IsNullOrEmpty(GeometryServiceUrl)) { if (Target is Polyline || Target is Polygon) // Only these types need simplification { Graphic g = new Graphic() { Geometry = Target }; // If a previous simplify operation is still executing, cancel it if (_geometryService.IsBusy) { _geometryService.CancelAsync(); } _geometryService.SimplifyAsync(new Graphic[] { g }); } else { // No simplification required - just complete OutputGeometry = Target; OnCompleted(); } } else { OnFailed(new Exception(Strings.SimplifyInputsNotValid)); } } catch (Exception ex) { OnFailed(ex); } }
private void SimplifyAndQueryButton_Click(object sender, RoutedEventArgs e) { GeometryService geometryService = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer"); geometryService.SimplifyCompleted += GeometryService_SimplifyCompleted; geometryService.Failed += GeometryService_Failed; List<Graphic> graphicList = new List<Graphic>(); graphicList.Add(_unsimplifiedGraphic); geometryService.SimplifyAsync(graphicList); }
} // void gl_MouseLeftButtonDown(object sender, GraphicMouseButtonEventArgs e) private void evtDrawComplete(object sender, DrawEventArgs e) { // call from Map when user stop draw current mark //from exsample //ESRI.ArcGIS.Client.Graphic graphic = new ESRI.ArcGIS.Client.Graphic() //{ Geometry = args.Geometry, Symbol = _activeSymbol }; //graphicsLayer.Graphics.Add(graphic); log("evtDrawComplete"); currGeom = e.Geometry; frmElement.disabledDrawInternally = true; draw.DrawMode = DrawMode.None; draw.IsEnabled = false; try { var gl = getRLLayer(); var graphic = new ESRI.ArcGIS.Client.Graphic() { Geometry = currGeom, Symbol = polySymbol }; gl.Graphics.Add(graphic); log("evtDrawComplete, graphic added"); // sendRequest(currGeom); // Plone service //askGeoprocessor(currGeom); // Geoprocessor service // http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Simplify // http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer/simplify?sr=102100&geometries=%7B%0D%0A%09%22geometryType%22%3A%22esriGeometryPolygon%22%2C%0D%0A%09%22geometries%22%3A%5B%7B%0D%0A%09%09%22rings%22%3A%5B%5B%0D%0A%09%09%09%5B7827152.02924901%2C9666532.33347098%5D%2C%0D%0A%09%09%09%5B8316349.01027401%2C10057889.918291%5D%2C%0D%0A%09%09%09%5B7729312.63304402%2C10214432.952219%5D%2C%0D%0A%09%09%09%5B7827152.02924901%2C9666532.33347098%5D%5D%5D%0D%0A%09%7D%5D%0D%0A%7D&f=HTML var oldCursor = MapApplication.Current.Map.Cursor; var geometryService = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/" + "Geometry/GeometryServer"); var graphicList = new List <Graphic>(); graphicList.Add(graphic); geometryService.SimplifyCompleted += (sndr, args) => { MapApplication.Current.Map.Cursor = oldCursor; log("evtDrawComplete, SimplifyCompleted OK"); gl.Graphics.Remove(graphic); graphic.Geometry = args.Results[0].Geometry; gl.Graphics.Add(graphic); log("evtDrawComplete, askGeoprocessor..."); askGeoprocessor(graphic.Geometry); }; // geometryService.SimplifyCompleted geometryService.Failed += (sndr, args) => { MapApplication.Current.Map.Cursor = oldCursor; log(string.Format("evtDrawComplete, SimplifyCompleted err {0}", args.Error)); MessageBox.Show("Сбой нормализации полигона: " + args.Error); }; // geometryService.Failed MapApplication.Current.Map.Cursor = System.Windows.Input.Cursors.Wait; log("evtDrawComplete, asking SimplifyAsync"); geometryService.SimplifyAsync(graphicList); log("evtDrawComplete, wait for GeometryServer..."); } catch (Exception ex) { string msg = string.Format("Сбой отправки запроса: \n [{0}]", ex.Message); log(msg); MessageBox.Show(msg); } } // private void evtDrawComplete(object sender, DrawEventArgs e)