本文整理汇总了C#中FeatureDataTable.LoadDataRow方法的典型用法代码示例。如果您正苦于以下问题:C# FeatureDataTable.LoadDataRow方法的具体用法?C# FeatureDataTable.LoadDataRow怎么用?C# FeatureDataTable.LoadDataRow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FeatureDataTable
的用法示例。
在下文中一共展示了FeatureDataTable.LoadDataRow方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateGeometryLayer
public VectorLayer CreateGeometryLayer()
{
var gf = new NetTopologySuite.Geometries.GeometryFactory();
var fdt = new FeatureDataTable();
fdt.Columns.Add(new DataColumn("Name", typeof (String)));
fdt.BeginLoadData();
var fdr = (FeatureDataRow)fdt.LoadDataRow(new[] {(object) "Mayence"}, true);
fdr.Geometry = gf.CreatePoint(new Point(8.1, 50.0));
fdt.EndLoadData();
var vLayer = new VectorLayer("GeometryProvider");
vLayer.DataSource = new FeatureProvider(fdt);
vLayer.SRID = 4326;
return vLayer;
}
示例2: ExecuteIntersectionQuery
/// <summary>
/// Returns all features with the view box
/// </summary>
/// <param name="bbox">view box</param>
/// <param name="ds">FeatureDataSet to fill data into</param>
public override void ExecuteIntersectionQuery(Envelope bbox, FeatureDataSet ds)
{
//List<Geometries.Geometry> features = new List<SharpMap.Geometries.Geometry>();
using (var conn = new OleDbConnection(ConnectionString))
{
conn.Open();
var strSQL = "SELECT * FROM " + Table + " WHERE ";
//If a definition query has been specified, add this as a filter on the query
strSQL += GetDefinitionQueryConstraint(true);
//Limit to the points within the boundingbox
strSQL += GetSpatialConstraint(bbox);
using (var cmd = new OleDbCommand(strSQL, conn))
{
using (var reader = cmd.ExecuteReader())
{
if (reader == null)
throw new InvalidOperationException();
//Set up result table
var fdt = new FeatureDataTable();
fdt.TableName = Table;
for (var c = 0; c < reader.FieldCount; c++)
{
var fieldType = reader.GetFieldType(c);
if (fieldType == null)
throw new Exception("Failed to retrieve field type for column: " + c);
fdt.Columns.Add(reader.GetName(c), fieldType);
}
var dataTransfer = new object[reader.FieldCount];
//Get factory and precision model
var factory = Factory;
var pm = factory.PrecisionModel;
fdt.BeginLoadData();
while (reader.Read())
{
var count = reader.GetValues(dataTransfer);
System.Diagnostics.Debug.Assert(count == dataTransfer.Length);
var fdr = (FeatureDataRow) fdt.LoadDataRow(dataTransfer, true);
var c = new Coordinate(Convert.ToDouble(fdr[XColumn]), Convert.ToDouble(fdr[YColumn]));
pm.MakePrecise(c);
fdr.Geometry = Factory.CreatePoint(c);
}
fdt.EndLoadData();
ds.Tables.Add(fdt);
}
}
}
}
示例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;
}
示例4: CreateNewRow
/// <summary>
/// Creates a new row in the given <see cref="SharpMap.Data.FeatureDataTable"/> <paramref name="dataTable"/>
/// using data in <see cref="NetTopologySuite.Features.Feature"/> <paramref name="feature"/>.
/// </summary>
/// <param name="dataTable">The <see cref="SharpMap.Data.FeatureDataTable"/> to fill.</param>
/// <param name="feature">Data to insert in the <see cref="SharpMap.Data.FeatureDataTable"/>.</param>
private static void CreateNewRow(FeatureDataTable dataTable, Feature feature)
{
var row = (FeatureDataRow) dataTable.LoadDataRow(feature.Attributes.GetValues(), true);
row.Geometry = feature.Geometry;
}
示例5: ExecuteIntersectionQuery
/// <summary>
/// Throws an NotSupportedException. Attribute data is not supported by this datasource
/// </summary>
/// <param name="box"></param>
/// <param name="ds">FeatureDataSet to fill data into</param>
public void ExecuteIntersectionQuery(BoundingBox box, FeatureDataSet ds)
{
FeatureDataTable fdt = new FeatureDataTable();
fdt = _features.Clone();
foreach (FeatureDataRow fdr in _features)
if (fdr.Geometry.GetBoundingBox().Intersects(box))
{
fdt.LoadDataRow(fdr.ItemArray, false);
(fdt.Rows[fdt.Rows.Count - 1] as FeatureDataRow).Geometry = fdr.Geometry;
}
ds.Tables.Add(fdt);
}
示例6: FillRealDataTable
private static void FillRealDataTable(FeatureDataTable table)
{
table.BeginLoadData();
var factory = GeoAPI.GeometryServiceProvider.Instance.CreateGeometryFactory(4326);
uint id = 0;
foreach (var datas in PointData())
{
var row = (FeatureDataRow) table.LoadDataRow(new object[] {id++, datas[0]}, LoadOption.OverwriteChanges);
row.Geometry = factory.CreatePoint(new Coordinate(datas[2], datas[1]));
}
table.EndLoadData();
}
示例7: ExecuteIntersectionQuery
/// <summary>
/// Throws an NotSupportedException. Attribute data is not supported by this datasource
/// </summary>
/// <param name="geom"></param>
/// <param name="ds">FeatureDataSet to fill data into</param>
public void ExecuteIntersectionQuery(Geometry geom, FeatureDataSet ds)
{
FeatureDataTable fdt = new FeatureDataTable();
fdt = _features.Clone();
foreach (FeatureDataRow fdr in _features)
if (FilterDelegate == null || FilterDelegate(fdr))
{
if (fdr.Geometry.GetBoundingBox().Intersects(geom))
{
fdt.LoadDataRow(fdr.ItemArray, false);
(fdt.Rows[fdt.Rows.Count - 1] as FeatureDataRow).Geometry = fdr.Geometry;
}
}
ds.Tables.Add(fdt);
}