public virtual IGeometry IntersectsMuliDim(IGeometry byGeo, IGeometry pGeo) { IGeometry retGeo = null; IGeometry TopGeometry1 = byGeo; IGeometry TopGeometry2 = pGeo; if (TopGeometry1 == null || TopGeometry2 == null || TopGeometry1.IsEmpty == true || TopGeometry2.IsEmpty == true) { retGeo = null; MessageBox.Show("空间叠加有一对象为空", "空间分析错误"); return(retGeo); } if (!(TopGeometry1 is ITopologicalOperator2) && !(TopGeometry2 is ITopologicalOperator2)) { retGeo = null; MessageBox.Show("空间叠加有一对象不是高级对象(Polygon,Polyline,MuliPoint)", "空间分析错误"); return(retGeo); } try { Topoperator2 = (ITopologicalOperator2)TopGeometry2; Topoperator2.Simplify(); Topoperator2 = (ITopologicalOperator2)TopGeometry1; Topoperator2.Simplify(); retGeo = Topoperator2.IntersectMultidimension(TopGeometry2); } catch (Exception ee) { retGeo = null; System.Diagnostics.Debug.WriteLine(ee.ToString()); //ZH.Error.Write.Line("ZHFeature.IntersectsMuliDim():<Topoperator2.IntersectMultidimension>出错:<" + this.Tag.ToString() + ">", ee.Message); } return(retGeo); }
public bool Snap(IGeometry igeometry_0, IPoint ipoint_0, double double_0) { bool flag; int i; IHitTest shape; IGeometry geometry; if (!EditorLicenseProviderCheck.Check()) { flag = false; } else if (this.ifeatureCache_0.Count != 0) { bool flag1 = false; double num = 0; int num1 = 0; int num2 = 0; bool flag2 = true; IPoint pointClass = new ESRI.ArcGIS.Geometry.Point(); object value = Missing.Value; IArray arrayClass = new Array(); for (i = 0; i < this.ifeatureCache_0.Count; i++) { shape = (IHitTest)this.ifeatureCache_0.Feature[i].Shape; if ((shape is IPolyline ? true : shape is IPolygon) && shape.HitTest(ipoint_0, double_0, esriGeometryHitPartType.esriGeometryPartBoundary, pointClass, ref num, ref num1, ref num2, ref flag2)) { arrayClass.Add(shape); } } IPointCollection multipointClass = new Multipoint(); IArray arrayClass1 = new Array() as IArray; for (i = 0; i < arrayClass.Count; i++) { ITopologicalOperator2 element = (ITopologicalOperator2)arrayClass.Element[i]; for (int j = 0; j < arrayClass.Count; j++) { if (i != j) { if (((IGeometry)arrayClass.Element[i]).GeometryType != ((IGeometry)arrayClass.Element[j]).GeometryType) { geometry = element.IntersectMultidimension((IGeometry)arrayClass.Element[j]); if (geometry != null) { IGeometryCollection geometryCollection = geometry as IGeometryCollection; if (geometryCollection != null) { for (int k = 0; k < geometryCollection.GeometryCount; k++) { geometry = geometryCollection.Geometry[k]; if (geometry is IPointCollection) { multipointClass.AddPointCollection((IPointCollection)geometry); } else if (geometry is IPointCollection) { multipointClass.AddPoint((IPoint)geometry, ref value, ref value); } } } } } else { geometry = element.Intersect((IGeometry)arrayClass.Element[j], esriGeometryDimension.esriGeometry0Dimension); if (geometry != null) { if (geometry is IPointCollection) { multipointClass.AddPointCollection((IPointCollection)geometry); } else if (geometry is IPointCollection) { multipointClass.AddPoint((IPoint)geometry, ref value, ref value); } } } } } } shape = (IHitTest)multipointClass; if (shape.HitTest(ipoint_0, double_0, esriGeometryHitPartType.esriGeometryPartVertex, pointClass, ref num, ref num1, ref num2, ref flag2)) { ipoint_0.PutCoords(pointClass.X, pointClass.Y); flag1 = true; } flag = flag1; } else { flag = false; } return(flag); }
private IPoint method_8(IPoint ipoint_0, IFeatureCache2 ifeatureCache2_0, double double_0) { int i; IGeometry geometry; double num = 0; int num1 = 0; int num2 = 0; bool flag = true; IPoint point = null; List <IGeometry> geometries = new List <IGeometry>(); for (i = 0; i < ifeatureCache2_0.Count; i++) { IFeature feature = ifeatureCache2_0.Feature[i]; if ((feature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline ? true : feature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)) { IPoint pointClass = new ESRI.ArcGIS.Geometry.Point(); IHitTest shape = (IHitTest)feature.Shape; if ( shape.HitTest(ipoint_0, double_0, esriGeometryHitPartType.esriGeometryPartBoundary, pointClass, ref num, ref num1, ref num2, ref flag) && num <= double_0) { IGeometryCollection geometryCollection = shape as IGeometryCollection; if (geometryCollection != null) { ISegmentCollection segmentCollection = geometryCollection.Geometry[num1] as ISegmentCollection; if (segmentCollection != null) { //segmentCollection.Segment[num2] is ICircularArc; } } } } } IPointCollection multipointClass = new Multipoint(); for (i = 0; i < geometries.Count; i++) { ITopologicalOperator2 item = (ITopologicalOperator2)geometries[i]; for (int j = 0; j < geometries.Count; j++) { if (i != j) { if (geometries[i].GeometryType != geometries[j].GeometryType) { geometry = item.IntersectMultidimension(geometries[j]); if (geometry != null) { IGeometryCollection geometryCollection1 = geometry as IGeometryCollection; if (geometryCollection1 != null) { for (int k = 0; k < geometryCollection1.GeometryCount; k++) { geometry = geometryCollection1.Geometry[k]; if (geometry is IPointCollection) { multipointClass.AddPointCollection((IPointCollection)geometry); } else if (geometry is IPoint) { object value = Missing.Value; object obj = Missing.Value; multipointClass.AddPoint((IPoint)geometry, ref value, ref obj); } } } } } else { geometry = item.Intersect(geometries[j], esriGeometryDimension.esriGeometry0Dimension); if (geometry != null) { if (geometry is IPointCollection) { multipointClass.AddPointCollection((IPointCollection)geometry); } else if (geometry is IPoint) { object value1 = Missing.Value; object obj1 = Missing.Value; multipointClass.AddPoint((IPoint)geometry, ref value1, ref obj1); } } } } } } IHitTest hitTest = (IHitTest)multipointClass; IPoint pointClass1 = new ESRI.ArcGIS.Geometry.Point(); if ( hitTest.HitTest(ipoint_0, double_0, esriGeometryHitPartType.esriGeometryPartVertex, pointClass1, ref num, ref num1, ref num2, ref flag) && num < double_0) { point = pointClass1; } return(point); }