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


C# OSGeo.GetSpatialRef方法代码示例

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


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

示例1: map_fields

        public static void map_fields(OSGeo.OGR.Layer ogr_layer,
            out System.Collections.Hashtable outFieldMap,
            out ESRI.ArcGIS.Geodatabase.IFields outFields, 
            out ESRI.ArcGIS.Geodatabase.esriDatasetType outDatasetType,
            out ESRI.ArcGIS.Geometry.esriGeometryType outGeometryType,
            out int outShapeIndex,
            out int outOIDFieldIndex,
            out ISpatialReference outSpatialReference)
        {
            outSpatialReference = null;
            outFields = null;
            outDatasetType = ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTTable; // start assuming it is a table
            outGeometryType = esriGeometryType.esriGeometryNull; //don't know what it is
            outOIDFieldIndex = -1;
            outShapeIndex = -1;
            outFieldMap = new System.Collections.Hashtable();

            System.Collections.ArrayList fieldArray = new System.Collections.ArrayList();

            OSGeo.OGR.FeatureDefn featDef = ogr_layer.GetLayerDefn();

            int fieldsInserted = 0;

            // OIDs and Geometries can be pseudo fields in GDAL and are thus *may* not included in the OGR FieldDef
            // To account for that add those first (if they exist) and keep a mapping of fields using
            // fieldsInserted

            //////////////////////////////
            //
            // handle oid field pseudo column
            //
            ESRI.ArcGIS.Geodatabase.IFieldEdit2 oidFieldEdit = new ESRI.ArcGIS.Geodatabase.FieldClass();

            if (ogr_layer.GetFIDColumn().Length > 0)
            {

                oidFieldEdit.Name_2 = ogr_layer.GetFIDColumn();
                oidFieldEdit.AliasName_2 = ogr_layer.GetFIDColumn();
            }
            else
            {
                oidFieldEdit.Name_2 = "FID";
                oidFieldEdit.AliasName_2 = "FID";
            }

            oidFieldEdit.Type_2 = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeOID;
            fieldArray.Add(oidFieldEdit);
            outOIDFieldIndex = fieldsInserted;
            fieldsInserted++;

            //////////////////////////////////////
            //
            // handle (optional) geometry field pseudo column
            //

            if (!(ogr_layer.GetGeomType() == OSGeo.OGR.wkbGeometryType.wkbNone ||
                  ogr_layer.GetGeomType() == OSGeo.OGR.wkbGeometryType.wkbUnknown))
            {
                ESRI.ArcGIS.Geodatabase.IFieldEdit2 geomFieldEdit = new ESRI.ArcGIS.Geodatabase.FieldClass();

                if (ogr_layer.GetGeometryColumn().Length > 0)
                {

                    geomFieldEdit.Name_2 = ogr_layer.GetGeometryColumn();
                    geomFieldEdit.AliasName_2 = ogr_layer.GetGeometryColumn();

                }
                else
                {
                    geomFieldEdit.Name_2 = "Shape";
                    geomFieldEdit.AliasName_2 = "Shape";
                }

                geomFieldEdit.Type_2 = ESRI.ArcGIS.Geodatabase.esriFieldType.esriFieldTypeGeometry;

                // add geometry def

                ESRI.ArcGIS.Geometry.esriGeometryType gdbType;
                bool hasZ;
                ogr_geo_type_to_esri_geo_type(ogr_layer.GetGeomType(), out gdbType, out hasZ);

                ESRI.ArcGIS.Geodatabase.IGeometryDefEdit geomDef = new ESRI.ArcGIS.Geodatabase.GeometryDefClass();
                geomDef.GeometryType_2 = gdbType;
                geomDef.HasM_2 = false; //no M support on OGR
                geomDef.HasZ_2 = hasZ;
                geomDef.SpatialReference_2 = outSpatialReference = ogr_utils.get_spatialReference(ogr_layer.GetSpatialRef());

                geomFieldEdit.GeometryDef_2 = geomDef;

                fieldArray.Add(geomFieldEdit);

                outDatasetType = ESRI.ArcGIS.Geodatabase.esriDatasetType.esriDTFeatureClass; // upgrade to featureclass
                outGeometryType = gdbType;
                outShapeIndex = fieldsInserted;

                fieldsInserted++;
            }

            int fieldCount = featDef.GetFieldCount();

//.........这里部分代码省略.........
开发者ID:geobabbler,项目名称:arcgis-ogr,代码行数:101,代码来源:ogrplugin_utils.cs


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