protected override void OnClick() { try { if (Module1.Geometries == null || Module1.Geometries.Count <= 0) { MessageBox.Show($@"You have to first render a geometry before you can export the Geometry"); return; } var bpf = new BrowseProjectFilter("esri_browseDialogFilters_json_file") { Name = "Specify JSON file to export Geometries to" }; var saveItemDialog = new SaveItemDialog { BrowseFilter = bpf }; var result = saveItemDialog.ShowDialog(); if (result.Value == false) { return; } var jsonPath = $@"{saveItemDialog.FilePath}.json"; var folder = System.IO.Path.GetDirectoryName(jsonPath); if (!System.IO.Directory.Exists(folder)) { System.IO.Directory.CreateDirectory(folder); } var exists = System.IO.File.Exists(jsonPath); if (exists) { var isYes = MessageBox.Show($@"The export will write over the existing file {jsonPath}", "Override File", System.Windows.MessageBoxButton.YesNo); if (isYes != System.Windows.MessageBoxResult.Yes) { return; } System.IO.File.Delete(jsonPath); } GeometryBag bag = GeometryBagBuilder.CreateGeometryBag(Module1.Geometries, Module1.Geometries[0].SpatialReference); System.IO.File.WriteAllText(jsonPath, bag.ToJson()); MessageBox.Show($@"Export saved to {jsonPath}"); } catch (Exception ex) { MessageBox.Show($@"Export Exception: {ex}"); } }
private static ArcGIS.Core.Geometry.Geometry GetSearchGeometry( [NotNull] IList <Feature> intersectingFeatures, [CanBeNull] Envelope clipExtent) { var intersectingGeometries = GetSearchGeometries(intersectingFeatures, clipExtent); ArcGIS.Core.Geometry.Geometry result = null; if (intersectingGeometries.Count != 0) { var sr = intersectingGeometries[0].SpatialReference; result = GeometryBagBuilder.CreateGeometryBag(intersectingGeometries, sr); //result = GeometryEngine.Instance.Union(intersectingGeometries); } return(result); }