东华理工GIS二次开发实验报告(8)
发布时间:2021-06-06
发布时间:2021-06-06
21 {
22 mmap = map; 23 }
24 public ILayer getlayerbyname(string slayername) 25 {
26 if (slayername == "" || mmap == null) return null; 27 for (int i = 0; i < yerCount; i++) 28 if (mmap.get_Layer(i).Name == slayername) 29
31 } 32
33 public IFeatureClass createshapefile
34 (string sparentdirection, string sworkspc, string sfilename) 35 {
36 if (System.IO.Directory.Exists(sparentdirection + sworkspc)) 37 System.IO.Directory.Delete(sparentdirection + sworkspc, true); 38 IWorkspaceFactory workspacef = 39
new ShapefileWorkspaceFactoryClass();
40 IWorkspaceName workname; 41 workname = 42
workspacef.Create(sparentdirection, sworkspc, null, 0);
43 IName name = workname as IName;
44 IWorkspace workspace = (IWorkspace)name.Open(); 45 IFeatureWorkspace ftworkspace = 46
workspace as IFeatureWorkspace;
47 IFields fields = new FieldsClass();
48 IFieldsEdit fieldsedit = fields as IFieldsEdit; 49 IFieldEdit fedit = new FieldClass(); 50 _2 = "OID"; 51 fedit.AliasName_2 = "序号";
52 fedit.Type_2 = esriFieldType.esriFieldTypeOID; 53 fieldsedit.AddField((IField)fedit); 54 fedit = new FieldClass(); 55 _2 = "Name"; 56 fedit.AliasName_2 = "名称";
57 fedit.Type_2 = esriFieldType.esriFieldTypeString; 58 fieldsedit.AddField((IField)fedit);
59 IGeometryDefEdit geodefedit = new GeometryDefClass(); 60 ISpatialReference sparef = mmap.SpatialReference; 61 geodefedit.SpatialReference_2 = sparef; 62 geodefedit.GeometryType_2 = 63
esriGeometryType.esriGeometryPoint;
64 fedit = new FieldClass();
return mmap.get_Layer(i);
30 return null;
上一篇:周期问题(三年级奥数)