示例#1
0
        /// <summary>
        /// Tests whether a point lies on the line defined by a list of
        /// coordinates.
        /// </summary>
        /// <param name="p">The point to test</param>
        /// <param name="line">The line coordinates</param>
        /// <returns>
        /// <c>true</c> if the point is a vertex of the line or lies in the interior
        /// of a line segment in the line
        /// </returns>
        public static bool IsOnLine(Coordinate p, Coordinate[] line)
        {
            var lineIntersector = new RobustLineIntersector();

            for (int i = 1; i < line.Length; i++)
            {
                var p0 = line[i - 1];
                var p1 = line[i];
                lineIntersector.ComputeIntersection(p, p0, p1);
                if (lineIntersector.HasIntersection)
                {
                    return(true);
                }
            }
            return(false);
        }
示例#2
0
        /// <summary>
        /// Tests whether a point lies on the line defined by a list of
        /// coordinates.
        /// </summary>
        /// <param name="p">The point to test</param>
        /// <param name="line">The line coordinates</param>
        /// <returns>
        /// <c>true</c> if the point is a vertex of the line or lies in the interior
        /// of a line segment in the line
        /// </returns>
        public static bool IsOnLine(Coordinate p, CoordinateSequence line)
        {
            var lineIntersector = new RobustLineIntersector();
            var p0 = line.CreateCoordinate();
            var p1 = p0.Copy();
            int n  = line.Count;

            for (int i = 1; i < n; i++)
            {
                line.GetCoordinate(i - 1, p0);
                line.GetCoordinate(i, p1);
                lineIntersector.ComputeIntersection(p, p0, p1);
                if (lineIntersector.HasIntersection)
                {
                    return(true);
                }
            }
            return(false);
        }