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


C# OSGeo.GetFieldAsDateTime方法代码示例

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


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

示例1: get_mapped_value

        public object get_mapped_value(OSGeo.OGR.Feature feature, int esriFieldsIndex)
        {
            // get the ESRI Field
            ESRI.ArcGIS.Geodatabase.IField pField = m_fields.get_Field(esriFieldsIndex);

            if (esriFieldsIndex == m_oidFieldIndex)
                return feature.GetFID();

            if (esriFieldsIndex == m_geometryFieldIndex)
            {
                System.Diagnostics.Debug.Assert(false);
                return null; // this should never be called for geometries
            }

            int ogrIndex = (int) m_fieldMapping[esriFieldsIndex];

            if (!feature.IsFieldSet(ogrIndex))
                return null;

            switch (feature.GetFieldType(ogrIndex))
            {
                // must be kept in sync with utilities library

                case OSGeo.OGR.FieldType.OFTInteger:
                    return feature.GetFieldAsInteger(ogrIndex);

                case OSGeo.OGR.FieldType.OFTReal:
                    return feature.GetFieldAsDouble(ogrIndex);

                case OSGeo.OGR.FieldType.OFTString:
                    return ogr_utils.ghetto_fix_ogr_string(feature.GetFieldAsString(ogrIndex));

                case OSGeo.OGR.FieldType.OFTBinary:

                   // WTF, the C# bindings don't have a blob retrieval until this ticket gets solved
                  // http://trac.osgeo.org/gdal/ticket/4457#comment:2

                    return null;

                case OSGeo.OGR.FieldType.OFTDateTime:
                    {

                        int year, month, day, hour, minute, second, flag;
                        feature.GetFieldAsDateTime(ogrIndex, out year, out month, out day, out hour, out minute, out second, out flag);

                        DateTime date = new DateTime(year, month, day, hour, minute, second);
                        return date;
                    }

                default:
                    return ogr_utils.ghetto_fix_ogr_string(feature.GetFieldAsString(ogrIndex)); //most things coerce as strings
            }
        }
开发者ID:zhouqime,项目名称:arcgis-ogr,代码行数:53,代码来源:OGRDataset.cs

示例2: OgrFeatureToFeatureDataRow

        private static FeatureDataRow OgrFeatureToFeatureDataRow(FeatureDataTable table, OSGeo.OGR.Feature ogrFeature)
        {
            FeatureDataRow fdr = table.NewRow();
            Int32 fdrIndex = 0;
            for (int iField = 0; iField < ogrFeature.GetFieldCount(); iField++)
            {
                switch (ogrFeature.GetFieldType(iField))
                {
                    case OgrFieldType.OFTString:
                    case OgrFieldType.OFTWideString:
                        fdr[fdrIndex++] = ogrFeature.GetFieldAsString(iField);
                        break;
                    case OgrFieldType.OFTStringList:
                    case OgrFieldType.OFTWideStringList:
                        break;
                    case OgrFieldType.OFTInteger:
                        fdr[fdrIndex++] = ogrFeature.GetFieldAsInteger(iField);
                        break;
                    case OgrFieldType.OFTIntegerList:
                        break;
                    case OgrFieldType.OFTReal:
                        fdr[fdrIndex++] = ogrFeature.GetFieldAsDouble(iField);
                        break;
                    case OgrFieldType.OFTRealList:
                        break;
                    case OgrFieldType.OFTDate:
                    case OgrFieldType.OFTDateTime:
                    case OgrFieldType.OFTTime:
                        Int32 y, m, d, h, mi, s, tz;
                        ogrFeature.GetFieldAsDateTime(iField, out y, out m, out d, out h, out mi, out s, out tz);
                        fdr[fdrIndex++] = new DateTime(y, m, d, h, mi, s);
                        break;
                    default:
                        Debug.WriteLine(string.Format("Cannot handle Ogr DataType '{0}'", ogrFeature.GetFieldType(iField)));
                        break;
                }
            }

            fdr.Geometry = ParseOgrGeometry(ogrFeature.GetGeometryRef());
            return fdr;
        }
开发者ID:goranpavlovic,项目名称:Gis,代码行数:41,代码来源:OgrProvider.cs

示例3: LoadOgrFeatureToFeatureDataRow

        private static FeatureDataRow LoadOgrFeatureToFeatureDataRow(FeatureDataTable table, OSGeo.OGR.Feature ogrFeature, GeoAPI.Geometries.IGeometryFactory factory)
        {
            var values = new object[ogrFeature.GetFieldCount()];
            
            for (var iField = 0; iField < ogrFeature.GetFieldCount(); iField++)
            {
                // No need to get field value if there's no value available...
                if (!ogrFeature.IsFieldSet(iField))
                {
                    continue;
                }

                int count;
                switch (ogrFeature.GetFieldType(iField))
                {
                    case OgrFieldType.OFTString:
                    case OgrFieldType.OFTWideString:
                        values[iField] = ogrFeature.GetFieldAsString(iField);
                        break;
                    case OgrFieldType.OFTStringList:
                    case OgrFieldType.OFTWideStringList:
                        values[iField] = ogrFeature.GetFieldAsStringList(iField);
                        break;
                    case OgrFieldType.OFTInteger:
                        values[iField] = ogrFeature.GetFieldAsInteger(iField);
                        break;
                    case OgrFieldType.OFTIntegerList:
                        values[iField] = ogrFeature.GetFieldAsIntegerList(iField, out count);
                        break;
                    case OgrFieldType.OFTReal:
                        values[iField] = ogrFeature.GetFieldAsDouble(iField);
                        break;
                    case OgrFieldType.OFTRealList:
                        values[iField] = ogrFeature.GetFieldAsDoubleList(iField, out count);
                        break;
                    case OgrFieldType.OFTDate:
                    case OgrFieldType.OFTDateTime:
                    case OgrFieldType.OFTTime:
                        Int32 y, m, d, h, mi, s, tz;
                        ogrFeature.GetFieldAsDateTime(iField, out y, out m, out d, out h, out mi, out s, out tz);
                        try
                        {
                            if (y == 0 && m == 0 && d == 0)
                                values[iField] = DateTime.MinValue.AddMinutes(h * 60 + mi);
                            else
                                values[iField] = new DateTime(y, m, d, h, mi, s);
                        }
// ReSharper disable once EmptyGeneralCatchClause
                        catch { }
                        break;
                    default:
                        Debug.WriteLine("Cannot handle Ogr DataType '{0}'", ogrFeature.GetFieldType(iField));
                        break;
                }
            }

            var fdr = (FeatureDataRow)table.LoadDataRow(values, true);

            using (var gr = ogrFeature.GetGeometryRef())
            {
                fdr.Geometry = ParseOgrGeometry(gr, factory);
                gr.Dispose();
            }
            return fdr;
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:65,代码来源:OgrProvider.cs

示例4: OgrFeatureToFeatureDataRow

        private static FeatureDataRow OgrFeatureToFeatureDataRow(FeatureDataTable table, OSGeo.OGR.Feature ogrFeature, GeoAPI.Geometries.IGeometryFactory factory)
        {
            FeatureDataRow fdr = table.NewRow();
            Int32 fdrIndex = 0;
            for (int iField = 0; iField < ogrFeature.GetFieldCount(); iField++)
            {
                if (!ogrFeature.IsFieldSet(iField)) continue;

                switch (ogrFeature.GetFieldType(iField))
                {
                    case OgrFieldType.OFTString:
                    case OgrFieldType.OFTWideString:
                        fdr[fdrIndex++] = ogrFeature.GetFieldAsString(iField);
                        break;
                    case OgrFieldType.OFTStringList:
                    case OgrFieldType.OFTWideStringList:
                        break;
                    case OgrFieldType.OFTInteger:
                        fdr[fdrIndex++] = ogrFeature.GetFieldAsInteger(iField);
                        break;
                    case OgrFieldType.OFTIntegerList:
                        break;
                    case OgrFieldType.OFTReal:
                        fdr[fdrIndex++] = ogrFeature.GetFieldAsDouble(iField);
                        break;
                    case OgrFieldType.OFTRealList:
                        break;
                    case OgrFieldType.OFTDate:
                    case OgrFieldType.OFTDateTime:
                    case OgrFieldType.OFTTime:
                        Int32 y, m, d, h, mi, s, tz;
                        ogrFeature.GetFieldAsDateTime(iField, out y, out m, out d, out h, out mi, out s, out tz);
                        try
                        {
                            if (y == 0 && m == 0 && d == 0)
                                fdr[fdrIndex++] = DateTime.MinValue.AddMinutes(h*60 + mi);
                            else
                                fdr[fdrIndex++] = new DateTime(y, m, d, h, mi, s);
                        }
                        catch { }
                        break;
                    default:
                        Debug.WriteLine(string.Format("Cannot handle Ogr DataType '{0}'", ogrFeature.GetFieldType(iField)));
                        break;
                }
            }

            using (var gr = ogrFeature.GetGeometryRef())
            {
                fdr.Geometry = ParseOgrGeometry(gr, factory);
                gr.Dispose();
            }
            return fdr;
        }
开发者ID:PedroMaitan,项目名称:sharpmap,代码行数:54,代码来源:OgrProvider.cs


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