Exemple #1
0
        private List <string> getXZQMC()
        {
            List <string> res = new List <string>();

            GeoDrawSheetMap.clsGetGeoInfo getGeoinfo = new GeoDrawSheetMap.clsGetGeoInfo();
            getGeoinfo.m_lngMapScale    = (long)Convert.ToInt32(cBoxScale.Text.Split(':')[1]);
            getGeoinfo.m_strMapNO       = txtMapNo.Text.Replace(" ", "");
            getGeoinfo.m_intInsertCount = 3;
            getGeoinfo.m_pPrjCoor       = pAxMapControl.Map.SpatialReference as IProjectedCoordinateSystem;
            getGeoinfo.ComputerAllGeoInfo();
            IGeometry tfGeometry = getGeoinfo.m_pSheetMapGeometry;
            //GeoPageLayoutFn.drawPolygonElement(tfGeometry, pAxMapControl.ActiveView.GraphicsContainer);//测试用
            IRelationalOperator pRO      = tfGeometry as IRelationalOperator;
            IFeatureCursor      pFCursor = xzq_xianFC.Search(null, false);
            IFeature            pFeature = pFCursor.NextFeature();
            int idx = pFeature.Fields.FindField(xzq_xian_field);

            while (pFeature != null)
            {
                IGeometry pGm = pFeature.ShapeCopy;
                if (pRO.Relation(pGm, "RELATE(G1,G2,'T********')"))//(pRO.Within(pGm) || pRO.Overlaps(pGm)怀疑此方法有问题 || pRO.Contains(pGm))
                {
                    //GeoPageLayoutFn.drawPolygonElement(pGm, pAxMapControl.ActiveView.GraphicsContainer);//测试用
                    res.Add(getXZQMC(pFeature.get_Value(idx).ToString()));
                }
                pFeature = pFCursor.NextFeature();
            }
            //pAxMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);//测试用
            return(res);
        }
Exemple #2
0
        private double[,] RndPtswithStudyArea(int intNFeatureCount, IEnvelope pEnv, IFeature pFeature)
        {
            double[,] arrTable = new double[intNFeatureCount, 2];

            Random pRandom   = new Random();
            double dblWidth  = pEnv.Width;
            double dblHeight = pEnv.Height;
            double dblXMin   = pEnv.XMin;
            double dblYmin   = pEnv.YMin;


            IRelationalOperator pRel = pFeature.Shape as IRelationalOperator2;

            int intGenPt = 0;
            int intTest  = 0;

            while (intGenPt != intNFeatureCount)
            {
                IPoint pPnt = new PointClass();
                pPnt.X = (pRandom.NextDouble()) * dblWidth + dblXMin;
                pPnt.Y = (pRandom.NextDouble()) * dblHeight + dblYmin;
                if (pRel.Contains(pPnt))
                {
                    arrTable[intGenPt, 0] = pPnt.X;
                    arrTable[intGenPt, 1] = pPnt.Y;
                    intGenPt++;
                }
                else
                {
                    intTest++;
                }
            }
            return(arrTable);
        }
Exemple #3
0
        /// <summary>
        ///     Determines whether the specified objects are equal.
        /// </summary>
        /// <param name="x">The first object of type <see cref="IGeometry"/> to compare.</param>
        /// <param name="y">The second object of type <see cref="IGeometry"/> to compare.</param>
        /// <returns>
        ///     true if the specified objects are equal; otherwise, false.
        /// </returns>
        public bool Equals(IGeometry x, IGeometry y)
        {
            IRelationalOperator xc = x as IRelationalOperator;
            IRelationalOperator yc = y as IRelationalOperator;

            return((xc != null && yc != null) && xc.Equals(yc));
        }
Exemple #4
0
        private List <IPoint> SplitPolyline(IPolyline polyline, IPointCollection intersectpointsColl, IPoint presentCP)
        {
            IEnumVertex pEnumVertex = intersectpointsColl.EnumVertices;
            //IPolycurve2 has SplitAtPoints

            IPolycurve2 pPolyCurve = polyline as IPolycurve2;

            pPolyCurve.SplitAtPoints(pEnumVertex, false, true, -1);
            IGeometryCollection geoColl = pPolyCurve as IGeometryCollection;
            //MessageBox.Show(geoColl.GeometryCount.ToString());
            List <IPoint> ptlist = new List <IPoint>();
            // The results are pathclass
            IPath resultPath;

            for (int i = 0; i < geoColl.GeometryCount; i++)
            {
                object obj = Type.Missing;
                resultPath = new PathClass();
                resultPath = (IPath)geoColl.get_Geometry(i);
                IGeometryCollection lineColl = new PolylineClass();
                lineColl.AddGeometry(resultPath, ref obj, ref obj);
                IPolyline           line         = (IPolyline)lineColl;
                IRelationalOperator pRelOperator = (IRelationalOperator)line;
                if (pRelOperator.Touches(presentCP) || pRelOperator.Contains(presentCP))
                {
                    IPoint temPT1 = resultPath.FromPoint;
                    IPoint temPT2 = resultPath.ToPoint;
                    //pGeometryCollection.AddGeometry(temPT1);
                    //pGeometryCollection.AddGeometry(temPT2);
                    ptlist.Add(temPT1);
                    ptlist.Add(temPT2);
                }
            }
            return(ptlist);
        }
Exemple #5
0
        private void FlashFeature_ItemClick(object sender, ItemClickEventArgs e)
        {
            IFeatureFindData2 tag = null;
            int num;

            new ArrayClass();
            IEnvelope other = null;

            for (num = 0; num < this.listView1.SelectedItems.Count; num++)
            {
                tag = this.listView1.SelectedItems[num].Tag as IFeatureFindData2;
                if (num == 0)
                {
                    other = tag.Feature.Shape.Envelope;
                }
                else
                {
                    other.Union(tag.Feature.Shape.Envelope);
                }
            }
            IRelationalOperator extent = this.iactiveView_0.Extent as IRelationalOperator;

            if (!extent.Contains(other))
            {
                this.iactiveView_0.Extent = other;
                this.iactiveView_0.Refresh();
                this.iactiveView_0.ScreenDisplay.UpdateWindow();
            }
            for (num = 0; num < this.listView1.SelectedItems.Count; num++)
            {
                tag = this.listView1.SelectedItems[num].Tag as IFeatureFindData2;
                Flash.FlashFeature(this.iactiveView_0.ScreenDisplay, tag.Feature);
            }
        }
Exemple #6
0
        private List <IPoint> GetCorrectPoint(List <IPoint> splitresult, IPoint lastCP)
        {
            List <IPoint>       correctPT = new List <IPoint>();
            IRelationalOperator rel       = lastCP as IRelationalOperator;

            foreach (IPoint pt in splitresult)
            {
                if (!rel.Equals(pt))
                {
                    correctPT.Add(pt);
                }
            }
            if (correctPT.Count == 2)
            {
                IProximityOperator prox = lastCP as IProximityOperator;
                double             Dis1 = prox.ReturnDistance(correctPT[0]);
                double             Dis2 = prox.ReturnDistance(correctPT[1]);
                if (Dis1 > Dis2)
                {
                    correctPT.Remove(correctPT[1]);
                }
                else
                {
                    correctPT.Remove(correctPT[0]);
                }
            }
            return(correctPT);
        }
Exemple #7
0
        /// <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);
            }
        }
Exemple #8
0
        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();
            }
        }
        private void method_0(IArray iarray_0, IGeometry igeometry_0)
        {
            IRelationalOperator igeometry0 = igeometry_0 as IRelationalOperator;
            IList arrayLists = new ArrayList();
            int   i          = 0;

            while (true)
            {
                if (i < iarray_0.Count)
                {
                    IGeometry element = iarray_0.Element[i] as IGeometry;
                    if (igeometry0.Within(element))
                    {
                        break;
                    }
                    if (igeometry0.Contains(element))
                    {
                        arrayLists.Add(i);
                    }
                    i++;
                }
                else
                {
                    for (i = arrayLists.Count - 1; i >= 0; i--)
                    {
                        iarray_0.Remove(i);
                    }
                    iarray_0.Add(igeometry_0);
                    break;
                }
            }
        }
        private bool IsOverlaps(IGeometry pFeatureGeo, string typevalue)    //判断几何图形间是否有重叠
        {
            bool isoverlaps = false;

            switch (typevalue)
            {
            case "001":
                pBasicGeo = GetBasicGeo("003");
                break;

            case "002":
                pBasicGeo = GetBasicGeo("004");
                break;

            case "003":
                pBasicGeo = GetBasicGeo("001");
                break;

            case "004":
                pBasicGeo = GetBasicGeo("002");
                break;

            default:
                break;
            }

            IRelationalOperator pRelaOperator = pBasicGeo as IRelationalOperator;

            isoverlaps = pRelaOperator.Overlaps(pFeatureGeo) || pRelaOperator.Contains(pFeatureGeo);
            return(isoverlaps);
        }
        private void pointInPolygonButton_Click(object sender, EventArgs e)
        {
            // 获得点图层
            int           PointId    = 1;
            IFeatureLayer PointLayer = null;

            for (int i = 0; i < axMapControl1.LayerCount; i++)
            {
                PointLayer = axMapControl1.get_Layer(i) as IFeatureLayer;
                if (PointLayer is IFeatureLayer && PointLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPoint)
                {
                    PointId = i;
                }
            }
            if (PointId == -1)
            {
                MessageBox.Show("找不到质点图层,请重新加载", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // 获得面图层
            int           PolygonId    = -1;
            IFeatureLayer PolygonLayer = null;

            for (int i = 0; i < axMapControl1.LayerCount; i++)
            {
                PolygonLayer = axMapControl1.get_Layer(i) as IFeatureLayer;
                if (PolygonLayer is IFeatureLayer && PolygonLayer.FeatureClass.ShapeType == esriGeometryType.esriGeometryPolygon)
                {
                    PolygonId = i;
                }
            }
            if (PolygonId == -1)
            {
                MessageBox.Show("找不到边界图层,请重新加载", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            PointLayer   = axMapControl1.get_Layer(PointId) as IFeatureLayer;
            PolygonLayer = axMapControl1.get_Layer(PolygonId) as IFeatureLayer;

            IFeatureCursor PointFeatureCursor = PointLayer.Search(null, true);
            IFeature       PointFeature       = PointFeatureCursor.NextFeature();

            IFeatureCursor PolygonFeatureCursor = PolygonLayer.Search(null, true);
            IFeature       PolygonFeature       = PolygonFeatureCursor.NextFeature();

            IRelationalOperator pRelationalOperator = PolygonFeature.Shape as IRelationalOperator;

            if (pRelationalOperator.Contains(PointFeature.Shape))
            {
                MessageBox.Show("点在面内!", "恭喜你!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {
                MessageBox.Show("点在面外!", "很遗憾!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
Exemple #12
0
        public static int GetVertexIndex(IPoint pPoint, IGeometry pGeo)
        {
            int functionReturnValue = -2;

            //图形为空,则退出
            IPointCollection pPointCollection = pGeo as IPointCollection;

            if (pPointCollection == null)
            {
                return(functionReturnValue);
            }

            ITopologicalOperator pTopoOpt            = pPointCollection as ITopologicalOperator;
            IRelationalOperator  pRelationalOperator = pPoint as IRelationalOperator;
            IProximityOperator   pProx = pPoint as IProximityOperator;

            bool pIsEqual = false;

            for (int i = 0; i < pPointCollection.PointCount; i++)
            {
                pIsEqual = pRelationalOperator.Equals(pPointCollection.get_Point(i));
                if (pIsEqual)
                {
                    functionReturnValue = i;
                    break;
                }
            }
            return(functionReturnValue);
        }
Exemple #13
0
        public bool polygoncontain(IFeature SourceFeature, IFeature InspectedFeature)
        {
            //iscontains==true表示SourceFeature包含InspectedFeature
            IRelationalOperator RelationalOperator = SourceFeature.Shape as IRelationalOperator;
            bool iscontains = false;

            iscontains = RelationalOperator.Contains(InspectedFeature.Shape);
            return(iscontains);
        }
Exemple #14
0
        public static bool IsSameGeometry(IGeometry geom1, IGeometry geom2)
        {
            geom1.SnapToSpatialReference();
            geom2.SnapToSpatialReference();
            IRelationalOperator rel1 = geom1 as IRelationalOperator;
            bool relEqual            = rel1.Equals(geom2);

            return(relEqual);
        }
Exemple #15
0
        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);
        }
Exemple #16
0
        }//检查是否相交

        private double GetAngle(IGeometry pGeometry1, IGeometry pGeometry2)
        {
            double pAngle1;
            double pAngle2;
            double pAngle = 0;

            IGeometry pGPoint = new PointClass();

            IRelationalOperator  pRO = pGeometry1 as IRelationalOperator;
            ITopologicalOperator pTO = pGeometry1 as ITopologicalOperator;

            if (pRO.Touches(pGeometry2))
            {
                pGPoint = pTO.Intersect(pGeometry2, esriGeometryDimension.esriGeometry0Dimension);
            }

            IPolyline           pPolyline1 = pGeometry1 as IPolyline;
            IPoint              pPF1       = pPolyline1.FromPoint;
            IGeometry           pGeoPoint1 = pPF1 as IGeometry;
            IRelationalOperator pRO1       = pGeoPoint1 as IRelationalOperator;

            if (pRO1.Contains(pGPoint))
            {
                pAngle1 = this.AngleFromPoint(pGeometry1);
            }
            else
            {
                pAngle1 = this.AngleToPoint(pGeometry1);
            }

            IPolyline           pPolyline2 = pGeometry2 as IPolyline;
            IPoint              pPF2       = pPolyline2.FromPoint;
            IGeometry           pGeoPoint2 = pPF2 as IGeometry;
            IRelationalOperator pRO2       = pGeoPoint2 as IRelationalOperator;

            if (pRO2.Contains(pGPoint))
            {
                pAngle2 = this.AngleFromPoint(pGeometry2);
            }
            else
            {
                pAngle2 = this.AngleToPoint(pGeometry2);
            }
            if ((pAngle1 * pAngle2) >= 0)
            {
                pAngle = Math.Abs(pAngle2 - pAngle1);
            }
            if ((pAngle1 * pAngle2) < 0)
            {
                pAngle = Math.Abs(pAngle1) + Math.Abs(pAngle2);
                if (pAngle > Math.PI)
                {
                    pAngle = 2 * Math.PI - pAngle;
                }
            }
            return(pAngle);
        }//获取相交道路的夹角
Exemple #17
0
        public bool polygonOverlaps(IFeature SourceFeature, IFeature InspectedFeature)
        {
            //isOverlaps==true 表示两个面要素有重叠
            IRelationalOperator RelationalOperator = SourceFeature.Shape as IRelationalOperator;
            bool isOverlaps = false;

            isOverlaps = RelationalOperator.Overlaps(InspectedFeature.Shape);
            return(isOverlaps);
        }
Exemple #18
0
        public override void OnMouseDown(int Button, int Shift, int X, int Y)
        {
            if (Button != 1 || m_HookHelper.FocusMap.LayerCount <= 0)
            {
                return;
            }
            IMap        map        = m_HookHelper.FocusMap;
            IActiveView activeView = m_HookHelper.ActiveView;
            // 获取点击位置并抓化为点图形要素
            IPoint point = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(X, Y);
            // 获取地图中的图层
            IFeatureLayer featureLayer = activeView.FocusMap.get_Layer(0) as IFeatureLayer;

            if (featureLayer == null)
            {
                return;
            }
            IFeatureClass featureCLass = featureLayer.FeatureClass;
            // 进行点击,选择要素
            ISpatialFilter spatialFilter = new SpatialFilterClass();

            spatialFilter.Geometry   = point;
            spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
            IFeatureCursor featureCursor = featureCLass.Search(spatialFilter, false);
            // 获得点击查询的要素
            IFeature feature = featureCursor.NextFeature();

            if (feature != null && feature.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                map.ClearSelection();
                IRelationalOperator relationalOperator = feature.Shape as IRelationalOperator;
                // 设置被选择要素的颜色
                IRgbColor         rgbColor         = ColorTool.GetRgbColor(255, 0, 0);
                IFeatureSelection featureSelection = featureLayer as IFeatureSelection;
                featureSelection.SelectionColor = rgbColor;
                // 查找邻接要素,并之余地图的选择集中
                IFeatureCursor nearFeatureCursor = featureLayer.Search(null, false);
                IFeature       nearFeature       = nearFeatureCursor.NextFeature();

                // 遍历图层内所有要素进行邻接判定
                while (nearFeature != null)
                {
                    if (relationalOperator.Touches(nearFeature.Shape))
                    {
                        // 如果对比要素与当前选择要素邻接,则加入到地图选择集中
                        map.SelectFeature(featureLayer, nearFeature);
                    }
                    nearFeature = nearFeatureCursor.NextFeature();
                }
            }

            // 刷新地图
            activeView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, null, activeView.Extent);
        }
        private IEnumerable <INetworkEdge> EnumerateAdjacentTurnEdges(OSMTurnInfo osmTurn, bool useToJunction)
        {
            INetworkQuery query = (INetworkQuery)_networkDataset;

            // get turn FROM-edge
            INetworkSource      source          = _networkDataset.get_SourceByName(((IDataset)osmTurn.FromFeature.Class).Name);
            IEnumNetworkElement enumNetElements = null;

            IRelationalOperator relationalOperator = ((IPolyline)osmTurn.ToFeature.Shape).FromPoint as IRelationalOperator;

            bool useFromPointOfToFeature = relationalOperator.Contains(osmTurn.ViaFeature.Shape);

            if (useFromPointOfToFeature)
            {
                enumNetElements = query.get_EdgesByPosition(source.ID, osmTurn.ToFeature.OID, 0, false);
            }
            else
            {
                enumNetElements = query.get_EdgesByPosition(source.ID, osmTurn.ToFeature.OID, 1, false);
            }

            INetworkEdge edgeFrom = enumNetElements.Next() as INetworkEdge;

            // get the FROM-edge Junctions
            INetworkJunction fromJunction = query.CreateNetworkElement(esriNetworkElementType.esriNETJunction) as INetworkJunction;
            INetworkJunction toJunction   = query.CreateNetworkElement(esriNetworkElementType.esriNETJunction) as INetworkJunction;

            edgeFrom.QueryJunctions(fromJunction, toJunction);

            // Get adjacent edges from the turn center junction
            INetworkJunction junction = ((useFromPointOfToFeature) ? fromJunction : toJunction);

            for (int n = 0; n < junction.EdgeCount; ++n)
            {
                INetworkEdge edge = query.CreateNetworkElement(esriNetworkElementType.esriNETEdge) as INetworkEdge;
                if (useFromPointOfToFeature)
                {
                    junction.QueryEdge(n, true, edge);
                }
                else
                {
                    junction.QueryEdge(n, false, edge);
                }

                //if ((edge.SourceID == osmTurn.FromFeature.OID) || (edge.SourceID == osmTurn.ToFeature.OID))
                if ((edge.OID == osmTurn.ToFeature.OID))
                {
                    continue;
                }

                yield return(edge);
            }
        }
Exemple #20
0
        private bool IsNewPoint(IPoint Point, IPolygon lastcircle)
        {
            IRelationalOperator pRelOperator = (IRelationalOperator)lastcircle;

            if (pRelOperator.Contains(Point))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
 /// <summary>
 /// sourceGeometry与targetGeometry是否相邻
 /// </summary>
 /// <param name="sourceGeometry">源</param>
 /// <param name="targetGeometry">目标</param>
 /// <returns></returns>
 public static bool IsTouch(IGeometry sourceGeometry, IGeometry targetGeometry)
 {
     try
     {
         IRelationalOperator relationalOperator = sourceGeometry as IRelationalOperator;
         return(relationalOperator.Touches(targetGeometry));
     }
     catch (Exception ex)
     {
         LOG.Error(ex);
     }
     return(false);
 }
Exemple #22
0
        public List <GeoStruct> BufferAnalyseNew(IPolyline pGeom, double dist, IFeatureLayer fealyr, IGeometry Reg = null)
        {
            List <GeoStruct> geoList = new List <GeoStruct>();

            ITopologicalOperator top          = pGeom as ITopologicalOperator;
            IGeometry            geom         = top.Buffer(dist);
            IFeatureCursor       searchCursor = SpatialSearch(geom, "1=1", fealyr);

            if (searchCursor != null)
            {
                IFeature fea = searchCursor.NextFeature();


                while (fea != null)
                {
                    GeoStruct geoTmp = new GeoStruct();

                    var fieldDict = new Dictionary <string, string>();
                    for (var i = 0; i < fea.Fields.FieldCount; i++)
                    {
                        var field = fea.Fields.Field[i];
                        if (field.Type != esriFieldType.esriFieldTypeGeometry)
                        {
                            fieldDict.Add(field.Name, fea.Value[i].ToString());
                        }
                        else
                        {
                            geoTmp.geo = fea.Shape;
                        }
                    }
                    geoTmp.geoinfos = fieldDict;
                    IRelationalOperator relation = Reg as IRelationalOperator;
                    bool   bin      = (relation.Overlaps(fea.Shape) || relation.Touches(fea.Shape) || relation.Contains(fea.Shape));
                    double distance = CalculateDistanceNew(pGeom, geoTmp.geo);
                    if (bin)
                    {
                        distance = 0.0;
                    }
                    if (distance < Global.searchlen)
                    {
                        geoTmp.dist = distance;
                        geoList.Add(geoTmp);
                    }
                    //geoTmp.dist = distance;
                    //geoList.Add(geoTmp);

                    fea = searchCursor.NextFeature();
                }
            }
            return(geoList);
        }
Exemple #23
0
        private void SelectFeature_ItemClick(object sender, ItemClickEventArgs e)
        {
            IFeatureFindData2 tag   = null;
            IArray            array = new ArrayClass();

            try
            {
                for (int i = 0; i < this.listView1.SelectedItems.Count; i++)
                {
                    tag = this.listView1.SelectedItems[i].Tag as IFeatureFindData2;
                    if (this.ibasicMap_0 is IMap)
                    {
                        (this.ibasicMap_0 as IMap).SelectFeature(tag.Layer, tag.Feature);
                    }
                    array.Add(tag.Feature);
                }
                IEnumFeature featureSelection = null;
                if (this.ibasicMap_0 is IMap)
                {
                    featureSelection = (this.ibasicMap_0 as IMap).FeatureSelection as IEnumFeature;
                    featureSelection.Reset();
                    IFeature  feature2 = featureSelection.Next();
                    IEnvelope other    = null;
                    while (feature2 != null)
                    {
                        if (other == null)
                        {
                            other = feature2.Extent;
                        }
                        else
                        {
                            other.Union(feature2.Extent);
                        }
                        feature2 = featureSelection.Next();
                    }
                    if (other != null)
                    {
                        IRelationalOperator extent = (this.ibasicMap_0 as IActiveView).Extent as IRelationalOperator;
                        if (!extent.Contains(other))
                        {
                            (this.ibasicMap_0 as IActiveView).Extent = other;
                        }
                    }
                    (this.ibasicMap_0 as IActiveView).Refresh();
                }
            }
            catch (Exception exception)
            {
                Logger.Current.Error("", exception, "");
            }
        }
Exemple #24
0
        /// <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);
        }
Exemple #25
0
        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, "", "", "");
                    }
                }
            }
        }
        private int method_3(IArray iarray_0, IPoint ipoint_0)
        {
            int num = 0;
            IRelationalOperator ipoint0 = (IRelationalOperator)ipoint_0;

            for (int i = 0; i < iarray_0.Count; i++)
            {
                if (ipoint0.Touches((IGeometry)iarray_0.Element[i]))
                {
                    num++;
                }
            }
            return(num);
        }
Exemple #27
0
        private List <IPoint> GetCorrectPointInitial(List <IPoint> splitresult, IPoint lastCP)
        {
            List <IPoint>       correctPT = new List <IPoint>();
            IRelationalOperator rel       = lastCP as IRelationalOperator;

            foreach (IPoint pt in splitresult)
            {
                if (!rel.Equals(pt))
                {
                    correctPT.Add(pt);
                }
            }
            return(correctPT);
        }
Exemple #28
0
        private void axMapControl1_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            //If left mouse button then zoom in
            if (e.button == 1)
            {
                m_MapControl.Extent = m_MapControl.TrackRectangle();
            }
            else
            {
                //Create a point and get the IPoint interface
                IPoint point = new PointClass();
                //Set points coordinates
                point.PutCoords(e.mapX, e.mapY);

                //QI for ITopologicalOperator interface through IPoint interface
                ITopologicalOperator topologicalOperator = (ITopologicalOperator)point;
                //Create a polygon by buffering the point and get the IPolygon interface
                IPolygon polygon = (IPolygon)topologicalOperator.Buffer(m_MapControl.Extent.Width * 0.02);
                //QI for IRelationalOperator interface through IPolygon interface
                IRelationalOperator relationalOperator = (IRelationalOperator)polygon;

                object o = null;
                //Draw the polygon
                m_MapControl.DrawShape(polygon, ref o);

                //Loop through the elements in the GraphicContainer and get the IElement interface
                m_GraphicsContainer.Reset();
                IElement element = m_GraphicsContainer.Next();
                while (element != null)
                {
                    //If the polygon contains the point
                    if (relationalOperator.Contains(element.Geometry) == true)
                    {
                        //QI for IMarkerElement interface through IElement interface
                        IMarkerElement markerElement = (IMarkerElement)element;
                        markerElement.Symbol = GetMarkerSymbol(true);
                        //QI for the IElementProperties interface through IElement interface
                        IElementProperties elementProperties = (IElementProperties)element;
                        elementProperties.Name = true.ToString();
                    }
                    element = m_GraphicsContainer.Next();
                }
                if (chkTracking.CheckState == CheckState.Unchecked)
                {
                    //Refresh the graphics
                    m_MapControl.Refresh(esriViewDrawPhase.esriViewGraphics, Type.Missing, Type.Missing);
                }
            }
        }
Exemple #29
0
        private static bool EvaluateRelation([NotNull] IRelationalOperator shapeRelOp,
                                             [NotNull] IGeometry relatedShape,
                                             [NotNull] string relationDescription)
        {
            if (IsInteriorIntersectionRelation(relationDescription))
            {
                // more robust: (not disjoint) and (not touches)
                // "disjoint" geometries should not make it here.

                // TODO consolidate optimization of touches with GeometryEngine
                return(!shapeRelOp.Touches(relatedShape));
            }

            return(shapeRelOp.Relation(relatedShape, relationDescription));
        }
Exemple #30
0
        protected override int ExecuteCore(IRow row, int tableIndex)
        {
            var feature = row as IFeature;

            if (feature == null)
            {
                return(NoError);
            }

            feature.Shape.QueryEnvelope(_featureExtent);
            if (_featureExtent.IsEmpty)
            {
                return(NoError);
            }

            if (_boxRelOp == null)
            {
                ISpatialReference spatialReference = GetBoxSpatialReference(
                    _featureExtent.SpatialReference,
                    _xMin, _yMin,
                    _xMax, _yMax);

                IEnvelope box = GeometryFactory.CreateEnvelope(
                    _xMin, _yMin, _xMax, _yMax,
                    spatialReference);

                _boxRelOp = (IRelationalOperator)box;
            }

            if (_boxRelOp.Contains(_featureExtent))
            {
                return(NoError);
            }

            IGeometry errorGeometry = GetErrorGeometry(feature, (IEnvelope)_boxRelOp);

            if (errorGeometry.IsEmpty)
            {
                // tolerance issue?
                return(NoError);
            }

            const string description = "Geometry is not within expected extent";

            return(ReportError(description, errorGeometry,
                               Codes[Code.GeometryNotWithinBox],
                               _shapeFieldName, feature));
        }
Exemple #31
0
        /// <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;
        }