Example #1
0
		/// <summary>
		/// 获取VCT注记实体节点
		/// </summary>
		public override EntityNode GetEntityNode()
        {
            try
            {
                AnnotationNode pAnnotationNode = new AnnotationNode();

                //特征类型统一设置为单点注记
                pAnnotationNode.AnnotationType = Convert.ToInt32(Metadata.MetaDataFile.GraphConfig.GetGraphSymbol("ANNOTATIONFEATURETYPE", "SingPointAnnotation"));
                IFeature pFeature = this.Feature as IFeature;
                if (pFeature != null)
                {
                    ///标识码赋值
                    int dBSMIndex = -1;
                    dBSMIndex = this.Feature.Fields.FindField(m_strEntityIDFiled);
                    if (dBSMIndex != -1)
                        pAnnotationNode.EntityID = Convert.ToInt32(this.Feature.get_Value(dBSMIndex));

                    ///要素代码赋值
                        pAnnotationNode.FeatureCode = this.FeatureCode;

                    ///图形表现赋值 
                     //pAnnotationNode.Representation = pFeature.Class.AliasName;

                    ///注记坐标赋值

                     IGeometry5 pArea = pFeature.Shape as IGeometry5;
                     if (pArea != null)
                     {
                         PointInfoNode pPTInfoNode = new PointInfoNode(pArea.CentroidEx.X, pArea.CentroidEx.Y);
                         pAnnotationNode.PointLocation = pPTInfoNode;
                     }
                    m_AnnotationNode = pAnnotationNode;
                    return pAnnotationNode;
                }
                return null;
            }
            catch (Exception ex)
            {
                Logger.WriteErrorLog(ex);
                return null;
            }
		}
Example #2
0
        private void itemPanel1_ItemDoubleClick(object sender, MouseEventArgs e)
        {
            //若是左建双击缩放至要素:
            if (e.Clicks == 2)
            {
                ButtonItem item = new ButtonItem();
                item = sender as ButtonItem;
                if (item == null)
                {
                    return;
                }
                string FeatureClassName = item.Tooltip.Substring(item.Tooltip.IndexOf('.') + 1);
                string strOID           = item.Tooltip.Substring(0, item.Tooltip.IndexOf('.'));
                int    OID = Convert.ToInt32(strOID);

                IFeature   feature  = DBOperator.getFeatureFrom(OID, FeatureClassName, m_GlobalWorkspace);
                IGeometry5 geometry = feature.Shape as IGeometry5;
                this.m_MapCtrls.CenterAt(geometry.CentroidEx);
                this.m_MapCtrls.ActiveView.Extent = geometry.Envelope;
                ILayer iLayer = null;

                if (FeatureClassName.Contains("CheckItemPtn"))
                {
                    iLayer = m_MapCtrls.Map.Layer[1];
                }
                else if (FeatureClassName.Contains("CheckItemPtn"))
                {
                    iLayer = m_MapCtrls.Map.Layer[2];
                }
                else
                {
                    iLayer = m_MapCtrls.Map.Layer[3];
                }

                clearFeatureSelection();

                m_MapCtrls.Map.SelectFeature(iLayer, feature);
                //this.m_MapCtrls.ActiveView.FocusMap.SelectByShape(feature.Shape, null, true);
                //this.m_MapCtrls.ActiveView.FocusMap.SelectByShape(feature.Shape, selectionEnv, true);
            }
        }
Example #3
0
 private void itemPanel3_ItemDoubleClick(object sender, MouseEventArgs e)
 {
     //双击,且不是点击非button item;
     if (e.Clicks == 2)
     {
         ButtonItem item = new ButtonItem();
         item = sender as ButtonItem;
         if (item == null)
         {
             return;
         }
         IFeature feature = DBOperator.getFeatureFrom(item.Name, Properties.Settings.Default.Grid, Properties.Settings.Default.GridCodeField, m_GlobalWorkspace);
         if (feature == null)
         {
             return;
         }
         IGeometry5 geometry = feature.Shape as IGeometry5;
         this.m_MapCtrls.CenterAt(geometry.CentroidEx);
         this.m_MapCtrls.ActiveView.Extent = geometry.Envelope;
     }
 }
Example #4
0
        public static IPoint GetFeatureCenterPoint(IFeature pFeatCity)
        {
            if (pFeatCity.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
            {
                return(pFeatCity.Shape as IPoint);
            }

            else if (pFeatCity.Shape.GeometryType == esriGeometryType.esriGeometryPolygon)
            {
                IGeometry5 centerPoint = pFeatCity.Shape as IGeometry5;
                return(centerPoint.CentroidEx);
            }

            else if (pFeatCity.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
            {
                IPoint    centerPoint = new PointClass();
                IPolyline pl          = pFeatCity.Shape as IPolyline;
                pl.QueryPoint(esriSegmentExtension.esriExtendAtFrom, 0.5, true, centerPoint);
                return(centerPoint);
            }
            return(null);
        }
Example #5
0
        /// <summary>
        /// Occurs when this command is clicked
        /// </summary>
        public override void OnClick()
        {
            // TODO: Add ClsAsortVertex.OnClick implementation
            IToolbarControl2 pToolbarControl;

            if (m_hookHelper.Hook is IToolbarControl)
            {
                pToolbarControl = (m_hookHelper.Hook) as IToolbarControl2;
                m_MapControl    = (pToolbarControl.Buddy) as IMapControl4;
            }
            else if (m_hookHelper.Hook is IMapControl4)
            {
                m_MapControl = (IMapControl4)(m_hookHelper.Hook);
            }

            IMap    pMap   = m_MapControl.ActiveView.FocusMap as IMap;
            ILayer2 pLayer = null;

            //m_MapControl.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint();

            for (int i = 0; i < pMap.LayerCount; i++)
            {
                pLayer = pMap.get_Layer(i) as ILayer2;
                if (pLayer is IFeatureLayer2)
                {
                    IFeatureLayer2    pFeatLyr = pLayer as IFeatureLayer2;
                    IFeatureSelection pFeatSel = pFeatLyr as IFeatureSelection;

                    ISelectionSet2 pSelSet = pFeatSel.SelectionSet as ISelectionSet2;
                    if (pSelSet.Count <= 0)
                    {
                        return;
                    }
                    else
                    {
                        ICursor pCursor = null;
                        pSelSet.Search(null, false, out pCursor);
                        IFeatureCursor pFeatCursor = pCursor as IFeatureCursor;

                        IFeature pFeat = pFeatCursor.NextFeature();
                        while (pFeat != null)
                        {
                            IGeometry5       pGeometry = pFeat.Shape as IGeometry5;
                            IPointCollection pPointCol = new Multipoint();
                            pPointCol = pGeometry as IPointCollection;

                            double[] arrayX = new double[200];
                            double[] arrayY = new double[200];

                            IPointArray pPtArray = new PointArrayClass();
                            pPtArray = AsortVertex(pPointCol, arrayX, arrayY);


                            for (int k = 0; k < pPointCol.PointCount; k++)
                            {
                                IPoint pPoint = new PointClass();
                                pPoint = pPointCol.get_Point(k);

                                MessageBox.Show(pPointCol.get_Point(k).ID.ToString());
                                for (int l = 0; l < pPtArray.Count; l++)
                                {
                                    if (pPoint.X == pPtArray.get_Element(l).X)
                                    {
                                        int ID = pPtArray.get_Element(l).ID;
                                        pPointCol.get_Point(k).ID = ID;
                                        MessageBox.Show(pPointCol.get_Point(k).ID.ToString());
                                        break;
                                    }
                                }
                            }
                            pFeat = pFeatCursor.NextFeature();
                        }
                    }
                }
            }
            m_MapControl.ActiveView.Refresh();
        }
Example #6
0
        /// <summary>
        /// 节点的相似值
        /// </summary>
        /// <param name="buffer">缓冲区</param>
        /// <returns>返回值</returns>
        public double MatchedPointsSimilarValue(double buffer)
        {
            try
            {
                IPointCollection targetPointCollection = targetFeature.Shape as IPointCollection;
                IPointCollection sourcePointCollection = sourceFeature.Shape as IPointCollection;

                Dictionary <string, string> pointDic       = new Dictionary <string, string>();
                Dictionary <string, string> sourcePointDic = new Dictionary <string, string>();

                //IUnitConverter unitConverter = new UnitConverterClass();
                int i = 0, j = 0;
                int position = 0;

                int m       = 0;
                int sameKey = 0;
                int outKey  = 0;
                //遍历待匹配图层中所有的点
                for (i = 0; i < targetPointCollection.PointCount; i++)
                {
                    IPoint targetPoint = new PointClass();
                    //目标图层中的点cPoint
                    targetPoint = targetPointCollection.get_Point(i);

                    //IPoint unitCPoint = new PointClass();
                    //unitCPoint.X = unitConverter.ConvertUnits(cPoint.X, esriUnits.esriDecimalDegrees, esriUnits.esriMeters);
                    //unitCPoint.Y = unitConverter.ConvertUnits(cPoint.Y, esriUnits.esriDecimalDegrees, esriUnits.esriMeters);

                    ITopologicalOperator cTopOperator = targetPoint as ITopologicalOperator;

                    IGeometry5 targetGeo = cTopOperator.Buffer(buffer) as IGeometry5;
                    //遍历源图层中所有的点
                    for (j = position; j < sourcePointCollection.PointCount; j++)
                    {
                        IPoint sourcePoint = new PointClass();
                        sourcePoint = sourcePointCollection.get_Point(j);

                        //IPoint unitTUPoint = new PointClass();
                        //unitTUPoint.X = unitConverter.ConvertUnits(tuPoint.X, esriUnits.esriDecimalDegrees, esriUnits.esriMeters);
                        //unitTUPoint.Y = unitConverter.ConvertUnits(tuPoint.Y, esriUnits.esriDecimalDegrees, esriUnits.esriMeters);

                        IRelationalOperator targetRelationOperator = targetGeo as IRelationalOperator;
                        //IGeometry5 tuGeo = tuPoint as IGeometry5;
                        IGeometry sourceGeo = sourcePoint as IGeometry;
                        //如果是点集中的第一个点
                        if (j == 0)
                        {
                            if (sourceGeo != null)
                            {
                                if (targetRelationOperator.Contains(sourceGeo))
                                {
                                    if (!sourcePointDic.ContainsKey(sourcePoint.X.ToString("#0.000")))
                                    {
                                        sourcePointDic.Add(sourcePoint.X.ToString("#0.000"), sourcePoint.Y.ToString("#0.000"));
                                    }
                                    m++;
                                    position = m;
                                    break;
                                }
                                else
                                {
                                    if (pointDic.ContainsKey(sourcePoint.X.ToString("#0.000")))
                                    {
                                        if (pointDic.ContainsValue(sourcePoint.Y.ToString("#0.000")))
                                        {
                                            continue;
                                        }
                                        else
                                        {
                                            if (!sourcePointDic.ContainsKey(sourcePoint.X.ToString("#0.000")) && !pointDic.ContainsValue(sourcePoint.Y.ToString("#0.000")))
                                            {
                                                sameKey++;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (!sourcePointDic.ContainsKey(sourcePoint.X.ToString("#0.000")) && !pointDic.ContainsValue(sourcePoint.Y.ToString("#0.000")))
                                        {
                                            pointDic.Add(sourcePoint.X.ToString("#0.000"), sourcePoint.Y.ToString("#0.000"));
                                        }
                                    }
                                }
                            }
                        }
                        //如果是点集中的最后一个点
                        else if (j == sourcePointCollection.PointCount - 1)
                        {
                            if (targetRelationOperator.Contains(sourceGeo))
                            {
                                if (pointDic.ContainsKey(sourcePoint.X.ToString("#0.000")))
                                {
                                    if (pointDic.ContainsValue(sourcePoint.Y.ToString("#0.000")))
                                    {
                                        outKey--;
                                    }
                                }
                                if (!sourcePointDic.ContainsKey(sourcePoint.X.ToString("#0.000")))
                                {
                                    sourcePointDic.Add(sourcePoint.X.ToString("#0.000"), sourcePoint.Y.ToString("#0.000"));
                                }
                                m++;
                                position = m;
                                break;
                            }
                            else
                            {
                                if (pointDic.ContainsKey(sourcePoint.X.ToString("#0.000")))
                                {
                                    if (pointDic.ContainsValue(sourcePoint.Y.ToString("#0.000")))
                                    {
                                        continue;
                                    }
                                    else
                                    {
                                        if (!sourcePointDic.ContainsKey(sourcePoint.X.ToString("#0.000")) && !pointDic.ContainsValue(sourcePoint.Y.ToString("#0.000")))
                                        {
                                            sameKey++;
                                        }
                                    }
                                }
                                else
                                {
                                    if (!sourcePointDic.ContainsKey(sourcePoint.X.ToString("#0.000")) && !pointDic.ContainsValue(sourcePoint.Y.ToString("#0.000")))
                                    {
                                        pointDic.Add(sourcePoint.X.ToString("#0.000"), sourcePoint.Y.ToString("#0.000"));
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (targetRelationOperator.Contains(sourceGeo))
                            {
                                if (pointDic.ContainsKey(sourcePoint.X.ToString("#0.000")))
                                {
                                    if (pointDic.ContainsValue(sourcePoint.Y.ToString("#0.000")))
                                    {
                                        outKey--;
                                    }
                                }
                                if (!sourcePointDic.ContainsKey(sourcePoint.X.ToString("#0.000")))
                                {
                                    sourcePointDic.Add(sourcePoint.X.ToString("#0.000"), sourcePoint.Y.ToString("#0.000"));
                                }
                                m++;
                                position = m;
                                break;
                            }
                            else
                            {
                                ILine backLine   = new LineClass();
                                ILine beforeLine = new LineClass();

                                backLine.PutCoords(sourcePointCollection.get_Point(j - 1), sourcePointCollection.get_Point(j));
                                beforeLine.PutCoords(sourcePointCollection.get_Point(j), sourcePointCollection.get_Point(j + 1));

                                double backAngle   = backLine.Angle * 180 / Math.PI;
                                double beforeAngle = beforeLine.Angle * 180 / Math.PI;
                                double t           = 0;

                                if (backAngle > 0 && beforeAngle > 0)
                                {
                                    t = beforeAngle - backAngle;
                                    if (t < 0)
                                    {
                                        t = -t;
                                    }
                                }
                                else if (backAngle < 0 && beforeAngle < 0)
                                {
                                    t = beforeAngle - backAngle;
                                    if (t < 0)
                                    {
                                        t = -t;
                                    }
                                }
                                else if (backAngle > 0 && beforeAngle < 0)
                                {
                                    beforeAngle = -beforeAngle;
                                    t           = backAngle + beforeAngle;
                                    if (t > 180)
                                    {
                                        t = 360 - 180;
                                    }
                                }
                                else if (backAngle < 0 && beforeAngle > 0)
                                {
                                    backAngle = -backAngle;
                                    t         = backAngle + beforeAngle;
                                    if (t > 180)
                                    {
                                        t = 360 - t;
                                    }
                                }

                                if (t < 10)
                                {
                                    continue;
                                }
                                else
                                {
                                    if (pointDic.ContainsKey(sourcePoint.X.ToString("#0.000")))
                                    {
                                        if (pointDic.ContainsValue(sourcePoint.Y.ToString("#0.000")))
                                        {
                                            continue;
                                        }
                                        else
                                        {
                                            if (!sourcePointDic.ContainsKey(sourcePoint.X.ToString("#0.000")) && !pointDic.ContainsValue(sourcePoint.Y.ToString("#0.000")))
                                            {
                                                sameKey++;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        if (!sourcePointDic.ContainsKey(sourcePoint.X.ToString("#0.000")) && !pointDic.ContainsValue(sourcePoint.Y.ToString("#0.000")))
                                        {
                                            pointDic.Add(sourcePoint.X.ToString("#0.000"), sourcePoint.Y.ToString("#0.000"));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                int    sum = targetPointCollection.PointCount + pointDic.Count + sameKey + outKey;
                double shapeSimiliarValue = Convert.ToDouble(m) / sum;
                return(shapeSimiliarValue);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                throw;
            }
        }