示例#1
0
        /// <summary>
        /// Gets the count of related objects for a given object
        /// </summary>
        /// <param name="anObject">Object to check</param>
        /// <param name="relationshipClassName">Relationship class to check</param>
        /// <returns>int</returns>
        public static int GetRelatedObjectCount(ESRI.ArcGIS.Geodatabase.IObject anObject, string relationshipClassName)
        {
            int result = 0;

            if (null == anObject)
            {
                throw new ArgumentNullException("anObject");
            }

            if (1 > relationshipClassName.Length)
            {
                throw new ArgumentException("relationshipClassName not specified.");
            }

            ESRI.ArcGIS.Geodatabase.IRelationshipClass relationshipClass = GetRelationshipClass(anObject.Class, relationshipClassName);
            if (null == relationshipClass)
            {
                throw new Exception(string.Format("Relationship class {0} could not be found.", relationshipClassName));
            }

            ESRI.ArcGIS.esriSystem.ISet relatedObjects = relationshipClass.GetObjectsRelatedToObject(anObject);
            result = relatedObjects.Count;
            return(result);
        }
示例#2
0
        /// <summary>
        /// 根据参考线要素,对选择的线要素进行裁剪
        /// </summary>
        /// <param name="featTrim">待裁剪的线要素</param>
        /// <param name="featRef">参考线要素</param>
        /// <returns>成功返回True</returns>
        public bool TrimLine(IFeature featTrim, IFeature featRef, IPoint pMousePnt)
        {
            IFeatureEdit pFeatEdit = null;

            ESRI.ArcGIS.esriSystem.ISet pSet = null;
            IFeature pFeature = null;

            try
            {
                //当没有交点的时候不做任何操作
                IPolyline        pTrimLine     = featTrim.ShapeCopy as IPolyline;
                IPointCollection pIntelsectCol = GetIntersection(featRef.ShapeCopy, pTrimLine);
                if (pIntelsectCol == null || pIntelsectCol.PointCount < 1)
                {
                    System.Windows.Forms.MessageBox.Show("参考线与要裁剪的线没有交点,无法完成裁剪!");
                    return(false);
                }
                if (pIntelsectCol.PointCount > 1)  //大于1个交点也不处理
                {
                    System.Windows.Forms.MessageBox.Show("参考线与要裁剪的线交点大于1个,无法完成裁剪!");
                    return(false);
                }
                IPoint pIntersectPt = pIntelsectCol.Point[0];     //裁剪线与参考线的交点

                pFeatEdit = featTrim as IFeatureEdit;

                pSet = pFeatEdit.Split(pIntersectPt);
                pSet.Reset();

                //pFeature = (IFeature)pSet.Next();
                //while (pFeature != null)
                //{
                //    IPolyline5 polylineTemp = pFeature.ShapeCopy as IPolyline5;
                //    IRelationalOperator relaOperator = pMousePnt as IRelationalOperator;
                //    if (relaOperator.Within(polylineTemp))//如果包含鼠标点,则删除
                //    {
                //        if (m_engineEditor != null)
                //        {
                //            m_engineEditor.StartOperation();
                //            pFeature.Delete();
                //            m_engineEditor.StopOperation("Delete Features");
                //        }
                //    }
                //    pFeature = (IFeature)pSet.Next();
                //}


                //ISegmentCollection trimSegCol = featTrim.ShapeCopy as ISegmentCollection;
                //ISegmentCollection refSegCol = featRef.ShapeCopy as ISegmentCollection;

                ////得到选中地物离点击处最近的segment
                //ISegment seg = null;
                //int indexSegment = GetSelectSegment(featTrim, pMousePnt, ref seg);
                //if (seg == null)
                //    return false;

                ////得到与segment相交的所有交点
                //ISegmentCollection pLineSegCol = new PolylineClass();
                //pLineSegCol.AddSegment(seg);

                //IPolyline pSegLine = pLineSegCol as IPolyline;



                //IPoint pLeftPnt = null;
                //IPoint pRightPnt = null;
                //GetColseIntersect(pIntelsectCol, pMousePnt, seg, out pLeftPnt, out pRightPnt);
                //if (pLeftPnt == null || pRightPnt == null)
                //    return false;

                //List<IFeature> lstFeats = null;

                //IFeature pNewFeatOne = null;
                //IFeature pNewFeatTwo = null;

                ////修剪在启始端
                //if (indexSegment == 0 && pLeftPnt.X == pLineSegCol.Segment[0].FromPoint.X && pLeftPnt.Y == pLineSegCol.Segment[0].FromPoint.Y)
                //{
                //    lstFeats = new List<IFeature>();

                //    pFeatEdit = featTrim as IFeatureEdit;
                //    pSet = pFeatEdit.Split(pRightPnt);
                //    pSet.Reset();

                //    pFeature = (IFeature)pSet.Next();
                //    while (pFeature != null)
                //    {
                //        lstFeats.Add(pFeature);
                //        pFeature = (IFeature)pSet.Next();
                //    }

                //    pFeature = GetCloseFeature(m_hookHelper.FocusMap, pMousePnt, lstFeats);

                //    m_engineEditor.StartOperation();
                //    pFeature.Delete();
                //    m_engineEditor.StopOperation("Delete Features");

                //    for (int j = 0; j < lstFeats.Count; j++)
                //    {
                //        if (!lstFeats[j].Equals(pFeature))
                //            pNewFeatOne = lstFeats[j];
                //    }
                //}
                ////修剪在末端
                //else if (indexSegment == pLineSegCol.SegmentCount - 1 && pRightPnt.X == pLineSegCol.Segment[pLineSegCol.SegmentCount - 1].ToPoint.X)
                //{
                //    lstFeats = new List<IFeature>();

                //    pFeatEdit = featTrim as IFeatureEdit;
                //    pSet = pFeatEdit.Split(pLeftPnt);
                //    pSet.Reset();

                //    pFeature = (IFeature)pSet.Next();
                //    while (pFeature != null)
                //    {
                //        lstFeats.Add(pFeature);
                //        pFeature = (IFeature)pSet.Next();
                //    }

                //    pFeature = GetCloseFeature(m_hookHelper.FocusMap, pMousePnt, lstFeats);

                //    m_engineEditor.StartOperation();
                //    pFeature.Delete();
                //    m_engineEditor.StopOperation("Delete Features");

                //    for (int j = 0; j < lstFeats.Count; j++)
                //    {
                //        if (!lstFeats[j].Equals(pFeature))
                //            pNewFeatOne = lstFeats[j];
                //    }
                //}
                //else   //修剪在其它位置
                //{
                //    lstFeats = new List<IFeature>();

                //    pFeatEdit = featTrim as IFeatureEdit;
                //    pSet = pFeatEdit.Split(pLeftPnt);
                //    pSet.Reset();

                //    pFeature = (IFeature)pSet.Next();
                //    while (pFeature != null)
                //    {
                //        lstFeats.Add(pFeature);
                //        pFeature = (IFeature)pSet.Next();
                //    }

                //    pFeature = GetCloseFeature(m_hookHelper.FocusMap, pMousePnt, lstFeats);
                //    for (int j = 0; j < lstFeats.Count; j++)
                //    {
                //        if (!lstFeats[j].Equals(pFeature))
                //            pNewFeatOne = lstFeats[j];
                //    }


                //    lstFeats = new List<IFeature>();

                //    pFeatEdit = pFeature as IFeatureEdit;
                //    pSet = pFeatEdit.Split(pRightPnt);
                //    pSet.Reset();

                //    pFeature = (IFeature)pSet.Next();
                //    while (pFeature != null)
                //    {
                //        lstFeats.Add(pFeature);
                //        pFeature = (IFeature)pSet.Next();
                //    }

                //    pFeature = GetCloseFeature(m_hookHelper.FocusMap, pMousePnt, lstFeats);

                //    m_engineEditor.StartOperation();
                //    pFeature.Delete();
                //    m_engineEditor.StopOperation("Delete Features");

                //    for (int j = 0; j < lstFeats.Count; j++)
                //    {
                //        if (!lstFeats[j].Equals(pFeature))
                //            pNewFeatTwo = lstFeats[j];
                //    }
                //}
                return(true);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message, "Trim Line");
                return(false);
            }
        }
示例#3
0
 public bool Applies(ESRI.ArcGIS.esriSystem.ISet objects)
 {
     return(false);
 }
示例#4
0
 public void SetObjects(ESRI.ArcGIS.esriSystem.ISet objects)
 {
 }