本文整理汇总了C#中OSGeo.IsFieldSet方法的典型用法代码示例。如果您正苦于以下问题:C# OSGeo.IsFieldSet方法的具体用法?C# OSGeo.IsFieldSet怎么用?C# OSGeo.IsFieldSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OSGeo
的用法示例。
在下文中一共展示了OSGeo.IsFieldSet方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例2: 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
}
}
示例3: 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++)
{
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;
}
}
fdr.Geometry = ParseOgrGeometry(ogrFeature.GetGeometryRef());
return fdr;
}