예제 #1
0
        /// <summary>
        /// Get Segment And Angle on which point is placed
        /// </summary>
        /// <param name="m_gtPolylineGeometry"></param>
        /// <param name="gtPoint"></param>
        /// <returns></returns>
        protected IGTGeometry GetSegmentAndAngle(IGTGeometry m_gtPolylineGeometry, IGTPoint gtPoint)
        {
            bool        flag = false;
            IGTGeometry m_gtPolylineGeometrySegment = GTClassFactory.Create <IGTGeometry>();
            IGTSegment  m_gtSegment   = GTClassFactory.Create <IGTSegment>();
            IGTPoint    m_gtsnapPoint = GetSnapPoint(m_gtPolylineGeometry, gtPoint);

            try
            {
                if (m_gtPolylineGeometry.Type == "CompositePolylineGeometry")
                {
                    //get the segment
                    for (int i = 0; i < m_gtPolylineGeometry.KeypointCount - 1; i++)
                    {
                        m_gtSegment.Begin = m_gtPolylineGeometry.GetKeypointPosition(i);
                        m_gtSegment.End   = m_gtPolylineGeometry.GetKeypointPosition(i + 1);
                        if (m_gtsnapPoint.IsOn(m_gtSegment))
                        {
                            flag = true;
                            break;
                        }
                    }
                    if (flag)
                    {
                        m_gtPolylineGeometrySegment = m_gtPolylineGeometry.ExtractGeometry(m_gtSegment.Point1, m_gtSegment.Point2, false);
                    }
                }
                return(m_gtPolylineGeometrySegment);
            }
            catch
            {
                throw;
            }
        }
예제 #2
0
        /// <summary>
        /// Get Point And Angle
        /// </summary>
        /// <param name="m_gtPolylineGeom"></param>
        /// <param name="m_gtPoint">Related Virtual point</param>
        /// <returns></returns>
        protected IGTPoint GetPointAndAngle(IGTGeometry m_gtPolylineGeom, IGTPoint m_gtPoint)
        {
            bool     flag = false;
            IGTPoint m_gtProjectedPoint = null;
            //Get snappoint if the point feature is not snapped to the linear
            IGTPoint m_gtsnapPoint = GetSnapPoint(m_gtPolylineGeom, m_gtPoint);

            try
            {
                //Check if the geometry is linear
                if ((m_gtPolylineGeom.Type == "CompositePolylineGeometry") || (m_gtPolylineGeom.Type == "PolylineGeometry"))
                {
                    IGTSegment m_segment = GTClassFactory.Create <IGTSegment>();
                    //get the segment
                    for (int i = 0; i < m_gtPolylineGeom.KeypointCount - 1; i++)
                    {
                        m_segment.Begin = m_gtPolylineGeom.GetKeypointPosition(i);
                        m_segment.End   = m_gtPolylineGeom.GetKeypointPosition(i + 1);
                        if (m_gtsnapPoint.IsOn(m_segment))
                        {
                            flag = true;
                            ang  = AngleBetweenTwoPoints(m_segment.Begin, m_segment.End);
                            break;
                        }
                        else
                        {
                            // m_gtProjectedPoint = m_gtsnapPoint;
                        }
                    }
                    if (flag)
                    {
                        m_gtProjectedPoint = m_segment.ProjectPointAtAngle(m_segment.Begin, m_gtsnapPoint, ang);
                    }
                }
                return(m_gtProjectedPoint);
            }
            catch
            {
                throw;
            }
        }