当前位置:   article > 正文

ArcGIS Engine代码共享-字段(Field)操作_applyedits esrifieldtypedouble 如何传值

applyedits esrifieldtypedouble 如何传值
  1. public class FieldHelper
  2. {
  3. // Methods
  4. public static IField CreateDoubleField(string pFieldName, int pFieldLen, int pFieldScale)
  5. {
  6. FieldClass class2 = new FieldClass();
  7. IFieldEdit edit = class2;
  8. edit.Name_2 = pFieldName;
  9. edit.Type_2 = esriFieldType.esriFieldTypeDouble;
  10. edit.Precision_2 = pFieldLen;
  11. edit.Scale_2 = pFieldScale;
  12. return class2;
  13. }
  14. public static IField CreateGeometryField(esriGeometryType pGT, ISpatialReference pSR)
  15. {
  16. return CreateGeometryField(pGT, pSR, false);
  17. }
  18. public static IField CreateGeometryField(esriGeometryType pGT, ISpatialReference pSR, bool pHasZ)
  19. {
  20. FieldClass class2 = new FieldClass();
  21. IFieldEdit edit = class2;
  22. edit.Name_2 = "SHAPE";
  23. edit.AliasName_2 = "图形对象";
  24. edit.Type_2 = esriFieldType.esriFieldTypeGeometry;
  25. IGeometryDef pGeoDef = new GeometryDefClass();
  26. IGeometryDefEdit class3 = (IGeometryDefEdit)pGeoDef;
  27. class3.GeometryType_2 = pGT;
  28. class3.HasM_2 = false;
  29. class3.HasZ_2 = pHasZ;
  30. class3.GridCount_2 = 1;
  31. class3.set_GridSize(0, 1000.0);
  32. class3.SpatialReference_2 = pSR;
  33. edit.GeometryDef_2 = class3;
  34. return class2;
  35. }
  36. public static IField CreateIntField(string pFieldName, int pFieldLen)
  37. {
  38. FieldClass class2 = new FieldClass();
  39. IFieldEdit edit = class2;
  40. edit.Name_2 = pFieldName;
  41. edit.Precision_2 = pFieldLen;
  42. edit.Type_2 = esriFieldType.esriFieldTypeInteger;
  43. return class2;
  44. }
  45. public static IField CreateOIDField()
  46. {
  47. FieldClass class2 = new FieldClass();
  48. IFieldEdit edit = class2;
  49. edit.Name_2 = "OBJECTID";
  50. edit.AliasName_2 = "表内唯一编号";
  51. edit.Type_2 = esriFieldType.esriFieldTypeOID;
  52. return class2;
  53. }
  54. public static IField CreateRasterField(string pName, string pAliasName, ISpatialReference pSR)
  55. {
  56. FieldClass class2 = new FieldClass();
  57. IFieldEdit edit = class2;
  58. edit.Name_2 = pName;
  59. edit.AliasName_2 = pAliasName;
  60. edit.Type_2 = esriFieldType.esriFieldTypeRaster;
  61. IRasterDef def = new RasterDefClass();
  62. def.IsRasterDataset = false;
  63. def.SpatialReference = pSR;
  64. (edit as IFieldEdit2).RasterDef = def;
  65. return class2;
  66. }
  67. public static IField CreateTextField(string pName, string pAliasName, int aWidth)
  68. {
  69. FieldClass class2 = new FieldClass();
  70. IFieldEdit edit = class2;
  71. edit.Name_2 = pName.ToUpper();
  72. edit.AliasName_2 = pAliasName;
  73. edit.Type_2 = esriFieldType.esriFieldTypeString;
  74. edit.Length_2 = aWidth;
  75. return class2;
  76. }
  77. public static int QueryFieldLength(IField paramFld)
  78. {
  79. if ((paramFld.Type == esriFieldType.esriFieldTypeSingle) || (paramFld.Type == esriFieldType.esriFieldTypeDouble))
  80. {
  81. return paramFld.Precision;
  82. }
  83. if (paramFld.Type == esriFieldType.esriFieldTypeInteger)
  84. {
  85. return paramFld.Length;
  86. }
  87. return paramFld.Length;
  88. }
  89. public static int QueryFieldPrecision(IField paramFld)
  90. {
  91. if ((paramFld.Type == esriFieldType.esriFieldTypeSingle) || (paramFld.Type == esriFieldType.esriFieldTypeDouble))
  92. {
  93. return paramFld.Scale;
  94. }
  95. return 0;
  96. }
  97. public static string QueryFieldTypeName(esriFieldType paramFT)
  98. {
  99. string str = "";
  100. if (esriFieldType.esriFieldTypeBlob == paramFT)
  101. {
  102. return "二进制";
  103. }
  104. if (esriFieldType.esriFieldTypeDate == paramFT)
  105. {
  106. return "日期";
  107. }
  108. if (esriFieldType.esriFieldTypeDouble == paramFT)
  109. {
  110. return "浮点数";
  111. }
  112. if (esriFieldType.esriFieldTypeGeometry == paramFT)
  113. {
  114. return "图形对象";
  115. }
  116. if (esriFieldType.esriFieldTypeGlobalID == paramFT)
  117. {
  118. return "全局编号";
  119. }
  120. if (esriFieldType.esriFieldTypeGUID == paramFT)
  121. {
  122. return "永久唯一编号";
  123. }
  124. if (esriFieldType.esriFieldTypeInteger == paramFT)
  125. {
  126. return "整型";
  127. }
  128. if (esriFieldType.esriFieldTypeOID == paramFT)
  129. {
  130. return "表内编号";
  131. }
  132. if (esriFieldType.esriFieldTypeRaster == paramFT)
  133. {
  134. return "影像图";
  135. }
  136. if (esriFieldType.esriFieldTypeSingle == paramFT)
  137. {
  138. return "浮点数";
  139. }
  140. if (esriFieldType.esriFieldTypeSmallInteger == paramFT)
  141. {
  142. return "短整型";
  143. }
  144. if (esriFieldType.esriFieldTypeString == paramFT)
  145. {
  146. str = "字符串";
  147. }
  148. return str;
  149. }
  150. public static IField QueryField(IFields pFields, string sName)
  151. {
  152. IField pField = null;
  153. int n = pFields.FindField(sName);
  154. if (n > -1)
  155. {
  156. pField = pFields.get_Field(n);
  157. return pField;
  158. }
  159. return pField;
  160. }
  161. public static IField AlterGeometryFieldSR(IField pField, ISpatialReference sr)
  162. {
  163. IFieldEdit pEdit = pField as IFieldEdit;
  164. IGeometryDef pGeoDef = pField.GeometryDef;
  165. IGeometryDefEdit pDEdit = pGeoDef as IGeometryDefEdit;
  166. pDEdit.SpatialReference_2 = sr;
  167. pEdit.GeometryDef_2 = pGeoDef;
  168. return pField;
  169. }
  170. public static IField AlterRasterFieldSR(IField pField, ISpatialReference sr)
  171. {
  172. IFieldEdit2 pEdit = pField as IFieldEdit2;
  173. IRasterDef pRDef = pEdit.RasterDef;
  174. pRDef.SpatialReference = sr;
  175. return pField;
  176. }
  177. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/228202
推荐阅读
相关标签
  

闽ICP备14008679号