/// <summary> /// Recursively parses a d8list and determines in any of the features /// are in the extent. Intended for use with an ATE. /// </summary> /// <param name="IRO">Bounding Extent</param> /// <param name="List">Designer List Object</param> /// <returns></returns> private static bool HasD8ChildInExtent(IRelationalOperator IRO, ID8List List) { bool allchildrenoutofextent = true; #region Check the current list item if (List is ID8GeoAssoc) { IFeature GuFeat = ((ID8GeoAssoc)List).AssociatedGeoRow as IFeature; if (GuFeat != null && GuFeat.Shape != null) { if (!IRO.Disjoint(GuFeat.Shape)) { allchildrenoutofextent = false; } } } #endregion List.Reset(); ID8ListItem Child = List.Next(false); while (Child != null && allchildrenoutofextent) { #region Process children until we find a child inside the extent if (Child is ID8GeoAssoc) { IFeature GuFeat = ((ID8GeoAssoc)Child).AssociatedGeoRow as IFeature; if (GuFeat != null && GuFeat.Shape != null) { if (!IRO.Disjoint(GuFeat.Shape)) { allchildrenoutofextent = false; } } } if (Child is ID8List) { allchildrenoutofextent = !HasD8ChildInExtent(IRO, (ID8List)Child); } Child = List.Next(false); #endregion } return(!allchildrenoutofextent); }
public void OnMouseUp(int button, int shift, int x, int y) { IRelationalOperator envelope = this._feedBack.Stop().Envelope as IRelationalOperator; if (!envelope.Disjoint(this._feature.Shape)) { string[] strArray = this._errInf.Split(new char[] { ',' }); double num = double.Parse(strArray[0]); double num2 = double.Parse(strArray[1]); IPoint point = new PointClass { X = num, Y = num2 }; if (!envelope.Disjoint(point.Envelope)) { IGeometryCollection shape = this._feature.Shape as IGeometryCollection; try { Editor.UniqueInstance.StartEditOperation(); for (int i = 0; i < shape.GeometryCount; i++) { IPointCollection points = shape.get_Geometry(i) as IPointCollection; int num4 = -1; for (int j = 0; j < points.PointCount; j++) { IPoint point2 = points.get_Point(j); if ((point2.X == x) && (point2.Y == y)) { if (num4 == -1) { num4 = j; } else { points.RemovePoints(j, 1); } } } } Editor.UniqueInstance.StopEditOperation(); EditTask.ToplogicChkState = ToplogicCheckState.Failure; } catch (Exception exception) { Editor.UniqueInstance.AbortEditOperation(); this.mErrOpt.ErrorOperate(this.mSubSysName, "ShapeEdit.RPointDelete", "OnMouseUp", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", ""); } } } }
/// <summary> /// 两点之间的连线是否与线相交 /// </summary> /// <param name="mFPoint"></param> /// <param name="mLPoint"></param> /// <param name="lineFeature"></param> /// <returns>true:相交;false:不相交</returns> private bool IsIntersect(IPoint mFPoint, IPoint mLPoint, IFeature lineFeature) { //声明线要素 //IPolyline mPLine = new PolylineClass(); //mPLine.FromPoint = mFPoint; //mPLine.ToPoint = mLPoint; //声明点集 //IPointCollection mPointCol = new PolylineClass(); //object obj = System.Reflection.Missing.Value; //mPointCol.AddPoint(mFPoint, ref obj, ref obj); //mPointCol.AddPoint(mLPoint, ref obj, ref obj); //mPLine = mPointCol as IPolyline; ILine pLine = new LineClass(); pLine.PutCoords(mFPoint, mLPoint); ISegmentCollection pSegCol = new PolylineClass(); object obj = Type.Missing; pSegCol.AddSegment(pLine as ISegment, ref obj, ref obj); IRelationalOperator pRelOpera = pSegCol as IRelationalOperator; if (pRelOpera.Disjoint(lineFeature.Shape)) { //不相交 return(false); } else { //相交 return(true); } }
private void FeatureMerge(ArrayList arrFeature) { ArrayList arrayList = new ArrayList(); for (int i = 0; i < arrFeature.Count; i++) { IFeature feature = (IFeature)arrFeature[i]; if (!arrayList.Contains(feature)) { IRelationalOperator relationalOperator = (IRelationalOperator)feature.Shape; IGeometry geometry = feature.Shape; for (int j = 0; j < arrFeature.Count; j++) { IFeature feature2 = (IFeature)arrFeature[j]; if (feature2.OID != feature.OID && !arrayList.Contains(feature2)) { IGeometry shape = feature2.Shape; if (!relationalOperator.Disjoint(shape) || relationalOperator.Touches(shape)) { geometry = CommonFunction.UnionGeometry(geometry, shape); arrayList.Add(feature2); } } } feature.Shape = geometry; feature.Store(); } } for (int k = 0; k < arrayList.Count; k++) { (arrayList[k] as IFeature).Delete(); } }
/// <summary>创建各河流间的干支关系</summary> /// <param name="CAllRiverLt">河流数据</param> private void CreateRiverRelationship(ref List <CRiver> CAllRiverLt) { //创建各河流间的干支关系 for (int i = 0; i < CAllRiverLt.Count - 1; i++) { IRelationalOperator pSmallBufferRel = CAllRiverLt[i].pSmallBufferGeo as IRelationalOperator; IRelationalOperator pToptSmallBufferGeo = CAllRiverLt[i].pToptSmallBufferGeo as IRelationalOperator; for (int j = i + 1; j < CAllRiverLt.Count; j++) { bool isDisjoint = pSmallBufferRel.Disjoint(CAllRiverLt[j].pPolyline); if (isDisjoint == false) { if (pToptSmallBufferGeo.Disjoint(CAllRiverLt[j].pToptSmallBufferGeo) == false) //如果两条河流的终点重合,则互相之间不存在干支关系 { continue; } if (CAllRiverLt[i].CMainStream != null) //如果"河流i"有了干河流,则"河流j"必然是它的支流 { CAllRiverLt[j].CMainStream = CAllRiverLt[i]; CAllRiverLt[i].CTributaryLt.Add(CAllRiverLt[j]); } else if (CAllRiverLt[j].CMainStream != null) //如果"河流j"有了干河流,则"河流i"必然是它的支流 { CAllRiverLt[i].CMainStream = CAllRiverLt[j]; CAllRiverLt[j].CTributaryLt.Add(CAllRiverLt[i]); } else { bool isDisjoint2 = pSmallBufferRel.Disjoint(CAllRiverLt[j].pPolyline.ToPoint); if (isDisjoint2 == false) { CAllRiverLt[j].CMainStream = CAllRiverLt[i]; CAllRiverLt[i].CTributaryLt.Add(CAllRiverLt[j]); } else { CAllRiverLt[i].CMainStream = CAllRiverLt[j]; CAllRiverLt[j].CTributaryLt.Add(CAllRiverLt[i]); } } } } } }
public bool polinedisjust(IFeature SourceFeature, IFeature InspectedFeature) { //isdisjust==true 表示两个线要素不相交 IRelationalOperator RelationalOperator = SourceFeature.Shape as IRelationalOperator; bool isdisjust = false; isdisjust = RelationalOperator.Disjoint(InspectedFeature.Shape); return(isdisjust); }
public void NextRecord() { if (m_bIsFinished) //error already thrown once { return; } //OID search has been performed if (m_iOID > -1 && m_sbuffer != null) { m_pStreamReader.Close(); m_bIsFinished = true; throw new COMException("End of SimplePoint Plugin cursor", E_FAIL); } else { //HIGHLIGHT: 1.1 Next - Read the file for text m_sbuffer = ReadFile(m_pStreamReader, m_iOID); if (m_sbuffer == null) { //finish reading, close the stream reader so resources will be released m_pStreamReader.Close(); m_bIsFinished = true; //HIGHLIGHT: 1.2 Next - Raise E_FAIL to notify end of cursor throw new COMException("End of SimplePoint Plugin cursor", E_FAIL); } //HIGHLIGHT: 1.3 Next - Search by envelope; or return all records and let post-filtering do //the work for you (performance overhead) else if (m_searchEnv != null && !(m_searchEnv.IsEmpty)) { this.QueryShape(m_wkGeom); IRelationalOperator pRelOp = (IRelationalOperator)m_wkGeom; if (!pRelOp.Disjoint((IGeometry)m_searchEnv)) { return; //HIGHLIGHT: 1.4 Next - valid record within search geometry - stop advancing } else { this.NextRecord(); } } } }
/// <summary> /// 判断两个几何形状是否没有交集 /// </summary> /// <param name="geometry1">待判断的几何形状1</param> /// <param name="geometry2">待判断的几何形状2</param> /// <returns>是否没有交集</returns> public static bool Disjoint(IGeometry geometry1, IGeometry geometry2) { if (GeometryUtility.IsHighLevelGeometry(geometry1) && GeometryUtility.IsHighLevelGeometry(geometry2)) { try { IRelationalOperator relateOP = (IRelationalOperator)geometry1; return(relateOP.Disjoint(geometry2)); } catch { return(true); } } else { return(true); } }
public bool checkExtents() { IEnvelope zenv = zRs.RasterInfo.Extent; IEnvelope venv = vRs.RasterInfo.Extent; IRelationalOperator rsOp = (IRelationalOperator)zenv; if (rsOp.Disjoint(venv)) { return(false); } else { if (!rsOp.Equals(venv)) { zenv.Intersect(venv); } intEnv = zenv; return(true); } }
public static IPolyline GetSubcurves([NotNull] IPolyline polyline, double mMin, double mMax, [NotNull] out IList <IPoint> points) { Assert.ArgumentNotNull(polyline, nameof(polyline)); points = new List <IPoint>(); if (polyline.IsEmpty) { return(null); } IMultipoint multipoint = GetPointsAtMs(polyline, mMin, mMax); var mSegmentation = (IMSegmentation3)polyline; var subcurves = (IPolyline)mSegmentation.GetSubcurveBetweenMs(mMin, mMax); GeometryUtils.AllowIndexing(subcurves); IRelationalOperator subcurvesRelOp = subcurves.IsEmpty ? null : (IRelationalOperator)subcurves; var pointCollection = (IPointCollection)multipoint; int pointCount = pointCollection.PointCount; for (var i = 0; i < pointCount; i++) { IPoint point = pointCollection.Point[i]; if (subcurvesRelOp == null || subcurvesRelOp.Disjoint(point)) { points.Add(point); } } return(subcurves.IsEmpty ? null : subcurves); }
private bool checkExtentsFtr() { IEnvelope envFtr = ((IGeoDataset)ftrCls).Extent; if (needToProject) { envFtr.Project(vRs.RasterInfo.SpatialReference); } IEnvelope envRst = vRs.RasterInfo.Extent; IRelationalOperator rO = (IRelationalOperator)envRst; bool dis = rO.Disjoint(envFtr); if (dis) { return(false); } else { return(true); } }
private IEnvelope _GetSurfaceOutputExtent(IPoint mapPoint) { IEnvelope extent = null; SetupOp setupOp = UrbanDelineationExtension.Extension.Setup; if (setupOp.Catchments != null) { // Find all inlet catchments that intersect any source feature and union envelopes IFeatureCursor catchCursor = setupOp.Catchments.Search(null, false); try { IFeature catchment = catchCursor.NextFeature(); while (catchment != null) { try { IRelationalOperator relationOp = (IRelationalOperator)catchment.Shape; if (!relationOp.Disjoint(mapPoint)) { extent = new EnvelopeClass(); catchment.Extent.QueryEnvelope(extent); break; } } finally { UrbanDelineationExtension.ReleaseComObject(catchment); } catchment = catchCursor.NextFeature(); } } finally { UrbanDelineationExtension.ReleaseComObject(catchCursor); } } return(extent); }
/// <summary> /// Recursively parses a d8list and determines in any of the features /// are in the extent. Intended for use with an ATE. /// </summary> /// <param name="IRO">Bounding Extent</param> /// <param name="List">Designer List Object</param> /// <returns></returns> private static bool HasD8ChildInExtent(IRelationalOperator IRO, ID8List List) { bool allchildrenoutofextent = true; #region Check the current list item if (List is ID8GeoAssoc) { IFeature GuFeat = ((ID8GeoAssoc)List).AssociatedGeoRow as IFeature; if (GuFeat != null && GuFeat.Shape != null) { if (!IRO.Disjoint(GuFeat.Shape)) allchildrenoutofextent = false; } } #endregion List.Reset(); ID8ListItem Child = List.Next(false); while (Child != null && allchildrenoutofextent) { #region Process children until we find a child inside the extent if (Child is ID8GeoAssoc) { IFeature GuFeat = ((ID8GeoAssoc)Child).AssociatedGeoRow as IFeature; if (GuFeat != null && GuFeat.Shape != null) { if (!IRO.Disjoint(GuFeat.Shape)) allchildrenoutofextent = false; } } if (Child is ID8List) allchildrenoutofextent = !HasD8ChildInExtent(IRO, (ID8List)Child); Child = List.Next(false); #endregion } return !allchildrenoutofextent; }
public override void OnMouseDown(int Button, int Shift, int X, int Y) { //m_Cursor = new System.Windows.Forms.Cursor(GetType().Assembly.GetManifestResourceStream(GetType(), "AopenMap.cur")); if (Button == 1) { if (m_InUse == true) { m_pAV = m_HookHelper.ActiveView; m_pScrD = m_pAV.ScreenDisplay; IMap pMap = m_HookHelper.FocusMap; IPoint pPnt; pPnt = (IPoint)m_pScrD.DisplayTransformation.ToMapPoint(X, Y); if (m_pNewPolygonFeedback == null) { m_pNewPolygonFeedback = new NewPolygonFeedbackClass(); ISimpleLineSymbol pSLnSym; IRgbColor pRGB = new RgbColorClass(); pSLnSym = (ISimpleLineSymbol)m_pNewPolygonFeedback.Symbol; pRGB.Red = 140; pRGB.Green = 140; pRGB.Blue = 255; pSLnSym.Color = pRGB; pSLnSym.Style = esriSimpleLineStyle.esriSLSSolid; pSLnSym.Width = 2; m_pNewPolygonFeedback.Display = m_pScrD; m_pNewPolygonFeedback.Start(pPnt); } else { m_pNewPolygonFeedback.AddPoint(pPnt); } } } else if (Button == 2) { IPolygon pGeomLn; pGeomLn = m_pNewPolygonFeedback.Stop(); m_pNewPolygonFeedback = null; IMap pMap = m_HookHelper.FocusMap; ISpatialReference spatialReference = pMap.SpatialReference; //IBorder pBorder = new SymbolBorderClass(); //*****************************************88888888 if (pFirstGeom == null) { pFirstGeom = pGeomLn; } if (mGeomln != null) { pFirstGeom = mGeomln; } if (pFirstGeom != pGeomLn) { IPolygon mFirstGeom; mFirstGeom = pFirstGeom; IRelationalOperator pROperator = (IRelationalOperator)mFirstGeom; if (pROperator.Disjoint((IGeometry)pGeomLn) == false) { //先定义一个IGeometrycollection的多边形,将每个画出来的IgeometryCollection添加进去 //先添一个构成一个IPolygon,转化为ITopo_ ,再同样构成另一个,进行Union IGeometryCollection pcGeometry = new PolygonClass(); object o = System.Type.Missing; IPolygon cFirstGeom = new PolygonClass(); cFirstGeom = pFirstGeom; ITopologicalOperator tempTopo = (ITopologicalOperator)cFirstGeom; tempTopo.Simplify(); ITopologicalOperator pTopo = (ITopologicalOperator)pGeomLn; pTopo.Simplify(); IGeometry kGeom; kGeom = pTopo.Union((IGeometry)cFirstGeom); mGeomln = (IPolygon)kGeom; mGeomln.SpatialReference = spatialReference; m_pAV.FocusMap.ClipGeometry = mGeomln; //IBorder pBorder = new SymbolBorderClass(); //m_HookHelper.FocusMap.ClipBorder = pBorder; m_pAV.Extent = mGeomln.Envelope; m_pAV.Refresh(); m_Cursor = base.m_cursor; //layVisbleExceptMap(); } } else { //*************************************************8 //mGeomln = pGeomLn; pGeomLn.SpatialReference = spatialReference; LayerControl.LyrPolygon = pGeomLn; m_HookHelper.FocusMap.ClipGeometry = pGeomLn; IBorder pBorder = new SymbolBorderClass(); m_HookHelper.FocusMap.ClipBorder = pBorder; m_pAV.Extent = pGeomLn.Envelope; m_pAV.Refresh(); m_Cursor = base.m_cursor; pGeomLn = null; } } }