IFeatureClass_CreateFeature_Example

本文提供了一个使用ArcGIS API创建管线特征类的例子。通过构造一个具有起点和终点的Polyline对象,并将其作为新特征的Shape属性,展示了如何初始化特征并设置默认值,最后将这些值保存到数据库。



代码
public void IFeatureClass_CreateFeature_Example(IFeatureClass featureClass)
{
//Function is designed to work with polyline data
if (featureClass.ShapeType != ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline)
{
return;
}
//create a geometry for the features shape
ESRI.ArcGIS.Geometry.IPolyline polyline = new ESRI.ArcGIS.Geometry.PolylineClass();
ESRI.ArcGIS.Geometry.IPoint point
= new ESRI.ArcGIS.Geometry.PointClass();
point.X
= 0;
point.Y
= 0;
polyline.FromPoint
= point;
point
= new ESRI.ArcGIS.Geometry.PointClass();
point.X
= 10; point.Y = 10;
polyline.ToPoint
= point;
IFeature feature
= featureClass.CreateFeature();
//Apply the constructed shape to the new features shape
feature.Shape = polyline;
ISubtypes subtypes
= (ISubtypes)featureClass;
IRowSubtypes rowSubtypes
= (IRowSubtypes)feature;
if (subtypes.HasSubtype)
// does the feature class have subtypes?
{
rowSubtypes.SubtypeCode
= 1;
//in this example 1 represents the Primary Pipeline subtype
}
// initalize any default values that the feature has
rowSubtypes.InitDefaultValues();
//Commit the default values in the feature to the database
feature.Store();
//update the value on a string field that indicates who installed the feature.
feature.set_Value(feature.Fields.FindField("InstalledBy"), "K Johnston");
//Commit the updated values in the feature to the database
feature.Store();
}

 

 

转载于:https://www.cnblogs.com/hl3292/archive/2010/12/06/1897790.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值