/// <summary> /// Copies the feature class. /// </summary> /// <param name="inputPaths">The input paths.</param> /// <param name="outPutPath">The out put path.</param> /// <param name="outputHasMValues"></param> /// <param name="outputHasZValues"></param> /// <returns></returns> public IGeoProcessorResult CopyFeatureClass(string inputPaths, string outPutPath, bool outputHasZValues, bool outputHasMValues) { try { CopyFeatures pCopyFeature = new CopyFeatures(inputPaths, outPutPath); Geoprocessor GP = new Geoprocessor(); GP.OverwriteOutput = true; GP.TemporaryMapLayers = false; if (outputHasZValues) { object obj = GP.GetEnvironmentValue("OutputZFlag"); //设置Output has Z Values GP.SetEnvironmentValue("OutputZFlag", "DEFAULT"); } if (outputHasMValues) { object obj = GP.GetEnvironmentValue("OutputMFlag"); //设置Output has M Values GP.SetEnvironmentValue("OutputMFlag", "DEFAULT"); } IGeoProcessorResult result = GP.Execute(pCopyFeature, null) as IGeoProcessorResult; //GT_CONST.LogAPI.CheckLog.AppendErrLogs(result.Status.ToString()); //GT_CONST.LogAPI.CheckLog.AppendErrLogs(result.GetMessages(0)); return(result); } catch (Exception exp) { Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString()); return(null); } }
/// <summary> /// Gets the ArcGIS Geoprocessor, configured with the given parameters. /// </summary> /// <param name="temporaryMapLayers">Whether new map layers are temporary by default.</param> /// <param name="addOutputsToMap">Whether resulting output datasets should be added to the application display.</param> /// <param name="overwriteOutput">Whether existing output datasets should be overwritten.</param> /// <param name="gridReference">A raster to be used as a template for output grids in regard to dimensions (width, height, cell size, and coordinates)</param> /// <returns>The ArcGIS Geoprocessor</returns> public static Geoprocessor GetGeoprocessor(bool temporaryMapLayers = true, bool addOutputsToMap = false, bool overwriteOutput = true, IRaster gridReference = null) { Geoprocessor gp = new Geoprocessor(); if (!userTempLayers.HasValue) { userTempLayers = gp.TemporaryMapLayers; } if (!userAddOutputs.HasValue) { userAddOutputs = gp.AddOutputsToMap; } if (!userOverwrite.HasValue) { userOverwrite = gp.OverwriteOutput; } gp.TemporaryMapLayers = temporaryMapLayers; gp.AddOutputsToMap = addOutputsToMap; gp.OverwriteOutput = overwriteOutput; if (gridReference != null) { IRasterDataset rds = ((IRasterAnalysisProps)gridReference).RasterDataset; IDataset ds = (IDataset)rds; string path = System.IO.Path.Combine(ds.Workspace.PathName, ds.Name); gp.SetEnvironmentValue("snapRaster", path); string extent = string.Format("{0} {1} {2} {3}", ((IGeoDataset2)rds).Extent.XMin, ((IGeoDataset2)rds).Extent.YMin, ((IGeoDataset2)rds).Extent.XMax, ((IGeoDataset2)rds).Extent.YMax); gp.SetEnvironmentValue("extent", extent); } if (workspace == null) { workspace = gp.GetEnvironmentValue("workspace"); } if (scratchWorkspace == null) { scratchWorkspace = gp.GetEnvironmentValue("scratchWorkspace"); } if (gp.GetEnvironmentValue("workspace") == null) { gp.SetEnvironmentValue("workspace", GetDefaultWorkspace()); } if (gp.GetEnvironmentValue("scratchWorkspace") == null) { gp.SetEnvironmentValue("scratchWorkspace", GetDefaultWorkspace()); } return(gp); }
/// <summary> /// Copies the feature class. /// </summary> /// <param name="inputPaths">The input paths.</param> /// <param name="outPutPath">The out put path.</param> /// <param name="outputHasMValues"></param> /// <param name="outputHasZValues"></param> /// <returns></returns> public IGeoProcessorResult CopyFeatureClass(string inputPaths, string outPutPath, bool outputHasZValues, bool outputHasMValues) { try { CopyFeatures pCopyFeature = new CopyFeatures(inputPaths, outPutPath); Geoprocessor GP = new Geoprocessor(); GP.OverwriteOutput = true; GP.TemporaryMapLayers = false; if (outputHasZValues) { object obj = GP.GetEnvironmentValue("OutputZFlag"); //设置Output has Z Values GP.SetEnvironmentValue("OutputZFlag", "DEFAULT"); } if (outputHasMValues) { object obj = GP.GetEnvironmentValue("OutputMFlag"); //设置Output has M Values GP.SetEnvironmentValue("OutputMFlag", "DEFAULT"); } IGeoProcessorResult result = GP.Execute(pCopyFeature, null) as IGeoProcessorResult; //GT_CONST.LogAPI.CheckLog.AppendErrLogs(result.Status.ToString()); //GT_CONST.LogAPI.CheckLog.AppendErrLogs(result.GetMessages(0)); return result; } catch (Exception exp) { Hy.Common.Utility.Log.OperationalLogManager.AppendMessage(exp.ToString()); return null; } }