///<summary>
        /// Determines the <see cref="Gisoft.GeoAPI.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);
        }
        /// <summary>
        /// Determines the <see cref="Gisoft.GeoAPI.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, ICoordinateSequence ring)
        {
            var counter = new RayCrossingCounter(p);

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

            for (var 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);
        }
Exemple #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, ICoordinateSequence ring)
 {
     return(RayCrossingCounter.LocatePointInRing(p, ring));
 }