public Location Locate(Coordinate p)
 {
     RayCrossingCounter rcc = new RayCrossingCounter(p);
     RayCrossingSegmentFilter filter = new RayCrossingSegmentFilter(rcc);
     geom.Apply(filter);
     return rcc.Location;
 }
        ///<summary>
        /// Determines the <see cref="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="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();
            for (var i = 1; i < ring.Count; i++)
            {
                ring.GetCoordinate(i, p1);
                ring.GetCoordinate(i - 1, p2);
                counter.CountSegment(p1, p2);
                if (counter.IsOnSegment)
                    return counter.Location;
            }
            return counter.Location;
        }
Пример #4
0
        ///<summary>
        /// Determines the <see cref="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);
        }
Пример #5
0
        /// <summary>
        /// Determines the <see cref="LocationUtility" /> of a point in an areal <see cref="IGeometry" />.
        /// </summary>
        /// <param name="p"> the point to test</param>
        /// <returns> the location of the point in the geometry</returns>
        public Location Locate(ICoordinate p)
        {
            RayCrossingCounter rcc = new RayCrossingCounter(p);


            SegmentVisitor visitor = new SegmentVisitor(rcc);

            _index.Query(p.Y, p.Y, visitor);

            /*
             * // MD - slightly slower alternative
             * List segs = index.query(p.y, p.y);
             * countSegs(rcc, segs);
             */

            return(rcc.Location);
        }
Пример #6
0
        /// <summary>
        /// Determines the <see cref="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();

            for (var i = 1; i < ring.Count; i++)
            {
                ring.GetCoordinate(i, p1);
                ring.GetCoordinate(i - 1, p2);
                counter.CountSegment(p1, p2);
                if (counter.IsOnSegment)
                {
                    return(counter.Location);
                }
            }
            return(counter.Location);
        }
Пример #7
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));
 }
Пример #8
0
 public SegmentVisitor(RayCrossingCounter counter)
 {
     _counter = counter;
 }
 public RayCrossingSegmentFilter(RayCrossingCounter rcc)
 {
     this.rcc = rcc;
 }
Пример #10
0
 ///<summary>
 /// Determines whether a point lies in the interior, on the boundary, or in the exterior of a ring.
 ///</summary>
 /// <remarks>
 /// <para>The ring may be oriented in either direction.</para>
 /// <para>This method does <i>not</i> first check the point against the envelope of the ring.</para>
 /// </remarks>
 /// <param name="p">Point to check for ring inclusion</param>
 /// <param name="ring">An array of coordinates representing the ring (which must have first point identical to last point)</param>
 /// <returns>The <see cref="Location"/> of p relative to the ring</returns>
 public static Location LocatePointInRing(Coordinate p, Coordinate[] ring)
 {
     return(RayCrossingCounter.LocatePointInRing(p, ring));
 }