代码
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();
}

 

 

posted on 2010-12-06 15:25  hl3292  阅读(1527)  评论(0编辑  收藏  举报