IPoint point = new PointClass();
point.PutCoords(, ); //ITopologicalOperator接口用于几何对象的几何操作
ITopologicalOperator topo = point as ITopologicalOperator;
//做一个几何对象的缓冲区(结果也是个几何对象),参数1是缓冲半径
//点线面的缓冲区都是面,所以可以直接as到IPolygon
IPolygon polygon = topo.Buffer() as IPolygon; ITopologicalOperator2 topo2 = point as ITopologicalOperator2;
//错误几何对象的修复,如果当几何对象有几何错误,例如面有自相交,可以用此修复
topo2.IsKnownSimple_2 = false;
topo2.Simplify(); topo = polygon as ITopologicalOperator;
//获取面的边,面的边是线
IPolyline polyline = topo.Boundary as IPolyline; IPolygon polygon2 = new PolygonClass(); topo = polygon as ITopologicalOperator;
//求两个几何对象的重叠部分
//两个几何对象的重叠部分,可以有很多种几何类型组合,例如面与面重叠是面,线与线重叠是线或者点,点与点重叠是点,点与面重叠是点,线与面重叠是线等等
//参数2是返回结果是多少维的意思,根据经验如果返回结果是点就是0维(esriGeometry0Dimension),线就是1维,面就是2维
//官方文档还有详细说明,使用者要结合文档和实际使用情况相互对照来学习
IGeometry geometry3 = topo.Intersect(polygon2, esriGeometryDimension.esriGeometry2Dimension); //两个几何对象的几何操作还有:
//Union 求两个几何对象合并后的,也就是求并集
//Clip 裁剪
//Cut 用线把面一份为二
//Difference 擦除 //IRelationalOperator用于判断两个几何对象的空间关系
//IRelationalOperator的每种空间关系在官方文档有具体截图
IRelationalOperator relaOper = polygon as IRelationalOperator;
//求两个几何对象是否有重叠部分,注意:Overlaps判断的两个几何对象的几何类型必须相同
bool result = relaOper.Overlaps(polygon2); //其他空间关系判断有:
//Contains-完全包含
//Crosses-穿过?
//Disjoint-完全不相交
//Equals-完全重叠(就是两个几何对象完全一样,常用!!!!!)
//Touches-边沿重叠?
//Within-完全包含2 IPoint point2 = new PointClass();
point.PutCoords(, ); //计算两点距离
double distance = GeometryHelper.TwoPointDistance(point, point2);