本文整理汇总了C#中PolylineClass.RemovePoints方法的典型用法代码示例。如果您正苦于以下问题:C# PolylineClass.RemovePoints方法的具体用法?C# PolylineClass.RemovePoints怎么用?C# PolylineClass.RemovePoints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PolylineClass
的用法示例。
在下文中一共展示了PolylineClass.RemovePoints方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: deleteFeature
//IFeatureLayer m_FeatureLayer
/// <summary>
/// 删除节点
/// </summary>
/// <param name="m_Feature"></param>
public bool deleteFeature(int x, int y)
{
//IGeometryCollection pGeomColn ;
//IPointCollection pPointColn;
IObjectClass pObjectClass;
IFeature pFeature;
IGeometry pGeom;
//IPath pPath ;
IPoint pHitPoint = null;
IPoint pPoint = null;
Double hitDist = 0.0;
double tol;
int vertexIndex = 0;
//int numVertices;
int partIndex = 0;
bool vertex = false;
try
{
m_pMap.ClearSelection();
// 取得鼠标击中的第一个对象
SelectMouseDown(x, y);
IEnumFeature pSelected = (IEnumFeature)m_pMap.FeatureSelection;
pFeature = pSelected.Next();
if (pFeature == null) return false;
IActiveView pActiveView = (IActiveView)m_pMap;
pPoint = pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y);
// 节点空间查询容差
tol = ConvertPixelsToMapUnits(pActiveView, 4.0);
pGeom = pFeature.Shape;
pObjectClass = pFeature.Class;
m_pEditFeature = pFeature;
object objNull = Missing.Value;
//object objBefore, objAfter;
IPointCollection pointCollection;
if (m_pEditFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline & TestGeometryHit(tol, pPoint, pFeature, pHitPoint, hitDist, out partIndex, out vertexIndex, out vertex))
{
pointCollection = new PolylineClass();
IPolyline polyline = m_pEditFeature.Shape as IPolyline;
pointCollection = polyline as IPointCollection;
//如果点个数少于两个就无法构成线
if (pointCollection.PointCount > 2)
{
//移除指定的节点
pointCollection.RemovePoints(vertexIndex, 1);
}
else
{
MessageBox.Show("此先已经少于两个点,不能在删除");
}
}
else if (m_pEditFeature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon & TestGeometryHit(tol, pPoint, pFeature, pHitPoint, hitDist, out partIndex, out vertexIndex, out vertex))
{
pointCollection = new PolygonClass();
IPolygon polygon = m_pEditFeature.Shape as IPolygon;
pointCollection = polygon as IPointCollection;
//点数少于三个就不能能构成面
if (pointCollection.PointCount > 3)
{
//移除指点的节点
pointCollection.RemovePoints(vertexIndex, 1);
}
else
{
MessageBox.Show("此先已经少于三个点,不能在删除");
}
}
IWorkspaceEdit workspaceEdit;
IWorkspace workspace;
IFeatureLayer pFeatureLayer = (IFeatureLayer)m_pCurrentLayer;
IDataset dataset = pFeatureLayer.FeatureClass as IDataset;
workspace = dataset.Workspace;
workspaceEdit = workspace as IWorkspaceEdit;
//开始编辑
workspaceEdit.StartEditing(true);
workspaceEdit.StartEditOperation();
//保存数据
m_pEditFeature.Store();
//结束编辑
workspaceEdit.StopEditOperation();
workspaceEdit.StopEditing(true);
pActiveView = (IActiveView)m_pMap;
pActiveView.Refresh();
return true;
}
catch (Exception e)
{
Console.WriteLine(e.Message.ToString());
return false;
}
}