FeatureClass의 "import"(변환) 기능
12055 단어 import
1 /// <summary>
2 /// FeatureClass "import" .
3 /// </summary>
4 /// <param name="srcWorkspaceFactory"> IWorkspaceFactory2 </param>
5 /// <param name="srcWorkspacePath"> , :"G:\doc\gis\1.400\data\pdb.mdb"</param>
6 /// <param name="srcFeatureName"> , :"hyd1_4l_1"</param>
7 /// <param name="desWorkspaceFactory"> IWorkspaceFactory2 </param>
8 /// <param name="desWorkspacePath"> , :"G:\doc\gis\1.400\data\desPdb.mdb"( )</param>
9 /// <param name="desFeatureName"> , :"desF"</param>
10 public static void ConvertFeatureClass(ESRI.ArcGIS.Geodatabase.IWorkspaceFactory2 srcWorkspaceFactory, string srcWorkspacePath, string srcFeatureName, ESRI.ArcGIS.Geodatabase.IWorkspaceFactory2 desWorkspaceFactory, string desWorkspacePath, string desFeatureName) {
11 // .
12 ESRI.ArcGIS.Geodatabase.IWorkspace srcWs = srcWorkspaceFactory.OpenFromFile(srcWorkspacePath, 0);
13 ESRI.ArcGIS.Geodatabase.IWorkspace desWs = desWorkspaceFactory.OpenFromFile(desWorkspacePath, 0); // , open.
14
15 // .
16 ESRI.ArcGIS.Geodatabase.IFeatureWorkspace srcFws = (ESRI.ArcGIS.Geodatabase.IFeatureWorkspace)srcWs;
17 ESRI.ArcGIS.Geodatabase.IFeatureClass srcFc = srcFws.OpenFeatureClass(srcFeatureName);
18 ESRI.ArcGIS.Geodatabase.IDataset srcDs = (ESRI.ArcGIS.Geodatabase.IDataset)srcFc;
19 ESRI.ArcGIS.Geodatabase.IFeatureClassName srcFcName = (ESRI.ArcGIS.Geodatabase.IFeatureClassName)srcDs.FullName;
20
21 // .
22 ESRI.ArcGIS.Geodatabase.IDataset desDs = (ESRI.ArcGIS.Geodatabase.IDataset)desWs;
23 ESRI.ArcGIS.esriSystem.IName desName = (ESRI.ArcGIS.esriSystem.IName)desDs.FullName;
24 ESRI.ArcGIS.Geodatabase.IWorkspaceName2 desWsName = (ESRI.ArcGIS.Geodatabase.IWorkspaceName2)desName;
25 ESRI.ArcGIS.Geodatabase.IFeatureClassName desFcName = new ESRI.ArcGIS.Geodatabase.FeatureClassNameClass();
26 ESRI.ArcGIS.Geodatabase.IDatasetName2 desDsName = (ESRI.ArcGIS.Geodatabase.IDatasetName2)desFcName;
27 desDsName.Name = desFeatureName;
28 desDsName.WorkspaceName = desWsName;
29
30 // .
31 ESRI.ArcGIS.Geodatabase.IFieldChecker fieldChecker = new ESRI.ArcGIS.Geodatabase.FieldCheckerClass();
32 ESRI.ArcGIS.Geodatabase.IFields srcFields = srcFc.Fields;
33 ESRI.ArcGIS.Geodatabase.IFields desFields = null;
34 ESRI.ArcGIS.Geodatabase.IEnumFieldError enumFieldErr = null;
35 fieldChecker.InputWorkspace = srcWs;
36 fieldChecker.ValidateWorkspace = desWs;
37 fieldChecker.Validate(srcFields, out enumFieldErr, out desFields);
38 if (enumFieldErr != null)
39 System.Windows.Forms.MessageBox.Show("Errors were encountered during field validation");
40
41 string shpFieldName = srcFc.ShapeFieldName;
42 int fieldIndex = srcFc.FindField(shpFieldName);
43 ESRI.ArcGIS.Geodatabase.IField shpField = srcFields.get_Field(fieldIndex);
44 ESRI.ArcGIS.Geodatabase.IGeometryDef DesGeoDef = shpField.GeometryDef;
45
46 // .
47 ESRI.ArcGIS.Geodatabase.IFeatureDataConverter fdConverter = new ESRI.ArcGIS.Geodatabase.FeatureDataConverterClass();
48 ESRI.ArcGIS.Geodatabase.IEnumInvalidObject enuInvalidObj = fdConverter.ConvertFeatureClass(srcFcName, null, null, desFcName, DesGeoDef, desFields, "", 1000, 0);
49 enuInvalidObj.Reset();
50 ESRI.ArcGIS.Geodatabase.IInvalidObjectInfo inValidObjInfo = null;
51 while ((inValidObjInfo = enuInvalidObj.Next()) != null)
52 System.Windows.Forms.MessageBox.Show(string.Format("Errors occurred for the following feature: {0}", inValidObjInfo.InvalidObjectID));
53 }
주 함수에서 호출하기
1 ESRI.ArcGIS.Geodatabase.IWorkspaceFactory2 srcWsf = new ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactoryClass();
2 ESRI.ArcGIS.Geodatabase.IWorkspaceFactory2 desWsf = new ESRI.ArcGIS.DataSourcesGDB.AccessWorkspaceFactoryClass();
3
4 string srcWsPath = @"G:\doc\gis\1.400\data\pdb.mdb";
5 string desWsPath = @"G:\doc\gis\1.400\data\desPdb.mdb";
6
7 string srcFcName = "hyd1_4l_1";
8 string desFcName = "desF";
9 Engine.App_Code.Feature_Assist.ConvertFeatureClass(srcWsf, srcWsPath, srcFcName, desWsf, desWsPath, desFcName);
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
Access Request, Session and Application in Struts2If we want to use request, Session and application in JSP, what should we do? We can obtain Map type objects such as Req...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.