当前位置: 首页>>代码示例>>C#>>正文


C# FieldsClass.get_Field方法代码示例

本文整理汇总了C#中FieldsClass.get_Field方法的典型用法代码示例。如果您正苦于以下问题:C# FieldsClass.get_Field方法的具体用法?C# FieldsClass.get_Field怎么用?C# FieldsClass.get_Field使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FieldsClass的用法示例。


在下文中一共展示了FieldsClass.get_Field方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateShapefile


//.........这里部分代码省略.........
                else if ((dt == typeof(Int16)) || (dt == typeof(Int32)) || (dt == typeof(Int64)))
                    pFieldEdit.Type_2 = esriFieldType.esriFieldTypeInteger;
                else if (dt == typeof(Double))
                    pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDouble;
                else if (dt == typeof(Single))
                    pFieldEdit.Type_2 = esriFieldType.esriFieldTypeSingle;
                else if (dt == typeof(DateTime))
                    pFieldEdit.Type_2 = esriFieldType.esriFieldTypeDate;
                else if (dt == typeof(Guid))
                    //pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGUID;    // not supported by shapefile
                    pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                else if (dt == typeof(ESRI.ArcGIS.Mobile.GlobalId))
                    pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                //pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGlobalID;  // not supported by shapefile

                else if (dt == typeof(Bitmap))   // raster or blob, not supported by shapefile,
                {
                    Console.WriteLine(dc.ColumnName + ": raster field found\n");
                    string folder = strShapeFolder + "\\" + dc.ColumnName;
                    try
                    {
                        if (!Directory.Exists(folder))
                            Directory.CreateDirectory(folder);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                        return null;
                    }
                    pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                }
                else if (dt == typeof(System.Byte[]))   // raster or blob, not supported by shapefile,
                {
                    Console.WriteLine(dc.ColumnName + ": blob field found\n");
                    pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                }
                else if (dt == typeof(Bitmap))   // raster or blob, not supported by shapefile,
                {
                    Console.WriteLine(dc.ColumnName + ": raster field found\n");
                    string folder = strShapeFolder + "\\" + dc.ColumnName;
                    try
                    {
                        if (!Directory.Exists(folder))
                            Directory.CreateDirectory(folder);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.ToString());
                        return null;
                    }

                    pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                }
                else if (dt == typeof(System.Byte[]))   // raster or blob, not supported by shapefile,
                {
                    Console.WriteLine(dc.ColumnName + ": blob field found\n");
                    pFieldEdit.Type_2 = esriFieldType.esriFieldTypeString;
                }
                else if (dt == typeof(ESRI.ArcGIS.Mobile.Geometries.Geometry))
                {
                    Console.WriteLine("geometry field found\n");
                    shpFldName = dc.ColumnName;
                    pFieldEdit.Type_2 = esriFieldType.esriFieldTypeGeometry;
                    IGeometryDef pGeoDef = new GeometryDefClass();
                    IGeometryDefEdit pGeoDefEdit = (IGeometryDefEdit)pGeoDef;
                    pGeoDefEdit.GeometryType_2 = (ESRI.ArcGIS.Geometry.esriGeometryType)selLayer.GeometryType;
                    pGeoDefEdit.SpatialReference_2 = new ESRI.ArcGIS.Geometry.UnknownCoordinateSystemClass();
                    pFieldEdit.GeometryDef_2 = pGeoDef;
                }

                else
                {
                    throw (new Exception("different data type found, modify the code"));
                }

                // add the field to fields
                pFieldsEdit.set_Field(col, pFieldEdit);
            }

            for (int ii = 0; ii < pFields.FieldCount; ii++)
            {
                Console.WriteLine(pFields.get_Field(ii).Name + "\t\t" + pFields.get_Field(ii).Type.ToString());
            }

            //create shapefile
            IFeatureClass fc = null;
            try
            {
                fc = pWS.CreateFeatureClass(shpFileName, pFields, null, null, esriFeatureType.esriFTSimple, shpFldName, "");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            if (fc != null)
                return fc;
            else
                return null;
        }
开发者ID:EricG66,项目名称:mobileCache2Shape1011,代码行数:101,代码来源:Form1.cs


注:本文中的FieldsClass.get_Field方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。