コード例 #1
0
        /// <summary>
        /// Determines the <see cref="Geometries.Location"/> of a point in a ring.
        /// This method is an exemplar of how to use this class.
        /// </summary>
        /// <param name="p">The point to test</param>
        /// <param name="ring">An array of Coordinates forming a ring</param>
        /// <returns>The location of the point in the ring</returns>
        public static Location LocatePointInRing(Coordinate p, Coordinate[] ring)
        {
            var counter = new RayCrossingCounter(p);

            for (int i = 1; i < ring.Length; i++)
            {
                var p1 = ring[i];
                var p2 = ring[i - 1];
                counter.CountSegment(p1, p2);
                if (counter.IsOnSegment)
                {
                    return(counter.Location);
                }
            }
            return(counter.Location);
        }
コード例 #2
0
        /// <summary>
        /// Determines the <see cref="Geometries.Location"/> of a point in a ring.
        /// </summary>
        /// <param name="p">The point to test</param>
        /// <param name="ring">A coordinate sequence forming a ring</param>
        /// <returns>The location of the point in the ring</returns>
        public static Location LocatePointInRing(Coordinate p, CoordinateSequence ring)
        {
            var counter = new RayCrossingCounter(p);

            var p1    = ring.CreateCoordinate();
            var p2    = ring.CreateCoordinate();
            int count = ring.Count;

            for (int i = 1; i < count; i++)
            {
                ring.GetCoordinate(i, p1);
                ring.GetCoordinate(i - 1, p2);
                counter.CountSegment(p1, p2);
                if (counter.IsOnSegment)
                {
                    return(counter.Location);
                }
            }
            return(counter.Location);
        }
コード例 #3
0
 /// <summary>
 /// Determines whether a point lies in the interior, on the boundary, or in the
 /// exterior of a ring.The ring may be oriented in either direction.
 /// <para/>
 /// This method does<i> not</i> first check the point against the envelope of
 /// the ring.
 /// </summary>
 /// <param name="p">The point to check for ring inclusion</param>
 /// <param name="ring">A <c>CoordinateSequence</c> representing the ring (which must have
 /// first point identical to last point)</param>
 public static Location LocateInRing(Coordinate p, CoordinateSequence ring)
 {
     return(RayCrossingCounter.LocatePointInRing(p, ring));
 }