public override bool Exexute() { IWorkspace workspace = GisDataHelper.OpenWorkspace(dataSourceId); if (workspace.HasFeatureClass(layerName) && deleteOld) { workspace.DeleteFeatureClass(layerName); } IFeatureClass targetFeatureClass = workspace.TryOpenFeatureClass(layerName); if (targetFeatureClass == null) { if (shpPaths.Length > 0) { IFeatureClass shpFeatureClass = XWorkspace.OpenShapeFile(shpPaths[0]); targetFeatureClass = workspace.CreateFeatureClass(layerName, shpFeatureClass.Fields); } } else { if (clearRecord) { targetFeatureClass.Delete(); } } for (int i = 0; i < shpPaths.Length; i++) { IFeatureClass shpFeatureClass = XWorkspace.OpenShapeFile(shpPaths[i]); shpFeatureClass.CopyTo(targetFeatureClass); } Output = targetFeatureClass; return(Output != null); }
public override bool Exexute() { string tempLayerName = $"mappings{DateTime.Now.ToString("yyyyMMddHHmmss")}"; IWorkspace tempWorkspace = XWorkspace.GetFileGDBWorkspace(TempGDB); inFeatureClass.CopyTo(tempWorkspace, tempLayerName, true, fieldMaps); Output = tempWorkspace.TryOpenFeatureClass(tempLayerName); return(Output != null); }
static void CheckAndCreateFolder() { // GIS数据文件夹 string GisDataFolder = GlobalConfig.AppCfg.getValueByPath("configuration/Custom/GisDataFolder"); System.IO.Directory.CreateDirectory(GisDataFolder); // 临时文件夹 string TempDataFolder = GlobalConfig.AppCfg.getValueByPath("configuration/Custom/TempDataFolder"); System.IO.Directory.CreateDirectory(TempDataFolder); // 临时GDB string TempGDB = GlobalConfig.AppCfg.getValueByPath("configuration/Custom/TempGDB"); XWorkspace.CreateGDB(TempGDB, open: false); }
/// <summary> /// 执行函数 /// </summary> /// <returns></returns> public override bool Exexute() { // 输出路径 string LayerName = $"clip{DateTime.Now.ToString("yyyyMMddHHmmss")}"; // 使用GP工具执行Clip操作,会生成临时文件 Geoprocessor mGeoprocessor = new Geoprocessor(); mGeoprocessor.OverwriteOutput = true; Clip mClip = new Clip(); mClip.in_features = inFeatureClass; mClip.clip_features = clipFeatureClass; mClip.out_feature_class = TempGDB + "/" + LayerName; mGeoprocessor.Execute(mClip, null); // 打开Clip的结果 IWorkspace tempWorkspace = XWorkspace.GetFileGDBWorkspace(TempGDB); Output = tempWorkspace.TryOpenFeatureClass(LayerName); tempWorkspace.Dispose(); return(Output != null); }
public override bool Exexute() { // 输出路径 string LayerName = $"project{DateTime.Now.ToString("yyyyMMddHHmmss")}"; // 使用GP工具执行Clip操作,会生成临时文件 Geoprocessor mGeoprocessor = new Geoprocessor(); mGeoprocessor.OverwriteOutput = true; Project mProject = new Project(); mProject.in_dataset = inFeatureClass; // mProject.in_coor_system = mProject.out_dataset = TempGDB + "/" + LayerName; mProject.out_coor_system = "PROJCS[\"CGCS2000_3_Degree_GK_CM_113E\",GEOGCS[\"GCS_China_Geodetic_Coordinate_System_2000\",DATUM[\"D_China_2000\",SPHEROID[\"CGCS2000\",6378137.0,298.257222101]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Gauss_Kruger\"],PARAMETER[\"False_Easting\",700000.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",113.0],PARAMETER[\"Scale_Factor\",1.0],PARAMETER[\"Latitude_Of_Origin\",0.0],UNIT[\"Meter\",1.0]]"; mGeoprocessor.Execute(mProject, null); // 打开结果图层 IWorkspace tempWorkspace = XWorkspace.GetFileGDBWorkspace(TempGDB); Output = tempWorkspace.TryOpenFeatureClass(LayerName); tempWorkspace.Dispose(); return(Output != null); }
public override bool Exexute() { // 输出路径 string LayerName = $"join{DateTime.Now.ToString("yyyyMMddHHmmss")}"; // 使用GP工具执行Clip操作,会生成临时文件 Geoprocessor mGeoprocessor = new Geoprocessor(); mGeoprocessor.OverwriteOutput = true; ESRI.ArcGIS.AnalysisTools.SpatialJoin mJoin = new ESRI.ArcGIS.AnalysisTools.SpatialJoin(); mJoin.target_features = targetFeatureClass; mJoin.join_features = joinFeatureClass; mJoin.join_operation = "JOIN_ONE_TO_ONE"; // JOIN_ONE_TO_MANY mJoin.match_option = "INTERSECTS"; mJoin.join_type = "KEEP_ALL"; mJoin.out_feature_class = TempGDB + "/" + LayerName; //mJoin.field_mapping mGeoprocessor.Execute(mJoin, null); // 打开Join的结果 IWorkspace tempWorkspace = XWorkspace.GetFileGDBWorkspace(TempGDB); Output = tempWorkspace.TryOpenFeatureClass(LayerName); tempWorkspace.Dispose(); return(Output != null); }
/// <summary> /// 通过数据源配置信息打开GDB工作空间 /// </summary> /// <param name="dict"></param> /// <returns></returns> static IWorkspace OpenSHP(Dictionary <string, object> dict) { string filePath = dict["FILEPATH"].ToString(""); return(XWorkspace.GetShapefileWorkspace($"{GisDataFolder}/{filePath}")); }
/// <summary> /// 打开临时数据工作空间 /// </summary> /// <returns></returns> public static IWorkspace OpenTempWorkspace() { return(XWorkspace.GetFileGDBWorkspace(TempGDB)); }