private void EraseRun(IFeatureClass in_features, IFeatureClass erase_features, object out_feature_class) { // IAoInitialize m_AoInitialize = new AoInitializeClass(); // esriLicenseStatus licenseStatus = esriLicenseStatus.esriLicenseUnavailable; // // licenseStatus = m_AoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngine); Erase erase = new Erase() { in_features = in_features, erase_features = erase_features, out_feature_class = out_feature_class }; Geoprocessor processor = new Geoprocessor(); processor.OverwriteOutput = true; try { IGeoProcessorResult result = processor.Execute(erase, new TrackCancelClass()) as IGeoProcessorResult; } catch (Exception e) { Show(e.ToString()); throw; } }
/// <summary> /// 空间擦除 /// </summary> /// <param name="featureClassPath"></param> /// <param name="layerId"></param> /// <param name="outFsName"></param> /// <returns></returns> public static IFeatureClass spatialErase(string gdb, IFeatureClass features, int layerId) { IFeatureClass kzxFs = Utils.featureClsArray[layerId]; string layer_name = kzxFs.AliasName; Geoprocessor gp = new Geoprocessor(); Erase erase = new Erase(); erase.in_features = features; erase.erase_features = kzxFs; erase.out_feature_class = gdb + @"\results\" + layer_name + @"EraseResult"; try { gp.AddOutputsToMap = false; gp.OverwriteOutput = true; gp.Execute(erase, null); gp.ResetEnvironments(); IFeatureClass outFs = FeatureOperations.OpenFeatureClass(gdb, "results", layer_name + @"EraseResult"); return(outFs); } catch (System.Exception ex) { string error = ""; for (int i = 0; i < gp.MessageCount; i++) { error += gp.GetMessage(i); } return(null); } }
private void Delete_Click(object sender, RoutedEventArgs e) { Erase.delete(Journalinfo.journalID); NavigationService delete = NavigationService.GetNavigationService(this); delete.Navigate(new Uri("MainPage.xaml", UriKind.Relative)); }
/// <summary> /// 擦除图层 /// </summary> /// <param name="inFile"></param> /// <param name="eraseFile"></param> /// <param name="outFile"></param> public static void Erase(string inFile, string eraseFile, string outFile) { Erase pErase = new Erase { in_features = inFile, erase_features = eraseFile, out_feature_class = outFile }; GeoprocessorHelper.GpExecute(pErase); }
public static bool Erase(string in_feature, string erase_feature, string out_feature, string tolerance = "0.0001 METERS") { var tool = new Erase(); tool.in_features = in_feature; tool.erase_features = erase_feature; tool.out_feature_class = out_feature; tool.cluster_tolerance = tolerance; return(Excute(tool)); }
private IGeoProcessorResult EraseOverlay(Geoprocessor gp) { //Erase_analysis (in_features, erase_features, out_feature_class, cluster_tolerance) Erase erase = new Erase(); erase.in_features = m_InputLayer; erase.erase_features = m_OverlayLayer; string outputFullPath = System.IO.Path.Combine(m_OutPutPath, m_InputLayer + "_" + m_OverlayLayer + "_" + "Erase"); erase.out_feature_class = outputFullPath; erase.cluster_tolerance = m_Tolerance; IGeoProcessorResult results = (IGeoProcessorResult)gp.Execute(erase, null); return(results); }
private void btupdate_Click(object sender, EventArgs e) { Erase?.Invoke(ev); Save?.Invoke(); this.Close(); }
private void btnOK_Click(object sender, EventArgs e) { /*FileInfo openpath = new FileInfo(textBox1.Text); string ss = openpath.Directory.ToString();//·���ĸ�Ŀ¼ ILayer pLayer; pLayer = m_mapControl.Map.get_Layer(comboBox1.SelectedIndex); IFeatureLayer pInputFeatureLayer; pInputFeatureLayer = pLayer as IFeatureLayer; IFeatureClass pInputFeatureClass = pInputFeatureLayer.FeatureClass; ITable pInputTable; pInputTable = pInputFeatureClass as ITable; pInputFeatureClass = pInputFeatureLayer.FeatureClass; pLayer = m_mapControl.Map.get_Layer(comboBox2.SelectedIndex); IFeatureLayer pOverlayFeatureLayer; pOverlayFeatureLayer = pLayer as IFeatureLayer; IFeatureClass pOverlayFeatureClass; pOverlayFeatureClass = pOverlayFeatureLayer.FeatureClass; ITable pOverlayTable; pOverlayTable = pOverlayFeatureClass as ITable; //IFeatureClass pOverlayFeatureClass; //pOverlayFeatureClass = pOverlayFeatureLayer.FeatureClass; if (pInputTable == null) { MessageBox.Show("����ͼ��Ϊ��"); return; } if (pOverlayTable == null) { MessageBox.Show("����ͼ��Ϊ��"); return; } IFeatureClassName pFeatureClassName; pFeatureClassName = new FeatureClassNameClass(); pFeatureClassName.FeatureType = esriFeatureType.esriFTSimple; pFeatureClassName.ShapeFieldName = "Shape"; pFeatureClassName.ShapeType = pInputFeatureClass.ShapeType; IWorkspaceName pNewWSName; pNewWSName = new WorkspaceNameClass(); pNewWSName.WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory"; pNewWSName.PathName = ss; IDatasetName pDatasetName; pDatasetName = pFeatureClassName as IDatasetName; pDatasetName.Name = openpath.Name; //"Intersect_Result"; pDatasetName.WorkspaceName = pNewWSName; double tol = 0.1; IBasicGeoprocessor pBGP; pBGP = new BasicGeoprocessorClass(); pBGP.SpatialReference = m_mapControl.Map.SpatialReference; IFeatureClass pOutputFeatureClass; IFeatureLayer pOutputFeatLayer; pOutputFeatLayer = new FeatureLayerClass(); int n = listBox1.SelectedIndex; if (n>= 0 && n< 3) { switch (n) { case(0): pOutputFeatureClass = pBGP.Intersect(pInputTable, false, pOverlayTable, false, tol, pFeatureClassName); pOutputFeatLayer.FeatureClass = pOutputFeatureClass; pOutputFeatLayer.Name = pOutputFeatureClass.AliasName; m_mapControl.Map.AddLayer(pOutputFeatLayer); break; case(1): pOutputFeatureClass = pBGP.Union(pInputTable, false, pOverlayTable, false, tol, pFeatureClassName); pOutputFeatLayer.FeatureClass = pOutputFeatureClass; pOutputFeatLayer.Name = pOutputFeatureClass.AliasName; m_mapControl.Map.AddLayer(pOutputFeatLayer); break; case(2): pOutputFeatureClass = pBGP.Clip(pInputTable, false, pOverlayTable, false, tol, pFeatureClassName); pOutputFeatLayer.FeatureClass = pOutputFeatureClass; pOutputFeatLayer.Name = pOutputFeatureClass.AliasName; m_mapControl.Map.AddLayer(pOutputFeatLayer); break; } }*/ //Geoprocessor processor = new Geoprocessor(); IFeatureLayer inputLyr = m_mapControl.Map.get_Layer(comboBox1.SelectedIndex) as IFeatureLayer; IDataLayer2 dataLy = inputLyr as IDataLayer2; IDatasetName inputdsName = dataLy.DataSourceName as IDatasetName; IWorkspaceName inputws = inputdsName.WorkspaceName as IWorkspaceName; string input=inputws.PathName+"\\"+inputLyr.Name; IFeatureLayer overlayLyr = m_mapControl.Map.get_Layer(comboBox2.SelectedIndex) as IFeatureLayer; IDataLayer2 dataOverlay = overlayLyr as IDataLayer2; IDatasetName overlayDsName = dataOverlay.DataSourceName as IDatasetName; IWorkspaceName overlayWs = overlayDsName.WorkspaceName; string overlay =overlayWs.PathName+"\\"+overlayLyr.Name; string output =textBox1.Text; Geoprocessor processor = new Geoprocessor(); processor.OverwriteOutput = true; IGPProcess process=null; switch (listBox1.SelectedIndex) { case 0: Intersect intersect = new Intersect(); intersect.in_features = "'" + input + "'" + ";" + "'" + overlay + "'"; intersect.out_feature_class =output; intersect.output_type = "INPUT"; intersect.join_attributes = "ALL"; //intersect.cluster_tolerance=0.1; process = intersect; break; case 1: Union union = new Union(); union.in_features = "'" + input+"'" +";"+"'"+overlay+ "'"; union.out_feature_class = @""+output; union.join_attributes = "ALL"; //union.cluster_tolerance = 0.1; process = union; break; case 2: Erase erase = new Erase(); erase.in_features = "'" + input + "'"; erase.erase_features = "'" + overlay + "'"; erase.out_feature_class = output; //erase.cluster_tolerance = 0.1; process = erase; break; } processor.Validate(process, true); processor.Execute(process, null); this.Dispose(); FileInfo fi = new FileInfo(textBox1.Text); string pathDir = fi.Directory.FullName; string name = fi.Name; IWorkspaceFactory wsf = new ShapefileWorkspaceFactoryClass(); IFeatureWorkspace fws = wsf.OpenFromFile(pathDir, 0) as IFeatureWorkspace; IFeatureClass featCls = fws.OpenFeatureClass(name); IFeatureLayer layer = new FeatureLayerClass(); layer.FeatureClass = featCls; layer.Name = featCls.AliasName; m_mapControl.Map.AddLayer(layer as ILayer); }
private void btnOK_Click(object sender, EventArgs e) { /*FileInfo openpath = new FileInfo(textBox1.Text); * string ss = openpath.Directory.ToString();//路径的父目录 * * ILayer pLayer; * pLayer = m_mapControl.Map.get_Layer(comboBox1.SelectedIndex); * IFeatureLayer pInputFeatureLayer; * pInputFeatureLayer = pLayer as IFeatureLayer; * IFeatureClass pInputFeatureClass = pInputFeatureLayer.FeatureClass; * * * ITable pInputTable; * pInputTable = pInputFeatureClass as ITable; * * * pInputFeatureClass = pInputFeatureLayer.FeatureClass; * * pLayer = m_mapControl.Map.get_Layer(comboBox2.SelectedIndex); * IFeatureLayer pOverlayFeatureLayer; * pOverlayFeatureLayer = pLayer as IFeatureLayer; * IFeatureClass pOverlayFeatureClass; * pOverlayFeatureClass = pOverlayFeatureLayer.FeatureClass; * * ITable pOverlayTable; * pOverlayTable = pOverlayFeatureClass as ITable; * * * //IFeatureClass pOverlayFeatureClass; * //pOverlayFeatureClass = pOverlayFeatureLayer.FeatureClass; * * if (pInputTable == null) * { * MessageBox.Show("输入图层为空"); * return; * } * * if (pOverlayTable == null) * { * MessageBox.Show("叠置图层为空"); * return; * } * * IFeatureClassName pFeatureClassName; * pFeatureClassName = new FeatureClassNameClass(); * pFeatureClassName.FeatureType = esriFeatureType.esriFTSimple; * pFeatureClassName.ShapeFieldName = "Shape"; * pFeatureClassName.ShapeType = pInputFeatureClass.ShapeType; * * IWorkspaceName pNewWSName; * pNewWSName = new WorkspaceNameClass(); * pNewWSName.WorkspaceFactoryProgID = "esriDataSourcesFile.ShapefileWorkspaceFactory"; * pNewWSName.PathName = ss; * * IDatasetName pDatasetName; * pDatasetName = pFeatureClassName as IDatasetName; * pDatasetName.Name = openpath.Name; //"Intersect_Result"; * pDatasetName.WorkspaceName = pNewWSName; * * double tol = 0.1; * * IBasicGeoprocessor pBGP; * pBGP = new BasicGeoprocessorClass(); * pBGP.SpatialReference = m_mapControl.Map.SpatialReference; * IFeatureClass pOutputFeatureClass; * IFeatureLayer pOutputFeatLayer; * pOutputFeatLayer = new FeatureLayerClass(); * int n = listBox1.SelectedIndex; * * if (n>= 0 && n< 3) * { * switch (n) * { * case(0): * pOutputFeatureClass = pBGP.Intersect(pInputTable, false, pOverlayTable, false, tol, pFeatureClassName); * pOutputFeatLayer.FeatureClass = pOutputFeatureClass; * pOutputFeatLayer.Name = pOutputFeatureClass.AliasName; * m_mapControl.Map.AddLayer(pOutputFeatLayer); * break; * case(1): * pOutputFeatureClass = pBGP.Union(pInputTable, false, pOverlayTable, false, tol, pFeatureClassName); * pOutputFeatLayer.FeatureClass = pOutputFeatureClass; * pOutputFeatLayer.Name = pOutputFeatureClass.AliasName; * m_mapControl.Map.AddLayer(pOutputFeatLayer); * break; * case(2): * pOutputFeatureClass = pBGP.Clip(pInputTable, false, pOverlayTable, false, tol, pFeatureClassName); * pOutputFeatLayer.FeatureClass = pOutputFeatureClass; * pOutputFeatLayer.Name = pOutputFeatureClass.AliasName; * m_mapControl.Map.AddLayer(pOutputFeatLayer); * break; * } * }*/ //Geoprocessor processor = new Geoprocessor(); IFeatureLayer inputLyr = m_mapControl.Map.get_Layer(comboBox1.SelectedIndex) as IFeatureLayer; IDataLayer2 dataLy = inputLyr as IDataLayer2; IDatasetName inputdsName = dataLy.DataSourceName as IDatasetName; IWorkspaceName inputws = inputdsName.WorkspaceName as IWorkspaceName; string input = inputws.PathName + "\\" + inputLyr.Name; IFeatureLayer overlayLyr = m_mapControl.Map.get_Layer(comboBox2.SelectedIndex) as IFeatureLayer; IDataLayer2 dataOverlay = overlayLyr as IDataLayer2; IDatasetName overlayDsName = dataOverlay.DataSourceName as IDatasetName; IWorkspaceName overlayWs = overlayDsName.WorkspaceName; string overlay = overlayWs.PathName + "\\" + overlayLyr.Name; string output = textBox1.Text; Geoprocessor processor = new Geoprocessor(); processor.OverwriteOutput = true; IGPProcess process = null; switch (listBox1.SelectedIndex) { case 0: Intersect intersect = new Intersect(); intersect.in_features = "'" + input + "'" + ";" + "'" + overlay + "'"; intersect.out_feature_class = output; intersect.output_type = "INPUT"; intersect.join_attributes = "ALL"; //intersect.cluster_tolerance=0.1; process = intersect; break; case 1: Union union = new Union(); union.in_features = "'" + input + "'" + ";" + "'" + overlay + "'"; union.out_feature_class = @"" + output; union.join_attributes = "ALL"; //union.cluster_tolerance = 0.1; process = union; break; case 2: Erase erase = new Erase(); erase.in_features = "'" + input + "'"; erase.erase_features = "'" + overlay + "'"; erase.out_feature_class = output; //erase.cluster_tolerance = 0.1; process = erase; break; } processor.Validate(process, true); processor.Execute(process, null); this.Dispose(); FileInfo fi = new FileInfo(textBox1.Text); string pathDir = fi.Directory.FullName; string name = fi.Name; IWorkspaceFactory wsf = new ShapefileWorkspaceFactoryClass(); IFeatureWorkspace fws = wsf.OpenFromFile(pathDir, 0) as IFeatureWorkspace; IFeatureClass featCls = fws.OpenFeatureClass(name); IFeatureLayer layer = new FeatureLayerClass(); layer.FeatureClass = featCls; layer.Name = featCls.AliasName; m_mapControl.Map.AddLayer(layer as ILayer); }
private void btnBuffer_Click(object sender, EventArgs e) {//判断是否选择要素 if (this.texInputFeat.Text == "" || this.texInputFeat.Text == null || this.texOverlayFeat.Text == "" || this.texOverlayFeat.Text == null) { texMessage.Text = "请设置叠置要素!"; return; } ESRI.ArcGIS.Geoprocessor.Geoprocessor gp = new ESRI.ArcGIS.Geoprocessor.Geoprocessor(); //overwriteOutput为真时,输出图层会覆盖当前文件夹下的同名的图层 gp.OverwriteOutput = true; //设置参与叠置分析的多个对象 object inputFeat = this.texInputFeat.Text; object overlayFeat = this.texOverlayFeat.Text; IGpValueTableObject pObject = new GpValueTableObjectClass(); pObject.SetColumns(2); pObject.AddRow(ref inputFeat); pObject.AddRow(ref overlayFeat); //获取要素名称 string str = System.IO.Path.GetFileName(this.texInputFeat.Text); int index = str.LastIndexOf("."); string strName = str.Remove(index); //设置输出路径 strOutputPath = tetOutputPath.Text; //叠置分析结果 IGeoProcessorResult result = null; //创建叠置分析实例 string strOverlay = cboOverLay.SelectedItem.ToString(); try { //添加处理过程消息 texMessage.Text = "开始叠置分析......" + "\r\n"; switch (strOverlay) { case "求交(Intersect)": Intersect intersectTool = new Intersect(); //设置输入要素 intersectTool.in_features = pObject; //设置输出路径 //strOutputPath += strName + "_" + "_intersect.shp"; intersectTool.out_feature_class = strOutputPath; intersectTool.output_type = "ALL"; //执行求交运算 result = gp.Execute(intersectTool, null) as IGeoProcessorResult; break; case "求并(Union)": Union unionTool = new Union(); //设置输入要素 unionTool.in_features = pObject; //设置输出路径 strOutputPath += strName + "_" + "_union.shp"; unionTool.out_feature_class = strOutputPath; //执行联合运算 result = gp.Execute(unionTool, null) as IGeoProcessorResult; break; case "擦除(Erase)": //Identity identityTool = new Identity(); Erase eraseTool = new Erase(); //设置输入要素 eraseTool.in_features = inputFeat; eraseTool.erase_features = overlayFeat; //设置输出路径 strOutputPath += strName + "-" + "_erase.shp"; eraseTool.out_feature_class = strOutputPath; //执行标识结果 result = gp.Execute(eraseTool, null) as IGeoProcessorResult; break; } } catch (System.Exception ex) { //添加处理过程消息 texMessage.Text += "叠置分析过程出现错误:" + ex.Message + "\r\n"; } //判断叠置分析是否成功 if (result.Status != ESRI.ArcGIS.esriSystem.esriJobStatus.esriJobSucceeded) { texMessage.Text += "叠置失败!"; } else { this.DialogResult = DialogResult.OK; texMessage.Text += "叠置成功!"; //int index1 = strOutputPath.LastIndexOf("\\"); //this.mMapControl.AddShapeFile(strOutputPath.Substring(0, index1), strOutputPath.Substring(index1)); } }
public static int Main(string[] args) { var assembly = Assembly.GetExecutingAssembly(); var version = assembly.GetName().Version; var buildArch = (Is64BitBuild ? 64 : 86); if (!IsLinux) { ServiceImpl.ServiceEarlyParseArguments(ref args); InitializeSystemConsole(); ServiceImpl.ServiceEarlyMain(args); } if (!IsServiceEnvironment) { WriteLine("{0} {1}.{2}.{3}-{4} {5:dd-MM-yyyy HH\\:mm\\:ss} [x{6}-built]", assembly.GetCustomAttribute <AssemblyProductAttribute>().Product, version.Major, version.Minor, version.Build, version.Revision, assembly.GetLinkerTime(), buildArch); WriteLine("{0}. Licensed under GPLv3.", assembly.GetCustomAttribute <AssemblyCopyrightAttribute>().Copyright); } if (!IsLinux && !ServiceImpl.ServiceMain(args)) { CloseParent(); return(0); } WriteLine("Running as {0}.", Environment.UserName); WriteLine(); var options = new[] { typeof(Benchmark.Options), typeof(Clone.Options), typeof(Compare.Options), typeof(DeepScan.Options), typeof(Erase.Options), typeof(ListDisks.Options), typeof(ListPartitions.Options), typeof(MakeDirectoryImage.Options), typeof(MakeImage.Options), typeof(MakeRaidImage.Options), typeof(MountImage.Options), typeof(MountPartition.Options), typeof(MountRaidImage.Options), typeof(PhysicalCheck.Options), typeof(Ramdisk.Options), typeof(Security.Options), typeof(Smart.Options), typeof(Sync.Options), }; var result = INVALID_ARGUMENT; var parserResult = Parser.Default.ParseArguments(args, options); if (parserResult is Parsed <object> parsed && parsed != null) { if (parsed.Value is Benchmark.Options) { result = Benchmark.Run((Benchmark.Options)parsed.Value); } else if (parsed.Value is Clone.Options) { result = Clone.Run((Clone.Options)parsed.Value); } else if (parsed.Value is Compare.Options) { result = Compare.Run((Compare.Options)parsed.Value); } else if (parsed.Value is DeepScan.Options) { result = DeepScan.Run((DeepScan.Options)parsed.Value); } else if (parsed.Value is Erase.Options) { result = Erase.Run((Erase.Options)parsed.Value); } else if (parsed.Value is ListDisks.Options) { result = ListDisks.Run((ListDisks.Options)parsed.Value); } else if (parsed.Value is ListPartitions.Options) { result = ListPartitions.Run((ListPartitions.Options)parsed.Value); } else if (parsed.Value is MakeDirectoryImage.Options) { result = MakeDirectoryImage.Run((MakeDirectoryImage.Options)parsed.Value); } else if (parsed.Value is MakeImage.Options) { result = MakeImage.Run((MakeImage.Options)parsed.Value); } else if (parsed.Value is MakeRaidImage.Options) { result = MakeRaidImage.Run((MakeRaidImage.Options)parsed.Value); } else if (parsed.Value is MountImage.Options) { result = MountImage.Run((MountImage.Options)parsed.Value); } else if (parsed.Value is MountPartition.Options) { result = MountPartition.Run((MountPartition.Options)parsed.Value); } else if (parsed.Value is MountRaidImage.Options) { result = MountRaidImage.Run((MountRaidImage.Options)parsed.Value); } else if (parsed.Value is Ramdisk.Options) { result = Ramdisk.Run((Ramdisk.Options)parsed.Value); } else if (parsed.Value is PhysicalCheck.Options) { result = PhysicalCheck.Run((PhysicalCheck.Options)parsed.Value); } else if (parsed.Value is Security.Options) { result = Security.Run((Security.Options)parsed.Value); } else if (parsed.Value is Smart.Options) { result = Smart.Run((Smart.Options)parsed.Value); } else if (parsed.Value is Sync.Options) { result = Sync.Run((Sync.Options)parsed.Value); } } if (!IsLinux) { CloseParent(); } return(result); }