本文整理汇总了C#中IProvider.GetFeatureCount方法的典型用法代码示例。如果您正苦于以下问题:C# IProvider.GetFeatureCount方法的具体用法?C# IProvider.GetFeatureCount怎么用?C# IProvider.GetFeatureCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IProvider
的用法示例。
在下文中一共展示了IProvider.GetFeatureCount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestProvider
private static void TestProvider(IProvider provider, GpkgContent content)
{
int numFeatures = 0;
Assert.DoesNotThrow(() => numFeatures = provider.GetFeatureCount(),
"GetFeatureCount threw exception:\n\tConnection{0}\n\t{1}",
provider.ConnectionID, content.TableName);
var extent = provider.GetExtents();
Collection<uint> oids = null;
Assert.DoesNotThrow(() => oids = provider.GetObjectIDsInView(extent),
"GetObjectIDsInView threw exception:\n\tConnection{0}\n\t{1}",
provider.ConnectionID, content.TableName);
Assert.AreEqual(numFeatures, oids.Count);
foreach (var oid in oids)
{
IGeometry geom = null;
Assert.DoesNotThrow(() => geom = provider.GetGeometryByID(oid),
"GetGeometryByID threw exception:\n\tConnection{0}\n\t{1}",
provider.ConnectionID, content.TableName);
FeatureDataRow feat = null;
Assert.DoesNotThrow(() => feat = provider.GetFeature(oid),
"GetFeature threw exception:\n\tConnection{0}\n\t{1}",
provider.ConnectionID, content.TableName);
Assert.IsTrue(geom.EqualsExact(feat.Geometry));
}
Collection<IGeometry> geoms = null;
Assert.DoesNotThrow(() => geoms = provider.GetGeometriesInView(extent),
"GetFeature threw exception:\n\tConnection{0}\n\t{1}",
provider.ConnectionID, content.TableName);
Assert.AreEqual(numFeatures, geoms.Count);
var fds = new FeatureDataSet();
Assert.DoesNotThrow(() => provider.ExecuteIntersectionQuery(extent, fds),
"GetFeature threw exception:\n\tConnection{0}\n\t{1}",
provider.ConnectionID, content.TableName);
Assert.AreEqual(numFeatures, fds.Tables[0].Rows.Count);
}
示例2: BuildFromProvider
/// <summary>
/// Builds from the given provider.
/// </summary>
/// <param name="provider">
/// The base <see cref="SharpMap.Data.Providers.IProvider"/>
/// from witch initialize the <see cref="NtsProvider"/> instance.
/// </param>
private void BuildFromProvider(IProvider provider)
{
// Features list initialization
features = new List<Feature>(provider.GetFeatureCount());
try
{
// Load all features from the given provider
provider.Open();
Collection<uint> ids = provider.GetObjectIDsInView(provider.GetExtents());
foreach (uint id in ids)
{
FeatureDataRow dataRow = provider.GetFeature(id);
GisSharpBlog.NetTopologySuite.Geometries.Geometry geometry =
GeometryConverter.ToNTSGeometry(dataRow.Geometry, geometryFactory);
AttributesTable attributes = new AttributesTable();
foreach (DataColumn column in dataRow.Table.Columns)
{
if (dataRow[column] == null || dataRow[column].GetType() == typeof (DBNull))
throw new ApplicationException("Null values not supported");
attributes.AddAttribute(column.ColumnName, dataRow[column]);
}
features.Add(new Feature(geometry, attributes));
}
}
finally
{
if (provider.IsOpen)
provider.Close();
}
}
示例3: BuildFromProvider
/// <summary>
/// Builds from the given provider.
/// </summary>
/// <param name="provider">
/// The base <see cref="SharpMap.Data.Providers.IProvider"/>
/// from witch initialize the <see cref="NtsProvider"/> instance.
/// </param>
private void BuildFromProvider(IProvider provider)
{
// Features list initialization
_features = new List<Feature>(provider.GetFeatureCount());
try
{
// Load all features from the given provider
provider.Open();
var ids = provider.GetOidsInView(provider.GetExtents());
foreach (var id in ids)
{
var dataRow = provider.GetFeatureByOid(id);
var geometry = dataRow.Geometry;
AttributesTable attributes = new AttributesTable();
var att = dataRow.Attributes;
foreach (var column in dataRow.Factory.AttributesDefinition)
{
var attName = column.AttributeName;
if (att[attName] == null || att[attName] is DBNull)
throw new ApplicationException("Null values not supported");
attributes.AddAttribute(attName, att[column.AttributeName]);
}
_features.Add(new Feature(geometry, attributes));
}
}
finally
{
if (provider.IsOpen)
provider.Close();
}
}
示例4: BuildFromProvider
/// <summary>
/// Builds from the given provider.
/// </summary>
/// <param name="provider">
/// The base <see cref="SharpMap.Data.Providers.IProvider"/>
/// from witch initialize the <see cref="NtsProvider"/> instance.
/// </param>
private void BuildFromProvider(IProvider provider)
{
// Features list initialization
_features = new List<Feature>(provider.GetFeatureCount());
try
{
// Load all features from the given provider
provider.Open();
Collection<uint> ids = provider.GetObjectIDsInView(provider.GetExtents());
foreach (uint id in ids)
{
var dataRow = provider.GetFeature(id);
var geometry = dataRow.Geometry;
AttributesTable attributes = new AttributesTable();
foreach (DataColumn column in dataRow.Table.Columns)
{
if (dataRow[column] == null || dataRow[column] is DBNull)
throw new ApplicationException("Null values not supported");
attributes.AddAttribute(column.ColumnName, dataRow[column]);
}
_features.Add(new Feature(geometry, attributes));
}
}
finally
{
if (provider.IsOpen)
provider.Close();
}
}